diff --git a/.taplo.toml b/.taplo.toml index a094b25da..317d23a8a 100644 --- a/.taplo.toml +++ b/.taplo.toml @@ -5,3 +5,8 @@ exclude = ["**/target/**", "**/.direnv/**", ".scratch/**", ".tmp/**", "uniffi/** indent_string = " " column_width = 150 align_comments = false + +# A root added at the end of reject's long list would conflict with any other added there. +[[rule]] +include = ["ts/fixtures/reject/ts.toml"] +formatting.reorder_arrays = true diff --git a/quest/m3/ts-fma-allowance.md b/quest/m3/ts-fma-allowance.md index 3e33b25ea..4fec469b8 100644 --- a/quest/m3/ts-fma-allowance.md +++ b/quest/m3/ts-fma-allowance.md @@ -5,13 +5,12 @@ Waits on upstream. wasm32's `fma`, compiler-builtins' generic libm, rounds some near-ties a last place off ([rust-lang/compiler-builtins#1353](https://github.com/rust-lang/compiler-builtins/issues/1353)), -so the lang fixture's differential accepts a `floats::mul_adds` result where the +so the `lang/floats` fixture's differential accepts a `floats::mul_adds` result where the translation is the exactly rounded one and native is a last place from it -(`ts/fixtures/lang/fma.ts`). +(`ts/fixtures/lang/floats/fma.ts`). Once [rust-lang/compiler-builtins#1358](https://github.com/rust-lang/compiler-builtins/pull/1358) ships in the compiler-builtins that the pinned nightly in `ts/rust-toolchain.toml` -builds, delete `fma.ts` and every use of it: `caller.ts`'s import and `within`'s -call, its copy in `ts/tests/fixtures.rs`'s `lang_differential`, and its test -`ts/tests/fma.ts` with `fma_allowance` in `ts/tests/runtime.rs`, so any difference -fails again, and delete this quest. +builds, delete `fma.ts` and every use of it: `floats/caller.ts`'s import and +`within`'s call, and its test `ts/tests/fma.ts` with `fma_allowance` in +`ts/tests/runtime.rs`, so any difference fails again, and delete this quest. diff --git a/ts/Cargo.lock b/ts/Cargo.lock index 77eb53a88..e808baebe 100644 --- a/ts/Cargo.lock +++ b/ts/Cargo.lock @@ -35,6 +35,13 @@ version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" +[[package]] +name = "census-fixture" +version = "0.0.0" +dependencies = [ + "bytes", +] + [[package]] name = "cfg-if" version = "1.0.5" @@ -157,7 +164,267 @@ dependencies = [ ] [[package]] -name = "lang-fixture" +name = "lang-args-fixture" +version = "0.0.0" + +[[package]] +name = "lang-arrays-fixture" +version = "0.0.0" + +[[package]] +name = "lang-ascii-fixture" +version = "0.0.0" + +[[package]] +name = "lang-atomics-fixture" +version = "0.0.0" + +[[package]] +name = "lang-borrows-fixture" +version = "0.0.0" + +[[package]] +name = "lang-bounds-fixture" +version = "0.0.0" + +[[package]] +name = "lang-boxes-fixture" +version = "0.0.0" + +[[package]] +name = "lang-capacity-fixture" +version = "0.0.0" + +[[package]] +name = "lang-captures-fixture" +version = "0.0.0" + +[[package]] +name = "lang-cells-fixture" +version = "0.0.0" + +[[package]] +name = "lang-chars-fixture" +version = "0.0.0" + +[[package]] +name = "lang-chunks-fixture" +version = "0.0.0" + +[[package]] +name = "lang-clones-fixture" +version = "0.0.0" + +[[package]] +name = "lang-collections-fixture" +version = "0.0.0" + +[[package]] +name = "lang-combinators-fixture" +version = "0.0.0" + +[[package]] +name = "lang-conversions-fixture" +version = "0.0.0" + +[[package]] +name = "lang-counts-fixture" +version = "0.0.0" + +[[package]] +name = "lang-cows-fixture" +version = "0.0.0" + +[[package]] +name = "lang-cycles-fixture" +version = "0.0.0" + +[[package]] +name = "lang-defaults-fixture" +version = "0.0.0" + +[[package]] +name = "lang-durations-fixture" +version = "0.0.0" + +[[package]] +name = "lang-dyns-fixture" +version = "0.0.0" + +[[package]] +name = "lang-edits-fixture" +version = "0.0.0" + +[[package]] +name = "lang-elements-fixture" +version = "0.0.0" + +[[package]] +name = "lang-ends-fixture" +version = "0.0.0" + +[[package]] +name = "lang-errors-fixture" +version = "0.0.0" + +[[package]] +name = "lang-fields-fixture" +version = "0.0.0" + +[[package]] +name = "lang-floats-fixture" +version = "0.0.0" + +[[package]] +name = "lang-folds-fixture" +version = "0.0.0" + +[[package]] +name = "lang-hashes-fixture" +version = "0.0.0" + +[[package]] +name = "lang-heap-fixture" +version = "0.0.0" + +[[package]] +name = "lang-hints-fixture" +version = "0.0.0" + +[[package]] +name = "lang-holds-fixture" +version = "0.0.0" + +[[package]] +name = "lang-ints-fixture" +version = "0.0.0" + +[[package]] +name = "lang-iters-fixture" +version = "0.0.0" + +[[package]] +name = "lang-joins-fixture" +version = "0.0.0" + +[[package]] +name = "lang-keys-fixture" +version = "0.0.0" + +[[package]] +name = "lang-lengths-fixture" +version = "0.0.0" + +[[package]] +name = "lang-lists-fixture" +version = "0.0.0" + +[[package]] +name = "lang-locals-fixture" +version = "0.0.0" + +[[package]] +name = "lang-locks-fixture" +version = "0.0.0" + +[[package]] +name = "lang-manual-fixture" +version = "0.0.0" + +[[package]] +name = "lang-methods-fixture" +version = "0.0.0" + +[[package]] +name = "lang-nested-fixture" +version = "0.0.0" + +[[package]] +name = "lang-objects-fixture" +version = "0.0.0" + +[[package]] +name = "lang-orders-fixture" +version = "0.0.0" + +[[package]] +name = "lang-pointers-fixture" +version = "0.0.0" + +[[package]] +name = "lang-refs-fixture" +version = "0.0.0" + +[[package]] +name = "lang-results-fixture" +version = "0.0.0" + +[[package]] +name = "lang-returns-fixture" +version = "0.0.0" + +[[package]] +name = "lang-rings-fixture" +version = "0.0.0" + +[[package]] +name = "lang-saturates-fixture" +version = "0.0.0" + +[[package]] +name = "lang-searches-fixture" +version = "0.0.0" + +[[package]] +name = "lang-separated-fixture" +version = "0.0.0" + +[[package]] +name = "lang-shapes-fixture" +version = "0.0.0" + +[[package]] +name = "lang-singles-fixture" +version = "0.0.0" + +[[package]] +name = "lang-slices-fixture" +version = "0.0.0" + +[[package]] +name = "lang-sorts-fixture" +version = "0.0.0" + +[[package]] +name = "lang-splits-fixture" +version = "0.0.0" + +[[package]] +name = "lang-statics-fixture" +version = "0.0.0" + +[[package]] +name = "lang-strs-fixture" +version = "0.0.0" + +[[package]] +name = "lang-tuples-fixture" +version = "0.0.0" + +[[package]] +name = "lang-utf8-fixture" +version = "0.0.0" + +[[package]] +name = "lang-wrappers-fixture" +version = "0.0.0" + +[[package]] +name = "lang-wraps-fixture" +version = "0.0.0" + +[[package]] +name = "lang-zeros-fixture" version = "0.0.0" [[package]] diff --git a/ts/Cargo.toml b/ts/Cargo.toml index 3909e04b8..ab3eff8c1 100644 --- a/ts/Cargo.toml +++ b/ts/Cargo.toml @@ -15,7 +15,19 @@ rustc_private = true [workspace] # Its own workspace, apart from the repo's: the driver builds on ts/rust-toolchain.toml's # nightly, which the other projects do not use. -members = ["fixtures/*"] +members = [ + "fixtures/bind", + "fixtures/census", + "fixtures/codec", + "fixtures/crates", + # A fixture per module of the language, beside what they share. + "fixtures/lang/*", + "fixtures/names", + "fixtures/reject", + "fixtures/share", + "fixtures/stock", + "fixtures/task", +] resolver = "3" [workspace.package] diff --git a/ts/README.md b/ts/README.md index d81a14fd3..287504ae2 100644 --- a/ts/README.md +++ b/ts/README.md @@ -917,7 +917,7 @@ which lower from core's MIR. ```bash just ts test # translate each fixture, compare, type-check, and diff -UPDATE_EXPECT=1 just ts test # rewrite the snapshots in fixtures/*/expected +UPDATE_EXPECT=1 just ts test # rewrite the snapshots in each fixture's expected/ just ts moq # translate moq-net's codec at a pinned revision just ts census # census moq-net and kio at the same revision ``` @@ -932,39 +932,17 @@ built natively for wasm32 and run beside its translation on the same inputs by `bench::run` and then with it as the first root, which must keep every line in order. Bun bundles a caller of `Decoder.u8` and `Decoder.new` through `import * as Decoder`, which must keep only those and what they call. -- `lang` covers every integer width's arithmetic, casts, and inherent methods, with - `NonZero`'s, `Wrapping`'s, and `Saturating`'s, at each width's edges, the ASCII methods of - every byte, of chars either side of ASCII, Latin-1, and the surrogates, and of slices and strings, `char`s next to each - encoding's edges and the surrogates, `Cow` and `Cow<[T]>` borrowed and owned, `Box<[T]>` and `Box` made each way, cloned into, lent, and turned back, into a boxed array or bytes included, `Wrapping` and `Saturating` at every width, `Duration`s whose - seconds pass 2^53 or reach `u64::MAX`, control flow, - patterns, `Copy` aggregates, those a container stores included and those written into - only in another module, behind a type parameter, or through a box, formatting, methods - on generic types, iterators, with - closures that log what each - adaptor reads, `Option`'s and `Result`'s combinators, with closures that log each call, - and std's collections, over keys whose own `Hash`, `Eq`, and `Ord` - disagree with JS's, sequences, tuples, `Arc`s, and cells compared across forms and item - types by an `eq` and `ne` that disagree, a `RefCell` compared while mutably borrowed, - `vec![x; n]` of types whose `Clone` counts its clones, `&mut` - to values JS copies, of locals, fields, elements, and a map's values, passed on, - returned, kept in a struct, and captured, a `Vec`'s edits and sorts, with closures - that log what each is called with, `concat` and `join` of arrays, slices, `Vec`s, and - `Cow`s, of bytes and of items whose `Clone` logs, std's `Bound`, `Reverse`, and - `NonZero`, and raw pointers: a linked list of boxed nodes as `hashlink` keeps one, through a union and a - `MaybeUninit` entry, pointers to locals, fields, and whole structs, those - `UnsafeCell::get` gives, as crossbeam-epoch's own `OnceLock` keeps its collector, and - those a generic type holds to its parameter, at each form a pointer takes, pointers - into a `Vec`, an array, a boxed slice, and a `MaybeUninit` array, as `smallvec` and - moq-net's frame segments move and copy through them, and a - generic type's arrays, slices, `Vec`s, and `Cow`s of its parameter at bytes, at - `u16`, and at values that drop. Its - differential test runs through `caller.ts`, a - hand-written caller that also prints a `printable` error nothing translated prints, - and adds every 64- and 128-bit case over each pair of values next to a power of two, - where the runtime switches between numbers and limbs, and its limbs carry and borrow, - with products of those values at 128 bits, 128-bit quotients by divisors below 2^32, - and their halves joined back. - `brands.ts`, another caller, mixes integer types where `tsc` must refuse them. +- `lang` is the language, a fixture per module under `fixtures/lang/`, each module's doc + saying what it covers; `fmt`, `generics`, and `shapes`, which share types, share + `shapes`. Each crate's `cases` names what it runs, which the first two bytes of an input + pick through the `harness.rs` they share. Its differential test runs through `lang.ts`, + a hand-written caller, which a fixture's own `caller.ts` extends with the inputs its + cases name: `ints`' adds every 64- and 128-bit case over each pair of values next to a + power of two, where the runtime switches between numbers and limbs, and its limbs carry + and borrow, with products of those values at 128 bits, 128-bit quotients by divisors + below 2^32, and their halves joined back, and `shapes`' prints a `printable` error + nothing translated prints. `shapes/brands.ts`, another caller, mixes integer types where + `tsc` must refuse them. `just ts test lang::ints` runs one. - `names` is translated from `run`, then with `added` as its first root, which reaches another instance of what `run` reaches one of, each sorting before it: a generic method's, a closure's, an impl's of another trait, a std function's that merges with `run`'s, and @@ -1010,8 +988,12 @@ built natively for wasm32 and run beside its translation on the same inputs by `refused.toml` drops the binding, its `rev` feature makes the dependency's iterator run from either end, and its `shared` feature adds a module of the dependency's name, with the errors in `refused.txt`, `rev.txt`, and `shared.txt`. -- `reject` holds constructs outside the subset; its expected errors are `expected.txt`, - and its expected census is `census.md`. +- `reject` holds constructs outside the subset, a module per kind of construct. Its + expected errors are `expected.txt` and its census's spans `census.txt`, each line keyed + by the item it points into and sorted, so cases added to different items don't conflict. + Its roots in `ts.toml` stay sorted through taplo. +- `census` holds a few constructs translation refuses for good, whose census, with its + totals, is `census.md`. `tests/spawn.ts` checks that `rt.spawn` yields to a timer after its 128-poll budget, rejects when a future panics as it drops, and drops a future when its signal aborts: diff --git a/ts/fixtures/bind/refused.txt b/ts/fixtures/bind/refused.txt index e46876b88..8239f0729 100644 --- a/ts/fixtures/bind/refused.txt +++ b/ts/fixtures/bind/refused.txt @@ -2,18 +2,18 @@ binding `blob::Blob`: no such item, or more than one, in the crate or a crate it binding `buf::Source`: a binding is of a function or a type, not Trait binding `buf::empty`: ../blob.ts must be relative to ts.toml, inside its directory binding `nowhere::Thing`: no such item, or more than one, in the crate or a crate it depends on -binding `raw`: a binding is of a function or a type, not Mod binding `raw::Held::new`: RT/held.ts would replace the runtime, rt.ts and rt/ -binding `raw::Tally`: bind/blob.ts binds another type binding `raw::Tally::get`: only a type's value drops binding `raw::Tally::new`: rt/tally.ts would replace the runtime, rt.ts and rt/ +binding `raw::Tally`: bind/blob.ts binds another type binding `raw::checksum`: `checksum` binds the same item +binding `raw`: a binding is of a function or a type, not Mod binding `std::vec::Vec`: the type has a representation of its own -reading bind/missing.ts: No such file or directory (os error 2) at fixtures/bind/src/harness.rs:28:12 -`raw::Held` binds without drop, so it would never drop its `raw::Tally` at fixtures/bind/src/harness.rs:121:13 -a binding of `raw::value`, whose `N` one export for every instance can't recover from its arguments at fixtures/bind/src/raw.rs:65:1 -a binding of `raw::zero`, whose `T` one export for every instance can't recover from its arguments at fixtures/bind/src/raw.rs:60:1 -`raw::Held` binds without drop, so it would never drop its `raw::Tally` at fixtures/bind/src/harness.rs:121:6 -unsupported call to `std::sync::Arc::::from_raw` at fixtures/bind/src/raw.rs:55:17 -unsupported call to `std::sync::Arc::::into_raw` at fixtures/bind/src/raw.rs:42:11 -an assignment through a reference to `blob::Blob` at fixtures/bind/src/harness.rs:128:2 +fixtures/bind/src/harness.rs:refused+3:6: `raw::Held` binds without drop, so it would never drop its `raw::Tally` +fixtures/bind/src/harness.rs:refused+3:13: `raw::Held` binds without drop, so it would never drop its `raw::Tally` +fixtures/bind/src/harness.rs:replace+1:2: an assignment through a reference to `blob::Blob` +fixtures/bind/src/harness.rs:run+14:12: reading bind/missing.ts: No such file or directory (os error 2) +fixtures/bind/src/raw.rs:impl Drop for Tally+3:17: unsupported call to `std::sync::Arc::::from_raw` +fixtures/bind/src/raw.rs:impl Tally+3:11: unsupported call to `std::sync::Arc::::into_raw` +fixtures/bind/src/raw.rs:value+0:1: a binding of `raw::value`, whose `N` one export for every instance can't recover from its arguments +fixtures/bind/src/raw.rs:zero+0:1: a binding of `raw::zero`, whose `T` one export for every instance can't recover from its arguments diff --git a/ts/fixtures/bind/wrong.txt b/ts/fixtures/bind/wrong.txt index e135ffa17..f82f44a7a 100644 --- a/ts/fixtures/bind/wrong.txt +++ b/ts/fixtures/bind/wrong.txt @@ -1,15 +1,15 @@ -the binding of `blob::Blob::len` in wrong/blob.ts doesn't type-check: error TS2322: Type '(self: ByteSlice) => string' is not assignable to type '(a0: ByteSlice) => usize'. +fixtures/bind/blob/src/lib.rs:impl Blob+21:2: the binding of `blob::Blob::len` in wrong/blob.ts doesn't type-check: error TS2322: Type '(self: ByteSlice) => string' is not assignable to type '(a0: ByteSlice) => usize'. Type 'string' is not assignable to type 'usize'. - Type 'string' is not assignable to type 'number'. at fixtures/bind/blob/src/lib.rs:38:2 -the binding of `blob::Blob::slice::>` in wrong/blob.ts doesn't type-check: error TS2339: Property 'slice' does not exist on type 'typeof import("wrong/blob")'. at fixtures/bind/blob/src/lib.rs:48:2 -the binding of `::eq` in wrong/blob.ts doesn't type-check: error TS2322: Type '(self: ByteSlice, other: string) => boolean' is not assignable to type '(a0: ByteSlice, a1: ByteSlice) => boolean'. + Type 'string' is not assignable to type 'number'. +fixtures/bind/blob/src/lib.rs:impl Blob+31:2: the binding of `blob::Blob::slice::>` in wrong/blob.ts doesn't type-check: error TS2339: Property 'slice' does not exist on type 'typeof import("wrong/blob")'. +fixtures/bind/blob/src/lib.rs:impl Hash for Blob+1:2: the binding of `::hash::` in wrong/blob.ts doesn't type-check: error TS2339: Property 'hash$Hash' does not exist on type 'typeof import("wrong/blob")'. +fixtures/bind/blob/src/lib.rs:impl Ord for Blob+1:2: the binding of `::cmp` in wrong/blob.ts doesn't type-check: error TS2339: Property 'cmp$cmp_Ord' does not exist on type 'typeof import("wrong/blob")'. +fixtures/bind/blob/src/lib.rs:impl PartialEq for Blob+1:2: the binding of `::eq` in wrong/blob.ts doesn't type-check: error TS2322: Type '(self: ByteSlice, other: string) => boolean' is not assignable to type '(a0: ByteSlice, a1: ByteSlice) => boolean'. Types of parameters 'other' and 'a1' are incompatible. - Type 'ByteSlice' is not assignable to type 'string'. at fixtures/bind/blob/src/lib.rs:94:2 -the binding of `raw::skip` in wrong/skip.ts doesn't type-check: error TS2322: Type '(bytes: ByteSlice, at: Place) => usize' is not assignable to type '(a0: ByteSlice, a1: Place) => undefined'. - Type 'usize' is not assignable to type 'undefined'. at fixtures/bind/src/raw.rs:26:1 -the binding of `raw::Tally` in wrong/tally.ts doesn't type-check: error TS2322: Type 'Tally' is not assignable to type '"a bound value that drops must have a [Symbol.dispose]"'. at fixtures/bind/src/raw.rs:35:1 -the binding of `raw::Held>` in wrong/held.ts doesn't type-check: error TS2322: Type 'u8 | undefined' is not assignable to type '"a bound value can't be undefined, which None is"'. - Type 'undefined' is not assignable to type '"a bound value can't be undefined, which None is"'. at fixtures/bind/src/raw.rs:70:1 -the binding of `::hash::` in wrong/blob.ts doesn't type-check: error TS2339: Property 'hash$Hash' does not exist on type 'typeof import("wrong/blob")'. at fixtures/bind/blob/src/lib.rs:102:2 -the binding of `::cmp` in wrong/blob.ts doesn't type-check: error TS2339: Property 'cmp$cmp_Ord' does not exist on type 'typeof import("wrong/blob")'. at fixtures/bind/blob/src/lib.rs:114:2 -the binding of `::partial_cmp` in wrong/blob.ts doesn't type-check: error TS2339: Property 'partialCmp$cmp_PartialOrd' does not exist on type 'typeof import("wrong/blob")'. at fixtures/bind/blob/src/lib.rs:108:2 + Type 'ByteSlice' is not assignable to type 'string'. +fixtures/bind/blob/src/lib.rs:impl PartialOrd for Blob+1:2: the binding of `::partial_cmp` in wrong/blob.ts doesn't type-check: error TS2339: Property 'partialCmp$cmp_PartialOrd' does not exist on type 'typeof import("wrong/blob")'. +fixtures/bind/src/raw.rs:Held+0:1: the binding of `raw::Held>` in wrong/held.ts doesn't type-check: error TS2322: Type 'u8 | undefined' is not assignable to type '"a bound value can't be undefined, which None is"'. + Type 'undefined' is not assignable to type '"a bound value can't be undefined, which None is"'. +fixtures/bind/src/raw.rs:Tally+0:1: the binding of `raw::Tally` in wrong/tally.ts doesn't type-check: error TS2322: Type 'Tally' is not assignable to type '"a bound value that drops must have a [Symbol.dispose]"'. +fixtures/bind/src/raw.rs:skip+0:1: the binding of `raw::skip` in wrong/skip.ts doesn't type-check: error TS2322: Type '(bytes: ByteSlice, at: Place) => usize' is not assignable to type '(a0: ByteSlice, a1: Place) => undefined'. + Type 'usize' is not assignable to type 'undefined'. diff --git a/ts/fixtures/census/Cargo.toml b/ts/fixtures/census/Cargo.toml new file mode 100644 index 000000000..3713b8255 --- /dev/null +++ b/ts/fixtures/census/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "census-fixture" +description = "What a census of rust2-ts ranks" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[dependencies] +bytes = "1.12.1" + +[lints] +workspace = true diff --git a/ts/fixtures/census/census.md b/ts/fixtures/census/census.md new file mode 100644 index 000000000..5ba68a1ad --- /dev/null +++ b/ts/fixtures/census/census.md @@ -0,0 +1,94 @@ +# Census of `census-fixture` + +- Refusals: 12 +- Function instances: 6 +- Generic functions no instance reached, lowered over their type parameters: 1 + +## By construct + +| Count | Construct | First | +| ---: | --- | --- | +| 3 | a raw pointer to `_` behind a reference, which is the object and not where it is kept | fixtures/census/src/lib.rs:9:2 | +| 2 | a cast from `_` to `_`, between a pointer and an integer | fixtures/census/src/lib.rs:9:2 | +| 2 | a cast from a pointer to `_` to one to `_`, which reads the bytes of one type as another | fixtures/census/src/lib.rs:19:12 | +| 2 | a mutable static, which any code may write | fixtures/census/src/lib.rs:38:3 | +| 1 | `Pointer` formatting, as in `{:p}`, is not supported | fixtures/census/src/lib.rs:24:2 | +| 1 | `_`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported | fixtures/census/src/lib.rs:45:36 | +| 1 | union `_`, whose fields overlap in `_` and `f64`, which JS keeps apart | fixtures/census/src/lib.rs:28:1 | + +## By API + +The type or module each refused type or path belongs to. + +| Count | API | First | +| ---: | --- | --- | +| 4 | `u32` | fixtures/census/src/lib.rs:9:2 | +| 2 | `u64` | fixtures/census/src/lib.rs:19:47 | +| 2 | `u8` | fixtures/census/src/lib.rs:19:12 | +| 2 | `usize` | fixtures/census/src/lib.rs:9:2 | +| 1 | `*const T` | fixtures/census/src/lib.rs:14:2 | +| 1 | `*const u32` | fixtures/census/src/lib.rs:9:2 | +| 1 | `Bits` | fixtures/census/src/lib.rs:28:1 | +| 1 | `BytesMut` | fixtures/census/src/lib.rs:45:36 | + +## By type or path + +| Count | Construct | Type or path | First | +| ---: | --- | --- | --- | +| 2 | a raw pointer to `_` behind a reference, which is the object and not where it is kept | `u32` | fixtures/census/src/lib.rs:9:2 | +| 1 | `_`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported | `BytesMut::capacity` | fixtures/census/src/lib.rs:45:36 | +| 1 | a cast from `_` to `_`, between a pointer and an integer | `*const T`, `usize` | fixtures/census/src/lib.rs:14:2 | +| 1 | a cast from `_` to `_`, between a pointer and an integer | `*const u32`, `usize` | fixtures/census/src/lib.rs:9:2 | +| 1 | a cast from a pointer to `_` to one to `_`, which reads the bytes of one type as another | `u32`, `u8` | fixtures/census/src/lib.rs:19:12 | +| 1 | a cast from a pointer to `_` to one to `_`, which reads the bytes of one type as another | `u64`, `u8` | fixtures/census/src/lib.rs:19:47 | +| 1 | a raw pointer to `_` behind a reference, which is the object and not where it is kept | `u64` | fixtures/census/src/lib.rs:19:48 | +| 1 | union `_`, whose fields overlap in `_` and `f64`, which JS keeps apart | `Bits`, `u32` | fixtures/census/src/lib.rs:28:1 | + +## Spans + +
a raw pointer to `_` behind a reference, which is the object and not where it is kept (3) + +- fixtures/census/src/lib.rs:9:2: a raw pointer to `u32` behind a reference, which is the object and not where it is kept +- fixtures/census/src/lib.rs:19:13: a raw pointer to `u32` behind a reference, which is the object and not where it is kept +- fixtures/census/src/lib.rs:19:48: a raw pointer to `u64` behind a reference, which is the object and not where it is kept + +
+ +
a cast from `_` to `_`, between a pointer and an integer (2) + +- fixtures/census/src/lib.rs:9:2: a cast from `*const u32` to `usize`, between a pointer and an integer +- fixtures/census/src/lib.rs:14:2: a cast from `*const T` to `usize`, between a pointer and an integer + +
+ +
a cast from a pointer to `_` to one to `_`, which reads the bytes of one type as another (2) + +- fixtures/census/src/lib.rs:19:12: a cast from a pointer to `u32` to one to `u8`, which reads the bytes of one type as another +- fixtures/census/src/lib.rs:19:47: a cast from a pointer to `u64` to one to `u8`, which reads the bytes of one type as another + +
+ +
a mutable static, which any code may write (2) + +- fixtures/census/src/lib.rs:38:3: a mutable static, which any code may write +- fixtures/census/src/lib.rs:39:3: a mutable static, which any code may write + +
+ +
`Pointer` formatting, as in `{:p}`, is not supported (1) + +- fixtures/census/src/lib.rs:24:2: `Pointer` formatting, as in `{:p}`, is not supported + +
+ +
`_`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported (1) + +- fixtures/census/src/lib.rs:45:36: `BytesMut::capacity`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported + +
+ +
union `_`, whose fields overlap in `_` and `f64`, which JS keeps apart (1) + +- fixtures/census/src/lib.rs:28:1: union `Bits`, whose fields overlap in `u32` and `f64`, which JS keeps apart + +
diff --git a/ts/fixtures/census/src/lib.rs b/ts/fixtures/census/src/lib.rs new file mode 100644 index 000000000..fc229642c --- /dev/null +++ b/ts/fixtures/census/src/lib.rs @@ -0,0 +1,46 @@ +//! Constructs translation refuses for good, which a census ranks: each item is a root, a +//! generic one lowered over its type parameter, and the same construct refused at +//! different types groups together. + +#![allow(dead_code, reason = "each item is a census root, not called from Rust")] + +/// A pointer's address, which JS has no counterpart of. +pub fn addressed(n: u32) -> usize { + &n as *const u32 as usize +} + +/// A pointer's address in a body no instance reaches, lowered over `T`. +pub fn generic(t: T) -> usize { + &t as *const T as usize +} + +/// A pointer read as another type's bytes, at two types. +pub fn reinterpreted(n: u32, m: u64) -> u8 { + unsafe { *(&n as *const u32 as *const u8) ^ *(&m as *const u64 as *const u8) } +} + +/// A pointer's address, formatted. +pub fn printed(n: u8) -> String { + format!("{:p}", &n) +} + +/// A union whose fields overlap in values JS keeps apart. +pub union Bits { + int: u32, + float: f64, +} + +static mut COUNT: u8 = 0; + +/// A mutable static, which any code may write. +pub fn counted() -> u8 { + unsafe { + COUNT += 1; + COUNT + } +} + +/// A `BytesMut`'s capacity, which `bytes` reclaims only once the `Bytes` it froze drops. +pub fn capacity(n: usize) -> usize { + bytes::BytesMut::with_capacity(n).capacity() +} diff --git a/ts/fixtures/census/ts.toml b/ts/fixtures/census/ts.toml new file mode 100644 index 000000000..2fd667b47 --- /dev/null +++ b/ts/fixtures/census/ts.toml @@ -0,0 +1,3 @@ +# The census's: no roots, so every item is one. +package = "census-fixture" +roots = [] diff --git a/ts/fixtures/crates/alike.txt b/ts/fixtures/crates/alike.txt index f5ed0c49f..676582637 100644 --- a/ts/fixtures/crates/alike.txt +++ b/ts/fixtures/crates/alike.txt @@ -1 +1 @@ -`alike::one::` and `alike::one::` would both be named `one$alike_fmt_Error` in lib.ts at fixtures/crates/src/lib.rs:18:2 +fixtures/crates/src/lib.rs:alike+1:2: `alike::one::` and `alike::one::` would both be named `one$alike_fmt_Error` in lib.ts diff --git a/ts/fixtures/crates/refused.txt b/ts/fixtures/crates/refused.txt index b727be708..4d8ec80f7 100644 --- a/ts/fixtures/crates/refused.txt +++ b/ts/fixtures/crates/refused.txt @@ -1 +1 @@ -unsupported call to `std::ptr::const_ptr::::byte_add` at fixtures/crates/dep/src/lib.rs:128:27 +fixtures/crates/dep/src/lib.rs:last+3:27: unsupported call to `std::ptr::const_ptr::::byte_add` diff --git a/ts/fixtures/crates/shared.txt b/ts/fixtures/crates/shared.txt index 195eae720..a0adb885d 100644 --- a/ts/fixtures/crates/shared.txt +++ b/ts/fixtures/crates/shared.txt @@ -1 +1 @@ -module `crates_dep` would share its files with the crate of its name at fixtures/crates/src/lib.rs:7:1 +fixtures/crates/src/lib.rs:crates_dep+0:1: module `crates_dep` would share its files with the crate of its name diff --git a/ts/fixtures/lang/Cargo.toml b/ts/fixtures/lang/args/Cargo.toml similarity index 66% rename from ts/fixtures/lang/Cargo.toml rename to ts/fixtures/lang/args/Cargo.toml index 6f693c423..b8a8564ff 100644 --- a/ts/fixtures/lang/Cargo.toml +++ b/ts/fixtures/lang/args/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "lang-fixture" -description = "The language rust2-ts translates, exercised against native Rust" +name = "lang-args-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" version = "0.0.0" edition.workspace = true license.workspace = true diff --git a/ts/fixtures/lang/expected/args.Scale.ts b/ts/fixtures/lang/args/expected/args.Scale.ts similarity index 100% rename from ts/fixtures/lang/expected/args.Scale.ts rename to ts/fixtures/lang/args/expected/args.Scale.ts diff --git a/ts/fixtures/lang/expected/args.ts b/ts/fixtures/lang/args/expected/args.ts similarity index 96% rename from ts/fixtures/lang/expected/args.ts rename to ts/fixtures/lang/args/expected/args.ts index aa5376bef..1688cc083 100644 --- a/ts/fixtures/lang/expected/args.ts +++ b/ts/fixtures/lang/args/expected/args.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import * as args_Scale from "./args.Scale.ts"; +import * as Scale from "./args.Scale.ts"; import { map$0waqle9 as option_map$0waqle9, map$1yogfym as option_map$1yogfym, mapOr$0dk8jdr as option_mapOr$0dk8jdr } from "./core/option.ts"; /** A use that needs the slice itself. */ @@ -147,8 +147,8 @@ export function pair(n: rt.u8, s: rt.ByteSlice): rt.u8 { return n ^ opaque(s); } -export function weigh$args_Scale(w: args_Scale.Scale, data: rt.ByteSlice): rt.u8 { - return args_Scale.weigh$args_Weigh(w, data); +export function weigh$args_Scale(w: Scale.Scale, data: rt.ByteSlice): rt.u8 { + return Scale.weigh$args_Weigh(w, data); } export function args(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { @@ -236,7 +236,7 @@ export function args(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, sum(data.data, data.start, data.length)); } else { rt.byteVecPush(out, weigh$args_Scale({ _0: kind }, data)); - rt.byteVecPush(out, args_Scale.weigh$args_Weigh({ _0: 3 }, rt.byteSliceRange(data, rt.min(data.length, 2)))); + rt.byteVecPush(out, Scale.weigh$args_Weigh({ _0: 3 }, rt.byteSliceRange(data, rt.min(data.length, 2)))); } } diff --git a/ts/fixtures/lang/args/expected/core/option.ts b/ts/fixtures/lang/args/expected/core/option.ts new file mode 100644 index 000000000..2e934a440 --- /dev/null +++ b/ts/fixtures/lang/args/expected/core/option.ts @@ -0,0 +1,27 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import { opaque, len as args_len } from "../args.ts"; + +export function map$0waqle9(self: rt.ByteSlice | undefined, _: (a0: rt.ByteSlice) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return opaque(self); +} + +export function map$1yogfym(self: [rt.u8, rt.ByteSlice] | undefined, f: (a0: [rt.u8, rt.ByteSlice]) => rt.ByteSlice): rt.ByteSlice | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function mapOr$0dk8jdr(self: rt.ByteSlice | undefined, default_: rt.usize, _: (a0: rt.ByteSlice) => rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return args_len(self.data, self.start, self.length); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/args/expected/harness.ts b/ts/fixtures/lang/args/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/args/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/args/expected/lib.ts b/ts/fixtures/lang/args/expected/lib.ts new file mode 100644 index 000000000..1050052e9 --- /dev/null +++ b/ts/fixtures/lang/args/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { args } from "./args.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["args::args", args as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/args.rs b/ts/fixtures/lang/args/src/args.rs similarity index 100% rename from ts/fixtures/lang/src/args.rs rename to ts/fixtures/lang/args/src/args.rs diff --git a/ts/fixtures/lang/args/src/lib.rs b/ts/fixtures/lang/args/src/lib.rs new file mode 100644 index 000000000..1a84f2d04 --- /dev/null +++ b/ts/fixtures/lang/args/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod args; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("args::args", args::args)] +} diff --git a/ts/fixtures/lang/args/ts.toml b/ts/fixtures/lang/args/ts.toml new file mode 100644 index 000000000..d1bcd899f --- /dev/null +++ b/ts/fixtures/lang/args/ts.toml @@ -0,0 +1,2 @@ +package = "lang-args-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/arrays/Cargo.toml b/ts/fixtures/lang/arrays/Cargo.toml new file mode 100644 index 000000000..1d6190f28 --- /dev/null +++ b/ts/fixtures/lang/arrays/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-arrays-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/expected/arrays.Bracketed.ts b/ts/fixtures/lang/arrays/expected/arrays.Bracketed.ts similarity index 100% rename from ts/fixtures/lang/expected/arrays.Bracketed.ts rename to ts/fixtures/lang/arrays/expected/arrays.Bracketed.ts diff --git a/ts/fixtures/lang/expected/arrays.Framed.ts b/ts/fixtures/lang/arrays/expected/arrays.Framed.ts similarity index 100% rename from ts/fixtures/lang/expected/arrays.Framed.ts rename to ts/fixtures/lang/arrays/expected/arrays.Framed.ts diff --git a/ts/fixtures/lang/expected/arrays.Listed.ts b/ts/fixtures/lang/arrays/expected/arrays.Listed.ts similarity index 100% rename from ts/fixtures/lang/expected/arrays.Listed.ts rename to ts/fixtures/lang/arrays/expected/arrays.Listed.ts diff --git a/ts/fixtures/lang/expected/arrays.ts b/ts/fixtures/lang/arrays/expected/arrays.ts similarity index 100% rename from ts/fixtures/lang/expected/arrays.ts rename to ts/fixtures/lang/arrays/expected/arrays.ts diff --git a/ts/fixtures/lang/arrays/expected/core/bool.ts b/ts/fixtures/lang/arrays/expected/core/bool.ts new file mode 100644 index 000000000..3e33ce452 --- /dev/null +++ b/ts/fixtures/lang/arrays/expected/core/bool.ts @@ -0,0 +1,10 @@ +// Generated by rust2-ts. Do not edit. + +export function then$11x7xqs(self: boolean, f: () => Uint8Array): Uint8Array | undefined { + if (!self) { + return undefined; + } + return f(); +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/arrays/expected/core/option.ts b/ts/fixtures/lang/arrays/expected/core/option.ts new file mode 100644 index 000000000..8c39a353f --- /dev/null +++ b/ts/fixtures/lang/arrays/expected/core/option.ts @@ -0,0 +1,62 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function isSomeAnd$09tpccf(self: rt.u8 | undefined, f: (a0: rt.u8) => boolean): boolean { + if (self === undefined) { + return false; + } + return f(self); +} + +export function unwrapOr$1rbuegs(self: rt.ByteSlice | undefined, default_: rt.ByteSlice): rt.ByteSlice { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$1j8xzu6(self: rt.u8 | undefined | rt.None, f: (a0: rt.u8 | undefined) => undefined): undefined | rt.None { + if (self === rt.None) { + return rt.None; + } + f(self); + return undefined; +} + +export function map$0p6o7wa(self: Uint8Array | undefined, f: (a0: Uint8Array) => Uint8Array): Uint8Array | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$1jcn6wm(self: rt.ByteSlice | undefined, f: (a0: rt.ByteSlice) => Uint8Array): Uint8Array | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0rbsrz6(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8 | undefined): rt.u8 | undefined | rt.None { + if (self === undefined) { + return rt.None; + } + return f(self); +} + +export function mapOr$1surhce(self: rt.u8 | undefined, default_: rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/arrays/expected/harness.ts b/ts/fixtures/lang/arrays/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/arrays/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/arrays/expected/lib.ts b/ts/fixtures/lang/arrays/expected/lib.ts new file mode 100644 index 000000000..f00664e18 --- /dev/null +++ b/ts/fixtures/lang/arrays/expected/lib.ts @@ -0,0 +1,90 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { fromFns, maps, lent, asSlices, given, flattened } from "./arrays.ts"; + +export function copy$Option_Option_array0_u8(v: Uint8Array | undefined | rt.None): Uint8Array | undefined | rt.None { + return v === rt.None ? v : copy$Option_array0_u8(v); +} + +export function copy$Option_Option_array1_u8(v: Uint8Array | undefined | rt.None): Uint8Array | undefined | rt.None { + return v === rt.None ? v : copy$Option_array1_u8(v); +} + +export function copy$Option_Option_array5_u8(v: Uint8Array | undefined | rt.None): Uint8Array | undefined | rt.None { + return v === rt.None ? v : copy$Option_array5_u8(v); +} + +export function copy$Option_array0_u8(v: Uint8Array | undefined): Uint8Array | undefined { + return v === undefined ? v : copy$array_u8(v); +} + +export function copy$Option_array1_u8(v: Uint8Array | undefined): Uint8Array | undefined { + return v === undefined ? v : copy$array_u8(v); +} + +export function copy$Option_array3_u8(v: Uint8Array | undefined): Uint8Array | undefined { + return v === undefined ? v : copy$array_u8(v); +} + +export function copy$Option_array40_u8(v: Uint8Array | undefined): Uint8Array | undefined { + return v === undefined ? v : copy$array_u8(v); +} + +export function copy$Option_array5_u8(v: Uint8Array | undefined): Uint8Array | undefined { + return v === undefined ? v : copy$array_u8(v); +} + +export function copy$array_Option_Option_array0_u8(v: Array): Array { + return v.map(copy$Option_Option_array0_u8); +} + +export function copy$array_Option_Option_array1_u8(v: Array): Array { + return v.map(copy$Option_Option_array1_u8); +} + +export function copy$array_Option_Option_array5_u8(v: Array): Array { + return v.map(copy$Option_Option_array5_u8); +} + +export function copy$array_array0_u8(v: Uint8Array[]): Uint8Array[] { + return v.map(copy$array_u8); +} + +export function copy$array_array1_u8(v: Uint8Array[]): Uint8Array[] { + return v.map(copy$array_u8); +} + +export function copy$array_array2_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); +} + +export function copy$array_u32(v: rt.u32[]): rt.u32[] { + return v.slice(); +} + +export function copy$array_u8(v: Uint8Array): Uint8Array { + return v.slice(); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["arrays::from_fns", (_22: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + fromFns(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["arrays::as_slices", (_23: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + asSlices(data2, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["arrays::maps", (_24: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + maps(data3, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["arrays::lent", (_25: rt.u8, data4: rt.ByteSlice, out4: rt.ByteVec): undefined => { + lent(data4, out4); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["arrays::given", given as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["arrays::flattened", flattened as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/arrays.rs b/ts/fixtures/lang/arrays/src/arrays.rs similarity index 100% rename from ts/fixtures/lang/src/arrays.rs rename to ts/fixtures/lang/arrays/src/arrays.rs diff --git a/ts/fixtures/lang/arrays/src/lib.rs b/ts/fixtures/lang/arrays/src/lib.rs new file mode 100644 index 000000000..ca11865d1 --- /dev/null +++ b/ts/fixtures/lang/arrays/src/lib.rs @@ -0,0 +1,26 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod arrays; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("arrays::from_fns", |_, data, out| arrays::from_fns(data, out)), + ("arrays::as_slices", |_, data, out| arrays::as_slices(data, out)), + ("arrays::maps", |_, data, out| arrays::maps(data, out)), + ("arrays::lent", |_, data, out| arrays::lent(data, out)), + ("arrays::given", arrays::given), + ("arrays::flattened", arrays::flattened), + ] +} diff --git a/ts/fixtures/lang/arrays/ts.toml b/ts/fixtures/lang/arrays/ts.toml new file mode 100644 index 000000000..6409ca4ee --- /dev/null +++ b/ts/fixtures/lang/arrays/ts.toml @@ -0,0 +1,2 @@ +package = "lang-arrays-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/ascii/Cargo.toml b/ts/fixtures/lang/ascii/Cargo.toml new file mode 100644 index 000000000..7d0a9dac0 --- /dev/null +++ b/ts/fixtures/lang/ascii/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-ascii-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/ascii/caller.ts b/ts/fixtures/lang/ascii/caller.ts new file mode 100644 index 000000000..5f6d0433f --- /dev/null +++ b/ts/fixtures/lang/ascii/caller.ts @@ -0,0 +1,27 @@ +// The inputs `ascii`'s cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `ascii` cases of each kind: bytes and slices on each prefix of text padded by ASCII + * whitespace, vertical tab among it, holding a byte of each escape and class, so escapes + * are read from both ends; slices on text of each char `ascii.rs` tries; chars on the + * scalars either side of the surrogates and past the last. + */ +const asciiText = [0x20, 0x09, 0x0b, 0x48, 0x7a, 0x22, 0x5c, 0x27, 0x7f, 0x80, 0xff, 0x0a, 0x0c, 0x0d, 0x20]; +const asciiCases = [ + ...["ascii::bytes", "ascii::slices"].flatMap((name) => + Array.from({ length: 4 * (asciiText.length + 1) }, (_, i) => Uint8Array.of(...op(name), i % 4, ...asciiText.slice(0, Math.floor(i / 4)))), + ), + // Text of every char `ascii.rs` tries, each once. + ...[0, 1, 2, 3].map((kind) => Uint8Array.of(...op("ascii::slices"), kind, ...Array.from({ length: 41 }, (_, i) => i))), + Uint8Array.of(...op("ascii::chars"), 0, ...[0xd7ff, 0xd800, 0xdfff, 0xe000, 0x1f600, 0x10ffff, 0x110000].flatMap((n) => [n >>> 24, (n >>> 16) & 0xff, (n >>> 8) & 0xff, n & 0xff])), + // `parts` of each kind at every pair of byte offsets up to two past the end of its + // 14 bytes of text, and of no text. + ...Array.from({ length: 8 * 17 * 17 }, (_, i) => Uint8Array.of(...op("ascii::parts"), i % 8, Math.floor(i / 8) % 17, Math.floor(i / 8 / 17))), + ...Array.from({ length: 8 * 3 * 3 }, (_, i) => Uint8Array.of(...op("ascii::parts"), 0x10 | (i % 8), Math.floor(i / 8) % 3, Math.floor(i / 24))), +]; + +export const cases: Uint8Array[] = [...asciiCases]; diff --git a/ts/fixtures/lang/expected/ascii.Held.ts b/ts/fixtures/lang/ascii/expected/ascii.Held.ts similarity index 100% rename from ts/fixtures/lang/expected/ascii.Held.ts rename to ts/fixtures/lang/ascii/expected/ascii.Held.ts diff --git a/ts/fixtures/lang/expected/ascii.ts b/ts/fixtures/lang/ascii/expected/ascii.ts similarity index 91% rename from ts/fixtures/lang/expected/ascii.ts rename to ts/fixtures/lang/ascii/expected/ascii.ts index 94e96dee6..007f77889 100644 --- a/ts/fixtures/lang/expected/ascii.ts +++ b/ts/fixtures/lang/ascii/expected/ascii.ts @@ -1,9 +1,9 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import type * as ascii_Held from "./ascii.Held.ts"; -import { isSomeAnd$09tpccf, unwrapOr$1iemzn8 as option_unwrapOr$1iemzn8, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOr$0l7j3f6 as option_unwrapOr$0l7j3f6, mapOr$1t0muvr as option_mapOr$1t0muvr, mapOr$02k4ito as option_mapOr$02k4ito, mapOr$0jad0p1 as option_mapOr$0jad0p1, asDeref$0w8at8i as option_asDeref$0w8at8i } from "./core/option.ts"; -import { put as fmt_put } from "./fmt.ts"; +import type * as Held from "./ascii.Held.ts"; +import { isSomeAnd$09tpccf, unwrapOr$1iemzn8 as option_unwrapOr$1iemzn8, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOr$0l7j3f6 as option_unwrapOr$0l7j3f6, mapOr$1t0muvr as option_mapOr$1t0muvr, mapOr$0jad0p1 as option_mapOr$0jad0p1, mapOr$02k4ito as option_mapOr$02k4ito, asDeref$0w8at8i as option_asDeref$0w8at8i } from "./core/option.ts"; +import { put } from "./harness.ts"; /** Each test of `b`, a bit apiece. */ export function byteTests(b: rt.u8): rt.u16 { @@ -62,7 +62,7 @@ export function steps$ascii_EscapeDefault(e: rt.Iter, data: rt.ByteSlice, const written = rt.fmtWriteString(shown, [args2[0]]); shown = written.s; rt.resultUnwrap(written.result, rt.fmtErrorDebug); - fmt_put(out, shown); + put(out, shown); i = rt.usizeAdd(i, 1); } else { return; @@ -146,7 +146,7 @@ export function bytes(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const written = rt.fmtWriteString(shown, [args2[0], "|", rt.fmtSpec({ align: ">", width: 6 }, args2[1]), "|", args2[2]]); shown = written.s; rt.resultUnwrap(written.result, rt.fmtErrorDebug); - fmt_put(out, shown); + put(out, shown); rt.iterExtendBytes(out, e.clone(), "next"); rt.iterExtendBytes(out, rt.iterRev(e.clone()), "next"); rt.byteVecPush(out, rt.optionUnwrap(rt.iterLast(e.clone()))); @@ -268,32 +268,32 @@ export function slices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, rt.strIsAscii(s) ? 1 : 0); rt.byteVecPush(out, rt.strEqIgnoreAsciiCase(_124, _127) ? 1 : 0); rt.byteVecPush(out, rt.strEqIgnoreAsciiCase(_124, rt.strToAsciiUppercase(_127)) ? 1 : 0); - fmt_put(out, rt.strToAsciiUppercase(s)); - fmt_put(out, rt.stringExtendChars("", rt.iterFilter(rt.strChars(s), (a0: rt.char): boolean => { + put(out, rt.strToAsciiUppercase(s)); + put(out, rt.stringExtendChars("", rt.iterFilter(rt.strChars(s), (a0: rt.char): boolean => { return rt.isAsciiAlphanumeric(a0); }))); - fmt_put(out, rt.strToAsciiLowercase(s)); - fmt_put(out, rt.strTrimAsciiStart(s)); - fmt_put(out, rt.strTrimAsciiEnd(s)); - fmt_put(out, rt.strTrimAscii(s)); + put(out, rt.strToAsciiLowercase(s)); + put(out, rt.strTrimAsciiStart(s)); + put(out, rt.strTrimAsciiEnd(s)); + put(out, rt.strTrimAscii(s)); let t: string = s; t = rt.strToAsciiUppercase(t); - fmt_put(out, t); + put(out, t); t = rt.strToAsciiLowercase(t); - fmt_put(out, t); - const held: ascii_Held.Held = { n: 0, text: t }; + put(out, t); + const held: Held.Held = { n: 0, text: t }; upperText(rt.place(() => held.text, (value) => held.text = value)); - fmt_put(out, held.text); + put(out, held.text); held.text = rt.strToAsciiLowercase(held.text); - fmt_put(out, held.text); + put(out, held.text); held.n = rt.toAsciiUppercase(held.n); rt.byteVecPush(out, held.n); } else if (_10 === 2) { const e: rt.Iter = rt.byteSliceEscapeAscii(data); - fmt_put(out, rt.fmtToString((f: rt.Formatter) => rt.fmtEscapeAscii(e, f))); + put(out, rt.fmtToString((f: rt.Formatter) => rt.fmtEscapeAscii(e, f))); const _221: rt.usize = rt.iterCount(e.clone()); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtEscapeAscii(e, f), (f: rt.Formatter) => rt.usizeDisplay(_221, f)]; - fmt_put(out, rt.fmtFormat([rt.fmtSpec({ align: ">", width: 40 }, args2[0]), "|", args2[1]])); + put(out, rt.fmtFormat([rt.fmtSpec({ align: ">", width: 40 }, args2[0]), "|", args2[1]])); rt.iterExtendBytes(out, rt.iterRev(e.clone()), "next"); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.iterLast(e.clone()), 255)); } else { @@ -316,7 +316,7 @@ export function slices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } if (next !== undefined) { rt.byteVecPush(out, next); - fmt_put(out, rt.fmtToString((f: rt.Formatter) => rt.fmtEscapeAscii(e2, f))); + put(out, rt.fmtToString((f: rt.Formatter) => rt.fmtEscapeAscii(e2, f))); rt.iterExtendBytes(out, e2.clone(), "next"); i = rt.usizeAdd(i, 1); } else { @@ -342,7 +342,7 @@ export function putUpper(out: rt.ByteVec, part: rt.Place | undefined): v rt.byteVecPush(out, 254); } else { part.v = rt.strToAsciiUppercase(part.v); - fmt_put(out, part.v); + put(out, part.v); } } @@ -375,24 +375,24 @@ export function parts(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const _32: rt.u8 = rt.u8Rem(kind, 8); if (_32 === 0) { s = rt.strToAsciiUppercase(s); - fmt_put(out, s); + put(out, s); const _41: rt.Place = rt.strPart(rt.place(() => s, (value15) => s = value15), a, b); _41.v = rt.strToAsciiLowercase(_41.v); - fmt_put(out, s); + put(out, s); } else if (_32 === 1) { pair[1] = rt.strToAsciiUppercase(pair[1]); - fmt_put(out, pair[1]); + put(out, pair[1]); const _54: rt.Place = rt.strPart(rt.place(() => pair[1], (value14) => pair[1] = value14), a); _54.v = rt.strToAsciiLowercase(_54.v); - fmt_put(out, pair[1]); + put(out, pair[1]); rt.byteVecPush(out, pair[0]); } else if (_32 === 2) { array[1] = rt.strToAsciiUppercase(array[1]); - fmt_put(out, array[1]); + put(out, array[1]); const _73: rt.Place = rt.strPart(rt.place(() => array[1], (value13) => array[1] = value13), 0, b); _73.v = rt.strToAsciiLowercase(_73.v); - fmt_put(out, array[1]); - fmt_put(out, array[0]); + put(out, array[1]); + put(out, array[0]); } else if (_32 === 3) { const iter: rt.Iter> = rt.iterSliceMut(v); while (true) { @@ -408,28 +408,28 @@ export function parts(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const at7 = rt.idx(v, 1); const _105: rt.Place = rt.strPart(rt.place(() => v[at7], (value12) => v[at7] = value12), a, b); _105.v = rt.strToAsciiLowercase(_105.v); - fmt_put(out, v[rt.idx(v, 0)]); - fmt_put(out, v[rt.idx(v, 1)]); + put(out, v[rt.idx(v, 0)]); + put(out, v[rt.idx(v, 1)]); } else if (_32 === 4) { const _119: [rt.Place, rt.Place] = rt.strSplitAtMut(rt.place(() => s, (value10) => s = value10), a); _119[0].v = rt.strToAsciiUppercase(_119[0].v); _119[1].v = rt.strToAsciiUppercase(_119[1].v); _119[0].v = rt.strToAsciiLowercase(_119[0].v); - fmt_put(out, _119[0].v); - fmt_put(out, _119[1].v); + put(out, _119[0].v); + put(out, _119[1].v); const _131: [rt.Place, rt.Place] = rt.strSplitAtMut(_119[1], rt.usizeSaturatingSub(b, a)); _131[1].v = rt.strToAsciiLowercase(_131[1].v); - fmt_put(out, _131[0].v); - fmt_put(out, _131[1].v); - fmt_put(out, s); + put(out, _131[0].v); + put(out, _131[1].v); + put(out, s); } else if (_32 === 5) { putUpper(out, rt.strGetMut(rt.place(() => s, (value7) => s = value7), a, b)); putUpper(out, rt.strGetMut(rt.place(() => pair[1], (value8) => pair[1] = value8), a)); const at4 = rt.idx(v, 1); putUpper(out, rt.strGetMut(rt.place(() => v[at4], (value9) => v[at4] = value9), 0, b)); - fmt_put(out, s); - fmt_put(out, pair[1]); - fmt_put(out, v[rt.idx(v, 1)]); + put(out, s); + put(out, pair[1]); + put(out, v[rt.idx(v, 1)]); } else if (_32 === 6) { const _168: [rt.Place, rt.Place] | undefined = rt.strSplitAtMutChecked(rt.place(() => array[1], (value5) => array[1] = value5), a); if (_168 === undefined) { @@ -438,27 +438,27 @@ export function parts(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _168[1].v = rt.strToAsciiUppercase(_168[1].v); putUpper(out, rt.strGetMut(_168[0], rt.min(b, rt.stringLen(_168[0].v)))); } - fmt_put(out, array[1]); + put(out, array[1]); let held: string | undefined = text; const _191: rt.Place | undefined = held === undefined ? undefined : rt.place(() => held as string, (value6) => held = value6); if (_191 !== undefined) { _191.v = rt.strToAsciiUppercase(_191.v); } - fmt_put(out, option_unwrapOr$1iemzn8(option_asDeref$0w8at8i(held), "-")); + put(out, option_unwrapOr$1iemzn8(option_asDeref$0w8at8i(held), "-")); } else { const at2 = rt.idx(v, 1); upperPart(rt.strPart(rt.place(() => v[at2], (value) => v[at2] = value), a), 0, rt.usizeSaturatingSub(b, a)); - fmt_put(out, v[rt.idx(v, 1)]); + put(out, v[rt.idx(v, 1)]); upperPart(rt.place(() => s, (value2) => s = value2), a, b); - fmt_put(out, rt.strPart(rt.place(() => s, (value3) => s = value3), 0, a).v); - fmt_put(out, rt.strPart(rt.place(() => s, (value4) => s = value4), a).v); + put(out, rt.strPart(rt.place(() => s, (value3) => s = value3), 0, a).v); + put(out, rt.strPart(rt.place(() => s, (value4) => s = value4), a).v); const leaked: rt.Place = { v: pair[1] }; const _234: rt.Place = rt.strPart(leaked, rt.min(b, a)); _234.v = rt.strToAsciiUppercase(_234.v); - fmt_put(out, leaked.v); + put(out, leaked.v); const empty: rt.Place = { v: "" }; empty.v = rt.strToAsciiUppercase(empty.v); - fmt_put(out, empty.v); + put(out, empty.v); } } diff --git a/ts/fixtures/lang/ascii/expected/core/option.ts b/ts/fixtures/lang/ascii/expected/core/option.ts new file mode 100644 index 000000000..af5bdbb10 --- /dev/null +++ b/ts/fixtures/lang/ascii/expected/core/option.ts @@ -0,0 +1,67 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function isSomeAnd$09tpccf(self: rt.u8 | undefined, f: (a0: rt.u8) => boolean): boolean { + if (self === undefined) { + return false; + } + return f(self); +} + +export function unwrapOr$1iemzn8(self: string | undefined, default_: string): string { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0l7j3f6(self: rt.usize | undefined, default_: rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$1uo1d4o(self: string | undefined, _: (a0: string) => string): string | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function mapOr$1t0muvr(self: rt.u8 | undefined, default_: rt.usize, f: (a0: rt.u8) => rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0jad0p1(self: rt.usize | undefined, default_: rt.u32, f: (a0: rt.usize) => rt.u32): rt.u32 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$02k4ito(self: rt.usize | undefined, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function asDeref$0w8at8i(self: string | undefined): string | undefined { + return map$1uo1d4o(self, (a0: string): string => { + return a0; + }); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/ascii/expected/harness.ts b/ts/fixtures/lang/ascii/expected/harness.ts new file mode 100644 index 000000000..3b7bbcfb0 --- /dev/null +++ b/ts/fixtures/lang/ascii/expected/harness.ts @@ -0,0 +1,46 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/ascii/expected/lib.ts b/ts/fixtures/lang/ascii/expected/lib.ts new file mode 100644 index 000000000..0b2570e0f --- /dev/null +++ b/ts/fixtures/lang/ascii/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { bytes, chars, slices, parts } from "./ascii.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["ascii::bytes", bytes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ascii::chars", chars as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ascii::slices", slices as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ascii::parts", parts as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/ascii.rs b/ts/fixtures/lang/ascii/src/ascii.rs similarity index 99% rename from ts/fixtures/lang/src/ascii.rs rename to ts/fixtures/lang/ascii/src/ascii.rs index 63de112b8..495455162 100644 --- a/ts/fixtures/lang/src/ascii.rs +++ b/ts/fixtures/lang/ascii/src/ascii.rs @@ -8,7 +8,7 @@ use std::ascii; use std::borrow::BorrowMut; use std::fmt::Write; -use crate::fmt::put; +use crate::harness::put; /// Chars either side of each class's ends, of ASCII's and Latin-1's, and of the surrogates /// that are no char, a Latin-1 letter JS's case maps change, and those whose Unicode case diff --git a/ts/fixtures/lang/ascii/src/lib.rs b/ts/fixtures/lang/ascii/src/lib.rs new file mode 100644 index 000000000..821326ca6 --- /dev/null +++ b/ts/fixtures/lang/ascii/src/lib.rs @@ -0,0 +1,24 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod ascii; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("ascii::bytes", ascii::bytes), + ("ascii::chars", ascii::chars), + ("ascii::slices", ascii::slices), + ("ascii::parts", ascii::parts), + ] +} diff --git a/ts/fixtures/lang/ascii/ts.toml b/ts/fixtures/lang/ascii/ts.toml new file mode 100644 index 000000000..f0b1e171b --- /dev/null +++ b/ts/fixtures/lang/ascii/ts.toml @@ -0,0 +1,2 @@ +package = "lang-ascii-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/atomics/Cargo.toml b/ts/fixtures/lang/atomics/Cargo.toml new file mode 100644 index 000000000..343b728f5 --- /dev/null +++ b/ts/fixtures/lang/atomics/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-atomics-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/expected/atomics.Stats.ts b/ts/fixtures/lang/atomics/expected/atomics.Stats.ts similarity index 100% rename from ts/fixtures/lang/expected/atomics.Stats.ts rename to ts/fixtures/lang/atomics/expected/atomics.Stats.ts diff --git a/ts/fixtures/lang/expected/atomics.ts b/ts/fixtures/lang/atomics/expected/atomics.ts similarity index 99% rename from ts/fixtures/lang/expected/atomics.ts rename to ts/fixtures/lang/atomics/expected/atomics.ts index 6afe2cb9b..7e1e180da 100644 --- a/ts/fixtures/lang/expected/atomics.ts +++ b/ts/fixtures/lang/atomics/expected/atomics.ts @@ -2,7 +2,7 @@ import * as rt from "./rt.ts"; import * as Stats from "./atomics.Stats.ts"; -import { thenSome$0kwiij6, thenSome$0n2gkz4, thenSome$0tjggir, thenSome$1s4itlz, thenSome$0jkru5t, thenSome$0d5am30, thenSome$0b23a33, thenSome$1af3oea, thenSome$1ugl8af, thenSome$07z8k4h } from "./core/bool.ts"; +import { thenSome$0kwiij6, thenSome$0n2gkz4, thenSome$0tjggir, thenSome$1s4itlz, thenSome$0jkru5t, thenSome$0b23a33, thenSome$1af3oea, thenSome$1ugl8af, thenSome$0d5am30, thenSome$07z8k4h } from "./core/bool.ts"; import { isSomeAnd$09tpccf } from "./core/option.ts"; import { unwrapOr$1pnwyus as result_unwrapOr$1pnwyus, unwrapOr$0xokg9f as result_unwrapOr$0xokg9f, unwrapOr$1imvcmw as result_unwrapOr$1imvcmw, unwrapOr$06fxvgg as result_unwrapOr$06fxvgg, unwrapOr$0gr9tn5 as result_unwrapOr$0gr9tn5, unwrapOr$0hnup9g as result_unwrapOr$0hnup9g, unwrapOr$1dnnsw8 as result_unwrapOr$1dnnsw8, unwrapOr$1k2j44a as result_unwrapOr$1k2j44a, unwrapOr$0jmm2jy as result_unwrapOr$0jmm2jy, unwrapOr$1czbd6g as result_unwrapOr$1czbd6g } from "./core/result.ts"; diff --git a/ts/fixtures/lang/atomics/expected/core/bool.ts b/ts/fixtures/lang/atomics/expected/core/bool.ts new file mode 100644 index 000000000..777252c21 --- /dev/null +++ b/ts/fixtures/lang/atomics/expected/core/bool.ts @@ -0,0 +1,75 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0kwiij6(self: boolean, t: rt.i16): rt.i16 | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function thenSome$0n2gkz4(self: boolean, t: rt.i32): rt.i32 | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function thenSome$0tjggir(self: boolean, t: rt.i64): rt.i64 | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function thenSome$1s4itlz(self: boolean, t: rt.i8): rt.i8 | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function thenSome$0jkru5t(self: boolean, t: rt.isize): rt.isize | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function thenSome$0b23a33(self: boolean, t: rt.u16): rt.u16 | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function thenSome$1af3oea(self: boolean, t: rt.u32): rt.u32 | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function thenSome$1ugl8af(self: boolean, t: rt.u64): rt.u64 | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function thenSome$0d5am30(self: boolean, t: rt.u8): rt.u8 | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function thenSome$07z8k4h(self: boolean, t: rt.usize): rt.usize | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/atomics/expected/core/option.ts b/ts/fixtures/lang/atomics/expected/core/option.ts new file mode 100644 index 000000000..80602fe91 --- /dev/null +++ b/ts/fixtures/lang/atomics/expected/core/option.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function isSomeAnd$09tpccf(self: rt.u8 | undefined, f: (a0: rt.u8) => boolean): boolean { + if (self === undefined) { + return false; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/atomics/expected/core/result.ts b/ts/fixtures/lang/atomics/expected/core/result.ts new file mode 100644 index 000000000..3db834283 --- /dev/null +++ b/ts/fixtures/lang/atomics/expected/core/result.ts @@ -0,0 +1,75 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$1pnwyus(self: rt.Result, default_: rt.i16): rt.i16 { + if (self.ok) { + return self.value; + } + return default_; +} + +export function unwrapOr$0xokg9f(self: rt.Result, default_: rt.i32): rt.i32 { + if (self.ok) { + return self.value; + } + return default_; +} + +export function unwrapOr$1imvcmw(self: rt.Result, default_: rt.i64): rt.i64 { + if (self.ok) { + return self.value; + } + return default_; +} + +export function unwrapOr$06fxvgg(self: rt.Result, default_: rt.i8): rt.i8 { + if (self.ok) { + return self.value; + } + return default_; +} + +export function unwrapOr$0gr9tn5(self: rt.Result, default_: rt.isize): rt.isize { + if (self.ok) { + return self.value; + } + return default_; +} + +export function unwrapOr$0hnup9g(self: rt.Result, default_: rt.u16): rt.u16 { + if (self.ok) { + return self.value; + } + return default_; +} + +export function unwrapOr$1dnnsw8(self: rt.Result, default_: rt.u32): rt.u32 { + if (self.ok) { + return self.value; + } + return default_; +} + +export function unwrapOr$1k2j44a(self: rt.Result, default_: rt.u64): rt.u64 { + if (self.ok) { + return self.value; + } + return default_; +} + +export function unwrapOr$0jmm2jy(self: rt.Result, default_: rt.u8): rt.u8 { + if (self.ok) { + return self.value; + } + return default_; +} + +export function unwrapOr$1czbd6g(self: rt.Result, default_: rt.usize): rt.usize { + if (self.ok) { + return self.value; + } + return default_; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/atomics/expected/harness.ts b/ts/fixtures/lang/atomics/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/atomics/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/atomics/expected/lib.ts b/ts/fixtures/lang/atomics/expected/lib.ts new file mode 100644 index 000000000..ff8199bf5 --- /dev/null +++ b/ts/fixtures/lang/atomics/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { atomics } from "./atomics.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["atomics::atomics", atomics as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/atomics.rs b/ts/fixtures/lang/atomics/src/atomics.rs similarity index 100% rename from ts/fixtures/lang/src/atomics.rs rename to ts/fixtures/lang/atomics/src/atomics.rs diff --git a/ts/fixtures/lang/atomics/src/lib.rs b/ts/fixtures/lang/atomics/src/lib.rs new file mode 100644 index 000000000..7034a1551 --- /dev/null +++ b/ts/fixtures/lang/atomics/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod atomics; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("atomics::atomics", atomics::atomics)] +} diff --git a/ts/fixtures/lang/atomics/ts.toml b/ts/fixtures/lang/atomics/ts.toml new file mode 100644 index 000000000..d1109899f --- /dev/null +++ b/ts/fixtures/lang/atomics/ts.toml @@ -0,0 +1,2 @@ +package = "lang-atomics-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/borrows/Cargo.toml b/ts/fixtures/lang/borrows/Cargo.toml new file mode 100644 index 000000000..4b56d2fec --- /dev/null +++ b/ts/fixtures/lang/borrows/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-borrows-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/borrows/caller.ts b/ts/fixtures/lang/borrows/caller.ts new file mode 100644 index 000000000..cae44a6b8 --- /dev/null +++ b/ts/fixtures/lang/borrows/caller.ts @@ -0,0 +1,52 @@ +// The inputs `borrows`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `borrows::guards` scripts: each operation on cells empty and not, cloned while borrowed + * shared and exclusive, and borrowed exclusively while a mapped or cloned guard holds it. + */ +const guards = [ + [0x04, 0x05, 0x06, 0x03, 0x07, 0x02, 0x01], + [0x10, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0b, 0x0c, 0x0d], + [0x08, 0xe1, 0xf1], + [0x08, 0xe6], + [0xf6], +].map((bytes) => Uint8Array.of(...op("borrows::guards"), 0, ...bytes)); + +/** + * `borrows::maps` scripts: each operation through mapped, filtered, and split guards, with + * parts written whole and split parts dropped in either order, and each borrow again + * while one holds the cell, which panics. + */ +const maps = [ + [0x00, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x15, 0x07, 0xf1, 0xf2, 0x0b, 0x06, 0x13, 0x0c], + [0x02, 0x22, 0x0d, 0xc6], + [0x0a, 0xd6], + [0xe6], + [0x02, 0xf6], +].map((bytes) => Uint8Array.of(...op("borrows::maps"), 0, ...bytes)); + +/** + * `borrows::tries` scripts: each operation through tried guards, given back beside each + * error, printed, and each borrow again while a tried guard holds the cell, which panics. + */ +const tries = [ + [0x00, 0x00, 0x10, 0xf0, 0xe0, 0x01, 0x02, 0x05, 0x20, 0x21, 0x06, 0x03], + [0x01, 0x10, 0x01, 0x12, 0xe2], + [0xd3], + [0xe3], + [0x00, 0xf3], +].map((bytes) => Uint8Array.of(...op("borrows::tries"), 0, ...bytes)); + +/** + * `borrows::leaks` scripts: guards leaked and undone, whole byte arrays mapped, and each + * borrow again while a leak holds the cell, which panics. + */ +const leaks = [[0x00, 0x01, 0x02, 0xf1, 0xf2, 0x04, 0x05, 0x03, 0x06], [0xe3], [0x00, 0xf3]].map((bytes) => + Uint8Array.of(...op("borrows::leaks"), 0, ...bytes), +); + +export const cases: Uint8Array[] = [...guards, ...maps, ...tries, ...leaks]; diff --git a/ts/fixtures/lang/expected/borrows.Noisy.ts b/ts/fixtures/lang/borrows/expected/borrows.Noisy.ts similarity index 100% rename from ts/fixtures/lang/expected/borrows.Noisy.ts rename to ts/fixtures/lang/borrows/expected/borrows.Noisy.ts diff --git a/ts/fixtures/lang/expected/borrows.Parts.ts b/ts/fixtures/lang/borrows/expected/borrows.Parts.ts similarity index 80% rename from ts/fixtures/lang/expected/borrows.Parts.ts rename to ts/fixtures/lang/borrows/expected/borrows.Parts.ts index ddca0ed13..4703d0156 100644 --- a/ts/fixtures/lang/expected/borrows.Parts.ts +++ b/ts/fixtures/lang/borrows/expected/borrows.Parts.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import type * as borrows_Tagged from "./borrows.Tagged.ts"; +import type * as Tagged from "./borrows.Tagged.ts"; /** * What mapped guards lend parts of: a number and a `String`, which JS copies, a `Vec` and @@ -11,11 +11,11 @@ export class Parts { n: rt.u32; text: string; bytes: rt.ByteVec; - tagged: borrows_Tagged.Tagged; + tagged: Tagged.Tagged; maybe: rt.u16 | undefined; quad: Uint8Array; - constructor(n: rt.u32, text: string, bytes: rt.ByteVec, tagged: borrows_Tagged.Tagged, maybe: rt.u16 | undefined, quad: Uint8Array) { + constructor(n: rt.u32, text: string, bytes: rt.ByteVec, tagged: Tagged.Tagged, maybe: rt.u16 | undefined, quad: Uint8Array) { this.n = n; this.text = text; this.bytes = bytes; diff --git a/ts/fixtures/lang/expected/borrows.Polling.ts b/ts/fixtures/lang/borrows/expected/borrows.Polling.ts similarity index 100% rename from ts/fixtures/lang/expected/borrows.Polling.ts rename to ts/fixtures/lang/borrows/expected/borrows.Polling.ts diff --git a/ts/fixtures/lang/expected/borrows.Tagged.ts b/ts/fixtures/lang/borrows/expected/borrows.Tagged.ts similarity index 100% rename from ts/fixtures/lang/expected/borrows.Tagged.ts rename to ts/fixtures/lang/borrows/expected/borrows.Tagged.ts diff --git a/ts/fixtures/lang/expected/borrows.ts b/ts/fixtures/lang/borrows/expected/borrows.ts similarity index 79% rename from ts/fixtures/lang/expected/borrows.ts rename to ts/fixtures/lang/borrows/expected/borrows.ts index 160376c6a..eb1e2df50 100644 --- a/ts/fixtures/lang/expected/borrows.ts +++ b/ts/fixtures/lang/borrows/expected/borrows.ts @@ -2,12 +2,12 @@ import * as rt from "./rt.ts"; import { copy$Option_tuple2_u64_u64, copy$tuple2_u64_u64, drop$Result_cell_RefMut_Vec_u8_cell_BorrowMutError, drop$Result_cell_RefMut_array4_u8_cell_BorrowMutError, drop$Result_cell_RefMut_borrows_Parts_cell_BorrowMutError, drop$Result_cell_RefMut_borrows_Tagged_cell_BorrowMutError, drop$Result_cell_RefMut_tuple2_u16_Vec_u8_cell_BorrowMutError, drop$Result_cell_RefMut_u32_cell_BorrowMutError, drop$Result_cell_RefMut_u32_tuple2_cell_RefMut_borrows_Parts_unit, drop$Result_cell_Ref_Vec_u8_cell_BorrowError, drop$Result_cell_Ref_array4_u8_cell_BorrowError, drop$Result_cell_Ref_borrows_Parts_cell_BorrowError, drop$Result_cell_Ref_ref_str_tuple2_cell_Ref_tuple2_u8_ref_str_u8, drop$Result_cell_Ref_tuple2_u16_Vec_u8_cell_BorrowError, drop$Result_cell_Ref_u32_cell_BorrowError, drop$Result_cell_Ref_u32_cell_Ref_borrows_Parts, drop$Result_cell_Ref_u32_tuple2_cell_Ref_borrows_Parts_unit, drop$tuple2_Option_cell_Ref_borrows_Tagged_Option_cell_RefMut_borrows_Tagged, drop$tuple2_Result_cell_Ref_Vec_u8_cell_BorrowError_cell_Ref_Vec_u8, drop$tuple2_cell_RefMut_slice_u8_cell_RefMut_slice_u8, drop$tuple2_cell_Ref_Vec_u8_cell_Ref_u8, drop$tuple2_cell_Ref_str_cell_RefMut_u32, drop$tuple3_cell_Ref_String_cell_Ref_array4_u8_cell_Ref_u32 } from "./lib.ts"; -import * as borrows_Noisy from "./borrows.Noisy.ts"; -import * as borrows_Parts from "./borrows.Parts.ts"; -import * as borrows_Polling from "./borrows.Polling.ts"; -import * as borrows_Tagged from "./borrows.Tagged.ts"; +import * as Noisy from "./borrows.Noisy.ts"; +import * as Parts from "./borrows.Parts.ts"; +import * as Polling from "./borrows.Polling.ts"; +import * as Tagged from "./borrows.Tagged.ts"; import { thenSome$0zrlsto, then$1jgls7y } from "./core/bool.ts"; -import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, mapOr$0qqbaqw as option_mapOr$0qqbaqw, mapOr$1dvn0au as option_mapOr$1dvn0au, mapOr$099335t as option_mapOr$099335t, mapOr$0ucbp7g as option_mapOr$0ucbp7g, okOr$1oufq9m as option_okOr$1oufq9m } from "./core/option.ts"; +import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, mapOr$0qqbaqw as option_mapOr$0qqbaqw, mapOr$1dvn0au as option_mapOr$1dvn0au, mapOr$0ucbp7g as option_mapOr$0ucbp7g, mapOr$099335t as option_mapOr$099335t, okOr$1oufq9m as option_okOr$1oufq9m } from "./core/option.ts"; import { map$0n1xnuw as result_map$0n1xnuw, unwrapOr$0k9nfhn as result_unwrapOr$0k9nfhn } from "./core/result.ts"; /** @@ -18,10 +18,10 @@ export function borrows(data: rt.ByteSlice, out: rt.ByteVec): void { const log: rt.Arc> = new rt.Arc(new rt.Mutex(new rt.ByteVec())); const count: rt.Cell = new rt.Cell(0); const pair: rt.Cell<[rt.u64, rt.u64]> = new rt.Cell([0, 0] as [rt.u64, rt.u64]); - const noisy: rt.Cell = new rt.Cell(undefined as borrows_Noisy.Noisy | undefined); - const polling: borrows_Polling.Polling = borrows_Polling.default$Default(); + const noisy: rt.Cell = new rt.Cell(undefined as Noisy.Noisy | undefined); + const polling: Polling.Polling = Polling.default$Default(); const shared: rt.RefCell = new rt.RefCell(new rt.ByteVec()); - const owned: rt.RefCell = new rt.RefCell(new borrows_Noisy.Noisy(170, rt.arcClone(log))); + const owned: rt.RefCell = new rt.RefCell(new Noisy.Noisy(170, rt.arcClone(log))); for (const op of rt.byteSliceView(data)) { const _25: rt.u8 = rt.u8Rem(op, 10); if (_25 === 0) { @@ -36,11 +36,11 @@ export function borrows(data: rt.ByteSlice, out: rt.ByteVec): void { } else if (_25 === 2) { rt.byteVecPush(out, rt.cellReplace(count, op as rt.u32) & 0xff); } else if (_25 === 3) { - const _56: borrows_Noisy.Noisy | undefined = new borrows_Noisy.Noisy(op, rt.arcClone(log)); + const _56: Noisy.Noisy | undefined = new Noisy.Noisy(op, rt.arcClone(log)); rt.cellSet(noisy, _56, rt.drop); } else if (_25 === 4) { - const taken: borrows_Noisy.Noisy | undefined = rt.cellReplace(noisy, undefined); - rt.byteVecPush(out, option_mapOr$0qqbaqw(taken, 253, (n: borrows_Noisy.Noisy): rt.u8 => { + const taken: Noisy.Noisy | undefined = rt.cellReplace(noisy, undefined); + rt.byteVecPush(out, option_mapOr$0qqbaqw(taken, 253, (n: Noisy.Noisy): rt.u8 => { return n.id; })); rt.drop(taken); @@ -71,12 +71,12 @@ export function borrows(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _116.value.length & 0xff); rt.refRelease(_116); } else if (_25 === 8) { - const _118: borrows_Noisy.Noisy = new borrows_Noisy.Noisy(op, rt.arcClone(log)); - const _123: rt.RefCell = rt.refCellBorrowMut(owned); + const _118: Noisy.Noisy = new Noisy.Noisy(op, rt.arcClone(log)); + const _123: rt.RefCell = rt.refCellBorrowMut(owned); _123.value[Symbol.dispose](); _123.value = _118; rt.refMutRelease(_123); - const _129: rt.RefCell = rt.refCellBorrow(owned); + const _129: rt.RefCell = rt.refCellBorrow(owned); rt.byteVecPush(out, _129.value.id); rt.refRelease(_129); } else { @@ -119,12 +119,12 @@ export function borrows(data: rt.ByteSlice, out: rt.ByteVec): void { */ export function guards(data: rt.ByteSlice, out: rt.ByteVec): void { const log: rt.Arc> = new rt.Arc(new rt.Mutex(new rt.ByteVec())); - const tag: (a0: rt.u8) => borrows_Tagged.Tagged = (id2: rt.u8): borrows_Tagged.Tagged => { - return new borrows_Tagged.Tagged(id2, 0, rt.arcClone(log)); + const tag: (a0: rt.u8) => Tagged.Tagged = (id2: rt.u8): Tagged.Tagged => { + return new Tagged.Tagged(id2, 0, rt.arcClone(log)); }; const number: rt.RefCell = new rt.RefCell(0); const bytes: rt.RefCell = new rt.RefCell(new rt.ByteVec()); - let tagged: rt.RefCell = new rt.RefCell(tag(0)); + let tagged: rt.RefCell = new rt.RefCell(tag(0)); for (const op of rt.byteSliceView(data)) { const _22: rt.u8 = rt.u8Rem(op, 8); if (_22 === 0) { @@ -132,7 +132,7 @@ export function guards(data: rt.ByteSlice, out: rt.ByteVec): void { const _25: rt.Place = rt.valuePlace(number); _25.v = rt.u32Add(_25.v, _24); rt.byteVecPush(bytes.value, op); - const _31: borrows_Tagged.Tagged = tagged.value; + const _31: Tagged.Tagged = tagged.value; _31.n = rt.u32Add(_31.n, 1); const _39: rt.RefCell = rt.refCellBorrow(number); rt.byteVecPush(out, _39.value & 0xff); @@ -145,24 +145,24 @@ export function guards(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _53.value & 0xff); rt.refRelease(_53); rt.byteVecPush(out, twin$ref_sync_Arc_sync_Mutex_Vec_u8(log).strong & 0xff); - const held: rt.RefCell | undefined = then$1jgls7y((op >> 4) === 14, (): rt.RefCell => { + const held: rt.RefCell | undefined = then$1jgls7y((op >> 4) === 14, (): rt.RefCell => { return rt.refCellBorrow(tagged); }); - const heldMut: rt.RefCell | undefined = then$1jgls7y((op >> 4) === 15, (): rt.RefCell => { + const heldMut: rt.RefCell | undefined = then$1jgls7y((op >> 4) === 15, (): rt.RefCell => { return rt.refCellBorrowMut(tagged); }); - const copy: rt.RefCell = rt.refCellClone(tagged, borrows_Tagged.clone$Clone); - const _81: rt.RefCell = rt.refCellBorrow(copy); + const copy: rt.RefCell = rt.refCellClone(tagged, Tagged.clone$Clone); + const _81: rt.RefCell = rt.refCellBorrow(copy); rt.byteVecPush(out, _81.value.id); rt.refRelease(_81); - drop$tuple2_Option_cell_Ref_borrows_Tagged_Option_cell_RefMut_borrows_Tagged([held, heldMut] as [rt.RefCell | undefined, rt.RefCell | undefined]); + drop$tuple2_Option_cell_Ref_borrows_Tagged_Option_cell_RefMut_borrows_Tagged([held, heldMut] as [rt.RefCell | undefined, rt.RefCell | undefined]); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(rt.refCellClone(bytes, (a02: rt.ByteVec): rt.ByteVec => { return rt.byteVecFrom(rt.byteVecView(a02)); }).value)); rt.byteVecPush(out, rt.refCellClone(number, undefined).value & 0xff); copy[Symbol.dispose](); } else if (_22 === 2) { - const inner: borrows_Tagged.Tagged = new rt.RefCell(tag(op)).value; + const inner: Tagged.Tagged = new rt.RefCell(tag(op)).value; rt.byteVecPush(out, inner.id); flush(log.value, out); inner[Symbol.dispose](); @@ -203,24 +203,24 @@ export function guards(data: rt.ByteSlice, out: rt.ByteVec): void { return _05; }), 253)); } else if (_22 === 4) { - const _166: rt.RefCell = rt.refCellBorrow(tagged); - const n: rt.RefCell = rt.refMap(_166, ((t2: borrows_Tagged.Tagged): rt.u32 => { + const _166: rt.RefCell = rt.refCellBorrow(tagged); + const n: rt.RefCell = rt.refMap(_166, ((t2: Tagged.Tagged): rt.u32 => { return t2.n; })(_166.value)); - const _169: rt.RefCell = rt.refCellBorrow(tagged); - const id: rt.RefCell = rt.refMap(_169, ((t3: borrows_Tagged.Tagged): rt.u8 => { + const _169: rt.RefCell = rt.refCellBorrow(tagged); + const id: rt.RefCell = rt.refMap(_169, ((t3: Tagged.Tagged): rt.u8 => { return t3.id; })(_169.value)); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(n.value & 0xff, id.value))); - const _186: rt.Result, rt.BorrowMutError> = rt.refCellTryBorrowMut(tagged); + const _186: rt.Result, rt.BorrowMutError> = rt.refCellTryBorrowMut(tagged); rt.byteVecPush(out, !_186.ok ? 1 : 0); drop$Result_cell_RefMut_borrows_Tagged_cell_BorrowMutError(_186); rt.refRelease(n); - const _193: rt.Result, rt.BorrowMutError> = rt.refCellTryBorrowMut(tagged); + const _193: rt.Result, rt.BorrowMutError> = rt.refCellTryBorrowMut(tagged); rt.byteVecPush(out, !_193.ok ? 1 : 0); drop$Result_cell_RefMut_borrows_Tagged_cell_BorrowMutError(_193); rt.refRelease(id); - const _200: rt.Result, rt.BorrowMutError> = rt.refCellTryBorrowMut(tagged); + const _200: rt.Result, rt.BorrowMutError> = rt.refCellTryBorrowMut(tagged); rt.byteVecPush(out, !_200.ok ? 1 : 0); drop$Result_cell_RefMut_borrows_Tagged_cell_BorrowMutError(_200); const _203: rt.RefCell = rt.refCellBorrow(bytes); @@ -264,28 +264,28 @@ export function guards(data: rt.ByteSlice, out: rt.ByteVec): void { } else if (_22 === 6) { const _263: rt.u8 = op >> 4; if (_263 === 14) { - const _267: rt.RefCell = rt.refCellBorrow(tagged); - const _n: rt.RefCell = rt.refMap(_267, ((t: borrows_Tagged.Tagged): rt.u32 => { + const _267: rt.RefCell = rt.refCellBorrow(tagged); + const _n: rt.RefCell = rt.refMap(_267, ((t: Tagged.Tagged): rt.u32 => { return t.n; })(_267.value)); rt.refMutRelease(rt.refCellBorrowMut(tagged)); rt.refRelease(_n); } else if (_263 === 15) { - const a2: rt.RefCell = rt.refCellBorrow(tagged); - const _b: rt.RefCell = rt.refClone(a2); + const a2: rt.RefCell = rt.refCellBorrow(tagged); + const _b: rt.RefCell = rt.refClone(a2); rt.refRelease(a2); rt.refMutRelease(rt.refCellBorrowMut(tagged)); rt.refRelease(_b); } else { - const _281: rt.RefCell = rt.refCellBorrowMut(tagged); + const _281: rt.RefCell = rt.refCellBorrowMut(tagged); rt.byteVecPush(out, _281.value.id); rt.refMutRelease(_281); } } else { - const _285: rt.RefCell = new rt.RefCell(tag(op)); + const _285: rt.RefCell = new rt.RefCell(tag(op)); const old2 = tagged; tagged = _285; - const _291: borrows_Tagged.Tagged = old2.value; + const _291: Tagged.Tagged = old2.value; rt.byteVecPush(out, _291.id); _291[Symbol.dispose](); } @@ -293,7 +293,7 @@ export function guards(data: rt.ByteSlice, out: rt.ByteVec): void { } rt.byteVecPush(out, number.value & 0xff); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(bytes.value)); - const last2: borrows_Tagged.Tagged = tagged.value; + const last2: Tagged.Tagged = tagged.value; rt.byteVecPush(out, last2.id); flush(log.value, out); last2[Symbol.dispose](); @@ -308,18 +308,18 @@ export function guards(data: rt.ByteSlice, out: rt.ByteVec): void { */ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { const log: rt.Arc> = new rt.Arc(new rt.Mutex(new rt.ByteVec())); - const tag: (a0: rt.u8) => borrows_Tagged.Tagged = (id: rt.u8): borrows_Tagged.Tagged => { - return new borrows_Tagged.Tagged(id, 0, rt.arcClone(log)); + const tag: (a0: rt.u8) => Tagged.Tagged = (id: rt.u8): Tagged.Tagged => { + return new Tagged.Tagged(id, 0, rt.arcClone(log)); }; - const parts: rt.RefCell = new rt.RefCell(new borrows_Parts.Parts(0, "", new rt.ByteVec(), tag(1), undefined, rt.bytes(4))); + const parts: rt.RefCell = new rt.RefCell(new Parts.Parts(0, "", new rt.ByteVec(), tag(1), undefined, rt.bytes(4))); const number: rt.RefCell = new rt.RefCell(0); const bytes4: rt.RefCell = new rt.RefCell(Uint8Array.of(1, 2, 3, 4)); - const slot: rt.RefCell = new rt.RefCell(undefined as borrows_Tagged.Tagged | undefined); + const slot: rt.RefCell = new rt.RefCell(undefined as Tagged.Tagged | undefined); for (const op of rt.byteSliceView(data)) { const _29: rt.u8 = rt.u8Rem(op, 8); if (_29 === 0) { - const _32: rt.RefCell = rt.refCellBorrowMut(parts); - const n: rt.RefCell = rt.refMutMap(_32, ((p16: borrows_Parts.Parts): rt.Place => { + const _32: rt.RefCell = rt.refCellBorrowMut(parts); + const n: rt.RefCell = rt.refMutMap(_32, ((p16: Parts.Parts): rt.Place => { return rt.place(() => p16.n, (value8) => p16.n = value8); })(_32.value)); n.value = rt.u32Add(n.value, op as rt.u32); @@ -331,7 +331,7 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { again.value = rt.u32Add(again.value, 1); rt.refMutRelease(again); const _52: rt.u8 = borrowed$borrows_Parts(parts); - const _58: rt.RefCell = rt.refCellBorrow(parts); + const _58: rt.RefCell = rt.refCellBorrow(parts); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(_52, _58.value.n & 0xff))); rt.refRelease(_58); const _61: rt.RefCell = rt.refCellBorrowMut(number); @@ -345,8 +345,8 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _78.value & 0xff); rt.refRelease(_78); } else if (_29 === 1) { - const _81: rt.RefCell = rt.refCellBorrowMut(parts); - const text: rt.RefCell = rt.refMutMap(_81, ((p15: borrows_Parts.Parts): rt.Place => { + const _81: rt.RefCell = rt.refCellBorrowMut(parts); + const text: rt.RefCell = rt.refMutMap(_81, ((p15: Parts.Parts): rt.Place => { return rt.place(() => p15.text, (value7) => p15.text = value7); })(_81.value)); text.value = text.value + String.fromCodePoint(rt.u8Add(97, rt.u8Rem(op, 26)) as rt.char); @@ -355,12 +355,12 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { } rt.byteVecPush(out, rt.stringLen(text.value) & 0xff); rt.refMutRelease(text); - const _110: rt.RefCell = rt.refCellBorrow(parts); + const _110: rt.RefCell = rt.refCellBorrow(parts); rt.byteVecExtendFromSlice(out, rt.stringAsBytes(_110.value.text)); rt.refRelease(_110); } else if (_29 === 2) { - const _113: rt.RefCell = rt.refCellBorrowMut(parts); - const bytes: rt.RefCell = rt.refMutMap(_113, rt.partPlace(((p13: borrows_Parts.Parts): rt.ByteVec => { + const _113: rt.RefCell = rt.refCellBorrowMut(parts); + const bytes: rt.RefCell = rt.refMutMap(_113, rt.partPlace(((p13: Parts.Parts): rt.ByteVec => { return p13.bytes; })(_113.value))); rt.byteVecPush(bytes.value, op); @@ -369,30 +369,30 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { bytes.value = _122; } rt.refMutRelease(bytes); - const _133: rt.RefCell = rt.refCellBorrow(parts); + const _133: rt.RefCell = rt.refCellBorrow(parts); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(_133.value.bytes)); rt.refRelease(_133); - const _136: rt.RefCell = rt.refCellBorrowMut(parts); - const tagged: rt.RefCell = rt.refMutMap(_136, rt.partPlace(((p14: borrows_Parts.Parts): borrows_Tagged.Tagged => { + const _136: rt.RefCell = rt.refCellBorrowMut(parts); + const tagged: rt.RefCell = rt.refMutMap(_136, rt.partPlace(((p14: Parts.Parts): Tagged.Tagged => { return p14.tagged; })(_136.value))); tagged.value.n = rt.u32Add(tagged.value.n, 1); const _142: rt.u32 = tagged.value.n; const _145: rt.Arc> = rt.arcClone(log); - const _141: borrows_Tagged.Tagged = new borrows_Tagged.Tagged(op, _142, _145); + const _141: Tagged.Tagged = new Tagged.Tagged(op, _142, _145); tagged.value[Symbol.dispose](); tagged.value = _141; flush(log.value, out); rt.refMutRelease(tagged); - const _161: rt.RefCell = rt.refCellBorrow(parts); + const _161: rt.RefCell = rt.refCellBorrow(parts); const _158: rt.u8 = _161.value.tagged.id; - const _167: rt.RefCell = rt.refCellBorrow(parts); + const _167: rt.RefCell = rt.refCellBorrow(parts); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(_158, _167.value.tagged.n & 0xff))); rt.refRelease(_167); rt.refRelease(_161); } else if (_29 === 3) { - const _170: rt.RefCell = rt.refCellBorrowMut(parts); - const _169: rt.Result, rt.RefCell> = rt.refMutFilterMap(_170, ((p11: borrows_Parts.Parts): rt.Place | undefined => { + const _170: rt.RefCell = rt.refCellBorrowMut(parts); + const _169: rt.Result, rt.RefCell> = rt.refMutFilterMap(_170, ((p11: Parts.Parts): rt.Place | undefined => { return p11.maybe === undefined ? undefined : rt.place(() => p11.maybe as rt.u16, (value6) => p11.maybe = value6); })(_170.value)); if (_169.ok) { @@ -401,14 +401,14 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, m.value & 0xff); rt.refMutRelease(m); } else { - const whole2: rt.RefCell = _169.error; + const whole2: rt.RefCell = _169.error; whole2.value.maybe = op as rt.u16; rt.byteVecPush(out, borrowed$borrows_Parts(parts)); rt.refMutRelease(whole2); } rt.byteVecPush(out, borrowed$borrows_Parts(parts)); - const _195: rt.RefCell = rt.refCellBorrow(parts); - const _194: rt.Result, rt.RefCell> = rt.refFilterMap(_195, ((p12: borrows_Parts.Parts): rt.u8 | undefined => { + const _195: rt.RefCell = rt.refCellBorrow(parts); + const _194: rt.Result, rt.RefCell> = rt.refFilterMap(_195, ((p12: Parts.Parts): rt.u8 | undefined => { return rt.byteSliceLast(rt.byteVecSlice(p12.bytes)); })(_195.value)); if (_194.ok) { @@ -416,38 +416,38 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(last.value, borrowed$borrows_Parts(parts)))); rt.refRelease(last); } else { - const whole3: rt.RefCell = _194.error; + const whole3: rt.RefCell = _194.error; rt.byteVecPush(out, 240 | (whole3.value.bytes.length & 0xff)); rt.refRelease(whole3); } rt.byteVecPush(out, borrowed$borrows_Parts(parts)); - const _218: rt.RefCell = rt.refCellBorrowMut(slot); - const part = ((s2: rt.Place): borrows_Tagged.Tagged | undefined => { + const _218: rt.RefCell = rt.refCellBorrowMut(slot); + const part = ((s2: rt.Place): Tagged.Tagged | undefined => { return s2.v; })(rt.valuePlace(_218)); - const _217: rt.Result, rt.RefCell> = rt.refMutFilterMap(_218, part === undefined ? undefined : rt.partPlace(part)); + const _217: rt.Result, rt.RefCell> = rt.refMutFilterMap(_218, part === undefined ? undefined : rt.partPlace(part)); if (_217.ok) { - const t: rt.RefCell = _217.value; - const _222: borrows_Tagged.Tagged = tag(op); + const t: rt.RefCell = _217.value; + const _222: Tagged.Tagged = tag(op); t.value[Symbol.dispose](); t.value = _222; rt.refMutRelease(t); } else { - const s: rt.RefCell = _217.error; - const _228: borrows_Tagged.Tagged | undefined = tag(op); + const s: rt.RefCell = _217.error; + const _228: Tagged.Tagged | undefined = tag(op); rt.drop(s.value); s.value = _228; rt.refMutRelease(s); } flush(log.value, out); - const _242: rt.RefCell = rt.refCellBorrow(slot); - rt.byteVecPush(out, option_mapOr$1dvn0au(_242.value, 253, (t2: borrows_Tagged.Tagged): rt.u8 => { + const _242: rt.RefCell = rt.refCellBorrow(slot); + rt.byteVecPush(out, option_mapOr$1dvn0au(_242.value, 253, (t2: Tagged.Tagged): rt.u8 => { return t2.id; })); rt.refRelease(_242); } else if (_29 === 4) { - const _247: rt.RefCell = rt.refCellBorrow(parts); - const _246: [rt.RefCell, rt.RefCell] = rt.refMapSplit(_247, ((p10: borrows_Parts.Parts): [rt.u32, rt.ByteVec] => { + const _247: rt.RefCell = rt.refCellBorrow(parts); + const _246: [rt.RefCell, rt.RefCell] = rt.refMapSplit(_247, ((p10: Parts.Parts): [rt.u32, rt.ByteVec] => { return [p10.n, p10.bytes] as [rt.u32, rt.ByteVec]; })(_247.value)); const n2: rt.RefCell = _246[0]; @@ -458,8 +458,8 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { rt.refRelease(bytes2); rt.byteVecPush(out, borrowed$borrows_Parts(parts)); } else if (_29 === 5) { - const _274: rt.RefCell = rt.refCellBorrowMut(parts); - const _273: [rt.RefCell, rt.RefCell] = rt.refMutMapSplit(_274, ((p8: borrows_Parts.Parts): [rt.Place, rt.Place] => { + const _274: rt.RefCell = rt.refCellBorrowMut(parts); + const _273: [rt.RefCell, rt.RefCell] = rt.refMutMapSplit(_274, ((p8: Parts.Parts): [rt.Place, rt.Place] => { return [rt.place(() => p8.n, (value4) => p8.n = value4), rt.place(() => p8.text, (value5) => p8.text = value5)] as [rt.Place, rt.Place]; })(_274.value)); const n3: rt.RefCell = _273[0]; @@ -477,11 +477,11 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { rt.refMutRelease(text2); } const _305: rt.u8 = borrowed$borrows_Parts(parts); - const _311: rt.RefCell = rt.refCellBorrow(parts); + const _311: rt.RefCell = rt.refCellBorrow(parts); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(_305, _311.value.n & 0xff))); rt.refRelease(_311); - const _316: rt.RefCell = rt.refCellBorrowMut(parts); - const parts3 = ((p9: borrows_Parts.Parts): [rt.ByteSlice, rt.ByteSlice] => { + const _316: rt.RefCell = rt.refCellBorrowMut(parts); + const parts3 = ((p9: Parts.Parts): [rt.ByteSlice, rt.ByteSlice] => { const half: rt.usize = rt.usizeDiv(p9.bytes.length, 2); return rt.byteSliceSplitAt(rt.byteVecSlice(p9.bytes), half); })(_316.value); @@ -497,21 +497,21 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { _325.v = _325.v ^ 255; } drop$tuple2_cell_RefMut_slice_u8_cell_RefMut_slice_u8([low, high] as [rt.RefCell, rt.RefCell]); - const _339: rt.RefCell = rt.refCellBorrow(parts); + const _339: rt.RefCell = rt.refCellBorrow(parts); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(_339.value.bytes)); rt.refRelease(_339); } else if (_29 === 6) { const _341: rt.u8 = op >> 4; if (_341 === 12) { - const _345: rt.RefCell = rt.refCellBorrowMut(parts); - const _n: rt.RefCell = rt.refMutMap(_345, ((p7: borrows_Parts.Parts): rt.Place => { + const _345: rt.RefCell = rt.refCellBorrowMut(parts); + const _n: rt.RefCell = rt.refMutMap(_345, ((p7: Parts.Parts): rt.Place => { return rt.place(() => p7.n, (value3) => p7.n = value3); })(_345.value)); rt.refRelease(rt.refCellBorrow(parts)); rt.refMutRelease(_n); } else if (_341 === 13) { - const _352: rt.RefCell = rt.refCellBorrowMut(parts); - const parts2 = ((p6: borrows_Parts.Parts): [rt.Place, rt.ByteVec] => { + const _352: rt.RefCell = rt.refCellBorrowMut(parts); + const parts2 = ((p6: Parts.Parts): [rt.Place, rt.ByteVec] => { return [rt.place(() => p6.n, (value2) => p6.n = value2), p6.bytes] as [rt.Place, rt.ByteVec]; })(_352.value); const _351: [rt.RefCell, rt.RefCell] = rt.refMutMapSplit(_352, [parts2[0], rt.partPlace(parts2[1])]); @@ -521,15 +521,15 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { rt.refMutRelease(rt.refCellBorrowMut(parts)); rt.refMutRelease(_b); } else if (_341 === 14) { - const _358: rt.RefCell = rt.refCellBorrow(parts); - const _f: rt.Result, rt.RefCell> = rt.refFilterMap(_358, ((p5: borrows_Parts.Parts): rt.u32 | undefined => { + const _358: rt.RefCell = rt.refCellBorrow(parts); + const _f: rt.Result, rt.RefCell> = rt.refFilterMap(_358, ((p5: Parts.Parts): rt.u32 | undefined => { return p5.n; })(_358.value)); rt.refMutRelease(rt.refCellBorrowMut(parts)); drop$Result_cell_Ref_u32_cell_Ref_borrows_Parts(_f); } else if (_341 === 15) { - const _365: rt.RefCell = rt.refCellBorrow(parts); - const _364: [rt.RefCell, rt.RefCell] = rt.refMapSplit(_365, ((p4: borrows_Parts.Parts): [rt.u32, string] => { + const _365: rt.RefCell = rt.refCellBorrow(parts); + const _364: [rt.RefCell, rt.RefCell] = rt.refMapSplit(_365, ((p4: Parts.Parts): [rt.u32, string] => { return [p4.n, p4.text] as [rt.u32, string]; })(_365.value)); const _a: rt.RefCell = _364[0]; @@ -540,8 +540,8 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, borrowed$borrows_Parts(parts)); } } else { - const _373: rt.RefCell = rt.refCellBorrow(parts); - const text3: rt.RefCell = rt.refMap(_373, ((p: borrows_Parts.Parts): string => { + const _373: rt.RefCell = rt.refCellBorrow(parts); + const text3: rt.RefCell = rt.refMap(_373, ((p: Parts.Parts): string => { return p.text; })(_373.value)); const _376: rt.RefCell = rt.refCellBorrowMut(number); @@ -554,8 +554,8 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1]]))); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(borrowed$borrows_Parts(parts), borrowed$u32(number)))); drop$tuple2_cell_Ref_str_cell_RefMut_u32([text3, n4] as [rt.RefCell, rt.RefCell]); - const _411: rt.RefCell = rt.refCellBorrowMut(parts); - const quad: rt.RefCell = rt.refMutMap(_411, rt.partPlace(rt.byteSliceView(((p2: borrows_Parts.Parts): rt.ByteSlice => { + const _411: rt.RefCell = rt.refCellBorrowMut(parts); + const quad: rt.RefCell = rt.refMutMap(_411, rt.partPlace(rt.byteSliceView(((p2: Parts.Parts): rt.ByteSlice => { return rt.byteSliceFrom(p2.quad); })(_411.value)))); const _413: rt.ByteSlice = rt.byteSliceFrom(quad.value); @@ -569,8 +569,8 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { _423.data.set(rt.bytes(4).fill(op), _423.start); } rt.refMutRelease(quad); - const _428: rt.RefCell = rt.refCellBorrow(parts); - const quad2: rt.RefCell = rt.refMap(_428, rt.byteSliceView(((p3: borrows_Parts.Parts): rt.ByteSlice => { + const _428: rt.RefCell = rt.refCellBorrow(parts); + const quad2: rt.RefCell = rt.refMap(_428, rt.byteSliceView(((p3: Parts.Parts): rt.ByteSlice => { return rt.byteSliceFrom(p3.quad); })(_428.value))); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(quad2.value)); @@ -605,7 +605,7 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { } flush(log.value, out); } - const last2: borrows_Parts.Parts = parts.value; + const last2: Parts.Parts = parts.value; rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(last2.n & 0xff, last2.tagged.id, option_mapOr$099335t(last2.maybe, 253, (m2: rt.u16): rt.u8 => { return m2 & 0xff; })))); @@ -625,16 +625,16 @@ export function maps(data: rt.ByteSlice, out: rt.ByteVec): void { */ export function tries(data: rt.ByteSlice, out: rt.ByteVec): void { const log: rt.Arc> = new rt.Arc(new rt.Mutex(new rt.ByteVec())); - const parts: rt.RefCell = new rt.RefCell(new borrows_Parts.Parts(0, "", new rt.ByteVec(), new borrows_Tagged.Tagged(1, 0, rt.arcClone(log)), undefined, Uint8Array.of(1, 2, 3, 4))); + const parts: rt.RefCell = new rt.RefCell(new Parts.Parts(0, "", new rt.ByteVec(), new Tagged.Tagged(1, 0, rt.arcClone(log)), undefined, Uint8Array.of(1, 2, 3, 4))); const number: rt.RefCell = new rt.RefCell(0); for (const op of rt.byteSliceView(data)) { const _23: rt.u8 = rt.u8Rem(op, 4); if (_23 === 0) { - const _26: rt.RefCell = rt.refCellBorrowMut(parts); - const tried: rt.Result, [rt.RefCell, borrows_Noisy.Noisy]> = rt.refMutTryMap(_26, ((p9: borrows_Parts.Parts): rt.Result, borrows_Noisy.Noisy> => { + const _26: rt.RefCell = rt.refCellBorrowMut(parts); + const tried: rt.Result, [rt.RefCell, Noisy.Noisy]> = rt.refMutTryMap(_26, ((p9: Parts.Parts): rt.Result, Noisy.Noisy> => { const _39: rt.Place | undefined = p9.maybe === undefined ? undefined : rt.place(() => p9.maybe as rt.u16, (value3) => p9.maybe = value3); if (_39 === undefined) { - return rt.Err(new borrows_Noisy.Noisy(op, rt.arcClone(log))); + return rt.Err(new Noisy.Noisy(op, rt.arcClone(log))); } return rt.Ok(_39); })(_26.value)); @@ -645,8 +645,8 @@ export function tries(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, borrowed$borrows_Parts(parts)); rt.refMutRelease(m); } else { - const whole: rt.RefCell = tried.error[0]; - const noisy: borrows_Noisy.Noisy = tried.error[1]; + const whole: rt.RefCell = tried.error[0]; + const noisy: Noisy.Noisy = tried.error[1]; whole.value.maybe = noisy.id as rt.u16; rt.byteVecPush(out, borrowed$borrows_Parts(parts)); noisy[Symbol.dispose](); @@ -655,19 +655,19 @@ export function tries(data: rt.ByteSlice, out: rt.ByteVec): void { rt.refMutRelease(whole); } const _64: rt.u8 = borrowed$borrows_Parts(parts); - const _70: rt.RefCell = rt.refCellBorrow(parts); + const _70: rt.RefCell = rt.refCellBorrow(parts); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(_64, option_mapOr$099335t(_70.value.maybe, 253, (m2: rt.u16): rt.u8 => { return m2 & 0xff; })))); rt.refRelease(_70); - const _73: rt.RefCell = rt.refCellBorrowMut(parts); - const part = ((p10: borrows_Parts.Parts): rt.Result => { + const _73: rt.RefCell = rt.refCellBorrowMut(parts); + const part = ((p10: Parts.Parts): rt.Result => { if ((op & 16) === 0) { return rt.Ok(p10.bytes); } return rt.ERR; })(_73.value); - const tried2: rt.Result, [rt.RefCell, undefined]> = rt.refMutTryMap(_73, part.ok ? rt.Ok(rt.partPlace(part.value)) : rt.Err(part.error)); + const tried2: rt.Result, [rt.RefCell, undefined]> = rt.refMutTryMap(_73, part.ok ? rt.Ok(rt.partPlace(part.value)) : rt.Err(part.error)); if (tried2.ok) { const bytes: rt.RefCell = tried2.value; rt.byteVecPush(bytes.value, op); @@ -677,12 +677,12 @@ export function tries(data: rt.ByteSlice, out: rt.ByteVec): void { } rt.refMutRelease(bytes); } else { - const whole2: rt.RefCell = tried2.error[0]; + const whole2: rt.RefCell = tried2.error[0]; rt.byteVecPush(out, 240 | (whole2.value.bytes.length & 0xff)); rt.refMutRelease(whole2); } rt.byteVecPush(out, borrowed$borrows_Parts(parts)); - const _105: rt.RefCell = rt.refCellBorrow(parts); + const _105: rt.RefCell = rt.refCellBorrow(parts); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(_105.value.bytes)); rt.refRelease(_105); const _109: rt.RefCell = rt.refCellBorrowMut(number); @@ -695,9 +695,9 @@ export function tries(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _122.value & 0xff); rt.refRelease(_122); } else if (_23 === 1) { - const other: rt.RefCell = rt.refCellBorrow(parts); - const _128: rt.RefCell = rt.refCellBorrow(parts); - const _127: rt.Result, [rt.RefCell, rt.usize]> = rt.refTryMap(_128, ((p8: borrows_Parts.Parts): rt.Result => { + const other: rt.RefCell = rt.refCellBorrow(parts); + const _128: rt.RefCell = rt.refCellBorrow(parts); + const _127: rt.Result, [rt.RefCell, rt.usize]> = rt.refTryMap(_128, ((p8: Parts.Parts): rt.Result => { return option_okOr$1oufq9m(rt.byteSliceLast(rt.byteVecSlice(p8.bytes)), p8.bytes.length); })(_128.value)); if (_127.ok) { @@ -718,7 +718,7 @@ export function tries(data: rt.ByteSlice, out: rt.ByteVec): void { rt.refRelease(b2); } } else { - const whole3: rt.RefCell = _127.error[0]; + const whole3: rt.RefCell = _127.error[0]; rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(whole3.value.n & 0xff, _127.error[1] & 0xff))); rt.refRelease(whole3); } @@ -726,30 +726,30 @@ export function tries(data: rt.ByteSlice, out: rt.ByteVec): void { rt.refRelease(other); rt.byteVecPush(out, borrowed$borrows_Parts(parts)); } else if (_23 === 2) { - const _175: rt.RefCell = rt.refCellBorrowMut(parts); + const _175: rt.RefCell = rt.refCellBorrowMut(parts); _175.value.text = _175.value.text + String.fromCodePoint(rt.u8Add(97, rt.u8Rem(op, 26)) as rt.char); rt.refMutRelease(_175); - const _183: rt.RefCell = rt.refCellBorrow(parts); - const text: rt.RefCell = rt.refMap(_183, ((p3: borrows_Parts.Parts): string => { + const _183: rt.RefCell = rt.refCellBorrow(parts); + const text: rt.RefCell = rt.refMap(_183, ((p3: Parts.Parts): string => { return p3.text; })(_183.value)); - const _186: rt.RefCell = rt.refCellBorrow(parts); - const quad: rt.RefCell = rt.refMap(_186, rt.byteSliceView(((p4: borrows_Parts.Parts): rt.ByteSlice => { + const _186: rt.RefCell = rt.refCellBorrow(parts); + const quad: rt.RefCell = rt.refMap(_186, rt.byteSliceView(((p4: Parts.Parts): rt.ByteSlice => { return rt.byteSliceFrom(p4.quad); })(_186.value))); const n2: rt.RefCell = rt.refCellBorrow(number); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, text.value), (f: rt.Formatter) => rt.fmtStr(text.value, f), (f: rt.Formatter) => rt.fmtList(quad.value, f, rt.u8Debug), (f: rt.Formatter) => rt.u32Debug(n2.value, f), (f: rt.Formatter) => rt.u32Display(n2.value, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1], " [", rt.fmtSpec({ align: ">", width: 4 }, args2[0]), "] ", args2[2], " ", rt.fmtSpec({ alternate: true }, args2[3]), " ", args2[3], " ", rt.fmtSpec({ align: ">", width: 5 }, args2[4])]))); drop$tuple3_cell_Ref_String_cell_Ref_array4_u8_cell_Ref_u32([text, quad, n2] as [rt.RefCell, rt.RefCell, rt.RefCell]); - const _211: rt.RefCell = rt.refCellBorrowMut(parts); - const maybe: rt.RefCell = rt.refMutMap(_211, ((p5: borrows_Parts.Parts): rt.Place => { + const _211: rt.RefCell = rt.refCellBorrowMut(parts); + const maybe: rt.RefCell = rt.refMutMap(_211, ((p5: Parts.Parts): rt.Place => { return rt.place(() => p5.maybe, (value2) => p5.maybe = value2); })(_211.value)); const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(maybe.value, f, rt.u16Debug)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args4[0], " ", rt.fmtSpec({ alternate: true }, args4[0])]))); rt.refMutRelease(maybe); - const _227: rt.RefCell = rt.refCellBorrowMut(parts); - const bytes2: rt.RefCell = rt.refMutMap(_227, rt.partPlace(((p6: borrows_Parts.Parts): rt.ByteVec => { + const _227: rt.RefCell = rt.refCellBorrowMut(parts); + const bytes2: rt.RefCell = rt.refMutMap(_227, rt.partPlace(((p6: Parts.Parts): rt.ByteVec => { return p6.bytes; })(_227.value))); const _237: rt.RefCell = rt.refCellBorrowMut(number); @@ -782,22 +782,22 @@ export function tries(data: rt.ByteSlice, out: rt.ByteVec): void { } else { const _291: rt.u8 = op >> 4; if (_291 === 13) { - const _297: rt.RefCell = rt.refCellBorrowMut(parts); - const _whole: rt.RefCell = rt.resultUnwrapErr(rt.refMutTryMap(_297, ((_2: borrows_Parts.Parts): rt.Result, undefined> => { + const _297: rt.RefCell = rt.refCellBorrowMut(parts); + const _whole: rt.RefCell = rt.resultUnwrapErr(rt.refMutTryMap(_297, ((_2: Parts.Parts): rt.Result, undefined> => { return rt.ERR; })(_297.value)), (value: rt.RefCell, f: rt.Formatter) => rt.u32Debug(value.value, f))[0]; rt.refRelease(rt.refCellBorrow(parts)); rt.refMutRelease(_whole); } else if (_291 === 14) { - const _302: rt.RefCell = rt.refCellBorrow(parts); - const _n: rt.Result, [rt.RefCell, undefined]> = rt.refTryMap(_302, ((p2: borrows_Parts.Parts): rt.Result => { + const _302: rt.RefCell = rt.refCellBorrow(parts); + const _n: rt.Result, [rt.RefCell, undefined]> = rt.refTryMap(_302, ((p2: Parts.Parts): rt.Result => { return rt.Ok(p2.n); })(_302.value)); rt.refMutRelease(rt.refCellBorrowMut(parts)); drop$Result_cell_Ref_u32_tuple2_cell_Ref_borrows_Parts_unit(_n); } else if (_291 === 15) { - const _307: rt.RefCell = rt.refCellBorrowMut(parts); - const _n2: rt.Result, [rt.RefCell, undefined]> = rt.refMutTryMap(_307, ((p: borrows_Parts.Parts): rt.Result, undefined> => { + const _307: rt.RefCell = rt.refCellBorrowMut(parts); + const _n2: rt.Result, [rt.RefCell, undefined]> = rt.refMutTryMap(_307, ((p: Parts.Parts): rt.Result, undefined> => { return rt.Ok(rt.place(() => p.n, (value) => p.n = value)); })(_307.value)); rt.refRelease(rt.refCellBorrow(parts)); @@ -808,7 +808,7 @@ export function tries(data: rt.ByteSlice, out: rt.ByteVec): void { } flush(log.value, out); } - const last2: borrows_Parts.Parts = parts.value; + const last2: Parts.Parts = parts.value; rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(last2.n & 0xff, option_mapOr$099335t(last2.maybe, 253, (m3: rt.u16): rt.u8 => { return m3 & 0xff; })))); @@ -988,11 +988,11 @@ export function borrowed$array4_u8(cell: rt.RefCell): rt.u8 { } /** Whether `cell` is borrowed exclusively, as 2, shared, as 1, or not at all. */ -export function borrowed$borrows_Parts(cell: rt.RefCell): rt.u8 { +export function borrowed$borrows_Parts(cell: rt.RefCell): rt.u8 { let _0!: rt.u8; - const _5: rt.Result, rt.BorrowError> = rt.refCellTryBorrow(cell); + const _5: rt.Result, rt.BorrowError> = rt.refCellTryBorrow(cell); const _3: boolean = !_5.ok; - const _8: rt.Result, rt.BorrowMutError> = rt.refCellTryBorrowMut(cell); + const _8: rt.Result, rt.BorrowMutError> = rt.refCellTryBorrowMut(cell); const _2: [boolean, boolean] = [_3, !_8.ok]; if (!_3) { if (!_2[1]) { diff --git a/ts/fixtures/lang/borrows/expected/core/bool.ts b/ts/fixtures/lang/borrows/expected/core/bool.ts new file mode 100644 index 000000000..31890c18b --- /dev/null +++ b/ts/fixtures/lang/borrows/expected/core/bool.ts @@ -0,0 +1,20 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Tagged from "../borrows.Tagged.ts"; + +export function thenSome$0zrlsto(self: boolean, t: rt.ByteSlice): rt.ByteSlice | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function then$1jgls7y(self: boolean, f: () => rt.RefCell): rt.RefCell | undefined { + if (!self) { + return undefined; + } + return f(); +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/borrows/expected/core/option.ts b/ts/fixtures/lang/borrows/expected/core/option.ts new file mode 100644 index 000000000..88326f40d --- /dev/null +++ b/ts/fixtures/lang/borrows/expected/core/option.ts @@ -0,0 +1,49 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Noisy from "../borrows.Noisy.ts"; +import type * as Tagged from "../borrows.Tagged.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function mapOr$0qqbaqw(self: Noisy.Noisy | undefined, default_: rt.u8, f: (a0: Noisy.Noisy) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1dvn0au(self: Tagged.Tagged | undefined, default_: rt.u8, f: (a0: Tagged.Tagged) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0ucbp7g(self: [rt.u64, rt.u64] | undefined, default_: rt.u8, f: (a0: [rt.u64, rt.u64]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$099335t(self: rt.u16 | undefined, default_: rt.u8, f: (a0: rt.u16) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function okOr$1oufq9m(self: rt.u8 | undefined, err: rt.usize): rt.Result { + if (self === undefined) { + return rt.Err(err); + } + return rt.Ok(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/borrows/expected/core/result.ts b/ts/fixtures/lang/borrows/expected/core/result.ts new file mode 100644 index 000000000..f6bcfd668 --- /dev/null +++ b/ts/fixtures/lang/borrows/expected/core/result.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function map$0n1xnuw(self: rt.Result, rt.BorrowMutError>, op: (a0: rt.RefCell) => rt.u8): rt.Result { + if (self.ok) { + return rt.Ok(op(self.value)); + } + return self as rt.Result; +} + +export function unwrapOr$0k9nfhn(self: rt.Result, default_: rt.u8): rt.u8 { + if (self.ok) { + return self.value; + } + return default_; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/borrows/expected/harness.ts b/ts/fixtures/lang/borrows/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/borrows/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/borrows/expected/lib.ts b/ts/fixtures/lang/borrows/expected/lib.ts new file mode 100644 index 000000000..f46442981 --- /dev/null +++ b/ts/fixtures/lang/borrows/expected/lib.ts @@ -0,0 +1,187 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { borrows, guards, maps, tries, leaks } from "./borrows.ts"; +import type * as Parts from "./borrows.Parts.ts"; +import type * as Tagged from "./borrows.Tagged.ts"; + +export function copy$Option_tuple2_u64_u64(v: [rt.u64, rt.u64] | undefined): [rt.u64, rt.u64] | undefined { + return v === undefined ? v : copy$tuple2_u64_u64(v); +} + +export function copy$tuple2_u64_u64(v: [rt.u64, rt.u64]): [rt.u64, rt.u64] { + return [v[0], v[1]]; +} + +export function drop$Option_cell_RefMut_borrows_Tagged(_1: rt.RefCell | undefined): void { + if (_1 !== undefined) { + rt.refMutRelease(_1); + } +} + +export function drop$Option_cell_Ref_borrows_Tagged(_1: rt.RefCell | undefined): void { + if (_1 !== undefined) { + rt.refRelease(_1); + } +} + +export function drop$Result_cell_RefMut_Vec_u8_cell_BorrowMutError(_1: rt.Result, rt.BorrowMutError>): void { + if (_1.ok) { + rt.refMutRelease(_1.value); + } +} + +export function drop$Result_cell_RefMut_array4_u8_cell_BorrowMutError(_1: rt.Result, rt.BorrowMutError>): void { + if (_1.ok) { + rt.refMutRelease(_1.value); + } +} + +export function drop$Result_cell_RefMut_borrows_Parts_cell_BorrowMutError(_1: rt.Result, rt.BorrowMutError>): void { + if (_1.ok) { + rt.refMutRelease(_1.value); + } +} + +export function drop$Result_cell_RefMut_borrows_Tagged_cell_BorrowMutError(_1: rt.Result, rt.BorrowMutError>): void { + if (_1.ok) { + rt.refMutRelease(_1.value); + } +} + +export function drop$Result_cell_RefMut_tuple2_u16_Vec_u8_cell_BorrowMutError(_1: rt.Result, rt.BorrowMutError>): void { + if (_1.ok) { + rt.refMutRelease(_1.value); + } +} + +export function drop$Result_cell_RefMut_u32_cell_BorrowMutError(_1: rt.Result, rt.BorrowMutError>): void { + if (_1.ok) { + rt.refMutRelease(_1.value); + } +} + +export function drop$Result_cell_RefMut_u32_tuple2_cell_RefMut_borrows_Parts_unit(_1: rt.Result, [rt.RefCell, undefined]>): void { + if (_1.ok) { + rt.refMutRelease(_1.value); + } else { + drop$tuple2_cell_RefMut_borrows_Parts_unit(_1.error); + } +} + +export function drop$Result_cell_Ref_Vec_u8_cell_BorrowError(_1: rt.Result, rt.BorrowError>): void { + if (_1.ok) { + rt.refRelease(_1.value); + } +} + +export function drop$Result_cell_Ref_array4_u8_cell_BorrowError(_1: rt.Result, rt.BorrowError>): void { + if (_1.ok) { + rt.refRelease(_1.value); + } +} + +export function drop$Result_cell_Ref_borrows_Parts_cell_BorrowError(_1: rt.Result, rt.BorrowError>): void { + if (_1.ok) { + rt.refRelease(_1.value); + } +} + +export function drop$Result_cell_Ref_ref_str_tuple2_cell_Ref_tuple2_u8_ref_str_u8(_1: rt.Result, [rt.RefCell<[rt.u8, string]>, rt.u8]>): void { + if (_1.ok) { + rt.refRelease(_1.value); + } else { + drop$tuple2_cell_Ref_tuple2_u8_ref_str_u8(_1.error); + } +} + +export function drop$Result_cell_Ref_tuple2_u16_Vec_u8_cell_BorrowError(_1: rt.Result, rt.BorrowError>): void { + if (_1.ok) { + rt.refRelease(_1.value); + } +} + +export function drop$Result_cell_Ref_u32_cell_BorrowError(_1: rt.Result, rt.BorrowError>): void { + if (_1.ok) { + rt.refRelease(_1.value); + } +} + +export function drop$Result_cell_Ref_u32_cell_Ref_borrows_Parts(_1: rt.Result, rt.RefCell>): void { + if (_1.ok) { + rt.refRelease(_1.value); + } else { + rt.refRelease(_1.error); + } +} + +export function drop$Result_cell_Ref_u32_tuple2_cell_Ref_borrows_Parts_unit(_1: rt.Result, [rt.RefCell, undefined]>): void { + if (_1.ok) { + rt.refRelease(_1.value); + } else { + drop$tuple2_cell_Ref_borrows_Parts_unit(_1.error); + } +} + +export function drop$tuple2_Option_cell_Ref_borrows_Tagged_Option_cell_RefMut_borrows_Tagged(_1: [rt.RefCell | undefined, rt.RefCell | undefined]): void { + drop$Option_cell_Ref_borrows_Tagged(_1[0]); + drop$Option_cell_RefMut_borrows_Tagged(_1[1]); +} + +export function drop$tuple2_Result_cell_Ref_Vec_u8_cell_BorrowError_cell_Ref_Vec_u8(_1: [rt.Result, rt.BorrowError>, rt.RefCell]): void { + drop$Result_cell_Ref_Vec_u8_cell_BorrowError(_1[0]); + rt.refRelease(_1[1]); +} + +export function drop$tuple2_cell_RefMut_borrows_Parts_unit(_1: [rt.RefCell, undefined]): void { + rt.refMutRelease(_1[0]); +} + +export function drop$tuple2_cell_RefMut_slice_u8_cell_RefMut_slice_u8(_1: [rt.RefCell, rt.RefCell]): void { + rt.refMutRelease(_1[0]); + rt.refMutRelease(_1[1]); +} + +export function drop$tuple2_cell_Ref_Vec_u8_cell_Ref_u8(_1: [rt.RefCell, rt.RefCell]): void { + rt.refRelease(_1[0]); + rt.refRelease(_1[1]); +} + +export function drop$tuple2_cell_Ref_borrows_Parts_unit(_1: [rt.RefCell, undefined]): void { + rt.refRelease(_1[0]); +} + +export function drop$tuple2_cell_Ref_str_cell_RefMut_u32(_1: [rt.RefCell, rt.RefCell]): void { + rt.refRelease(_1[0]); + rt.refMutRelease(_1[1]); +} + +export function drop$tuple2_cell_Ref_tuple2_u8_ref_str_u8(_1: [rt.RefCell<[rt.u8, string]>, rt.u8]): void { + rt.refRelease(_1[0]); +} + +export function drop$tuple3_cell_Ref_String_cell_Ref_array4_u8_cell_Ref_u32(_1: [rt.RefCell, rt.RefCell, rt.RefCell]): void { + rt.refRelease(_1[0]); + rt.refRelease(_1[1]); + rt.refRelease(_1[2]); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["borrows::borrows", (_22: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + borrows(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["borrows::guards", (_23: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + guards(data2, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["borrows::maps", (_24: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + maps(data3, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["borrows::tries", (_25: rt.u8, data4: rt.ByteSlice, out4: rt.ByteVec): undefined => { + tries(data4, out4); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["borrows::leaks", (_26: rt.u8, data5: rt.ByteSlice, out5: rt.ByteVec): undefined => { + leaks(data5, out5); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/borrows.rs b/ts/fixtures/lang/borrows/src/borrows.rs similarity index 100% rename from ts/fixtures/lang/src/borrows.rs rename to ts/fixtures/lang/borrows/src/borrows.rs diff --git a/ts/fixtures/lang/borrows/src/lib.rs b/ts/fixtures/lang/borrows/src/lib.rs new file mode 100644 index 000000000..fb6e38a40 --- /dev/null +++ b/ts/fixtures/lang/borrows/src/lib.rs @@ -0,0 +1,27 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#![feature(cell_leak, refcell_try_map)] + +mod borrows; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("borrows::borrows", |_, data, out| borrows::borrows(data, out)), + ("borrows::guards", |_, data, out| borrows::guards(data, out)), + ("borrows::maps", |_, data, out| borrows::maps(data, out)), + ("borrows::tries", |_, data, out| borrows::tries(data, out)), + ("borrows::leaks", |_, data, out| borrows::leaks(data, out)), + ] +} diff --git a/ts/fixtures/lang/borrows/ts.toml b/ts/fixtures/lang/borrows/ts.toml new file mode 100644 index 000000000..0714a715d --- /dev/null +++ b/ts/fixtures/lang/borrows/ts.toml @@ -0,0 +1,2 @@ +package = "lang-borrows-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/bounds/Cargo.toml b/ts/fixtures/lang/bounds/Cargo.toml new file mode 100644 index 000000000..c303c8511 --- /dev/null +++ b/ts/fixtures/lang/bounds/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-bounds-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/bounds/caller.ts b/ts/fixtures/lang/bounds/caller.ts new file mode 100644 index 000000000..fe71caa7b --- /dev/null +++ b/ts/fixtures/lang/bounds/caller.ts @@ -0,0 +1,18 @@ +// The inputs `bounds`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `bounds` with each kind of bound at each end, over every pair of values around and past + * four items, so ranges are empty, backwards, equal, and out of bounds, and of no items. + */ +const boundsOp = op("bounds::bounds"); +const bounds = Array.from({ length: 6 * 9 * 36 }, (_, n) => { + const [kind, ends, at] = [n % 6, Math.floor(n / 6) % 9, Math.floor(n / 54)]; + const [a, b] = [at % 6, Math.floor(at / 6)]; + return [Uint8Array.of(...boundsOp, kind, ends % 3, Math.floor(ends / 3), a, b, 1, 3, 2, 5), Uint8Array.of(...boundsOp, kind, ends % 3, Math.floor(ends / 3), a, b)]; +}).flat(); + +export const cases: Uint8Array[] = [...bounds]; diff --git a/ts/fixtures/lang/expected/bounds.Asked.ts b/ts/fixtures/lang/bounds/expected/bounds.Asked.ts similarity index 87% rename from ts/fixtures/lang/expected/bounds.Asked.ts rename to ts/fixtures/lang/bounds/expected/bounds.Asked.ts index fd34ca660..13eb6b833 100644 --- a/ts/fixtures/lang/expected/bounds.Asked.ts +++ b/ts/fixtures/lang/bounds/expected/bounds.Asked.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { log as bounds_log } from "./bounds.ts"; +import { log } from "./bounds.ts"; /** The crate's own range, which logs each bound std asks it for: 0xa5 its start, 0xae its end. */ export class Asked { @@ -15,22 +15,22 @@ export class Asked { } export function startBound$ops_RangeBounds_u8_u8(self: Asked): rt.RangeBound { - bounds_log(165); + log(165); return self.start; } export function startBound$ops_RangeBounds_usize_usize(self: Asked): rt.RangeBound { - bounds_log(165); + log(165); return self.start; } export function endBound$ops_RangeBounds_u8_u8(self: Asked): rt.RangeBound { - bounds_log(174); + log(174); return self.end; } export function endBound$ops_RangeBounds_usize_usize(self: Asked): rt.RangeBound { - bounds_log(174); + log(174); return self.end; } diff --git a/ts/fixtures/lang/expected/bounds.Item.ts b/ts/fixtures/lang/bounds/expected/bounds.Item.ts similarity index 82% rename from ts/fixtures/lang/expected/bounds.Item.ts rename to ts/fixtures/lang/bounds/expected/bounds.Item.ts index cdcfe3ddd..e632e7244 100644 --- a/ts/fixtures/lang/expected/bounds.Item.ts +++ b/ts/fixtures/lang/bounds/expected/bounds.Item.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { log as bounds_log } from "./bounds.ts"; +import { log } from "./bounds.ts"; /** Logs its tag as it drops. */ export class Item { @@ -17,7 +17,7 @@ export class Item { } export function drop$ops_Drop(self: Item): void { - bounds_log(self.tag); + log(self.tag); } //# sourceMappingURL=bounds.Item.ts.map diff --git a/ts/fixtures/lang/expected/bounds.Key.ts b/ts/fixtures/lang/bounds/expected/bounds.Key.ts similarity index 88% rename from ts/fixtures/lang/expected/bounds.Key.ts rename to ts/fixtures/lang/bounds/expected/bounds.Key.ts index d4facea6b..0cf81a1db 100644 --- a/ts/fixtures/lang/expected/bounds.Key.ts +++ b/ts/fixtures/lang/bounds/expected/bounds.Key.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { log as bounds_log } from "./bounds.ts"; +import { log } from "./bounds.ts"; /** * A key the crate orders by its own `Ord`, high to low, as rangemap's keys are by theirs, @@ -12,7 +12,7 @@ export interface Key { } export function eq$cmp_PartialEq(self: Key, other: Key): boolean { - bounds_log(233); + log(233); return self._0 === other._0; } @@ -21,7 +21,7 @@ export function cmp$cmp_Ord(self: Key, other: Key): rt.Ordering { } export function partialCmp$cmp_PartialOrd(self: Key, other: Key): rt.Ordering | undefined { - bounds_log(201); + log(201); return cmp$cmp_Ord(self, other); } diff --git a/ts/fixtures/lang/expected/bounds.ts b/ts/fixtures/lang/bounds/expected/bounds.ts similarity index 90% rename from ts/fixtures/lang/expected/bounds.ts rename to ts/fixtures/lang/bounds/expected/bounds.ts index 5fc1955b0..c595a9826 100644 --- a/ts/fixtures/lang/expected/bounds.ts +++ b/ts/fixtures/lang/bounds/expected/bounds.ts @@ -2,7 +2,7 @@ import * as rt from "./rt.ts"; import * as Asked from "./bounds.Asked.ts"; -import * as bounds_Item from "./bounds.Item.ts"; +import * as Item from "./bounds.Item.ts"; import * as Key from "./bounds.Key.ts"; import { map$1iekgsb as option_map$1iekgsb, map$1hdkvwd as option_map$1hdkvwd, map$0a57co2 as option_map$0a57co2 } from "./core/option.ts"; @@ -127,19 +127,19 @@ export function bounds(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const _18: [rt.usize, rt.usize] = [rt.usizeRem(a as rt.usize, reach), rt.usizeRem(b as rt.usize, reach)]; const i: rt.usize = _18[0]; const j: rt.usize = _18[1]; - const items: bounds_Item.Item[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 4))), (_2: rt.u8): bounds_Item.Item => { - return new bounds_Item.Item(_2); + const items: Item.Item[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 4))), (_2: rt.u8): Item.Item => { + return new Item.Item(_2); }), undefined, 1, true); const _28: rt.u8 = rt.u8Rem(kind, 6); if (_28 === 0) { const range: [rt.RangeBound, rt.RangeBound] = [bound$usize(s, i), bound$usize(e, j)]; - const iter: rt.Iter = rt.vecDrain(items, range, rt.drop); + const iter: rt.Iter = rt.vecDrain(items, range, rt.drop); while (true) { - const _37: bounds_Item.Item | rt.Done = iter.next(); + const _37: Item.Item | rt.Done = iter.next(); if (_37 === rt.DONE) { break; } - const x: bounds_Item.Item = _37; + const x: Item.Item = _37; rt.byteVecPush(out, x.tag); flush(out); x[Symbol.dispose](); @@ -163,9 +163,9 @@ export function bounds(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { }), undefined, true); } else if (_28 === 1) { const _78: Asked.Asked = asked$usize(s, e, i, j); - const drain2: rt.Iter = rt.vecDrain(items, rt.boundsOf(_78, Asked.startBound$ops_RangeBounds_usize_usize, Asked.endBound$ops_RangeBounds_usize_usize), rt.drop); + const drain2: rt.Iter = rt.vecDrain(items, rt.boundsOf(_78, Asked.startBound$ops_RangeBounds_usize_usize, Asked.endBound$ops_RangeBounds_usize_usize), rt.drop); flush(out); - rt.iterExtendBytes(out, rt.iterOption(option_map$1iekgsb(rt.iterToOption(drain2.next()), (x5: bounds_Item.Item): rt.u8 => { + rt.iterExtendBytes(out, rt.iterOption(option_map$1iekgsb(rt.iterToOption(drain2.next()), (x5: Item.Item): rt.u8 => { const _09: rt.u8 = x5.tag; x5[Symbol.dispose](); return _09; @@ -179,7 +179,7 @@ export function bounds(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { flush(out); rt.iterExtendBytes(out, rt.iterSlice(rt.byteVecView(bytes2)), undefined, true); } else if (_28 === 2) { - const queue: rt.VecDeque = rt.dequeNew(1) as rt.VecDeque; + const queue: rt.VecDeque = rt.dequeNew(1) as rt.VecDeque; const iter2: rt.Iter<[rt.usize, rt.u8]> = rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 4)))); while (true) { const _104: [rt.usize, rt.u8] | rt.Done = iter2.next(); @@ -189,14 +189,14 @@ export function bounds(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const n: rt.usize = _104[0]; const tag: rt.u8 = _104[1]; if (rt.usizeRem(n, 2) === 0) { - rt.dequePushBack(queue, new bounds_Item.Item(tag)); + rt.dequePushBack(queue, new Item.Item(tag)); } else { - rt.dequePushFront(queue, new bounds_Item.Item(tag)); + rt.dequePushFront(queue, new Item.Item(tag)); } } const _117: [rt.RangeBound, rt.RangeBound] = [bound$usize(s, i), bound$usize(e, j)]; - const drain3: rt.Iter = rt.dequeDrain(queue, _117, rt.drop); - rt.iterExtendBytes(out, rt.iterOption(option_map$1iekgsb(rt.iterToOption(drain3.nextBack()), (x2: bounds_Item.Item): rt.u8 => { + const drain3: rt.Iter = rt.dequeDrain(queue, _117, rt.drop); + rt.iterExtendBytes(out, rt.iterOption(option_map$1iekgsb(rt.iterToOption(drain3.nextBack()), (x2: Item.Item): rt.u8 => { const _06: rt.u8 = x2.tag; x2[Symbol.dispose](); return _06; @@ -204,16 +204,16 @@ export function bounds(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { flush(out); rt.drop(drain3); flush(out); - rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(queue), (x3: bounds_Item.Item): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(queue), (x3: Item.Item): rt.u8 => { return x3.tag; }), undefined, true); const reach2: rt.usize = rt.usizeAdd(queue.n, 1); const _138: Asked.Asked = asked$usize(s, e, rt.usizeRem(a as rt.usize, reach2), rt.usizeRem(b as rt.usize, reach2)); - const drain4: rt.Iter = rt.dequeDrain(queue, rt.boundsOf(_138, Asked.startBound$ops_RangeBounds_usize_usize, Asked.endBound$ops_RangeBounds_usize_usize), rt.drop); + const drain4: rt.Iter = rt.dequeDrain(queue, rt.boundsOf(_138, Asked.startBound$ops_RangeBounds_usize_usize, Asked.endBound$ops_RangeBounds_usize_usize), rt.drop); flush(out); rt.byteVecPush(out, rt.ownedCount(drain4, rt.drop) & 0xff); flush(out); - rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(queue), (x4: bounds_Item.Item): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(queue), (x4: Item.Item): rt.u8 => { return x4.tag; }), undefined, true); rt.dequeDrop(queue, rt.drop); @@ -250,7 +250,7 @@ export function bounds(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.iterExtendBytes(out, rt.iterRev(rt.btreeRangeKeys(set, range2)), "next"); rt.byteVecPush(out, within$tuple2_ops_Bound_u8_ops_Bound_u8(set, range2) & 0xff); } else if (_28 === 4) { - const empty: rt.BTreeMap = rt.btreeNew(rt.cmp) as rt.BTreeMap; + const empty: rt.BTreeMap = rt.btreeNew(rt.cmp) as rt.BTreeMap; const _215: Asked.Asked = asked$u8(s, e, a, b); rt.byteVecPush(out, rt.iterCount(rt.btreeRange(empty, rt.boundsOf(_215, Asked.startBound$ops_RangeBounds_u8_u8, Asked.endBound$ops_RangeBounds_u8_u8))) & 0xff); flush(out); @@ -312,7 +312,7 @@ export function bounds(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { flush(out); } flush(out); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(items), (x6: bounds_Item.Item): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(items), (x6: Item.Item): rt.u8 => { return x6.tag; }), undefined, true); rt.dropAll(items); diff --git a/ts/fixtures/lang/bounds/expected/core/option.ts b/ts/fixtures/lang/bounds/expected/core/option.ts new file mode 100644 index 000000000..1ca931a41 --- /dev/null +++ b/ts/fixtures/lang/bounds/expected/core/option.ts @@ -0,0 +1,27 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Item from "../bounds.Item.ts"; + +export function map$1iekgsb(self: Item.Item | undefined, f: (a0: Item.Item) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$1hdkvwd(self: [rt.u8, rt.u8] | undefined, f: (a0: [rt.u8, rt.u8]) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0a57co2(self: rt.u32 | undefined, f: (a0: rt.u32) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/bounds/expected/harness.ts b/ts/fixtures/lang/bounds/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/bounds/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/bounds/expected/lib.ts b/ts/fixtures/lang/bounds/expected/lib.ts new file mode 100644 index 000000000..0c4fec559 --- /dev/null +++ b/ts/fixtures/lang/bounds/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { bounds } from "./bounds.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["bounds::bounds", bounds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/bounds.rs b/ts/fixtures/lang/bounds/src/bounds.rs similarity index 100% rename from ts/fixtures/lang/src/bounds.rs rename to ts/fixtures/lang/bounds/src/bounds.rs diff --git a/ts/fixtures/lang/bounds/src/lib.rs b/ts/fixtures/lang/bounds/src/lib.rs new file mode 100644 index 000000000..16cec2d06 --- /dev/null +++ b/ts/fixtures/lang/bounds/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod bounds; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("bounds::bounds", bounds::bounds)] +} diff --git a/ts/fixtures/lang/bounds/ts.toml b/ts/fixtures/lang/bounds/ts.toml new file mode 100644 index 000000000..404eaffa3 --- /dev/null +++ b/ts/fixtures/lang/bounds/ts.toml @@ -0,0 +1,2 @@ +package = "lang-bounds-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/boxes/Cargo.toml b/ts/fixtures/lang/boxes/Cargo.toml new file mode 100644 index 000000000..609902067 --- /dev/null +++ b/ts/fixtures/lang/boxes/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-boxes-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/expected/boxes.Held.ts b/ts/fixtures/lang/boxes/expected/boxes.Held.ts similarity index 64% rename from ts/fixtures/lang/expected/boxes.Held.ts rename to ts/fixtures/lang/boxes/expected/boxes.Held.ts index a9f872d57..c859a6ecc 100644 --- a/ts/fixtures/lang/expected/boxes.Held.ts +++ b/ts/fixtures/lang/boxes/expected/boxes.Held.ts @@ -1,14 +1,14 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import type * as boxes_Logged from "./boxes.Logged.ts"; +import type * as Logged from "./boxes.Logged.ts"; /** A boxed slice in a field, beside one that drops after it. */ export class Held { - items: boxes_Logged.Logged[]; - last: boxes_Logged.Logged; + items: Logged.Logged[]; + last: Logged.Logged; - constructor(items: boxes_Logged.Logged[], last: boxes_Logged.Logged) { + constructor(items: Logged.Logged[], last: Logged.Logged) { this.items = items; this.last = last; } diff --git a/ts/fixtures/lang/expected/boxes.Logged.ts b/ts/fixtures/lang/boxes/expected/boxes.Logged.ts similarity index 100% rename from ts/fixtures/lang/expected/boxes.Logged.ts rename to ts/fixtures/lang/boxes/expected/boxes.Logged.ts diff --git a/ts/fixtures/lang/expected/boxes.Owner.ts b/ts/fixtures/lang/boxes/expected/boxes.Owner.ts similarity index 100% rename from ts/fixtures/lang/expected/boxes.Owner.ts rename to ts/fixtures/lang/boxes/expected/boxes.Owner.ts diff --git a/ts/fixtures/lang/expected/boxes.ts b/ts/fixtures/lang/boxes/expected/boxes.ts similarity index 88% rename from ts/fixtures/lang/expected/boxes.ts rename to ts/fixtures/lang/boxes/expected/boxes.ts index a0a3a774a..fa5eb765c 100644 --- a/ts/fixtures/lang/expected/boxes.ts +++ b/ts/fixtures/lang/boxes/expected/boxes.ts @@ -2,14 +2,13 @@ import * as rt from "./rt.ts"; import { copy$array_tuple2_u8_u16, copy$array_u16, copy$array_u8, copy$tuple2_u8_u16, drop$Result_boxed_Box_array1_boxes_Logged_boxed_Box_slice_boxes_Logged } from "./lib.ts"; -import * as boxes_Held from "./boxes.Held.ts"; -import * as boxes_Logged from "./boxes.Logged.ts"; +import * as Held from "./boxes.Held.ts"; +import * as Logged from "./boxes.Logged.ts"; import type * as Owner from "./boxes.Owner.ts"; import { then$0ea5h05 } from "./core/bool.ts"; -import { unwrapOr$1iemzn8 as option_unwrapOr$1iemzn8, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOr$1j4op5y as option_unwrapOr$1j4op5y, unwrapOr$11c0we2 as option_unwrapOr$11c0we2, mapOr$1e4a1e0 as option_mapOr$1e4a1e0, asDeref$0w8at8i as option_asDeref$0w8at8i, asDeref$0w2m0zn as option_asDeref$0w2m0zn, asDeref$0avuzwv as option_asDeref$0avuzwv, flatten$08boupk as option_flatten$08boupk } from "./core/option.ts"; -import { map$0nfi04k as result_map$0nfi04k, asDeref$1fldd5d as result_asDeref$1fldd5d, asDeref$04i8i5u as result_asDeref$04i8i5u, unwrapOr$0e4foht as result_unwrapOr$0e4foht, copied$0bbq7yi as result_copied$0bbq7yi } from "./core/result.ts"; -import { put as fmt_put } from "./fmt.ts"; -import { text as strs_text } from "./strs.ts"; +import { unwrapOr$1iemzn8 as option_unwrapOr$1iemzn8, unwrapOr$1j4op5y as option_unwrapOr$1j4op5y, unwrapOr$11c0we2 as option_unwrapOr$11c0we2, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, mapOr$1e4a1e0 as option_mapOr$1e4a1e0, asDeref$0w2m0zn as option_asDeref$0w2m0zn, asDeref$0w8at8i as option_asDeref$0w8at8i, asDeref$0avuzwv as option_asDeref$0avuzwv, flatten$08boupk as option_flatten$08boupk } from "./core/option.ts"; +import { map$0nfi04k as result_map$0nfi04k, asDeref$1fldd5d as result_asDeref$1fldd5d, asDeref$04i8i5u as result_asDeref$04i8i5u, unwrapOr$0e4foht as result_unwrapOr$0e4foht, copied$0bbq7yi } from "./core/result.ts"; +import { put, text } from "./harness.ts"; /** Puts what was logged since the last flush, after a marker. */ export function flush(log: rt.RefCell, out: rt.ByteVec): void { @@ -70,9 +69,9 @@ export function wides(b: rt.u16[], out: rt.ByteVec): void { } /** Puts the ids of `b`. */ -export function ids(b: boxes_Logged.Logged[], out: rt.ByteVec): void { +export function ids(b: Logged.Logged[], out: rt.ByteVec): void { rt.byteVecPush(out, b.length & 0xff); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(b), (l: boxes_Logged.Logged): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(b), (l: Logged.Logged): rt.u8 => { return l.id; }), undefined, true); } @@ -106,7 +105,7 @@ export function scramble(b: rt.Place): void { } /** A whole boxed slice written through a `&mut`, of another length. */ -export function set$boxes_Logged(slot: rt.Place, value: boxes_Logged.Logged[]): void { +export function set$boxes_Logged(slot: rt.Place, value: Logged.Logged[]): void { rt.dropAll(slot.v); slot.v = value; } @@ -222,7 +221,7 @@ export function boxes(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.byteSliceFirst(a), 170)); const _261: rt.ByteSlice = rt.byteSliceFrom(new Uint8Array(0)); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(a), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(b), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_261), f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], "|", args2[1], "|", args2[2]])); + put(out, rt.fmtFormat([args2[0], "|", args2[1], "|", args2[2]])); } else if (_15 === 2) { const wide: rt.u16[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data2)), (_24: rt.u8): rt.u16 => { return rt.u16Mul(_24 as rt.u16, 257); @@ -264,7 +263,7 @@ export function boxes(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, rt.cmpSlice(rt.cmp)(collected2, cloned2) & 0xff); rt.byteVecPush(out, rt.u64Eq(hash$boxed_Box_slice_u16(collected2), hash$slice_u16(rt.sliceRange(collected2, 0))) ? 1 : 0); const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(collected2, f, rt.u16Debug)]; - fmt_put(out, rt.fmtFormat([args4[0]])); + put(out, rt.fmtFormat([args4[0]])); const v3: rt.u16[] = rt.vecExact(fromVec2, 2); v3.push(5); wides(v3, out); @@ -283,55 +282,55 @@ export function boxes(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { }), undefined, true); } else if (_15 === 3) { const log: rt.Arc> = new rt.Arc(new rt.RefCell(new rt.ByteVec())); - const logged: (a0: rt.u8) => boxes_Logged.Logged = (id: rt.u8): boxes_Logged.Logged => { - return new boxes_Logged.Logged(id, rt.arcClone(log)); + const logged: (a0: rt.u8) => Logged.Logged = (id: rt.u8): Logged.Logged => { + return new Logged.Logged(id, rt.arcClone(log)); }; - const boxed2: boxes_Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data2)), (_22: rt.u8): boxes_Logged.Logged => { + const boxed2: Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data2)), (_22: rt.u8): Logged.Logged => { return logged(_22 & 126); }), undefined, 8, true); ids(boxed2, out); - const cloned3: boxes_Logged.Logged[] = boxed2.map(boxes_Logged.clone$Clone); + const cloned3: Logged.Logged[] = boxed2.map(Logged.clone$Clone); flush(log.value, out); rt.dropAll(boxed2); flush(log.value, out); - const fromRef3: boxes_Logged.Logged[] = rt.sliceRange(cloned3, 0).map(boxes_Logged.clone$Clone); + const fromRef3: Logged.Logged[] = rt.sliceRange(cloned3, 0).map(Logged.clone$Clone); flush(log.value, out); - let collected3: boxes_Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data2)), (_23: rt.u8): boxes_Logged.Logged => { + let collected3: Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data2)), (_23: rt.u8): Logged.Logged => { return logged(_23 | 1); }), undefined, 8, true); ids(collected3, out); - const _433: boxes_Logged.Logged[] = [logged(16), logged(18)]; + const _433: Logged.Logged[] = [logged(16), logged(18)]; rt.dropAll(collected3); collected3 = _433; flush(log.value, out); - const _444: boxes_Logged.Logged = logged(20); + const _444: Logged.Logged = logged(20); rt.idx(collected3, 0); collected3[0][Symbol.dispose](); collected3[0] = _444; flush(log.value, out); - const it2: rt.Iter = rt.iterSlice(rt.vecExact(cloned3, 8), rt.drop); - const _454: boxes_Logged.Logged | rt.Done = it2.next(); + const it2: rt.Iter = rt.iterSlice(rt.vecExact(cloned3, 8), rt.drop); + const _454: Logged.Logged | rt.Done = it2.next(); if (_454 !== rt.DONE) { - const first: boxes_Logged.Logged = _454; + const first: Logged.Logged = _454; rt.byteVecPush(out, first.id); first[Symbol.dispose](); } - const back: boxes_Logged.Logged | undefined = rt.iterToOption(it2.nextBack()); + const back: Logged.Logged | undefined = rt.iterToOption(it2.nextBack()); flush(log.value, out); rt.drop(it2); flush(log.value, out); rt.drop(back); - const v4: boxes_Logged.Logged[] = rt.vecExact(fromRef3, 8); + const v4: Logged.Logged[] = rt.vecExact(fromRef3, 8); ids(v4, out); rt.dropAll(v4); flush(log.value, out); - const held: boxes_Held.Held = new boxes_Held.Held([logged(32), logged(34)], logged(36)); + const held: Held.Held = new Held.Held([logged(32), logged(34)], logged(36)); rt.byteVecPush(out, held.items.length & 0xff); rt.byteVecPush(out, held.last.id); held[Symbol.dispose](); flush(log.value, out); - const empty3: boxes_Logged.Logged[] = []; - const _506: boxes_Logged.Logged[] = empty3.map(boxes_Logged.clone$Clone); + const empty3: Logged.Logged[] = []; + const _506: Logged.Logged[] = empty3.map(Logged.clone$Clone); ids(_506, out); rt.dropAll(_506); set$boxes_Logged(rt.place(() => collected3, (value) => collected3 = value), [logged(48)]); @@ -410,26 +409,26 @@ export function boxes(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.iterExtendBytes(out, rt.iterSlice(rt.u16ToBeBytes(_634[1]).reverse()), undefined, true); } } else { - const s: string = strs_text(data2); + const s: string = text(data2); const fromRef4: string = s; const fromString: string = s; const into2: string = s; const collected4: string = rt.stringExtendChars("", rt.iterRev(rt.strChars(s))); const empty4: string = ""; - fmt_put(out, fromRef4); - fmt_put(out, fromString); - fmt_put(out, into2); - fmt_put(out, collected4); - fmt_put(out, empty4); + put(out, fromRef4); + put(out, fromString); + put(out, into2); + put(out, collected4); + put(out, empty4); rt.byteVecPush(out, fromRef4 === into2 ? 1 : 0); rt.byteVecPush(out, rt.cmpStr(collected4, fromRef4) & 0xff); rt.byteVecPush(out, rt.u64Eq(hash$boxed_Box_str(fromRef4), hash$str(s)) ? 1 : 0); const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, fromRef4), (f: rt.Formatter) => rt.fmtStr(collected4, f)]; - fmt_put(out, rt.fmtFormat([args6[0], "|", args6[1]])); + put(out, rt.fmtFormat([args6[0], "|", args6[1]])); let back2: string = into2; back2 = back2 + "!"; - fmt_put(out, back2); - fmt_put(out, collected4); + put(out, back2); + put(out, collected4); } } @@ -680,21 +679,21 @@ export function places(_1: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(n).reverse()), undefined, true); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(pair)); - fmt_put(out, s); - fmt_put(out, t); + put(out, s); + put(out, t); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(nested).reverse()), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(option_unwrapOr$11c0we2(maybe, 238)).reverse()), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(held.n).reverse()), undefined, true); - fmt_put(out, held.s); + put(out, held.s); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(held.nested).reverse()), undefined, true); rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (b: rt.u32): Uint8Array => { return rt.u32ToBeBytes(b).reverse(); }, (value: Uint8Array) => rt.iterSlice(value), false, 4), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(option_unwrapOr$11c0we2(option_asDeref$0avuzwv(o), 238)).reverse()), undefined, true); - rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(result_unwrapOr$0e4foht(result_copied$0bbq7yi(result_asDeref$04i8i5u(res)), 238)).reverse()), undefined, true); + rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(result_unwrapOr$0e4foht(copied$0bbq7yi(result_asDeref$04i8i5u(res)), 238)).reverse()), undefined, true); const _298: rt.Result = said; if (_298.ok) { - fmt_put(out, _298.value); + put(out, _298.value); } else { rt.byteVecPush(out, _298.error); } @@ -704,7 +703,7 @@ export function places(_1: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterFlatten(rt.iterOption(someWords), (value: rt.u32[]) => rt.iterSlice(value)), (w2: rt.u32): Uint8Array => { return rt.u32ToBeBytes(w2).reverse(); }, (value: Uint8Array) => rt.iterSlice(value), false, 4), "next"); - fmt_put(out, option_unwrapOr$1iemzn8(option_asDeref$0w8at8i(named), "-")); + put(out, option_unwrapOr$1iemzn8(option_asDeref$0w8at8i(named), "-")); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(leaked.v).reverse()), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(option_unwrapOr$11c0we2(option_flatten$08boupk(option_asDeref$0w2m0zn(deep)), 238)).reverse()), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(result_unwrapOr$0e4foht(result_map$0nfi04k(result_asDeref$1fldd5d(tup), (t2: [rt.u32, rt.u32]): rt.u32 => { @@ -715,8 +714,8 @@ export function places(_1: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } /** Clones `from` into `slot` by its `clone_from`. */ -export function refill$boxed_Box_slice_boxes_Logged(slot: rt.Place, from: boxes_Logged.Logged[]): void { - slot.v = rt.boxSliceCloneFrom(slot.v, from, boxes_Logged.clone$Clone, rt.drop); +export function refill$boxed_Box_slice_boxes_Logged(slot: rt.Place, from: Logged.Logged[]): void { + slot.v = rt.boxSliceCloneFrom(slot.v, from, Logged.clone$Clone, rt.drop); } /** Clones `from` into `slot` by its `clone_from`. */ @@ -802,8 +801,8 @@ export function impls(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const data2: rt.ByteSlice = rt.byteSliceRange(data, 0, rt.usizeRem(kind >> 3 as rt.usize, rt.usizeAdd(data.length, 1))); const half: rt.usize = rt.usizeDiv(data2.length, 2); const log: rt.Arc> = new rt.Arc(new rt.RefCell(new rt.ByteVec())); - const logged: (a0: rt.u8) => boxes_Logged.Logged = (id: rt.u8): boxes_Logged.Logged => { - return new boxes_Logged.Logged(id, rt.arcClone(log)); + const logged: (a0: rt.u8) => Logged.Logged = (id: rt.u8): Logged.Logged => { + return new Logged.Logged(id, rt.arcClone(log)); }; const _23: rt.u8 = rt.u8Rem(kind, 4); if (_23 === 0) { @@ -855,11 +854,11 @@ export function impls(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.iterExtendBytes(out, rt.iterSlice(rt.u16ToBeBytes(_113[1]).reverse()), undefined, true); } let s: string[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data2, 0, half))), (_222: rt.u8): string => { - return strs_text(rt.byteSliceFrom(Uint8Array.of(_222))); + return text(rt.byteSliceFrom(Uint8Array.of(_222))); }), undefined, 12, true); const t: string[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data2, half, rt.usizeMul(half, 2)))), (_223: rt.u8): string => { const x11: rt.u8 = _223; - return strs_text(rt.byteSliceFrom(Uint8Array.of(x11, x11))); + return text(rt.byteSliceFrom(Uint8Array.of(x11, x11))); }), undefined, 12, true); s = rt.boxSliceCloneFrom(s, t); const _138: rt.Place | undefined = rt.sliceFirstMut(s); @@ -872,28 +871,28 @@ export function impls(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (_150 === rt.DONE) { break; } - fmt_put(out, _150); + put(out, _150); } - let l: boxes_Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data2, 0, half))), (_224: rt.u8): boxes_Logged.Logged => { + let l: Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data2, 0, half))), (_224: rt.u8): Logged.Logged => { return logged(_224 & 126); }), undefined, 8, true); - const m: boxes_Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data2, half, rt.usizeMul(half, 2)))), (_226: rt.u8): boxes_Logged.Logged => { + const m: Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data2, half, rt.usizeMul(half, 2)))), (_226: rt.u8): Logged.Logged => { return logged(_226 | 1); }), undefined, 8, true); flush(log.value, out); - l = rt.boxSliceCloneFrom(l, m, boxes_Logged.clone$Clone, rt.drop); + l = rt.boxSliceCloneFrom(l, m, Logged.clone$Clone, rt.drop); flush(log.value, out); ids(l, out); - const _187: boxes_Logged.Logged[] = [logged(16), logged(18), logged(20)]; + const _187: Logged.Logged[] = [logged(16), logged(18), logged(20)]; refill$boxed_Box_slice_boxes_Logged(rt.place(() => l, (value3) => l = value3), _187); rt.dropAll(_187); flush(log.value, out); ids(l, out); - const held: boxes_Held.Held = new boxes_Held.Held(rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data2, 0, rt.usizeSub(data2.length, half)))), (_227: rt.u8): boxes_Logged.Logged => { + const held: Held.Held = new Held.Held(rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data2, 0, rt.usizeSub(data2.length, half)))), (_227: rt.u8): Logged.Logged => { return logged(_227 & 126); }), undefined, 8, true), logged(80)); flush(log.value, out); - held.items = rt.boxSliceCloneFrom(held.items, m, boxes_Logged.clone$Clone, rt.drop); + held.items = rt.boxSliceCloneFrom(held.items, m, Logged.clone$Clone, rt.drop); flush(log.value, out); ids(held.items, out); held[Symbol.dispose](); @@ -910,8 +909,8 @@ export function impls(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.dropAll(m); flush(log.value, out); let t2: string = "ab"; - t2 = strs_text(data2); - fmt_put(out, t2); + t2 = text(data2); + put(out, t2); } else if (_23 === 1) { let a2: rt.ByteSlice = rt.byteSliceFrom(rt.byteSliceToArray(data2)); bytes(a2, out); @@ -942,18 +941,18 @@ export function impls(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const v3: rt.ByteVec = rt.byteSliceToByteVec(data2); rt.byteVecPush(v3, 102); bytes(rt.byteVecSlice(v3), out); - let s2: string = strs_text(data2); + let s2: string = text(data2); s2 = s2 + "#"; - fmt_put(out, s2); + put(out, s2); const w2: rt.u16[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data2)), (_28: rt.u8): rt.u16 => { return rt.u16Add(_28 as rt.u16, 1); }), undefined, 2, true); rt.sliceSortUnstable(w2, rt.lt, 2, true, true); wides(w2, out); - const l2: boxes_Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data2)), (_214: rt.u8): boxes_Logged.Logged => { + const l2: Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data2)), (_214: rt.u8): Logged.Logged => { return logged(_214); }), undefined, 8, true); - const _368: boxes_Logged.Logged[] = l2; + const _368: Logged.Logged[] = l2; if (_368.length >= 2) { const swapped = _368[0]; _368[0] = _368[_368.length - 1]; @@ -995,31 +994,31 @@ export function impls(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } else { wides(_422.error, out); } - const l3: boxes_Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data2)), (_22: rt.u8): boxes_Logged.Logged => { + const l3: Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data2)), (_22: rt.u8): Logged.Logged => { return logged(_22 & 126); }), undefined, 8, true); - const _438: rt.Result = l3.length === 2 ? rt.Ok(l3) : rt.Err(l3); + const _438: rt.Result = l3.length === 2 ? rt.Ok(l3) : rt.Err(l3); if (_438.ok) { - const a5: boxes_Logged.Logged[] = _438.value; + const a5: Logged.Logged[] = _438.value; ids(a5, out); flush(log.value, out); rt.dropAll(a5); } else { - const l4: boxes_Logged.Logged[] = _438.error; + const l4: Logged.Logged[] = _438.error; ids(l4, out); flush(log.value, out); rt.dropAll(l4); } flush(log.value, out); - const l5: boxes_Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data2)), (_25: rt.u8): boxes_Logged.Logged => { + const l5: Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data2)), (_25: rt.u8): Logged.Logged => { return logged(_25 | 1); }), undefined, 8, true); - const r2: rt.Result = l5.length === 1 ? rt.Ok(l5) : rt.Err(l5); + const r2: rt.Result = l5.length === 1 ? rt.Ok(l5) : rt.Err(l5); flush(log.value, out); drop$Result_boxed_Box_array1_boxes_Logged_boxed_Box_slice_boxes_Logged(r2); flush(log.value, out); } else { - const s3: string = strs_text(data2); + const s3: string = text(data2); const a6: rt.ByteSlice = rt.stringAsBytes(s3); rt.byteSliceView(a6).reverse(); bytes(a6, out); diff --git a/ts/fixtures/lang/boxes/expected/core/bool.ts b/ts/fixtures/lang/boxes/expected/core/bool.ts new file mode 100644 index 000000000..a9e31d7f0 --- /dev/null +++ b/ts/fixtures/lang/boxes/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function then$0ea5h05(self: boolean, f: () => rt.u32): rt.u32 | undefined { + if (!self) { + return undefined; + } + return f(); +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/boxes/expected/core/option.ts b/ts/fixtures/lang/boxes/expected/core/option.ts new file mode 100644 index 000000000..f61d09eca --- /dev/null +++ b/ts/fixtures/lang/boxes/expected/core/option.ts @@ -0,0 +1,86 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$1iemzn8(self: string | undefined, default_: string): string { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$1j4op5y(self: rt.u16 | undefined, default_: rt.u16): rt.u16 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$11c0we2(self: rt.u32 | undefined, default_: rt.u32): rt.u32 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$1k1fy8u(self: rt.u32 | undefined | rt.None, _: (a0: rt.u32 | undefined) => rt.u32 | undefined): rt.u32 | undefined | rt.None { + if (self === rt.None) { + return rt.None; + } + return self; +} + +export function map$1uo1d4o(self: string | undefined, _: (a0: string) => string): string | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function map$0xz4pvf(self: rt.u32 | undefined, _: (a0: rt.u32) => rt.u32): rt.u32 | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function mapOr$1e4a1e0(self: rt.Ordering | undefined, default_: rt.u8, f: (a0: rt.Ordering) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function asDeref$0w2m0zn(self: rt.u32 | undefined | rt.None): rt.u32 | undefined | rt.None { + return map$1k1fy8u(self, (a0: rt.u32 | undefined): rt.u32 | undefined => { + return a0; + }); +} + +export function asDeref$0w8at8i(self: string | undefined): string | undefined { + return map$1uo1d4o(self, (a0: string): string => { + return a0; + }); +} + +export function asDeref$0avuzwv(self: rt.u32 | undefined): rt.u32 | undefined { + return map$0xz4pvf(self, (a0: rt.u32): rt.u32 => { + return a0; + }); +} + +export function flatten$08boupk(self: rt.u32 | undefined | rt.None): rt.u32 | undefined { + if (self === rt.None) { + return undefined; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/boxes/expected/core/result.ts b/ts/fixtures/lang/boxes/expected/core/result.ts new file mode 100644 index 000000000..a5e4c7199 --- /dev/null +++ b/ts/fixtures/lang/boxes/expected/core/result.ts @@ -0,0 +1,66 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function asRef$0iljode(self: rt.Result<[rt.u32, rt.u32], rt.u8>): rt.Result<[rt.u32, rt.u32], rt.u8> { + if (self.ok) { + return rt.Ok(self.value); + } + return rt.Err(self.error); +} + +export function asRef$10maq8w(self: rt.Result): rt.Result { + if (self.ok) { + return rt.Ok(self.value); + } + return rt.Err(self.error); +} + +export function map$17yn9bi(self: rt.Result<[rt.u32, rt.u32], rt.u8>, _: (a0: [rt.u32, rt.u32]) => [rt.u32, rt.u32]): rt.Result<[rt.u32, rt.u32], rt.u8> { + if (self.ok) { + return rt.Ok(self.value); + } + return self; +} + +export function map$0m0doqe(self: rt.Result, _: (a0: rt.u32) => rt.u32): rt.Result { + if (self.ok) { + return rt.Ok(self.value); + } + return self; +} + +export function map$0nfi04k(self: rt.Result<[rt.u32, rt.u32], rt.u8>, op: (a0: [rt.u32, rt.u32]) => rt.u32): rt.Result { + if (self.ok) { + return rt.Ok(op(self.value)); + } + return self as rt.Result; +} + +export function asDeref$1fldd5d(self: rt.Result<[rt.u32, rt.u32], rt.u8>): rt.Result<[rt.u32, rt.u32], rt.u8> { + return map$17yn9bi(asRef$0iljode(self), (a0: [rt.u32, rt.u32]): [rt.u32, rt.u32] => { + return a0; + }); +} + +export function asDeref$04i8i5u(self: rt.Result): rt.Result { + return map$0m0doqe(asRef$10maq8w(self), (a0: rt.u32): rt.u32 => { + return a0; + }); +} + +export function unwrapOr$0e4foht(self: rt.Result, default_: rt.u32): rt.u32 { + if (self.ok) { + return self.value; + } + return default_; +} + +export function copied$0bbq7yi(self: rt.Result): rt.Result { + if (self.ok) { + return rt.Ok(self.value); + } + return self; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/boxes/expected/harness.ts b/ts/fixtures/lang/boxes/expected/harness.ts new file mode 100644 index 000000000..7c19e53ff --- /dev/null +++ b/ts/fixtures/lang/boxes/expected/harness.ts @@ -0,0 +1,64 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +/** A char of the alphabet for each byte, by its low bits. */ +export function text(data: rt.ByteSlice): string { + let s: string = ""; + const iterS: Uint8Array = rt.byteSliceView(data); + let iterI: number = 0; + while (true) { + const _5: rt.u8 | rt.Done = iterI < iterS.length ? iterS[iterI++] : rt.DONE; + if (_5 === rt.DONE) { + return s; + } + const _13: rt.usize = rt.u8Rem(_5, 16) as rt.usize; + if (!(_13 < 16)) { + rt.panic("index out of bounds: the len is " + 16 + " but the index is " + _13); + } + s = s + String.fromCodePoint([47, 92, 97, 48, 57, 127, 128, 233, 2047, 2048, 55295, 57344, 65535, 65536, 128512, 1114111][_13]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/boxes/expected/lib.ts b/ts/fixtures/lang/boxes/expected/lib.ts new file mode 100644 index 000000000..68e4bdbca --- /dev/null +++ b/ts/fixtures/lang/boxes/expected/lib.ts @@ -0,0 +1,39 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { boxes, places, impls } from "./boxes.ts"; +import type * as Logged from "./boxes.Logged.ts"; + +export function copy$array_tuple2_u8_u16(v: [rt.u8, rt.u16][]): [rt.u8, rt.u16][] { + return v.map(copy$tuple2_u8_u16); +} + +export function copy$array_u16(v: rt.u16[]): rt.u16[] { + return v.slice(); +} + +export function copy$array_u8(v: Uint8Array): Uint8Array { + return v.slice(); +} + +export function copy$tuple2_u8_u16(v: [rt.u8, rt.u16]): [rt.u8, rt.u16] { + return [v[0], v[1]]; +} + +export function drop$Result_boxed_Box_array1_boxes_Logged_boxed_Box_slice_boxes_Logged(_1: rt.Result): void { + if (_1.ok) { + rt.dropAll(_1.value); + } else { + rt.dropAll(_1.error); + } +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["boxes::boxes", boxes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["boxes::places", places as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["boxes::impls", impls as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/boxes.rs b/ts/fixtures/lang/boxes/src/boxes.rs similarity index 99% rename from ts/fixtures/lang/src/boxes.rs rename to ts/fixtures/lang/boxes/src/boxes.rs index a6678ba6c..9633b2df8 100644 --- a/ts/fixtures/lang/src/boxes.rs +++ b/ts/fixtures/lang/boxes/src/boxes.rs @@ -11,8 +11,7 @@ use std::hash::{DefaultHasher, Hash, Hasher}; use std::ops::Deref; use std::rc::Rc; -use crate::fmt::put; -use crate::strs::text; +use crate::harness::{put, text}; /// 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. diff --git a/ts/fixtures/lang/boxes/src/lib.rs b/ts/fixtures/lang/boxes/src/lib.rs new file mode 100644 index 000000000..cc31d3179 --- /dev/null +++ b/ts/fixtures/lang/boxes/src/lib.rs @@ -0,0 +1,23 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod boxes; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("boxes::boxes", boxes::boxes), + ("boxes::places", boxes::places), + ("boxes::impls", boxes::impls), + ] +} diff --git a/ts/fixtures/lang/boxes/ts.toml b/ts/fixtures/lang/boxes/ts.toml new file mode 100644 index 000000000..89b4e7e8f --- /dev/null +++ b/ts/fixtures/lang/boxes/ts.toml @@ -0,0 +1,2 @@ +package = "lang-boxes-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/caller.ts b/ts/fixtures/lang/caller.ts deleted file mode 100644 index b403579a5..000000000 --- a/ts/fixtures/lang/caller.ts +++ /dev/null @@ -1,978 +0,0 @@ -// A hand-written caller of the translation, as moq's TypeScript is: it runs the harness, -// and prints a `Fault` with the `Display` and `Debug` that `printable` brings along, -// which nothing translated calls. `differential.ts` runs it beside native Rust's -// `harness::entry`, from the output directory. - -import { mulAddsWithin } from "./fma.ts"; -import * as Fault from "./fmt.Fault.ts"; -import { cases as named, run as harness, op as pick } from "./harness.ts"; -import * as rt from "./rt.ts"; - -/** The first two bytes, which pick the case named `name`. */ -function op(name: string): number[] { - const at = pick(name); - return [at >> 8, at & 0xff]; -} - -/** The bytes that pick each case, through `op`, which panics for one past what two bytes pick, and a `Fault`'s first byte. */ -export const ops: Uint8Array[] = [...named().map(([name]) => Uint8Array.from(op(name))), Uint8Array.of(0xff)]; - -export function run(input: rt.ByteSlice): rt.ByteVec { - if (rt.byteSliceFirst(input) !== 0xff) return harness(input); - const fault = Fault.new(rt.byteSliceRange(input, 1)); - const display: rt.Fmt = (f) => Fault.fmt$fmt_Display(fault, f); - const debug: rt.Fmt = (f) => Fault.fmt$fmt_Debug(fault, f); - const text = rt.fmtFormat([ - display, - "|", - rt.fmtSpec({ align: ">", width: 16 }, display), - "|", - debug, - "|", - rt.fmtSpec({ alternate: true }, debug), - ]); - return rt.byteVecFrom(new TextEncoder().encode(text)); -} - -/** `shapes::loops` with each first byte that one of its cases of `!` takes, with one more byte and without. */ -const loops = [0xf1, 0xf3, 0xf4, 0xf5, 0xf6, 0xf9, 0xfa].flatMap((b) => [Uint8Array.of(...op("shapes::loops"), 0, b), Uint8Array.of(...op("shapes::loops"), 0, b, 1)]); - -/** A `Duration`'s bytes as `durations` takes them: its seconds, then its nanoseconds. */ -function duration(secs: bigint, nanos: number): number[] { - const bytes = new Uint8Array(12); - const view = new DataView(bytes.buffer); - view.setBigUint64(0, secs); - view.setUint32(8, nanos); - return [...bytes]; -} - -/** - * `durations` where seconds leave a safe integer or reach `u64::MAX`, nanoseconds carry, - * a sum carries them past it, and a factor makes the nanoseconds' product or a - * quotient's remainder pass 2^53. - */ -const edges = [0n, 1n, (1n << 53n) - 1n, 1n << 53n, (1n << 64n) - 1n].flatMap((secs) => [0, 1, 999_999_999].map((nanos) => duration(secs, nanos))); -const factors = [0, 1, 3, 1000, 9_007_199, 1_000_000_000, 0xffffffff].map((n) => [n >>> 24, (n >>> 16) & 0xff, (n >>> 8) & 0xff, n & 0xff]); -const durationsOp = op("durations::durations"); -const durations = [ - ...[0n, 1n, 1n << 32n, (1n << 53n) - 1n, 1n << 53n, (1n << 64n) - 2n, (1n << 64n) - 1n].flatMap((secs) => - [0, 1, 999_999_999, 1_000_000_000, 0xffffffff].flatMap((nanos) => [0, 1].map((kind) => Uint8Array.of(...durationsOp, kind, ...duration(secs, nanos)))), - ), - ...edges.flatMap((a) => edges.flatMap((b) => factors.flatMap((n) => [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13].map((kind) => Uint8Array.of(...durationsOp, kind, ...a, ...b, ...n))))), - // Each side of where minutes, hours, and a `u128` of nanoseconds pass `u64::MAX` seconds. - ...[2n ** 64n / 60n, 2n ** 64n / 3600n].flatMap((units) => [units, units + 1n].map((n) => wide(n << 64n))), - ...[(7n << 64n) + 999_999_999n, 2n ** 64n * 1_000_000_000n - 1n, 2n ** 64n * 1_000_000_000n, 2n ** 128n - 1n].map((n) => wide(n)), -]; - -/** `durations`' larger units, of a `u128` whose high half is also its `u64`. */ -function wide(n: bigint): Uint8Array { - const bytes = new Uint8Array(19); - bytes.set([...durationsOp, 12]); - const view = new DataView(bytes.buffer); - view.setBigUint64(3, n >> 64n); - view.setBigUint64(11, n & 0xffff_ffff_ffff_ffffn); - return bytes; -} - -/** A double's bits, big-endian, as `floats` takes them. */ -function double(x: number | bigint): number[] { - const bytes = new Uint8Array(8); - const view = new DataView(bytes.buffer); - if (typeof x === "bigint") view.setBigUint64(0, x); - else view.setFloat64(0, x); - return [...bytes]; -} - -/** - * `floats`' operands: each side of a half, of 2^52 and 2^53, where each integer type - * saturates, of a nanosecond and `u64::MAX` seconds, subnormals, infinities, and NaNs, - * one of them negative and one with a payload. - */ -const doubles: (number | bigint)[] = [ - 0, -0, 0.5, -0.5, 1.5, 2.5, -2.5, 0.49999999999999994, 1, -1, 3, 0.1, 1 / 3, 2 ** 52 - 0.5, 2 ** 52, 2 ** 53, 2 ** 53 + 2, - 255.5, -128.5, 2147483647.5, -2147483648.5, 4294967295.9, 2 ** 63, -(2 ** 63), -(2 ** 63) - 2048, 2 ** 64, 2 ** 64 - 2048, - 2 ** 127, 2 ** 128, -(2 ** 128), 1e-9, 0.5e-9, 1.5e-9, 0.999999999, 0.9999999995, 1.0000000005, 4.656612873077393e-10, - 1e-310, 5e-324, 2.2250738585072014e-308, Number.MAX_VALUE, -Number.MAX_VALUE, Infinity, -Infinity, NaN, - 0xfff8000000000000n, 0x7ff0000000000001n, -]; -/** Integers whose `f64` rounds, as `floats`' kind 2 takes them: 16 bytes of a `u128`. */ -const wides = [0n, 1n, (1n << 53n) + 1n, (1n << 53n) + 3n, (1n << 54n) + 2n, (1n << 63n) + 1025n, (1n << 64n) - 1n, (1n << 64n) - 1025n, (1n << 64n) + (1n << 11n) + 1n, (1n << 127n) + 1n, (1n << 128n) - 1n, (1n << 128n) - (1n << 74n), -(1n << 100n) - 1n]; -const floatsOp = op("floats::floats"); -/** How many cases the first two bytes pick among, modulo. */ -const count = named().length; -const floats = [ - ...Array.from({ length: 10 }, (_, kind) => doubles.flatMap((a) => doubles.map((b) => Uint8Array.of(...floatsOp, kind, ...double(a), ...double(b), 1)))).flat(), - // `from_secs_f64`, `mul_f64`, and `div_f64` panicking, and `Duration::MAX.mul_f64`. - ...[18, 28, 38].flatMap((kind) => doubles.map((a) => Uint8Array.of(...floatsOp, kind, ...double(a), ...double(a), 3))), - ...wides.map((v) => { - const bytes = new Uint8Array(16); - new DataView(bytes.buffer).setBigUint64(0, BigInt.asUintN(64, v >> 64n)); - new DataView(bytes.buffer).setBigUint64(8, BigInt.asUintN(64, v)); - return Uint8Array.of(...floatsOp, 2, ...bytes); - }), -]; - -/** - * `floats::formats`' doubles: ties at each precision, which std rounds half to even on the - * exact value, carries through nines, each side of where `Debug` takes an exponent, the - * shortest digits that are not the nearest ones, and the extremes. - */ -const formatted: (number | bigint)[] = [ - ...doubles, - 0.125, 0.375, 0.625, 0.875, 0.0625, 3.5, 4.5, 9.5, 99.5, 999.5, 0.95, 9.995, 1.25, 1.35, 2.675, 1e-4, 9.999999999999999e-5, - 1e16, 9999999999999998, 1e21, 1e22, 1e23, 5e-324, 2.225073858507201e-308, 123456789.125, 1.5e300, -1.5e-300, 2 ** -1022 * 1.5, - 0.1 + 0.2, 100, 1e15, 1e-7, 0.000123, -9.5, -0.5, -]; -const formatsOp = op("floats::formats"); -const formats = [ - ...formatted.flatMap((a) => Array.from({ length: 22 }, (_, p) => Uint8Array.of(...formatsOp, 0, ...double(a), p))), - ...formatted.flatMap((a) => [1, 3, 4].map((kind) => Uint8Array.of(...formatsOp, kind, ...double(a), 0))), - // Seeds for `parses`' decimals, a signaling NaN's bits among them, which a seed keeps. - ...doubles.map((a) => Uint8Array.of(...op("floats::parses"), 2, ...double(a))), - ...formatted.flatMap((a) => [[1, 2], [2, 1], [NaN, 1], [1, NaN], [-0, 0], [0, -0]].map(([b, c]) => Uint8Array.of(...formatsOp, 2, ...double(a), ...double(b), ...double(c)))), -]; - -/** - * `floats::parses`' texts: std's grammar at each edge, past each end of a double's range, - * and digits that round half to even, or just off it past 19 digits. - */ -const parsed = [ - "", "+", "-", ".", "+.", "-.", "e5", ".e5", "1e", "1e+", "1e-", "1.e5", ".5", "5.", "-.5e-3", "+1", "++1", "+-1", "1_000", "0x10", " 1", - "1 ", "1,5", "1.5.5", "1e5e5", "1E+05", "1e400", "-1e400", "1e-400", "1e99999999999999999999", "0e99999999999", "-0", "+0.0e-5", - "0000.0000", "inf", "-inf", "+inf", "infinity", "INFINITY", "InFiNiTy", "infin", "in", "infinityy", "nan", "NaN", "-nan", "+NAN", - "nan1", "Infinity", "i\u0307nf", "\u0131nf", "2.2250738585072011e-308", "2.2250738585072012e-308", "4.9406564584124654e-324", - "2.4703282292062327e-324", "2.4703282292062328e-324", "1.7976931348623157e308", "1.7976931348623158e308", "1.7976931348623159e308", - "9007199254740993", "9007199254740993.0000000000000000001", "9007199254740992.9999999999999999999", "123456789012345678901234567890", - "0.1000000000000000055511151231257827021181583404541015625", "1e23", "8.98846567431158e307", `0.${"0".repeat(400)}1e400`, - `1${"0".repeat(800)}e-800`, `${"9".repeat(800)}e-1100`, "1e65535", `1e-65536`, `0.${"0".repeat(70000)}1e70000`, -].map((text) => Uint8Array.of(...op("floats::parses"), 0, ...new TextEncoder().encode(text))); - -/** A single's bits, big-endian, as `singles` takes them. */ -function single(x: number | bigint): number[] { - const bytes = new Uint8Array(4); - const view = new DataView(bytes.buffer); - if (typeof x === "bigint") view.setUint32(0, Number(x)); - else view.setFloat32(0, x); - return [...bytes]; -} - -/** - * `singles`' operands: each side of a half, of 2^23 and 2^24, where each integer type - * saturates, where a single's range and its normals end, the bounds of `Debug`'s - * exponent, infinities, and NaNs, one negative, one with a payload, and one signaling. - */ -const singlesValues: (number | bigint)[] = [ - 0, -0, 0.5, -0.5, 1.5, 2.5, -2.5, 0.49999997, 1, -1, 3, 0.1, 1 / 3, 2 ** 23 - 0.5, 2 ** 23, 2 ** 24, 2 ** 24 + 2, 255.5, -128.5, - 2147483520, 2 ** 31, -(2 ** 31), 4294967040, 2 ** 32, 2 ** 63, -(2 ** 63), 2 ** 64, 2 ** 127, 1e-9, 0.99999994, 1.0000001, 1e-4, 1e16, - 1e-40, 2 ** -149, 2 ** -126, 3.4028234663852886e38, -3.4028234663852886e38, Infinity, -Infinity, NaN, 0xffc00000n, 0x7fc00123n, 0x7f800001n, -]; -const singlesOp = op("singles::singles"); -const singlesCases = [ - ...Array.from({ length: 10 }, (_, kind) => singlesValues.flatMap((a) => singlesValues.map((b) => Uint8Array.of(...singlesOp, kind, ...single(a), ...single(b), 1)))).flat(), - // `from_secs_f32`, `mul_f32`, and `div_f32` panicking, and `Duration::MAX.mul_f32`. - ...[18, 28, 38].flatMap((kind) => singlesValues.map((a) => Uint8Array.of(...singlesOp, kind, ...single(a), ...single(a), 3))), - // Integers whose `f32` rounds once where through an `f64` it would round twice: past - // 2^53, a bit just past halfway between two singles. - ...wides.concat([(1n << 60n) + (1n << 36n) + 1n, (1n << 64n) - (1n << 39n) - 1n, (1n << 127n) + (1n << 103n) + 1n, (1n << 24n) + 1n]).map((v) => { - const bytes = new Uint8Array(16); - new DataView(bytes.buffer).setBigUint64(0, BigInt.asUintN(64, v >> 64n)); - new DataView(bytes.buffer).setBigUint64(8, BigInt.asUintN(64, v)); - return Uint8Array.of(...singlesOp, 2, ...bytes); - }), -]; - -/** `singles::formats`' singles: ties at each precision, carries through nines, and the shortest digits at each end. */ -const singlesFormatted: (number | bigint)[] = [ - ...singlesValues, - 0.125, 0.375, 3.5, 9.5, 99.5, 0.95, 9.995, 1.25, 1.35, 2.675, 9.999999e-5, 1e15, 9999999e9, 1e-7, 123456.79, 16777215, 7.006492e-46, 1.17549421e-38, 8388609, -]; -const singlesFormatsOp = op("singles::formats"); -const singlesParsesOp = op("singles::parses"); -const singlesFormats = [ - ...singlesFormatted.flatMap((a) => Array.from({ length: 12 }, (_, p) => Uint8Array.of(...singlesFormatsOp, 0, ...single(a), p))), - ...singlesFormatted.flatMap((a) => [1, 3, 4].map((kind) => Uint8Array.of(...singlesFormatsOp, kind, ...single(a), 0))), - ...singlesFormatted.flatMap((a) => [[1, 2], [2, 1], [NaN, 1], [1, NaN], [-0, 0], [0, -0]].map(([b, c]) => Uint8Array.of(...singlesFormatsOp, 2, ...single(a), ...single(b), ...single(c)))), - ...singlesValues.map((a) => Uint8Array.of(...singlesParsesOp, 2, ...single(a))), -]; - -/** - * `singles::parses`' texts: std's grammar, past each end of a single's range, and - * decimals within a hair of halfway between two singles, which rounding through the - * nearest double would round twice. - */ -const singlesParsed = [ - "", "+", "-", ".", "e5", "1e", "1.e5", ".5", "+1", "1_000", " 1", "1e40", "-1e40", "1e-50", "-0", "inf", "-infinity", "NaN", "nan1", - "3.4028235e38", "3.4028236e38", "3.40282357e38", "3.4028235677973366e38", "3.4028235677973367e38", "1.4e-45", "7e-46", - "7.006492321624085354618647916449580656401e-46", "7.006492321624085354618647916449580656402e-46", "1.1754942e-38", "1.17549435e-38", - "16777217", "16777217.000000000001", "16777218.99999999999", "16777219", "1.00000005960464477539062499", "1.000000059604644775390625", - "1.00000005960464477539062501", "1.0000000596046448", "0.1", "1e10", "1234567e-10", "12345678e-10", "9007199254740993", - `1${"0".repeat(60)}e-60`, `0.${"0".repeat(60)}1e61`, "1e65535", "1e-65536", -].map((text) => Uint8Array.of(...singlesParsesOp, 0, ...new TextEncoder().encode(text))); - -/** - * `mul_adds`' operands at each width: signed zeros, a product that underflows to either - * zero, infinities and NaN, a product past the type's range whose sum is in it, subnormal - * sums and ties, products whose error alone survives, which rounding twice loses, and a - * product of half `c`'s last place, which only its error moves off a tie; then - * seeds for its sweeps. - */ -const mulAdds = (max: number, tiny: number, eps: number, op: number[], bytes: (x: number) => number[]) => [ - ...[ - [0, 1, -0], [-0, 1, -0], [0, -1, 0], [-0, -0, -0], [-0, 0, -0], [1, -1, 1], [-1, 1, 1], - [tiny, -(2 ** -30), 0], [tiny, 2 ** -30, -0], [-tiny, 2 ** -30, -0], [tiny, 0.5, 0], [tiny, 0.5, -0], [-tiny, 0.5, 0], - [tiny, 1.5, 0], [tiny, 0.5, tiny], [tiny, -0.5, tiny], [tiny, 2 ** 52, tiny], - [Infinity, 0, 1], [0, -Infinity, 1], [Infinity, 1, -Infinity], [Infinity, -1, -Infinity], [1, 1, Infinity], [max, 2, -Infinity], [max, -2, Infinity], - [NaN, 1, 1], [1, NaN, 1], [1, 1, NaN], [Infinity, 1, NaN], - [max, 2, -max], [max, -2, max], [max, 1 + eps, -max], [max, 1 + eps, 0], [max * 0.5, 2, max * eps * 0.25], - [1 + 2 ** -27, 1 - 2 ** -27, -1], [1 + eps, 1 + eps, -1], [1 + eps, 1 - eps, -1], [0.1, 10, -1], [3, 1 / 3, -1], [1 + eps, 1 + eps, -(1 + 2 * eps)], - [1 + 2 ** -12, 1 + 2 ** -12, tiny], [1 + 2 ** -12, 1 + 2 ** -12, -tiny], [1 + eps, 1 + eps / 2, 0], [eps / 2 + eps * eps / 2, 1 - eps / 2, 1], [eps / 2 + eps * eps / 2, 1 - eps / 2, -1], - ].map((xs) => Uint8Array.of(...op, 0, ...xs.flatMap(bytes))), - ...Array.from({ length: 400 }, (_, i) => Uint8Array.of(...op, 1, ...double(BigInt(i + 1) * 0x9e3779b97f4a7c15n & 0xffff_ffff_ffff_ffffn))), -]; -const floatsMulAdds = mulAdds(Number.MAX_VALUE, 5e-324, 2 ** -52, op("floats::mul_adds"), double); -const singlesMulAdds = mulAdds(3.4028234663852886e38, 2 ** -149, 2 ** -23, op("singles::mul_adds"), single); - -const [floatsAt, singlesAt, floatsMulAddsAt] = [pick("floats::floats"), pick("singles::singles"), pick("floats::mul_adds")]; - -/** How many ULPs from native Rust's each float of `floats`' and `singles`' kind 7 may be, which Rust leaves to libm. */ -const ULPS = 2n; - -export function within(input: Uint8Array, native: Uint8Array, translated: Uint8Array): boolean { - // A first byte of 0xff prints a `Fault`, and picks no case. - if (input[0] === 0xff) return false; - const at = ((input[0] << 8) | input[1]) % count; - if (at === floatsMulAddsAt) return mulAddsWithin(native, translated); - const width = at === floatsAt ? 8 : at === singlesAt ? 4 : 0; - if (width === 0 || input[2] % 10 !== 7 || native.length !== translated.length) return false; - const [a, b] = [native, translated].map((v) => new DataView(v.buffer, v.byteOffset, v.length)); - const read = (v: DataView, i: number) => (width === 8 ? v.getBigInt64(i) : BigInt(v.getInt32(i))); - // Bits as a line through zero, so the distance between two is how many floats apart they are. - const magnitude = (1n << BigInt(width * 8 - 1)) - 1n; - const line = (v: bigint) => (v < 0n ? -(v & magnitude) : v); - for (let i = 0; i < native.length; i += width) { - const d = line(read(a, i)) - line(read(b, i)); - if (d > ULPS || d < -ULPS) return false; - } - return true; -} - -/** - * The 64- and 128-bit cases over operands that random bytes rarely make: every pair of - * values next to a power of two. - */ -function ints(): Uint8Array[] { - const [u64, u128, i64, i128] = ["ints::u64_op", "ints::u128_op", "ints::i64_op", "ints::i128_op"].map(op); - const [neg, cast, convert, fmtInts] = ["ints::neg", "ints::cast", "ints::convert", "fmt::ints"].map(op); - const cases: Uint8Array[] = []; - // 2^k - 1, 2^k, and 2^k + 1 for each k where a limb, a safe number, or a sign ends, - // and values without that structure, whose quotients and remainders are not round. - const edges = new Set([ - 1_000_000n, - 0x9e3779b97f4a7c15n, - 0x0123456789abcdefn, - 0xfedcba9876543210n, - // Safe integers whose halves carry when multiplied, and a negative one. - 0x1d3c5b7a9f8e6dn, - -0x1b2a3c4d5e6f71n & 0xffffffffffffffffn, - ]); - for (const k of [0n, 1n, 16n, 21n, 31n, 32n, 33n, 52n, 53n, 54n, 63n, 64n]) { - for (const delta of [-1n, 0n, 1n]) edges.add(((1n << k) + delta) & 0xffffffffffffffffn); - } - // Small negative numbers, -2^32, and where negative safe numbers end, as signed values. - for (const k of [1n, 32n, 53n]) { - for (const delta of [-1n, 0n, 1n]) edges.add((-(1n << k) + delta) & 0xffffffffffffffffn); - } - const values = [...edges]; - const be = (v: bigint) => { - const bytes = new Uint8Array(8); - new DataView(bytes.buffer).setBigUint64(0, v); - return [...bytes]; - }; - // Shift amounts in and past each limb, and past the width, which panics. - const shifts = [0, 1, 7, 31, 32, 33, 63, 64, 65, 95, 96, 127, 128, 200]; - let i = 0; - for (const x of values) { - for (const y of values) { - // A 64-bit case's operands are `x` and `y`. A 128-bit case's are `x:y` and `u:v`, - // whose high halves are equal a third of the time, so the low half decides. - const u = i % 3 === 0 ? x : values[(i * 7) % values.length]; - const v = values[(i * 13 + 5) % values.length]; - const shift = shifts[i++ % shifts.length]; - for (let kind = 0; kind < 31; kind++) { - for (const o of [u64, i64]) cases.push(Uint8Array.of(...o, kind, ...be(x), ...be(y), shift)); - for (const o of [u128, i128]) cases.push(Uint8Array.of(...o, kind, ...be(x), ...be(y), ...be(u), ...be(v), shift)); - } - // `clamp` between two values of the sweep, whose third operand follows the shift's place. - for (const o of [u64, i64]) cases.push(Uint8Array.of(...o, 26, ...be(x), ...be(y), ...be(u))); - for (const o of [u128, i128]) cases.push(Uint8Array.of(...o, 26, ...be(x), ...be(y), ...be(u), ...be(v), ...be(y), ...be(x))); - // Negating an `i64` and an `i128`. - cases.push(Uint8Array.of(...neg, 3, ...be(x)), Uint8Array.of(...neg, 4, ...be(x), ...be(y))); - // `x * y`, `checked_mul`, `saturating_mul`, and `wrapping_mul` at 128 bits, extended in - // each type's sign: a product of two numbers, past 2^53, multiplies their halves. - const signs = (v: bigint) => (v >> 63n === 1n ? 0xffffffffffffffffn : 0n); - for (const kind of [2, 13, 24, 25]) { - cases.push(Uint8Array.of(...u128, kind, ...be(0n), ...be(x), ...be(0n), ...be(y))); - cases.push(Uint8Array.of(...i128, kind, ...be(signs(x)), ...be(x), ...be(signs(y)), ...be(y))); - } - // `x:y / d`, `x:y % d`, `div_ceil`, and `is_multiple_of` at 128 bits by a divisor - // below 2^32 in magnitude, which divides limbs by a number, extended in each type's - // sign: -1 overflows `i128::MIN`. - for (const d of [3n, 1_000_000n, 0xffffffffn, -1n, -0xffffffffn]) { - for (const kind of [3, 4, 27, 28]) { - for (const o of [u128, i128]) cases.push(Uint8Array.of(...o, kind, ...be(x), ...be(y), ...be(signs(d & 0xffffffffffffffffn)), ...be(d & 0xffffffffffffffffn))); - } - } - } - // Conversions, and halves joined back. - cases.push(Uint8Array.of(...convert, 0, ...be(x), ...be(x))); - for (const y of [0n, 1n, 1n << 32n, 1n << 63n, 0xffffffffffffffffn]) { - for (const from of [3, 4, 9, 10]) { - // A cast to every type, and every format spec. - for (let to = 0; to < 12; to++) cases.push(Uint8Array.of(...cast, from, to, ...be(x), ...be(y))); - cases.push(Uint8Array.of(...fmtInts, from, ...be(x), ...be(y))); - } - } - } - return cases; -} - -/** - * `utf8::decodes` of raw bytes: a byte order mark, which std keeps, and the sequences at - * each edge of what it takes: surrogates, overlongs, past U+10FFFF, and cut short at the - * end or by another byte. - */ -const utf8 = [ - [0xef, 0xbb, 0xbf, 0x61], - [0xed, 0x9f, 0xbf, 0xed, 0xa0, 0x80, 0xed, 0xbf, 0xbf], - [0xc0, 0x80, 0xc1, 0xbf, 0xc2, 0x80], - [0xe0, 0x80, 0x80, 0xe0, 0x9f, 0xbf, 0xe0, 0xa0, 0x80], - [0xf0, 0x80, 0x80, 0x80, 0xf0, 0x8f, 0xbf, 0xbf, 0xf0, 0x90, 0x80, 0x80], - [0xf4, 0x8f, 0xbf, 0xbf, 0xf4, 0x90, 0x80, 0x80, 0xf5, 0x80, 0x80, 0x80], - [0xf0, 0x9f, 0x98, 0x80, 0xf0, 0x9f, 0x98, 0x41, 0xe2, 0x82, 0x41, 0xf0, 0x9f, 0x98], - [0xe2, 0x82], - [0xc2], - [0x80, 0xf8, 0xff], -].map((bytes) => Uint8Array.of(...op("utf8::decodes"), 0, ...bytes)); - -/** - * `dyns::dyns` too short to run, with a `Tri` of each variant, at the ends of each side and - * count, and boxing each kind of shape. - */ -const dyns = [[], [1, 2], [3, 0, 7], [255, 1, 255, 0, 1, 2, 3, 4, 5], [0, 3, 2, 9, 255, 6, 128]].map((bytes) => - Uint8Array.of(...op("dyns::dyns"), 0, ...bytes), -); - -/** - * `cells` scripts of (op, operand) pairs on every kind, so each cell and value type: reads - * and sets, a `None` and a `()` held, initializing from within initialization and - * panicking in it, empty and full, and a cell replaced; clones, `Debug`, and `get_mut`, - * empty and full; and `get_or_try_init` failing, succeeding, set, and set or initialized - * again from within, failing after or not. - */ -const cellsOp = op("cells::cells"); -const cellScripts = [ - [0, 0, 1, 5, 0, 0, 1, 6, 2, 7, 4, 0, 0, 0, 4, 0, 2, 9, 0, 0], - [1, 3, 0, 0, 1, 4, 4, 0, 1, 6, 2, 3], - [3, 4, 3, 5], - [5, 3], - [6, 3], - [7, 1], - [2, 1, 5, 3, 6, 3, 7, 1], - [8, 4, 0, 0, 8, 5, 0, 0, 1, 3, 8, 6], - [9, 0, 9, 1, 0, 0], - [10, 0, 10, 1, 11, 2, 0, 0], - [11, 1, 2, 1, 11, 4, 0, 0, 4, 0, 11, 5], - [12, 0, 12, 6, 0, 0, 12, 1], - [12, 1, 12, 2], - [12, 2], - [12, 3, 4, 0, 12, 7], - [12, 11], - [12, 7, 12, 4], - [], -]; -const cells = Array.from({ length: 256 }, (_, kind) => cellScripts.map((script) => Uint8Array.of(...cellsOp, kind, ...script))).flat(); - -/** - * `dyns::shared` too short to run, and with `Arc`s of each type, the last count of each at - * zero and at the top of its range. - */ -const shared = [[], [1], [0, 0], [255, 255, 0, 1, 2, 3, 4, 5], [7, 0xff, 255, 254, 253]].map((bytes) => - Uint8Array.of(...op("dyns::shared"), 0, ...bytes), -); - -/** - * `locks` scripts: writes through guards and reads, `get_mut`, and a lock matched. - */ -const locks = [[0, 1, 5, 6, 2, 7, 3, 8, 3, 0, 1], [4, 0, 4, 1], [2, 9, 2, 10, 4, 1], [3, 3, 4, 0]].map( - (bytes) => Uint8Array.of(...op("locks::locks"), 0, ...bytes), -); - -/** - * `borrows::guards` scripts: each operation on cells empty and not, cloned while borrowed - * shared and exclusive, and borrowed exclusively while a mapped or cloned guard holds it. - */ -const guards = [ - [0x04, 0x05, 0x06, 0x03, 0x07, 0x02, 0x01], - [0x10, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0b, 0x0c, 0x0d], - [0x08, 0xe1, 0xf1], - [0x08, 0xe6], - [0xf6], -].map((bytes) => Uint8Array.of(...op("borrows::guards"), 0, ...bytes)); - -/** - * `borrows::maps` scripts: each operation through mapped, filtered, and split guards, with - * parts written whole and split parts dropped in either order, and each borrow again - * while one holds the cell, which panics. - */ -const maps = [ - [0x00, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x15, 0x07, 0xf1, 0xf2, 0x0b, 0x06, 0x13, 0x0c], - [0x02, 0x22, 0x0d, 0xc6], - [0x0a, 0xd6], - [0xe6], - [0x02, 0xf6], -].map((bytes) => Uint8Array.of(...op("borrows::maps"), 0, ...bytes)); - -/** `locks::mapped` scripts: writes and reads through mapped and filtered guards. */ -const mappedLocks = [[0x04, 0x01, 0x02, 0x86, 0x05, 0x0a, 0x03, 0x02, 0x80, 0x01, 0x03]].map((bytes) => - Uint8Array.of(...op("locks::mapped"), 0, ...bytes), -); - -/** - * `locks::relock` with each pick: a mutex locked again while a guard holds it, which - * panics, and a read-write lock read or written again while a guard, mapped or not, holds - * it, which aborts but for a read under a read. - */ -const relocks = Array.from({ length: 16 }, (_, pick) => Uint8Array.of(...op("locks::relock"), 0, pick)); - -/** - * `borrows::tries` scripts: each operation through tried guards, given back beside each - * error, printed, and each borrow again while a tried guard holds the cell, which panics. - */ -const tries = [ - [0x00, 0x00, 0x10, 0xf0, 0xe0, 0x01, 0x02, 0x05, 0x20, 0x21, 0x06, 0x03], - [0x01, 0x10, 0x01, 0x12, 0xe2], - [0xd3], - [0xe3], - [0x00, 0xf3], -].map((bytes) => Uint8Array.of(...op("borrows::tries"), 0, ...bytes)); - -/** `locks::mutex_mapped` scripts: writes and reads through mapped and filtered mutex guards. */ -const mutexMaps = [[0x04, 0x01, 0x02, 0x86, 0xf5, 0x0a, 0x03, 0x02, 0xe1, 0x80, 0x07, 0x02]].map((bytes) => - Uint8Array.of(...op("locks::mutex_mapped"), 0, ...bytes), -); - -/** `locks::printed` scripts: each lock's guards printed, empty and not. */ -const printed = [[], [0, 1, 25, 200]].map((bytes) => Uint8Array.of(...op("locks::printed"), 0, ...bytes)); - -/** `locks::downgraded` scripts: write guards downgraded, each lock's released in either order, and whole byte arrays mapped. */ -const downgrades = [[0x00, 0x01, 0x11, 0x02, 0xf2, 0xe2, 0x03, 0x04, 0x13, 0x05]].map((bytes) => - Uint8Array.of(...op("locks::downgraded"), 0, ...bytes), -); - -/** - * `borrows::leaks` scripts: guards leaked and undone, whole byte arrays mapped, and each - * borrow again while a leak holds the cell, which panics. - */ -const leaks = [[0x00, 0x01, 0x02, 0xf1, 0xf2, 0x04, 0x05, 0x03, 0x06], [0xe3], [0x00, 0xf3]].map((bytes) => - Uint8Array.of(...op("borrows::leaks"), 0, ...bytes), -); - -/** - * `refs::compared` of a split and the bytes either side of it, whose remainders by 3 and 5 - * make the bytes and floats: sides that are equal, empty, or a prefix of the other, and - * floats with a NaN before, after, or where they differ, and a `-0.0` against `0.0`. - */ -const placeCompares = [ - [2, 1, 2, 1, 2], - [0], - [0, 1], - [1, 1, 1, 2], - [2, 1, 2, 1], - [2, 0, 3, 0, 3], - [2, 0, 3, 1, 3], - [1, 3, 3, 1], - [2, 3, 0, 3, 1], - [1, 4, 0], -].map(([split, ...data]) => Uint8Array.of(...op("refs::compared"), split, ...data)); - -/** `locks::rwlocks` scripts: `get_mut` and `into_inner` among writes and reads. */ -const rwlocks = [[6, 7, 0, 6, 2, 14, 15, 1]].map((bytes) => Uint8Array.of(...op("locks::rwlocks"), 0, ...bytes)); - -/** - * `statics::onces` scripts: a `Once` forced, called, and forced again, which drops the - * function it never runs, each static's, each `call_once` and `call_once_force` run again - * from within itself, and crossbeam-epoch's `OnceLock` of each kind. - */ -const onces = [[1, 0, 1, 7], [0, 6, 1, 2, 3, 4, 5, 11], [2, 14, 8], [9], [3, 15], [4, 17, 23, 29, 4]].map((bytes) => Uint8Array.of(...op("statics::onces"), 0, ...bytes)); - -/** - * `bounds` with each kind of bound at each end, over every pair of values around and past - * four items, so ranges are empty, backwards, equal, and out of bounds, and of no items. - */ -const boundsOp = op("bounds::bounds"); -const bounds = Array.from({ length: 6 * 9 * 36 }, (_, n) => { - const [kind, ends, at] = [n % 6, Math.floor(n / 6) % 9, Math.floor(n / 54)]; - const [a, b] = [at % 6, Math.floor(at / 6)]; - return [Uint8Array.of(...boundsOp, kind, ends % 3, Math.floor(ends / 3), a, b, 1, 3, 2, 5), Uint8Array.of(...boundsOp, kind, ends % 3, Math.floor(ends / 3), a, b)]; -}).flat(); - -/** - * `pointers::cells` scripts: each operation on every cell, a number wrapping past its top, a - * struct assigned through `get` and written over, and cells replaced or made and taken out. - */ -const unsafeCells = [ - [0, 248, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15], - [4, 12, 4, 5, 253, 7, 255, 0], - [3, 251, 6, 3, 2, 2, 254], - [], -].map((bytes) => Uint8Array.of(...op("pointers::cells"), 0, ...bytes)); - -/** - * `strs::edits` of each edit on `aé\u{800}😀`, a char of each UTF-8 width, at every byte - * offset into it and up to two past its end, each made a raw offset by its byte's bits. - */ -const editsOp = op("strs::edits"); -const edits = Array.from({ length: 14 * 16 * 16 }, (_, i) => Uint8Array.of(...editsOp, 4, 2, 7, 9, 14, i >> 8, (i >> 4) & 15, i & 15)); - -/** - * `subslices` of each kind over zero to four items, at every pair of bounds up to one past - * the end, so parts are empty, at the end, backwards, and out of bounds. - */ -const subslicesOp = op("slices::subslices"); -const subslices = [0, 1, 2, 3, 4].flatMap((n) => - Array.from({ length: 8 * (n + 2) ** 2 }, (_, i) => { - const [kind, a, b] = [i % 8, Math.floor(i / 8) % (n + 2), Math.floor(i / 8 / (n + 2))]; - return Uint8Array.of(...subslicesOp, kind, a, b, ...[0x31, 0xc2, 0x07, 0xfe].slice(0, n)); - }), -); - -/** - * `nested::consumers`, whose first byte is also `nth`'s index: of no items, one `Some` or - * `None`, `None` before `Some`, `nth` past the end, only `None`s, keys all tied, and - * `find` stopping early. - */ -const consumers = [[], [6], [5], [1, 2], [7, 2], [1, 3, 5], [2, 6, 10, 14], [4, 3, 0x90, 0x92, 5]].map((bytes) => Uint8Array.of(...op("nested::nested"), 3, ...bytes)); - -/** - * `nested::closures`, whose bytes `pick` each `None` (0 mod 3), `Some(None)` (1), or - * `Some(Some(_))` (2): of no bytes, only `None`s, only `Some(None)`s, `Some(None)` before - * a `None` and after it, a seed of each, and a `successors` whose size hint reserves past - * `isize::MAX`. - */ -const closures = [[], [3], [0, 3], [1], [4, 7, 1], [1, 2, 0, 4, 5], [4, 0, 1, 3, 5], [2, 1, 4, 3, 8], [5, 4], [0, 1, 2], [0xf0], [0xf1]].map((bytes) => Uint8Array.of(...op("nested::nested"), 5, ...bytes)); - -/** - * `nested::elements`, whose first byte is also the index and whose odd bytes are each a - * `None` element: of no elements, one of each, only `None`s, and an index in range and - * past the end of each mix. - */ -const elements = [[], [1], [2], [1, 3], [3, 1, 5], [0, 1, 2], [2, 6, 1, 8], [5, 4, 3, 0x10, 7, 0x40], [7, 0x22, 9, 0x22, 1, 0x80, 3, 6]].map((bytes) => Uint8Array.of(...op("nested::nested"), 6, ...bytes)); - -/** - * `ranges` of each kind, and each kind of `Bound` at the end, over zero to four items, at - * every pair of bounds up to one past the end and at `usize::MAX`. - */ -const rangesOp = op("slices::ranges"); -const ranges = [0, 1, 2, 3, 4].flatMap((n) => { - const ends = [...Array(n + 2).keys(), 0xff]; - return Array.from({ length: 24 * ends.length ** 2 }, (_, i) => { - const [kind, a, b] = [i % 24, ends[Math.floor(i / 24) % ends.length], ends[Math.floor(i / 24 / ends.length)]]; - return Uint8Array.of(...rangesOp, kind, a, b, ...[0x31, 0xc2, 0x07, 0xfe].slice(0, n)); - }); -}); - -/** - * `iters::reducers` of no items, one, one repeated, which `next_if_eq` takes, and keys - * that all tie. - */ -const reducers = [[], [9], [9, 9], [8, 4, 12, 0x40, 0x80]].map((bytes) => Uint8Array.of(...op("iters::reducers"), 0, ...bytes)); - -/** - * `iters::peeked_others` of no items, one, a run that matches the first throughout, and - * items that each match one comparison and miss the next. - */ -const peekedOthers = [[], [3], [4, 4, 4, 4], [0, 1, 2, 3, 4, 5, 6], [1, 0, 0, 2, 5, 9]].map((bytes) => - Uint8Array.of(...op("iters::peeked_others"), 0, ...bytes), -); - -/** - * `edits` of each kind over zero to four items, at every three bounds up to one past the - * end, so parts are empty, at the end, backwards, and out of bounds. - */ -const editsSlicesOp = op("slices::edits"); -const sliceEdits = [0, 1, 2, 3, 4].flatMap((n) => - Array.from({ length: 8 * (n + 2) ** 3 }, (_, i) => { - const [kind, a, b, c] = [i % 8, Math.floor(i / 8) % (n + 2), Math.floor(i / 8 / (n + 2)) % (n + 2), Math.floor(i / 8 / (n + 2) ** 2)]; - return Uint8Array.of(...editsSlicesOp, kind, a, b, c, ...[0x31, 0xc2, 0x07, 0xfe].slice(0, n)); - }), -); - -/** - * `strs::drains` of each range and way to end the drain on `aé\u{800}😀`, at every byte - * offset into it and up to two past its end, reading none, two from either end, or three - * from the back. - */ -const drainsOp = op("strs::drains"); -const drains = Array.from({ length: 32 * 13 * 13 }, (_, i) => { - const [form, a, b] = [i % 32, Math.floor(i / 32) % 13, Math.floor(i / 416)]; - return Uint8Array.of(...drainsOp, 4, 2, 7, 9, 14, form, a, b, [0, 0x0a, 0x1f][(form + a + b) % 3]); -}); - -/** `strs::iters` of each kind, on no text, text of each UTF-8 width, and parts between `/`s, empty ones too. */ -const iters = Array.from({ length: 12 }, (_, kind) => [[], [2, 7, 9, 14], [0, 2, 0, 0, 7, 9], [14, 0]].map((data) => Uint8Array.of(...op("strs::iters"), kind, ...data))).flat(); - -/** - * `strs::strs`' splits and `rsplit_once` by `/`, and `strs::slices`' by an empty and a - * one-char pattern, on no text, a separator alone, twice, and at either end, read from - * either end. - */ -const separatorEnds = [[], [0], [0, 0], [0, 2], [2, 0], [0, 2, 0], [0x80, 2, 0], [2, 0x80, 0x80], [0, 0x82, 0x80, 7]]; -const splitEnds = separatorEnds.flatMap((data) => [ - ...[1, 3].map((kind) => Uint8Array.of(...op("strs::strs"), kind, ...data)), - ...[2, 2 | 8].map((kind) => Uint8Array.of(...op("strs::slices"), kind, ...data)), -]); - -/** - * `collections::deque_ranges` of each form of range, over no items and over items whose - * front wraps past the buffer's end, at bounds empty, at either end, past it, and backwards. - */ -const dequeRangesOp = op("collections::deque_ranges"); -const dequeRanges = [0, 0x18, 0xa8].flatMap((high) => - Array.from({ length: 8 }, (_, form) => - [[0, 0], [0, 3], [2, 2], [1, 4], [5, 5], [3, 1], [6, 7]].flatMap(([a, b]) => [[], [7, 8, 9]].map((items) => Uint8Array.of(...dequeRangesOp, high | form, a, b, ...items))), - ).flat(), -); - -/** `strs::hinted` of each adaptor and each pair of range lengths, each way, on `aé` alone. */ -const hintedOp = op("strs::hinted"); -const hinted = Array.from({ length: 10 * 7 * 21 }, (_, i) => Uint8Array.of(...hintedOp, i % 10, Math.floor(i / 10) % 7, Math.floor(i / 70))); - -/** - * `hints::hints` of each iterator, each pair of lengths, and each of its arms, read three - * times each way, with as many bytes as the first length's index. - */ -const hintsOp = op("hints::hints"); -const hints = Array.from({ length: 24 * 8 * 8 * 8 * 2 }, (_, i) => { - const [kind, n, m, arm, back] = [i % 24, Math.floor(i / 24) % 8, Math.floor(i / 192) % 8, Math.floor(i / 1536) % 8, Math.floor(i / 12288)]; - const steps = (arm << 5) | ((back ? 0b101 : 0b010) << 2) | 3; - return Uint8Array.of(...hintsOp, kind, n, m, steps, ...Array.from({ length: n }, (_, b) => b * 37)); -}); - -/** `hints::reserves` of each collection and element type, each shape, length, and limit on what it reads. */ -const reservesOp = op("hints::reserves"); -const reserves = Array.from({ length: 13 * 6 * 5 * 4 * 5 }, (_, i) => - Uint8Array.of(...reservesOp, i % 78, Math.floor(i / 78) % 5, Math.floor(i / 390) % 4, Math.floor(i / 1560)), -); - -/** - * `collections::set_ops` of one key against 30, which std's B-tree looks up in the larger - * rather than merging, of each key type: a key below the rest, at either end, between, and - * above. Then `Nibble`s equal to another set's but for their high bits, of hash sets as - * large as each other and one larger, where std's picks which set's to yield by size. - */ -const setOpsOp = op("collections::set_ops"); -const setOps = [ - ...[15, 16, 17, 18, 19].flatMap((kind) => [0x20, 0x21, 0x25, 0x3e, 0x3f].map((single) => Uint8Array.of(...setOpsOp, kind, single, ...Array.from({ length: 30 }, (_, i) => 0x41 + i)))), - ...[ - [0x01, 0x02, 0x13, 0x21, 0x32, 0x44], - [0x01, 0x02, 0x13, 0x21, 0x32, 0x44, 0x55], - [0x01, 0x02, 0x13, 0x55, 0x21, 0x32, 0x44], - ].map((data) => Uint8Array.of(...setOpsOp, 3, ...data)), -]; - -/** `zeros::zeros` of each case, on up to three bytes. */ -const zerosOp = op("zeros::zeros"); -const zeros = Array.from({ length: 7 * 4 }, (_, i) => Uint8Array.of(...zerosOp, i % 7, ...Array.from({ length: Math.floor(i / 7) }, (_, b) => b))); - -/** `zeros::writes` of each case, on up to three bytes: the last past the slice it swaps in. */ -const writesOp = op("zeros::writes"); -const writes = Array.from({ length: 5 * 4 }, (_, i) => Uint8Array.of(...writesOp, i % 5, ...Array.from({ length: Math.floor(i / 5) }, (_, b) => b))); - -/** - * `collections::unlike_eqs` of every pair of positions where `eq` and `ne` disagree and each - * length the right side may lose, over no items, one, two, a wrapped deque's four, and nine, - * whose positions are all within it. - */ -const unlikeEqsOp = op("collections::unlike_eqs"); -const unlikeEqs = [[], [5], [1, 2], [0, 7, 2, 9], [3, 3, 3, 3, 3, 3, 3, 3, 3]].flatMap((bytes) => - Array.from({ length: 128 }, (_, kind) => Uint8Array.of(...unlikeEqsOp, kind, ...bytes)), -); - -/** `collections::own_nes` of the same positions, lengths, and items as `unlike_eqs`. */ -const ownNesOp = op("collections::own_nes"); -const ownNes = unlikeEqs.map((input) => Uint8Array.of(...ownNesOp, ...input.subarray(2))); - -/** `collections::unlike_compares` of the same positions, lengths, and items as `unlike_eqs`. */ -const unlikeComparesOp = op("collections::unlike_compares"); -const unlikeCompares = unlikeEqs.map((input) => Uint8Array.of(...unlikeComparesOp, ...input.subarray(2))); - -/** - * `iters::range_froms` of each case, each way its zips read the range, from each distance - * below its type's last value and from 250, on up to nine bytes: each length its zips - * panic at. - */ -const rangeFromsOp = op("iters::range_froms"); -const rangeFroms = Array.from({ length: 16 * 4 * 4 * 10 }, (_, i) => { - const kind = (i % 16) | ((Math.floor(i / 16) % 4) << 6); - const a = [0, 1, 3, 250][Math.floor(i / 64) % 4]; - const data = Array.from({ length: Math.floor(i / 256) }, (_, j) => (j === 0 ? a : (j * 37) & 0xff)); - return Uint8Array.of(...rangeFromsOp, kind, ...data); -}); - -/** `iters::range_methods` of each type's table, at each pair of its first eight values. */ -const rangeMethodsOp = op("iters::range_methods"); -const rangeMethods = Array.from({ length: 19 * 64 }, (_, i) => Uint8Array.of(...rangeMethodsOp, i % 19, Math.floor(i / 19) % 8, Math.floor(i / 152))); - -/** - * `iters::compares` of each comparison, shape, and pair, over no items, one, a run up to - * 255, which `start..` panics past and a sum overflows at, NaNs, and repeats. - */ -const comparesOp = op("iters::compares"); -const compares = [[], [5], [1, 2, 3], [250, 251, 252, 253, 254, 255], [0xff, 3, 0xff], [0, 1, 2, 3, 4, 5], [7, 7, 7, 7, 7, 7, 7, 7, 7]].flatMap((data) => - Array.from({ length: 256 }, (_, kind) => Uint8Array.of(...comparesOp, kind, ...data)), -); - -/** - * `collections::ref_orders` of no items, one, repeats, and runs whose remainders by 2, 3, - * 4, and 5 agree and disagree. - */ -const refOrdersOp = op("collections::ref_orders"); -const refOrders = [[], [5], [3, 3, 3], [1, 2], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [7, 2, 9, 4, 4, 11, 15, 6], [12, 6, 0, 30, 60]].map((data) => Uint8Array.of(...refOrdersOp, 0, ...data)); - -/** - * `separated::separated` of every form and order of reads, over data whose bytes its bounds - * make separators of alone, in runs, and at either end, and over one element and none. - */ -const separatedOp = op("separated::separated"); -const separated = [[], [0], [0x90], [0, 0, 0], [5, 0x90, 0, 0x7f, 0, 0xff, 3], [0x80, 1, 2, 0], [0xff, 0x7f, 0x80, 0x81]].flatMap((data) => - Array.from({ length: 256 }, (_, kind) => Uint8Array.of(...separatedOp, kind, ...data)), -); - -/** - * `wraps::*` of every kind at every width, over operands at the edges of its range: 0, 1, - * either end, the sign bit's neighbors, which make `MIN / -1`, and at 128 bits values past - * 2^64. Shift amounts are at, past, and many times past the width, which std masks. - */ -function wraps(): Uint8Array[] { - const widths: [string, number][] = [["u8s", 8], ["u16s", 16], ["u32s", 32], ["u64s", 64], ["u128s", 128], ["usizes", 32], ["i8s", 8], ["i16s", 16], ["i32s", 32], ["i64s", 64], ["i128s", 128], ["isizes", 32]]; - const cases: Uint8Array[] = []; - for (const [name, bits] of widths) { - const o = op(`wraps::${name}`); - const width = BigInt(bits); - const mask = (1n << width) - 1n; - const sign = 1n << (width - 1n); - const edges = [0n, 1n, 3n, mask, mask - 1n, sign, sign - 1n, sign + 1n]; - if (bits === 128) edges.push(1n << 64n, (1n << 64n) + 3n, 0x9e3779b97f4a7c150123456789abcdefn); - const be = (v: bigint) => Array.from({ length: bits / 8 }, (_, i) => Number((v >> BigInt(bits - 8 - 8 * i)) & 0xffn)); - // The amount's low byte and its high byte, which reads as `high << 24`. - const shifts = [[0, 0], [1, 0], [bits - 1, 0], [bits, 0], [bits + 1, 0], [2 * bits + 3, 0], [5, 1]]; - let i = 0; - for (const a of edges) { - for (const b of edges) { - const c = edges[(i * 5 + 3) % edges.length]; - const [low, high] = shifts[i++ % shifts.length]; - for (let kind = 0; kind < 24; kind++) cases.push(Uint8Array.of(...o, kind, ...be(a), ...be(b), ...be(c), low, high)); - } - } - } - return cases; -} - -/** - * `saturates::*` of every kind at every width, over operands at the edges of its range and - * across them: 0, 1, either end, the sign bit's neighbors, which make `MIN / -1` and - * `MIN % -1`, and at 128 bits values past 2^64. - */ -function saturates(): Uint8Array[] { - const widths: [string, number][] = [["u8s", 8], ["u16s", 16], ["u32s", 32], ["u64s", 64], ["u128s", 128], ["usizes", 32], ["i8s", 8], ["i16s", 16], ["i32s", 32], ["i64s", 64], ["i128s", 128], ["isizes", 32]]; - const cases: Uint8Array[] = []; - for (const [name, bits] of widths) { - const o = op(`saturates::${name}`); - const width = BigInt(bits); - const mask = (1n << width) - 1n; - const sign = 1n << (width - 1n); - const half = sign >> 1n; - const edges = [0n, 1n, 3n, mask, mask - 1n, sign, sign - 1n, sign + 1n, half, half + 1n, mask - half]; - if (bits === 128) edges.push(1n << 64n, (1n << 64n) + 3n, 0x9e3779b97f4a7c150123456789abcdefn); - const be = (v: bigint) => Array.from({ length: bits / 8 }, (_, i) => Number((v >> BigInt(bits - 8 - 8 * i)) & 0xffn)); - let i = 0; - for (const a of edges) { - for (const b of edges) { - const c = edges[(i++ * 5 + 3) % edges.length]; - for (let kind = 0; kind < 24; kind++) cases.push(Uint8Array.of(...o, kind, ...be(a), ...be(b), ...be(c))); - } - } - } - return cases; -} - -/** - * `methods::*` of every kind at every width, over operands at the edges of its range: - * both ends and their neighbors, the sign bit's, small values, and where they reach, - * either side of 2^53 and 2^64 and their negations. Each meets 0, 1, -1, 2, 10, and - * either end, which make `MIN / -1`, `MIN % -1`, and a zero divisor or base, and - * exponents and shifts in, at, and past the width. - */ -function methods(): Uint8Array[] { - const widths: [string, number, boolean][] = [["u8s", 8, false], ["u16s", 16, false], ["u32s", 32, false], ["u64s", 64, false], ["u128s", 128, false], ["usizes", 32, false], ["i8s", 8, true], ["i16s", 16, true], ["i32s", 32, true], ["i64s", 64, true], ["i128s", 128, true], ["isizes", 32, true]]; - // The kinds that read the `u32`, and the others, which read `b`. - const exponents = new Set([3, 4, 7, 8, 21, 22, 23, 38, 39, 40]); - const cases: Uint8Array[] = []; - for (const [name, bits, signed] of widths) { - const o = op(`methods::${name}`); - const width = BigInt(bits); - const min = signed ? -(1n << (width - 1n)) : 0n; - const max = (1n << (signed ? width - 1n : width)) - 1n; - const sign = 1n << (width - 1n); - const values = [min, min + 1n, min + 2n, -2n, -1n, 0n, 1n, 2n, 3n, 10n, 99n, max - 1n, max, sign - 1n, sign, sign + 1n]; - for (const k of [53n, 64n]) { - if (k < width) values.push(...[-1n, 0n, 1n].flatMap((d) => [(1n << k) + d, -(1n << k) + d])); - } - const edges = [...new Set(values.filter((v) => v >= min && v <= max))]; - const others = [0n, 1n, -1n, 2n, 10n, min, max].filter((v) => v >= min && v <= max); - const shifts = [0, 1, 2, bits - 1, bits, bits + 1, 2 * bits, 3 * bits - 1, 0x80000000, 0xffffffff]; - const be = (v: bigint) => Array.from({ length: bits / 8 }, (_, i) => Number((v >> BigInt(bits - 8 - 8 * i)) & 0xffn)); - const u32 = (n: number) => [n >>> 24, (n >>> 16) & 0xff, (n >>> 8) & 0xff, n & 0xff]; - let i = 0; - for (let kind = 0; kind < 42; kind++) { - for (const a of edges) { - if (exponents.has(kind)) { - for (const n of shifts) cases.push(Uint8Array.of(...o, kind, ...be(a), ...be(others[i++ % others.length]), ...u32(n))); - } else { - for (const b of others) cases.push(Uint8Array.of(...o, kind, ...be(a), ...be(b), ...u32(shifts[i++ % shifts.length]))); - } - } - } - } - return cases; -} - -/** - * `ascii` cases of each kind: bytes and slices on each prefix of text padded by ASCII - * whitespace, vertical tab among it, holding a byte of each escape and class, so escapes - * are read from both ends; slices on text of each char `ascii.rs` tries; chars on the - * scalars either side of the surrogates and past the last. - */ -const asciiText = [0x20, 0x09, 0x0b, 0x48, 0x7a, 0x22, 0x5c, 0x27, 0x7f, 0x80, 0xff, 0x0a, 0x0c, 0x0d, 0x20]; -const asciiCases = [ - ...["ascii::bytes", "ascii::slices"].flatMap((name) => - Array.from({ length: 4 * (asciiText.length + 1) }, (_, i) => Uint8Array.of(...op(name), i % 4, ...asciiText.slice(0, Math.floor(i / 4)))), - ), - // Text of every char `ascii.rs` tries, each once. - ...[0, 1, 2, 3].map((kind) => Uint8Array.of(...op("ascii::slices"), kind, ...Array.from({ length: 41 }, (_, i) => i))), - Uint8Array.of(...op("ascii::chars"), 0, ...[0xd7ff, 0xd800, 0xdfff, 0xe000, 0x1f600, 0x10ffff, 0x110000].flatMap((n) => [n >>> 24, (n >>> 16) & 0xff, (n >>> 8) & 0xff, n & 0xff])), - // `parts` of each kind at every pair of byte offsets up to two past the end of its - // 14 bytes of text, and of no text. - ...Array.from({ length: 8 * 17 * 17 }, (_, i) => Uint8Array.of(...op("ascii::parts"), i % 8, Math.floor(i / 8) % 17, Math.floor(i / 8 / 17))), - ...Array.from({ length: 8 * 3 * 3 }, (_, i) => Uint8Array.of(...op("ascii::parts"), 0x10 | (i % 8), Math.floor(i / 8) % 3, Math.floor(i / 24))), -]; - -/** - * `strs::gets` of each kind at every pair of byte offsets up to two past the end of its 13 - * bytes of text, and of no text, and at `usize::MAX`. - */ -const getsOp = op("strs::gets"); -const getsAt = (n: number) => [...Array.from({ length: n + 3 }, (_, i) => i), 0xff]; -const gets = [0, 0x10].flatMap((text) => { - const at = getsAt(text === 0 ? 13 : 0); - return Array.from({ length: 16 * at.length * at.length }, (_, i) => - Uint8Array.of(...getsOp, text | (i % 16), at[Math.floor(i / 16) % at.length], at[Math.floor(i / 16 / at.length)]), - ); -}); - -/** - * `capacity` cases of each element type: each step of a vector, a deque, and a heap, by a - * few, past what it may hold, and within eight of `usize::MAX`, once it grew past its - * least capacity, made by `new` and by `with_capacity`; each step after a `reserve` or - * `reserve_exact` that needed no room, whose floor it keeps; a run of pushes that doubles - * it from each; a heap that a `reserve` gave room past its length, remade from its `Vec` - * and cleared, which keeps that floor; and each way `collects` makes one, of each length - * it tries. - */ -const capacityCases = [ - ...[["capacity::vecs", 29], ["capacity::deques", 21], ["capacity::heaps", 13]].flatMap(([name, steps]) => - Array.from({ length: 5 * 2 * (steps as number) * 4 }, (_, i) => { - const [kind, first, step, arg] = [i % 5, (Math.floor(i / 5) % 2) * 0x11, Math.floor(i / 10) % (steps as number), [3, 0xc1, 0xe3, 0x16][Math.floor(i / (10 * (steps as number)))]]; - return Uint8Array.of(...op(name as string), kind, first, ...[0, 1, 0, 2, 0, 3, 0, 4, 0, 5].map((b, j) => (j % 2 === 0 ? b : b * 41)), step, arg, step, arg ^ 1); - }), - ), - ...[["capacity::vecs", 29], ["capacity::deques", 21], ["capacity::heaps", 13]].flatMap(([name, steps]) => - Array.from({ length: 5 * 2 * (steps as number) }, (_, i) => Uint8Array.of(...op(name as string), i % 5, 0, 0, 1, 3 + (Math.floor(i / 5) % 2), 3, Math.floor(i / 10), 0)), - ), - ...["capacity::vecs", "capacity::deques", "capacity::heaps"].flatMap((name) => - Array.from({ length: 5 * 2 }, (_, i) => Uint8Array.of(...op(name), i % 5, Math.floor(i / 5) * 0x11, ...Array.from({ length: 40 }, (_, p) => [0, p]).flat())), - ), - ...Array.from({ length: 5 }, (_, kind) => Uint8Array.of(...op("capacity::heaps"), kind, 0, 8, 15, 3, 0, 12, 0, 7, 0)), - ...Array.from({ length: 8 * 6 }, (_, i) => Uint8Array.of(...op("capacity::collects"), i % 8, [0, 1, 2, 5, 9, 23][Math.floor(i / 8)], 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), -]; - -/** - * `ends::ends`: each kind of iterator through every consumer and either end's bits, of - * runs empty, short, and long, whose hints are exact, loose, and lying, after none and a - * few steps through each of its methods. - */ -const endsCases = [0x00, 0x03, 0x0f, 0x15, 0x27, 0x36, 0x2f].flatMap((shape) => - [[], [0x01, 0x00], [0x0a, 0x0d, 0x03], [0x05, 0x06, 0x04, 0x0f]].flatMap((steps) => - Array.from({ length: 4 * 256 }, (_, i) => Uint8Array.of(...op("ends::ends"), i % 4, shape, i >> 2, ...steps)), - ), -); - -/** - * `rings::slices` of each item type, from a deque made by `new`, `with_capacity` of 5, and - * from a `Vec` of 7: pushed at both ends and popped at the front to wrap it, past a few - * capacities, then each step by a few arguments, twice. - */ -const ringsCases = Array.from({ length: 5 * 3 * 4 * 24 * 3 }, (_, i) => { - const [kind, first, wraps, step, arg] = [i % 5, [0, 0x15, 0x1e][Math.floor(i / 5) % 3], [1, 3, 6, 10][Math.floor(i / 15) % 4], Math.floor(i / 60) % 24, [0, 0x5b, 0xe7][Math.floor(i / 1440)]]; - const wrap = Array.from({ length: wraps }, (_, j) => [j % 3 === 2 ? 4 : 0, j * 3, 6, 0, 4, j]).flat(); - return Uint8Array.of(...op("rings::slices"), kind, first, ...wrap, step, arg, step, arg ^ 0x25); -}); - -/** - * `rings::slices` remaking each wrapped deque each way and with a few skips: a clone, - * `clone_from`, `clone_into`, its `into_iter` read in part and by `nth`, from a `Vec` as it - * is and filtered in place, and a `Vec`'s `into_iter` read in part, collected as it is and - * cloned; then pushed at both ends. - */ -const remadeCases = [0, 5, 0x2d, 0x37, 0x64, 0x6e, 1, 0x10, 2, 0x11, 3, 0x21, 0x0e, 0x13, 0x45, 0x5f].flatMap((arg) => - Array.from({ length: 5 * 3 * 4 }, (_, i) => { - const [kind, first, wraps] = [i % 5, [0, 0x15, 0x1e][Math.floor(i / 5) % 3], [1, 3, 6, 10][Math.floor(i / 15)]]; - const wrap = Array.from({ length: wraps }, (_, j) => [j % 3 === 2 ? 4 : 0, j * 3, 6, 0, 4, j]).flat(); - return Uint8Array.of(...op("rings::slices"), kind, first, ...wrap, 22, arg, 0, 9, 4, 9); - }), -); - -/** - * `sorts` cases of each length std's thresholds part, of each run of keys; `disorders` - * cases of each length, kind of item, and sort; and `btrees` cases of each length. - */ -const sortCases = [ - ...Array.from({ length: 20 * 5 }, (_, i) => Uint8Array.of(...op("sorts::sorts"), i % 20, Math.floor(i / 20), 7, 1, 3)), - ...Array.from({ length: 160 }, (_, kind) => Uint8Array.of(...op("sorts::disorders"), kind, kind % 5, 0x5a, 0xc3, 0x0f, 7)), - ...Array.from({ length: 20 * 5 }, (_, i) => Uint8Array.of(...op("sorts::btrees"), i % 20, Math.floor(i / 20), 2, 9)), -]; - -/** - * `searches::searches` of each search and pattern, by chars, needles, and counts its first - * byte picks: an empty needle, one, two, and three chars, and counts from 0 to 4. Of no - * text, a separator alone, twice, and at either end, runs a two-char needle overlaps in, - * chars of each UTF-8 width, and digits the closure matches, read from either end. - */ -const searchesOp = op("searches::searches"); -const searchesCases = [0x00, 0x12, 0x22, 0x31, 0x4e, 0x57].flatMap((pick) => - [[], [0], [0, 0], [0, 2], [2, 0], [0, 2, 0], [2, 2, 2], [2, 2, 2, 2], [14, 7, 14], [0x80, 2, 0x80], [0x82, 0x8e, 0x07, 0x83]].flatMap((text) => - Array.from({ length: 85 }, (_, kind) => Uint8Array.of(...searchesOp, kind, pick, ...text)), - ), -); - -/** - * `searches::texts` of each iterator and the trims, of no text, a line end of each kind - * alone, between lines and doubled, a `\r` without a `\n`, and whitespace of each UTF-8 - * width between the chars JS's `\s` alone counts, read from either end. - */ -const textsOp = op("searches::texts"); -const textsCases = [[], [0], [1, 0], [2, 1, 0, 2], [2, 0, 0, 2], [0, 2], [2, 1], [1, 1, 0], [3, 2, 3], [6, 7, 8, 9, 2, 10, 2, 11, 12, 13, 2, 14, 15, 4, 5], [0x83, 2, 0x8d, 0x0a, 0x84]].flatMap( - (text) => Array.from({ length: 4 }, (_, kind) => Uint8Array.of(...textsOp, kind, ...text)), -); - -export const cases: Uint8Array[] = [...loops, ...durations, ...ints(), ...utf8, ...floats, ...formats, ...parsed, ...singlesCases, ...singlesFormats, ...singlesParsed, ...dyns, ...cells, ...shared, ...locks, ...guards, ...maps, ...mappedLocks, ...relocks, ...tries, ...mutexMaps, ...printed, ...downgrades, ...leaks, ...placeCompares, ...rwlocks, ...onces, ...bounds, ...unsafeCells, ...edits, ...subslices, ...consumers, ...closures, ...elements, ...ranges, ...reducers, ...sliceEdits, ...drains, ...iters, ...splitEnds, ...dequeRanges, ...hinted, ...peekedOthers, ...hints, ...reserves, ...setOps, ...zeros, ...writes, ...floatsMulAdds, ...singlesMulAdds, ...unlikeEqs, ...ownNes, ...rangeFroms, ...compares, ...unlikeCompares, ...rangeMethods, ...wraps(), ...refOrders, ...saturates(), ...methods(), ...separated, ...asciiCases, ...gets, ...capacityCases, ...ringsCases, ...remadeCases, ...sortCases, ...endsCases, ...searchesCases, ...textsCases]; diff --git a/ts/fixtures/lang/capacity/Cargo.toml b/ts/fixtures/lang/capacity/Cargo.toml new file mode 100644 index 000000000..3b7a3bfaa --- /dev/null +++ b/ts/fixtures/lang/capacity/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-capacity-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/capacity/caller.ts b/ts/fixtures/lang/capacity/caller.ts new file mode 100644 index 000000000..bdc1e29dc --- /dev/null +++ b/ts/fixtures/lang/capacity/caller.ts @@ -0,0 +1,33 @@ +// The inputs `capacity`'s cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `capacity` cases of each element type: each step of a vector, a deque, and a heap, by a + * few, past what it may hold, and within eight of `usize::MAX`, once it grew past its + * least capacity, made by `new` and by `with_capacity`; each step after a `reserve` or + * `reserve_exact` that needed no room, whose floor it keeps; a run of pushes that doubles + * it from each; a heap that a `reserve` gave room past its length, remade from its `Vec` + * and cleared, which keeps that floor; and each way `collects` makes one, of each length + * it tries. + */ +const capacityCases = [ + ...[["capacity::vecs", 29], ["capacity::deques", 21], ["capacity::heaps", 13]].flatMap(([name, steps]) => + Array.from({ length: 5 * 2 * (steps as number) * 4 }, (_, i) => { + const [kind, first, step, arg] = [i % 5, (Math.floor(i / 5) % 2) * 0x11, Math.floor(i / 10) % (steps as number), [3, 0xc1, 0xe3, 0x16][Math.floor(i / (10 * (steps as number)))]]; + return Uint8Array.of(...op(name as string), kind, first, ...[0, 1, 0, 2, 0, 3, 0, 4, 0, 5].map((b, j) => (j % 2 === 0 ? b : b * 41)), step, arg, step, arg ^ 1); + }), + ), + ...[["capacity::vecs", 29], ["capacity::deques", 21], ["capacity::heaps", 13]].flatMap(([name, steps]) => + Array.from({ length: 5 * 2 * (steps as number) }, (_, i) => Uint8Array.of(...op(name as string), i % 5, 0, 0, 1, 3 + (Math.floor(i / 5) % 2), 3, Math.floor(i / 10), 0)), + ), + ...["capacity::vecs", "capacity::deques", "capacity::heaps"].flatMap((name) => + Array.from({ length: 5 * 2 }, (_, i) => Uint8Array.of(...op(name), i % 5, Math.floor(i / 5) * 0x11, ...Array.from({ length: 40 }, (_, p) => [0, p]).flat())), + ), + ...Array.from({ length: 5 }, (_, kind) => Uint8Array.of(...op("capacity::heaps"), kind, 0, 8, 15, 3, 0, 12, 0, 7, 0)), + ...Array.from({ length: 8 * 6 }, (_, i) => Uint8Array.of(...op("capacity::collects"), i % 8, [0, 1, 2, 5, 9, 23][Math.floor(i / 8)], 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), +]; + +export const cases: Uint8Array[] = [...capacityCases]; diff --git a/ts/fixtures/lang/expected/capacity.Known.ts b/ts/fixtures/lang/capacity/expected/capacity.Known.ts similarity index 100% rename from ts/fixtures/lang/expected/capacity.Known.ts rename to ts/fixtures/lang/capacity/expected/capacity.Known.ts diff --git a/ts/fixtures/lang/expected/capacity.ts b/ts/fixtures/lang/capacity/expected/capacity.ts similarity index 99% rename from ts/fixtures/lang/expected/capacity.ts rename to ts/fixtures/lang/capacity/expected/capacity.ts index 3887980c3..ab2960473 100644 --- a/ts/fixtures/lang/expected/capacity.ts +++ b/ts/fixtures/lang/capacity/expected/capacity.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { copy$array_u64, copy$array_usize, copy$tuple2_u32_u32, copy$tuple2_u64_u8 } from "./lib.ts"; +import { copy$array_u64, copy$tuple2_u64_u8 } from "./lib.ts"; import * as Known from "./capacity.Known.ts"; import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOrDefault$0301ewp as option_unwrapOrDefault$0301ewp, mapOr$1t0muvr as option_mapOr$1t0muvr, mapOr$1ttssgs as option_mapOr$1ttssgs } from "./core/option.ts"; @@ -1900,9 +1900,9 @@ export function collects(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const _66: rt.usize = rt.vecCapacity(wide, 2); Known.put(exact, out, _64, _66); } else if (_20 === 2) { - const _71: rt.Iter<[rt.u32, rt.u32]> = rt.iterCopied(rt.iterFilter(rt.iterSlice(pairs2), (_22: [rt.u32, rt.u32]): boolean => { + const _71: rt.Iter<[rt.u32, rt.u32]> = rt.iterFilter(rt.iterSlice(pairs2), (_22: [rt.u32, rt.u32]): boolean => { return rt.u32Rem(_22[0], 2) === 0; - }), copy$tuple2_u32_u32); + }); const _70: [rt.u32[], rt.VecDeque] = rt.tupleExtend([[], rt.dequeNew(4) as rt.VecDeque] as [rt.u32[], rt.VecDeque], _71, [rt.vecPart(4), rt.dequePart()]); const a: rt.u32[] = _70[0]; const b: rt.VecDeque = _70[1]; @@ -2007,10 +2007,9 @@ export function maps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const _22: rt.usize[] = [rt.hashLen(m), rt.hashLen(s)]; const _27: rt.usize[] = [rt.hashCapacity(m), rt.hashCapacity(s)]; const floor: rt.usize = rt.usizeMul(made, (kind & 1) as rt.usize); - const part = Array.from({ length: 2 }, (): rt.usize => { + _18(out, _22, _27, Array.from({ length: 2 }, (): rt.usize => { return floor; - }); - _18(out, _22, _27, part); + })); const iter: rt.Iter = rt.byteSliceChunks(option_unwrapOrDefault$0301ewp(rt.byteSliceGetRange(data, 1)), 2); while (true) { const _39: rt.ByteSlice | rt.Done = iter.next(); @@ -2073,10 +2072,9 @@ export function maps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { floors = before; } } - const part2 = [rt.hashLen(m), rt.hashLen(s)]; - const part3 = [rt.hashCapacity(m), rt.hashCapacity(s)]; - const part4 = copy$array_usize(floors); - _18(out, part2, part3, part4); + const part = [rt.hashLen(m), rt.hashLen(s)]; + const part2 = [rt.hashCapacity(m), rt.hashCapacity(s)]; + _18(out, part, part2, floors); } if ((kind & 128) !== 0) { put(out, rt.hashLen(rt.hashWithCapacity(rt.usizeShr(4294967295, kind & 3), 117440512, rt.hashing(rt.hash64, rt.u64Eq)) as rt.HashSet)); diff --git a/ts/fixtures/lang/capacity/expected/core/option.ts b/ts/fixtures/lang/capacity/expected/core/option.ts new file mode 100644 index 000000000..68f9f599c --- /dev/null +++ b/ts/fixtures/lang/capacity/expected/core/option.ts @@ -0,0 +1,33 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOrDefault$0301ewp(self: rt.ByteSlice | undefined): rt.ByteSlice { + if (self === undefined) { + return rt.byteSliceFrom(new Uint8Array(0)); + } + return self; +} + +export function mapOr$1t0muvr(self: rt.u8 | undefined, default_: rt.usize, f: (a0: rt.u8) => rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1ttssgs(self: [rt.u8, rt.ByteSlice] | undefined, default_: [rt.u8, rt.ByteSlice], f: (a0: [rt.u8, rt.ByteSlice]) => [rt.u8, rt.ByteSlice]): [rt.u8, rt.ByteSlice] { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/capacity/expected/harness.ts b/ts/fixtures/lang/capacity/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/capacity/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/capacity/expected/lib.ts b/ts/fixtures/lang/capacity/expected/lib.ts new file mode 100644 index 000000000..ab1f1e31e --- /dev/null +++ b/ts/fixtures/lang/capacity/expected/lib.ts @@ -0,0 +1,28 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { vecs, deques, heaps, collects, maps } from "./capacity.ts"; + +export function copy$array_u64(v: rt.u64[]): rt.u64[] { + return v.slice(); +} + +export function copy$tuple2_u64_u8(v: [rt.u64, rt.u8]): [rt.u64, rt.u8] { + return [v[0], v[1]]; +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["capacity::vecs", (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec): undefined => { + vecs(a0, a1.data, a1.start, a1.length, a2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["capacity::deques", (a02: rt.u8, a12: rt.ByteSlice, a22: rt.ByteVec): undefined => { + deques(a02, a12.data, a12.start, a12.length, a22); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["capacity::heaps", (a03: rt.u8, a13: rt.ByteSlice, a23: rt.ByteVec): undefined => { + heaps(a03, a13.data, a13.start, a13.length, a23); + }] 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", maps as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/capacity.rs b/ts/fixtures/lang/capacity/src/capacity.rs similarity index 100% rename from ts/fixtures/lang/src/capacity.rs rename to ts/fixtures/lang/capacity/src/capacity.rs diff --git a/ts/fixtures/lang/capacity/src/lib.rs b/ts/fixtures/lang/capacity/src/lib.rs new file mode 100644 index 000000000..3651150bc --- /dev/null +++ b/ts/fixtures/lang/capacity/src/lib.rs @@ -0,0 +1,25 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod capacity; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("capacity::vecs", capacity::vecs), + ("capacity::deques", capacity::deques), + ("capacity::heaps", capacity::heaps), + ("capacity::collects", capacity::collects), + ("capacity::maps", capacity::maps), + ] +} diff --git a/ts/fixtures/lang/capacity/ts.toml b/ts/fixtures/lang/capacity/ts.toml new file mode 100644 index 000000000..6bc09fdd6 --- /dev/null +++ b/ts/fixtures/lang/capacity/ts.toml @@ -0,0 +1,2 @@ +package = "lang-capacity-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/captures/Cargo.toml b/ts/fixtures/lang/captures/Cargo.toml new file mode 100644 index 000000000..741712583 --- /dev/null +++ b/ts/fixtures/lang/captures/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-captures-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/expected/captures.ts b/ts/fixtures/lang/captures/expected/captures.ts similarity index 100% rename from ts/fixtures/lang/expected/captures.ts rename to ts/fixtures/lang/captures/expected/captures.ts diff --git a/ts/fixtures/lang/captures/expected/harness.ts b/ts/fixtures/lang/captures/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/captures/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/captures/expected/lib.ts b/ts/fixtures/lang/captures/expected/lib.ts new file mode 100644 index 000000000..29811f147 --- /dev/null +++ b/ts/fixtures/lang/captures/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { captures } from "./captures.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["captures::captures", captures as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/captures.rs b/ts/fixtures/lang/captures/src/captures.rs similarity index 100% rename from ts/fixtures/lang/src/captures.rs rename to ts/fixtures/lang/captures/src/captures.rs diff --git a/ts/fixtures/lang/captures/src/lib.rs b/ts/fixtures/lang/captures/src/lib.rs new file mode 100644 index 000000000..cc9637e31 --- /dev/null +++ b/ts/fixtures/lang/captures/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod captures; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("captures::captures", captures::captures)] +} diff --git a/ts/fixtures/lang/captures/ts.toml b/ts/fixtures/lang/captures/ts.toml new file mode 100644 index 000000000..4a4da65cf --- /dev/null +++ b/ts/fixtures/lang/captures/ts.toml @@ -0,0 +1,2 @@ +package = "lang-captures-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/cells/Cargo.toml b/ts/fixtures/lang/cells/Cargo.toml new file mode 100644 index 000000000..be84896cb --- /dev/null +++ b/ts/fixtures/lang/cells/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-cells-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/cells/caller.ts b/ts/fixtures/lang/cells/caller.ts new file mode 100644 index 000000000..8f56678af --- /dev/null +++ b/ts/fixtures/lang/cells/caller.ts @@ -0,0 +1,37 @@ +// The inputs `cells`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `cells` scripts of (op, operand) pairs on every kind, so each cell and value type: reads + * and sets, a `None` and a `()` held, initializing from within initialization and + * panicking in it, empty and full, and a cell replaced; clones, `Debug`, and `get_mut`, + * empty and full; and `get_or_try_init` failing, succeeding, set, and set or initialized + * again from within, failing after or not. + */ +const cellsOp = op("cells::cells"); +const cellScripts = [ + [0, 0, 1, 5, 0, 0, 1, 6, 2, 7, 4, 0, 0, 0, 4, 0, 2, 9, 0, 0], + [1, 3, 0, 0, 1, 4, 4, 0, 1, 6, 2, 3], + [3, 4, 3, 5], + [5, 3], + [6, 3], + [7, 1], + [2, 1, 5, 3, 6, 3, 7, 1], + [8, 4, 0, 0, 8, 5, 0, 0, 1, 3, 8, 6], + [9, 0, 9, 1, 0, 0], + [10, 0, 10, 1, 11, 2, 0, 0], + [11, 1, 2, 1, 11, 4, 0, 0, 4, 0, 11, 5], + [12, 0, 12, 6, 0, 0, 12, 1], + [12, 1, 12, 2], + [12, 2], + [12, 3, 4, 0, 12, 7], + [12, 11], + [12, 7, 12, 4], + [], +]; +const cells = Array.from({ length: 256 }, (_, kind) => cellScripts.map((script) => Uint8Array.of(...cellsOp, kind, ...script))).flat(); + +export const cases: Uint8Array[] = [...cells]; diff --git a/ts/fixtures/lang/expected/cells.ts b/ts/fixtures/lang/cells/expected/cells.ts similarity index 100% rename from ts/fixtures/lang/expected/cells.ts rename to ts/fixtures/lang/cells/expected/cells.ts diff --git a/ts/fixtures/lang/cells/expected/core/bool.ts b/ts/fixtures/lang/cells/expected/core/bool.ts new file mode 100644 index 000000000..17d957542 --- /dev/null +++ b/ts/fixtures/lang/cells/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0d5am30(self: boolean, t: rt.u8): rt.u8 | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/cells/expected/core/option.ts b/ts/fixtures/lang/cells/expected/core/option.ts new file mode 100644 index 000000000..0fb1b6278 --- /dev/null +++ b/ts/fixtures/lang/cells/expected/core/option.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/cells/expected/core/result.ts b/ts/fixtures/lang/cells/expected/core/result.ts new file mode 100644 index 000000000..eca3e6b7d --- /dev/null +++ b/ts/fixtures/lang/cells/expected/core/result.ts @@ -0,0 +1,60 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function err$1nbmqmx(self: rt.Result): rt.u8 | undefined { + if (self.ok) { + return undefined; + } + return self.error; +} + +export function map$1ma2nl9(self: rt.Result, op: (a0: rt.u8 | undefined) => undefined): rt.Result { + if (self.ok) { + op(self.value); + return rt.OK; + } + return self as rt.Result; +} + +export function map$0l5uclx(self: rt.Result, op: (a0: string) => undefined): rt.Result { + if (self.ok) { + op(self.value); + return rt.OK; + } + return self as rt.Result; +} + +export function map$14n87rz(self: rt.Result, op: (a0: rt.ByteVec) => undefined): rt.Result { + if (self.ok) { + op(self.value); + return rt.OK; + } + return self as rt.Result; +} + +export function map$0h1vl84(self: rt.Result, op: (a0: rt.u64) => undefined): rt.Result { + if (self.ok) { + op(self.value); + return rt.OK; + } + return self as rt.Result; +} + +export function map$03hz3l7(self: rt.Result, op: (a0: rt.u8) => undefined): rt.Result { + if (self.ok) { + op(self.value); + return rt.OK; + } + return self as rt.Result; +} + +export function map$0yqi183(self: rt.Result, op: (a0: undefined) => undefined): rt.Result { + if (self.ok) { + op(self.value); + return rt.OK; + } + return self; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/cells/expected/harness.ts b/ts/fixtures/lang/cells/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/cells/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/cells/expected/lib.ts b/ts/fixtures/lang/cells/expected/lib.ts new file mode 100644 index 000000000..6154dabe5 --- /dev/null +++ b/ts/fixtures/lang/cells/expected/lib.ts @@ -0,0 +1,18 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cells } from "./cells.ts"; + +export const out$u64: { err: unknown } = { err: undefined }; + +export const out$u8: { err: unknown } = { err: undefined }; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["cells::cells", cells as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/cells.rs b/ts/fixtures/lang/cells/src/cells.rs similarity index 100% rename from ts/fixtures/lang/src/cells.rs rename to ts/fixtures/lang/cells/src/cells.rs diff --git a/ts/fixtures/lang/cells/src/lib.rs b/ts/fixtures/lang/cells/src/lib.rs new file mode 100644 index 000000000..df353fb6d --- /dev/null +++ b/ts/fixtures/lang/cells/src/lib.rs @@ -0,0 +1,21 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#![feature(once_cell_try)] + +mod cells; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("cells::cells", cells::cells)] +} diff --git a/ts/fixtures/lang/cells/ts.toml b/ts/fixtures/lang/cells/ts.toml new file mode 100644 index 000000000..df22f7062 --- /dev/null +++ b/ts/fixtures/lang/cells/ts.toml @@ -0,0 +1,2 @@ +package = "lang-cells-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/chars/Cargo.toml b/ts/fixtures/lang/chars/Cargo.toml new file mode 100644 index 000000000..eb12d26d8 --- /dev/null +++ b/ts/fixtures/lang/chars/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-chars-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/expected/chars.ts b/ts/fixtures/lang/chars/expected/chars.ts similarity index 92% rename from ts/fixtures/lang/expected/chars.ts rename to ts/fixtures/lang/chars/expected/chars.ts index 859c35d39..822baa588 100644 --- a/ts/fixtures/lang/expected/chars.ts +++ b/ts/fixtures/lang/chars/expected/chars.ts @@ -2,7 +2,7 @@ import * as rt from "./rt.ts"; import { unwrapOr$0k15iai as option_unwrapOr$0k15iai } from "./core/option.ts"; -import { put as fmt_put } from "./fmt.ts"; +import { put } from "./harness.ts"; /** The scalars to try: the edges, then each big-endian `u32` in `data`, zero-padded. */ export function scalars(data: rt.ByteSlice): rt.u32[] { @@ -123,7 +123,7 @@ export function chars(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const _144: rt.char | undefined = rt.charFromU32(_140); if (_144 !== undefined) { const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtCharDisplay(_144, f)]; - fmt_put(out, rt.fmtFormat([args2[0], "|", rt.fmtSpec({ align: ">", width: 3 }, args2[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 4 }, args2[0]), "|", rt.fmtSpec({ align: "<", width: 2 }, args2[0])])); + put(out, rt.fmtFormat([args2[0], "|", rt.fmtSpec({ align: ">", width: 3 }, args2[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 4 }, args2[0]), "|", rt.fmtSpec({ align: "<", width: 2 }, args2[0])])); } } const iter6: rt.Iter = rt.iterSlice([97, 39, 34, 92, 10, 0, 127, 233, 769, 173, 57344, 128512, 65438, 65439, 4447, 4448, 12644, 65440]); @@ -133,7 +133,7 @@ export function chars(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { break; } const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtCharDebug(_161, f), (f: rt.Formatter) => rt.fmtCharDisplay(_161, f)]; - fmt_put(out, rt.fmtFormat([args4[0], "|", rt.fmtSpec({ align: ">", width: 6 }, args4[0]), "|", args4[1]])); + put(out, rt.fmtFormat([args4[0], "|", rt.fmtSpec({ align: ">", width: 6 }, args4[0]), "|", args4[1]])); } } } diff --git a/ts/fixtures/lang/chars/expected/core/option.ts b/ts/fixtures/lang/chars/expected/core/option.ts new file mode 100644 index 000000000..747bdca7d --- /dev/null +++ b/ts/fixtures/lang/chars/expected/core/option.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0k15iai(self: rt.char | undefined, default_: rt.char): rt.char { + if (self === undefined) { + return default_; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/chars/expected/harness.ts b/ts/fixtures/lang/chars/expected/harness.ts new file mode 100644 index 000000000..3b7bbcfb0 --- /dev/null +++ b/ts/fixtures/lang/chars/expected/harness.ts @@ -0,0 +1,46 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/chars/expected/lib.ts b/ts/fixtures/lang/chars/expected/lib.ts new file mode 100644 index 000000000..47098d037 --- /dev/null +++ b/ts/fixtures/lang/chars/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { chars } from "./chars.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["chars::chars", chars as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/chars.rs b/ts/fixtures/lang/chars/src/chars.rs similarity index 99% rename from ts/fixtures/lang/src/chars.rs rename to ts/fixtures/lang/chars/src/chars.rs index 3f7b37d34..2712cf6a4 100644 --- a/ts/fixtures/lang/src/chars.rs +++ b/ts/fixtures/lang/chars/src/chars.rs @@ -2,7 +2,7 @@ use std::collections::{BTreeSet, HashSet}; -use crate::fmt::put; +use crate::harness::put; /// Values next to where a scalar's UTF-8 or UTF-16 length changes, the surrogates that /// are no char, and past the last char. diff --git a/ts/fixtures/lang/chars/src/lib.rs b/ts/fixtures/lang/chars/src/lib.rs new file mode 100644 index 000000000..016e9f49c --- /dev/null +++ b/ts/fixtures/lang/chars/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod chars; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("chars::chars", chars::chars)] +} diff --git a/ts/fixtures/lang/chars/ts.toml b/ts/fixtures/lang/chars/ts.toml new file mode 100644 index 000000000..e517cdfb2 --- /dev/null +++ b/ts/fixtures/lang/chars/ts.toml @@ -0,0 +1,2 @@ +package = "lang-chars-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/chunks/Cargo.toml b/ts/fixtures/lang/chunks/Cargo.toml new file mode 100644 index 000000000..92809805a --- /dev/null +++ b/ts/fixtures/lang/chunks/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-chunks-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/expected/chunks.Header.ts b/ts/fixtures/lang/chunks/expected/chunks.Header.ts similarity index 100% rename from ts/fixtures/lang/expected/chunks.Header.ts rename to ts/fixtures/lang/chunks/expected/chunks.Header.ts diff --git a/ts/fixtures/lang/expected/chunks.ts b/ts/fixtures/lang/chunks/expected/chunks.ts similarity index 100% rename from ts/fixtures/lang/expected/chunks.ts rename to ts/fixtures/lang/chunks/expected/chunks.ts diff --git a/ts/fixtures/lang/chunks/expected/core/option.ts b/ts/fixtures/lang/chunks/expected/core/option.ts new file mode 100644 index 000000000..3aee7a60b --- /dev/null +++ b/ts/fixtures/lang/chunks/expected/core/option.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function mapOr$1jgrjsu(self: [rt.ByteSlice, rt.ByteSlice] | undefined, default_: rt.ByteSlice, f: (a0: [rt.ByteSlice, rt.ByteSlice]) => rt.ByteSlice): rt.ByteSlice { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/chunks/expected/harness.ts b/ts/fixtures/lang/chunks/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/chunks/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/chunks/expected/lib.ts b/ts/fixtures/lang/chunks/expected/lib.ts new file mode 100644 index 000000000..219b715b6 --- /dev/null +++ b/ts/fixtures/lang/chunks/expected/lib.ts @@ -0,0 +1,16 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { chunks } from "./chunks.ts"; + +export const out$tuple2_ref_array4_u8_ref_slice_u8: { p_0Data: Uint8Array; p_0Start: number; p_0Len: number; p_1Data: Uint8Array; p_1Start: number; p_1Len: number } = { p_0Data: undefined as never, p_0Start: undefined as never, p_0Len: undefined as never, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never }; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["chunks::chunks", chunks as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/chunks.rs b/ts/fixtures/lang/chunks/src/chunks.rs similarity index 100% rename from ts/fixtures/lang/src/chunks.rs rename to ts/fixtures/lang/chunks/src/chunks.rs diff --git a/ts/fixtures/lang/chunks/src/lib.rs b/ts/fixtures/lang/chunks/src/lib.rs new file mode 100644 index 000000000..8362fa8e1 --- /dev/null +++ b/ts/fixtures/lang/chunks/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod chunks; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("chunks::chunks", chunks::chunks)] +} diff --git a/ts/fixtures/lang/chunks/ts.toml b/ts/fixtures/lang/chunks/ts.toml new file mode 100644 index 000000000..a6592e129 --- /dev/null +++ b/ts/fixtures/lang/chunks/ts.toml @@ -0,0 +1,2 @@ +package = "lang-chunks-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/clones/Cargo.toml b/ts/fixtures/lang/clones/Cargo.toml new file mode 100644 index 000000000..f71ab809f --- /dev/null +++ b/ts/fixtures/lang/clones/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-clones-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/expected/clones.Countdown.ts b/ts/fixtures/lang/clones/expected/clones.Countdown.ts similarity index 100% rename from ts/fixtures/lang/expected/clones.Countdown.ts rename to ts/fixtures/lang/clones/expected/clones.Countdown.ts diff --git a/ts/fixtures/lang/expected/clones.Logged.ts b/ts/fixtures/lang/clones/expected/clones.Logged.ts similarity index 100% rename from ts/fixtures/lang/expected/clones.Logged.ts rename to ts/fixtures/lang/clones/expected/clones.Logged.ts diff --git a/ts/fixtures/lang/expected/clones.Plan.ts b/ts/fixtures/lang/clones/expected/clones.Plan.ts similarity index 100% rename from ts/fixtures/lang/expected/clones.Plan.ts rename to ts/fixtures/lang/clones/expected/clones.Plan.ts diff --git a/ts/fixtures/lang/expected/clones.ts b/ts/fixtures/lang/clones/expected/clones.ts similarity index 96% rename from ts/fixtures/lang/expected/clones.ts rename to ts/fixtures/lang/clones/expected/clones.ts index a8dd1c354..9ae078f6b 100644 --- a/ts/fixtures/lang/expected/clones.ts +++ b/ts/fixtures/lang/clones/expected/clones.ts @@ -2,8 +2,8 @@ import * as rt from "./rt.ts"; import { drop$Vec_clones_Logged } from "./lib.ts"; -import * as clones_Countdown from "./clones.Countdown.ts"; -import * as clones_Logged from "./clones.Logged.ts"; +import * as Countdown from "./clones.Countdown.ts"; +import * as Logged from "./clones.Logged.ts"; import * as Plan from "./clones.Plan.ts"; import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$0y3liwu as option_map$0y3liwu, mapOr$1yabfom as option_mapOr$1yabfom, mapOr$1surhce as option_mapOr$1surhce, mapOr$02k4ito as option_mapOr$02k4ito } from "./core/option.ts"; @@ -1300,10 +1300,10 @@ export function turns$collections_btree_set_Union_u8_clones_iters_closure132_clo * then the original and the clone read in turns, each from either end, as `plan` picks, * until both end: each item as `put` makes it, and each end as 0xff and which ended. */ -export function turns$collections_vec_deque_IntoIter_clones_Logged_clones_owned_closure5_clones_owned_closure6(it: rt.Iter, back: (a0: rt.Iter) => clones_Logged.Logged | undefined, plan: Plan.Plan, put: (a0: clones_Logged.Logged) => rt.u8, out: rt.ByteVec): void { +export function turns$collections_vec_deque_IntoIter_clones_Logged_clones_owned_closure5_clones_owned_closure6(it: rt.Iter, back: (a0: rt.Iter) => Logged.Logged | undefined, plan: Plan.Plan, put: (a0: Logged.Logged) => rt.u8, out: rt.ByteVec): void { let first!: boolean; - let item3!: clones_Logged.Logged | undefined; - const _44: (a0: rt.Iter) => Uint8Array = (it2: rt.Iter): Uint8Array => { + let item3!: Logged.Logged | undefined; + const _44: (a0: rt.Iter) => Uint8Array = (it2: rt.Iter): Uint8Array => { const _5: [rt.usize, rt.usize | undefined] = it2.sizeHint(); return Uint8Array.of(_5[0] & 0xff, option_mapOr$02k4ito(_5[1], 254, (n: rt.usize): rt.u8 => { return n & 0xff; @@ -1313,7 +1313,7 @@ export function turns$collections_vec_deque_IntoIter_clones_Logged_clones_owned_ let iterStart: rt.u8 = 0; const iterEnd: rt.u8 = _8; while (iterStart++ < iterEnd) { - const _15: clones_Logged.Logged | rt.Done = it.next(); + const _15: Logged.Logged | rt.Done = it.next(); if (_15 !== rt.DONE) { rt.byteVecPush(out, put(_15)); } @@ -1322,12 +1322,12 @@ export function turns$collections_vec_deque_IntoIter_clones_Logged_clones_owned_ let iterStart2: rt.u8 = 0; const iterEnd2: rt.u8 = _25; while (iterStart2++ < iterEnd2) { - const _32: clones_Logged.Logged | undefined = back(it); + const _32: Logged.Logged | undefined = back(it); if (_32 !== undefined) { rt.byteVecPush(out, put(_32)); } } - const other: rt.Iter = it.clone({ v: clones_Logged.clone$Clone }); + const other: rt.Iter = it.clone({ v: Logged.clone$Clone }); rt.iterExtendBytes(out, rt.iterSlice(_44(it)), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(_44(other)), undefined, true); let ended: boolean = false; @@ -1542,10 +1542,10 @@ export function turns$collections_vec_deque_Iter_u8_clones_iters_closure138_clon * then the original and the clone read in turns, each from either end, as `plan` picks, * until both end: each item as `put` makes it, and each end as 0xff and which ended. */ -export function turns$iter_Chain_iter_Once_clones_Logged_option_IntoIter_clones_Logged_clones_owned_closure10_clones_owned_closure11(it: rt.Iter, back: (a0: rt.Iter) => clones_Logged.Logged | undefined, plan: Plan.Plan, put: (a0: clones_Logged.Logged) => rt.u8, out: rt.ByteVec): void { +export function turns$iter_Chain_iter_Once_clones_Logged_option_IntoIter_clones_Logged_clones_owned_closure10_clones_owned_closure11(it: rt.Iter, back: (a0: rt.Iter) => Logged.Logged | undefined, plan: Plan.Plan, put: (a0: Logged.Logged) => rt.u8, out: rt.ByteVec): void { let first!: boolean; - let item3!: clones_Logged.Logged | undefined; - const _44: (a0: rt.Iter) => Uint8Array = (it2: rt.Iter): Uint8Array => { + let item3!: Logged.Logged | undefined; + const _44: (a0: rt.Iter) => Uint8Array = (it2: rt.Iter): Uint8Array => { const _5: [rt.usize, rt.usize | undefined] = it2.sizeHint(); return Uint8Array.of(_5[0] & 0xff, option_mapOr$02k4ito(_5[1], 254, (n: rt.usize): rt.u8 => { return n & 0xff; @@ -1555,7 +1555,7 @@ export function turns$iter_Chain_iter_Once_clones_Logged_option_IntoIter_clones_ let iterStart: rt.u8 = 0; const iterEnd: rt.u8 = _8; while (iterStart++ < iterEnd) { - const _15: clones_Logged.Logged | rt.Done = it.next(); + const _15: Logged.Logged | rt.Done = it.next(); if (_15 !== rt.DONE) { rt.byteVecPush(out, put(_15)); } @@ -1564,12 +1564,12 @@ export function turns$iter_Chain_iter_Once_clones_Logged_option_IntoIter_clones_ let iterStart2: rt.u8 = 0; const iterEnd2: rt.u8 = _25; while (iterStart2++ < iterEnd2) { - const _32: clones_Logged.Logged | undefined = back(it); + const _32: Logged.Logged | undefined = back(it); if (_32 !== undefined) { rt.byteVecPush(out, put(_32)); } } - const other: rt.Iter = it.clone({ i: { v: clones_Logged.clone$Clone }, o: { v: clones_Logged.clone$Clone } }); + const other: rt.Iter = it.clone({ i: { v: Logged.clone$Clone }, o: { v: Logged.clone$Clone } }); rt.iterExtendBytes(out, rt.iterSlice(_44(it)), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(_44(other)), undefined, true); let ended: boolean = false; @@ -2666,10 +2666,10 @@ export function turns$iter_Flatten_slice_Chunks_u8_clones_iters_closure92_clones * then the original and the clone read in turns, each from either end, as `plan` picks, * until both end: each item as `put` makes it, and each end as 0xff and which ended. */ -export function turns$iter_Flatten_vec_IntoIter_Vec_clones_Logged_clones_owned_closure13_clones_owned_closure14(it: rt.Iter, back: (a0: rt.Iter) => clones_Logged.Logged | undefined, plan: Plan.Plan, put: (a0: clones_Logged.Logged) => rt.u8, out: rt.ByteVec): void { +export function turns$iter_Flatten_vec_IntoIter_Vec_clones_Logged_clones_owned_closure13_clones_owned_closure14(it: rt.Iter, back: (a0: rt.Iter) => Logged.Logged | undefined, plan: Plan.Plan, put: (a0: Logged.Logged) => rt.u8, out: rt.ByteVec): void { let first!: boolean; - let item3!: clones_Logged.Logged | undefined; - const _44: (a0: rt.Iter) => Uint8Array = (it2: rt.Iter): Uint8Array => { + let item3!: Logged.Logged | undefined; + const _44: (a0: rt.Iter) => Uint8Array = (it2: rt.Iter): Uint8Array => { const _5: [rt.usize, rt.usize | undefined] = it2.sizeHint(); return Uint8Array.of(_5[0] & 0xff, option_mapOr$02k4ito(_5[1], 254, (n: rt.usize): rt.u8 => { return n & 0xff; @@ -2679,7 +2679,7 @@ export function turns$iter_Flatten_vec_IntoIter_Vec_clones_Logged_clones_owned_c let iterStart: rt.u8 = 0; const iterEnd: rt.u8 = _8; while (iterStart++ < iterEnd) { - const _15: clones_Logged.Logged | rt.Done = it.next(); + const _15: Logged.Logged | rt.Done = it.next(); if (_15 !== rt.DONE) { rt.byteVecPush(out, put(_15)); } @@ -2688,14 +2688,14 @@ export function turns$iter_Flatten_vec_IntoIter_Vec_clones_Logged_clones_owned_c let iterStart2: rt.u8 = 0; const iterEnd2: rt.u8 = _25; while (iterStart2++ < iterEnd2) { - const _32: clones_Logged.Logged | undefined = back(it); + const _32: Logged.Logged | undefined = back(it); if (_32 !== undefined) { rt.byteVecPush(out, put(_32)); } } - const other: rt.Iter = it.clone({ i: { v: (a0: clones_Logged.Logged[]): clones_Logged.Logged[] => { - return rt.vecExact(a0.map(clones_Logged.clone$Clone), 8); - } }, o: { v: clones_Logged.clone$Clone } }); + const other: rt.Iter = it.clone({ i: { v: (a0: Logged.Logged[]): Logged.Logged[] => { + return rt.vecExact(a0.map(Logged.clone$Clone), 8); + } }, o: { v: Logged.clone$Clone } }); rt.iterExtendBytes(out, rt.iterSlice(_44(it)), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(_44(other)), undefined, true); let ended: boolean = false; @@ -3017,7 +3017,7 @@ export function turns$iter_Map_clones_Countdown_clones_iters_closure100_clones_i rt.byteVecPush(out, put(_32)); } } - const other: rt.Iter = it.clone({ i: { v: clones_Countdown.clone$Clone } }); + const other: rt.Iter = it.clone({ i: { v: Countdown.clone$Clone } }); rt.iterExtendBytes(out, rt.iterSlice(_44(it)), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(_44(other)), undefined, true); let ended: boolean = false; @@ -3630,10 +3630,10 @@ export function turns$iter_Peekable_slice_Iter_u8_clones_iters_closure86_clones_ * then the original and the clone read in turns, each from either end, as `plan` picks, * until both end: each item as `put` makes it, and each end as 0xff and which ended. */ -export function turns$iter_Peekable_vec_IntoIter_clones_Logged_clones_owned_closure8_clones_owned_closure9(it: rt.Peekable, back: (a0: rt.Peekable) => clones_Logged.Logged | undefined, plan: Plan.Plan, put: (a0: clones_Logged.Logged) => rt.u8, out: rt.ByteVec): void { +export function turns$iter_Peekable_vec_IntoIter_clones_Logged_clones_owned_closure8_clones_owned_closure9(it: rt.Peekable, back: (a0: rt.Peekable) => Logged.Logged | undefined, plan: Plan.Plan, put: (a0: Logged.Logged) => rt.u8, out: rt.ByteVec): void { let first!: boolean; - let item3!: clones_Logged.Logged | undefined; - const _44: (a0: rt.Peekable) => Uint8Array = (it2: rt.Peekable): Uint8Array => { + let item3!: Logged.Logged | undefined; + const _44: (a0: rt.Peekable) => Uint8Array = (it2: rt.Peekable): Uint8Array => { const _5: [rt.usize, rt.usize | undefined] = it2.sizeHint(); return Uint8Array.of(_5[0] & 0xff, option_mapOr$02k4ito(_5[1], 254, (n: rt.usize): rt.u8 => { return n & 0xff; @@ -3643,7 +3643,7 @@ export function turns$iter_Peekable_vec_IntoIter_clones_Logged_clones_owned_clos let iterStart: rt.u8 = 0; const iterEnd: rt.u8 = _8; while (iterStart++ < iterEnd) { - const _15: clones_Logged.Logged | rt.Done = it.next(); + const _15: Logged.Logged | rt.Done = it.next(); if (_15 !== rt.DONE) { rt.byteVecPush(out, put(_15)); } @@ -3652,12 +3652,12 @@ export function turns$iter_Peekable_vec_IntoIter_clones_Logged_clones_owned_clos let iterStart2: rt.u8 = 0; const iterEnd2: rt.u8 = _25; while (iterStart2++ < iterEnd2) { - const _32: clones_Logged.Logged | undefined = back(it); + const _32: Logged.Logged | undefined = back(it); if (_32 !== undefined) { rt.byteVecPush(out, put(_32)); } } - const other: rt.Peekable = it.clone({ i: { v: clones_Logged.clone$Clone }, v: clones_Logged.clone$Clone }); + const other: rt.Peekable = it.clone({ i: { v: Logged.clone$Clone }, v: Logged.clone$Clone }); rt.iterExtendBytes(out, rt.iterSlice(_44(it)), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(_44(other)), undefined, true); let ended: boolean = false; @@ -4032,10 +4032,10 @@ export function turns$iter_StepBy_slice_Iter_u8_clones_iters_closure79_clones_it * then the original and the clone read in turns, each from either end, as `plan` picks, * until both end: each item as `put` makes it, and each end as 0xff and which ended. */ -export function turns$iter_Successors_clones_Logged_clones_owned_closure15_clones_owned_closure16_clones_owned_closure17(it: rt.Iter, back: (a0: rt.Iter) => clones_Logged.Logged | undefined, plan: Plan.Plan, put: (a0: clones_Logged.Logged) => rt.u8, out: rt.ByteVec): void { +export function turns$iter_Successors_clones_Logged_clones_owned_closure15_clones_owned_closure16_clones_owned_closure17(it: rt.Iter, back: (a0: rt.Iter) => Logged.Logged | undefined, plan: Plan.Plan, put: (a0: Logged.Logged) => rt.u8, out: rt.ByteVec): void { let first!: boolean; - let item3!: clones_Logged.Logged | undefined; - const _44: (a0: rt.Iter) => Uint8Array = (it2: rt.Iter): Uint8Array => { + let item3!: Logged.Logged | undefined; + const _44: (a0: rt.Iter) => Uint8Array = (it2: rt.Iter): Uint8Array => { const _5: [rt.usize, rt.usize | undefined] = it2.sizeHint(); return Uint8Array.of(_5[0] & 0xff, option_mapOr$02k4ito(_5[1], 254, (n: rt.usize): rt.u8 => { return n & 0xff; @@ -4045,7 +4045,7 @@ export function turns$iter_Successors_clones_Logged_clones_owned_closure15_clone let iterStart: rt.u8 = 0; const iterEnd: rt.u8 = _8; while (iterStart++ < iterEnd) { - const _15: clones_Logged.Logged | rt.Done = it.next(); + const _15: Logged.Logged | rt.Done = it.next(); if (_15 !== rt.DONE) { rt.byteVecPush(out, put(_15)); } @@ -4054,12 +4054,12 @@ export function turns$iter_Successors_clones_Logged_clones_owned_closure15_clone let iterStart2: rt.u8 = 0; const iterEnd2: rt.u8 = _25; while (iterStart2++ < iterEnd2) { - const _32: clones_Logged.Logged | undefined = back(it); + const _32: Logged.Logged | undefined = back(it); if (_32 !== undefined) { rt.byteVecPush(out, put(_32)); } } - const other: rt.Iter = it.clone({ v: clones_Logged.clone$Clone }); + const other: rt.Iter = it.clone({ v: Logged.clone$Clone }); rt.iterExtendBytes(out, rt.iterSlice(_44(it)), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(_44(other)), undefined, true); let ended: boolean = false; @@ -4381,7 +4381,7 @@ export function turns$iter_Zip_clones_Countdown_slice_Iter_u8_clones_iters_closu rt.byteVecPush(out, put(_32)); } } - const other: rt.Iter<[rt.u8, rt.u8]> = it.clone({ i: { v: clones_Countdown.clone$Clone } }); + const other: rt.Iter<[rt.u8, rt.u8]> = it.clone({ i: { v: Countdown.clone$Clone } }); rt.iterExtendBytes(out, rt.iterSlice(_44(it)), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(_44(other)), undefined, true); let ended: boolean = false; @@ -6438,10 +6438,10 @@ export function turns$str_Split_ref_str_clones_iters_closure59_clones_iters_clos * then the original and the clone read in turns, each from either end, as `plan` picks, * until both end: each item as `put` makes it, and each end as 0xff and which ended. */ -export function turns$vec_IntoIter_clones_Logged_clones_owned_closure2_clones_owned_closure3(it: rt.Iter, back: (a0: rt.Iter) => clones_Logged.Logged | undefined, plan: Plan.Plan, put: (a0: clones_Logged.Logged) => rt.u8, out: rt.ByteVec): void { +export function turns$vec_IntoIter_clones_Logged_clones_owned_closure2_clones_owned_closure3(it: rt.Iter, back: (a0: rt.Iter) => Logged.Logged | undefined, plan: Plan.Plan, put: (a0: Logged.Logged) => rt.u8, out: rt.ByteVec): void { let first!: boolean; - let item3!: clones_Logged.Logged | undefined; - const _44: (a0: rt.Iter) => Uint8Array = (it2: rt.Iter): Uint8Array => { + let item3!: Logged.Logged | undefined; + const _44: (a0: rt.Iter) => Uint8Array = (it2: rt.Iter): Uint8Array => { const _5: [rt.usize, rt.usize | undefined] = it2.sizeHint(); return Uint8Array.of(_5[0] & 0xff, option_mapOr$02k4ito(_5[1], 254, (n: rt.usize): rt.u8 => { return n & 0xff; @@ -6451,7 +6451,7 @@ export function turns$vec_IntoIter_clones_Logged_clones_owned_closure2_clones_ow let iterStart: rt.u8 = 0; const iterEnd: rt.u8 = _8; while (iterStart++ < iterEnd) { - const _15: clones_Logged.Logged | rt.Done = it.next(); + const _15: Logged.Logged | rt.Done = it.next(); if (_15 !== rt.DONE) { rt.byteVecPush(out, put(_15)); } @@ -6460,12 +6460,12 @@ export function turns$vec_IntoIter_clones_Logged_clones_owned_closure2_clones_ow let iterStart2: rt.u8 = 0; const iterEnd2: rt.u8 = _25; while (iterStart2++ < iterEnd2) { - const _32: clones_Logged.Logged | undefined = back(it); + const _32: Logged.Logged | undefined = back(it); if (_32 !== undefined) { rt.byteVecPush(out, put(_32)); } } - const other: rt.Iter = it.clone({ v: clones_Logged.clone$Clone }); + const other: rt.Iter = it.clone({ v: Logged.clone$Clone }); rt.iterExtendBytes(out, rt.iterSlice(_44(it)), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(_44(other)), undefined, true); let ended: boolean = false; @@ -6893,16 +6893,16 @@ export function iters(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { }, plan, (x35: rt.u8): rt.u8 => { return x35; }, out); - turns$iter_Map_clones_Countdown_clones_iters_closure100_clones_iters_closure101_clones_iters_closure102(rt.iterMap(rt.iterFrom({ _0: rt.u8Mul(n & 0xff, 3) }, (it: clones_Countdown.Countdown) => clones_Countdown.next$iter_Iterator(it)), (x36: rt.u8): rt.u8 => { + turns$iter_Map_clones_Countdown_clones_iters_closure100_clones_iters_closure101_clones_iters_closure102(rt.iterMap(rt.iterFrom({ _0: rt.u8Mul(n & 0xff, 3) }, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it)), (x36: rt.u8): rt.u8 => { return x36 ^ 7; }), (it33: rt.Iter): rt.u8 | undefined => { return rt.iterToOption(it33.next()); }, plan, (x37: rt.u8): rt.u8 => { return x37; }, out); - const _236: clones_Countdown.Countdown = { _0: rt.u8Mul(n & 0xff, 3) }; + const _236: Countdown.Countdown = { _0: rt.u8Mul(n & 0xff, 3) }; const _240: rt.Iter = rt.iterSlice(rt.byteSliceView(data)); - turns$iter_Zip_clones_Countdown_slice_Iter_u8_clones_iters_closure103_clones_iters_closure104(rt.iterZip(rt.iterFrom(_236, (it: clones_Countdown.Countdown) => clones_Countdown.next$iter_Iterator(it)), _240), (it34: rt.Iter<[rt.u8, rt.u8]>): [rt.u8, rt.u8] | undefined => { + turns$iter_Zip_clones_Countdown_slice_Iter_u8_clones_iters_closure103_clones_iters_closure104(rt.iterZip(rt.iterFrom(_236, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it)), _240), (it34: rt.Iter<[rt.u8, rt.u8]>): [rt.u8, rt.u8] | undefined => { return rt.iterToOption(it34.next()); }, plan, (_261: [rt.u8, rt.u8]): rt.u8 => { return _261[0] ^ _261[1]; @@ -7389,97 +7389,97 @@ export function unordered$iter_Map_collections_hash_map_Iter_u8_u8_clones_iters_ */ export function owned(data: rt.ByteSlice, plan: Plan.Plan, out: rt.ByteVec): void { const log: rt.Arc> = new rt.Arc(new rt.RefCell(new rt.ByteVec())); - const logged: (a0: rt.u8) => clones_Logged.Logged = (id: rt.u8): clones_Logged.Logged => { - return new clones_Logged.Logged(id, rt.arcClone(log)); + const logged: (a0: rt.u8) => Logged.Logged = (id: rt.u8): Logged.Logged => { + return new Logged.Logged(id, rt.arcClone(log)); }; - const it: rt.Iter = rt.iterSlice(rt.iterToArray(rt.iterMap(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 6), (_2: rt.u8): clones_Logged.Logged => { + const it: rt.Iter = rt.iterSlice(rt.iterToArray(rt.iterMap(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 6), (_2: rt.u8): Logged.Logged => { return logged(_2 & 112); }), undefined, 8, true), rt.drop); rt.drop(rt.iterToOption(it.next())); rt.drop(rt.iterToOption(it.nextBack())); - const clone: rt.Iter = it.clone({ v: clones_Logged.clone$Clone }); + const clone: rt.Iter = it.clone({ v: Logged.clone$Clone }); flush(log.value, out); rt.drop(it); flush(log.value, out); - turns$vec_IntoIter_clones_Logged_clones_owned_closure2_clones_owned_closure3(clone, (it6: rt.Iter): clones_Logged.Logged | undefined => { + turns$vec_IntoIter_clones_Logged_clones_owned_closure2_clones_owned_closure3(clone, (it6: rt.Iter): Logged.Logged | undefined => { return rt.iterToOption(it6.nextBack()); - }, plan, (x: clones_Logged.Logged): rt.u8 => { - const _04: rt.u8 = clones_Logged.id(x); + }, plan, (x: Logged.Logged): rt.u8 => { + const _04: rt.u8 = Logged.id(x); x[Symbol.dispose](); return _04; }, out); flush(log.value, out); - turns$collections_vec_deque_IntoIter_clones_Logged_clones_owned_closure5_clones_owned_closure6(rt.dequeIntoIter(rt.dequeFromVec(rt.iterToArray(rt.iterMap(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 4), (_22: rt.u8): clones_Logged.Logged => { + turns$collections_vec_deque_IntoIter_clones_Logged_clones_owned_closure5_clones_owned_closure6(rt.dequeIntoIter(rt.dequeFromVec(rt.iterToArray(rt.iterMap(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 4), (_22: rt.u8): Logged.Logged => { return logged(_22 & 112); - }), undefined, 8, true), 8) as rt.VecDeque, rt.drop), (it7: rt.Iter): clones_Logged.Logged | undefined => { + }), undefined, 8, true), 8) as rt.VecDeque, rt.drop), (it7: rt.Iter): Logged.Logged | undefined => { return rt.iterToOption(it7.nextBack()); - }, plan, (x2: clones_Logged.Logged): rt.u8 => { - const _07: rt.u8 = clones_Logged.id(x2); + }, plan, (x2: Logged.Logged): rt.u8 => { + const _07: rt.u8 = Logged.id(x2); x2[Symbol.dispose](); return _07; }, out); flush(log.value, out); - const it2: rt.Peekable = rt.iterPeekable(rt.iterSlice(rt.iterToArray(rt.iterMap(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 4), (_24: rt.u8): clones_Logged.Logged => { + const it2: rt.Peekable = rt.iterPeekable(rt.iterSlice(rt.iterToArray(rt.iterMap(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 4), (_24: rt.u8): Logged.Logged => { return logged(_24 & 112); }), undefined, 8, true), rt.drop), rt.drop); - rt.byteVecPush(out, option_mapOr$1yabfom(rt.peekablePeek(it2), 238, clones_Logged.id)); - const clone2: rt.Peekable = it2.clone({ i: { v: clones_Logged.clone$Clone }, v: clones_Logged.clone$Clone }); + rt.byteVecPush(out, option_mapOr$1yabfom(rt.peekablePeek(it2), 238, Logged.id)); + const clone2: rt.Peekable = it2.clone({ i: { v: Logged.clone$Clone }, v: Logged.clone$Clone }); flush(log.value, out); rt.drop(clone2); flush(log.value, out); - turns$iter_Peekable_vec_IntoIter_clones_Logged_clones_owned_closure8_clones_owned_closure9(it2, (it8: rt.Peekable): clones_Logged.Logged | undefined => { + turns$iter_Peekable_vec_IntoIter_clones_Logged_clones_owned_closure8_clones_owned_closure9(it2, (it8: rt.Peekable): Logged.Logged | undefined => { return rt.iterToOption(it8.nextBack()); - }, plan, (x3: clones_Logged.Logged): rt.u8 => { - const _010: rt.u8 = clones_Logged.id(x3); + }, plan, (x3: Logged.Logged): rt.u8 => { + const _010: rt.u8 = Logged.id(x3); x3[Symbol.dispose](); return _010; }, out); flush(log.value, out); - const it3: rt.Iter = rt.iterChain(rt.iterOnce(logged(1), rt.drop), rt.iterOption(logged(2), rt.drop)); - const clone3: rt.Iter = it3.clone({ i: { v: clones_Logged.clone$Clone }, o: { v: clones_Logged.clone$Clone } }); + const it3: rt.Iter = rt.iterChain(rt.iterOnce(logged(1), rt.drop), rt.iterOption(logged(2), rt.drop)); + const clone3: rt.Iter = it3.clone({ i: { v: Logged.clone$Clone }, o: { v: Logged.clone$Clone } }); flush(log.value, out); rt.drop(it3); - turns$iter_Chain_iter_Once_clones_Logged_option_IntoIter_clones_Logged_clones_owned_closure10_clones_owned_closure11(clone3, (it9: rt.Iter): clones_Logged.Logged | undefined => { + turns$iter_Chain_iter_Once_clones_Logged_option_IntoIter_clones_Logged_clones_owned_closure10_clones_owned_closure11(clone3, (it9: rt.Iter): Logged.Logged | undefined => { return rt.iterToOption(it9.nextBack()); - }, plan, (x4: clones_Logged.Logged): rt.u8 => { - const _012: rt.u8 = clones_Logged.id(x4); + }, plan, (x4: Logged.Logged): rt.u8 => { + const _012: rt.u8 = Logged.id(x4); x4[Symbol.dispose](); return _012; }, out); flush(log.value, out); - const it4: rt.Iter = rt.iterFlatten(rt.iterSlice(rt.iterToArray(rt.iterMap(rt.iterTake(rt.byteSliceChunks(data, 3), 3), (c: rt.ByteSlice): clones_Logged.Logged[] => { - return rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(c)), (_25: rt.u8): clones_Logged.Logged => { + const it4: rt.Iter = rt.iterFlatten(rt.iterSlice(rt.iterToArray(rt.iterMap(rt.iterTake(rt.byteSliceChunks(data, 3), 3), (c: rt.ByteSlice): Logged.Logged[] => { + return rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(c)), (_25: rt.u8): Logged.Logged => { return logged(_25 & 112); }), undefined, 8, true); - }), undefined, 12, true), drop$Vec_clones_Logged), (value: clones_Logged.Logged[]) => rt.iterSlice(value, rt.drop), true); + }), undefined, 12, true), drop$Vec_clones_Logged), (value: Logged.Logged[]) => rt.iterSlice(value, rt.drop), true); rt.drop(rt.iterToOption(it4.next())); rt.drop(rt.iterToOption(it4.nextBack())); - const clone4: rt.Iter = it4.clone({ i: { v: (a07: clones_Logged.Logged[]): clones_Logged.Logged[] => { - return rt.vecExact(a07.map(clones_Logged.clone$Clone), 8); - } }, o: { v: clones_Logged.clone$Clone } }); + const clone4: rt.Iter = it4.clone({ i: { v: (a07: Logged.Logged[]): Logged.Logged[] => { + return rt.vecExact(a07.map(Logged.clone$Clone), 8); + } }, o: { v: Logged.clone$Clone } }); flush(log.value, out); rt.drop(it4); flush(log.value, out); - turns$iter_Flatten_vec_IntoIter_Vec_clones_Logged_clones_owned_closure13_clones_owned_closure14(clone4, (it10: rt.Iter): clones_Logged.Logged | undefined => { + turns$iter_Flatten_vec_IntoIter_Vec_clones_Logged_clones_owned_closure13_clones_owned_closure14(clone4, (it10: rt.Iter): Logged.Logged | undefined => { return rt.iterToOption(it10.nextBack()); - }, plan, (x5: clones_Logged.Logged): rt.u8 => { - const _016: rt.u8 = clones_Logged.id(x5); + }, plan, (x5: Logged.Logged): rt.u8 => { + const _016: rt.u8 = Logged.id(x5); x5[Symbol.dispose](); return _016; }, out); flush(log.value, out); - const it5: rt.Iter = rt.iterSuccessors(logged(40), (x6: clones_Logged.Logged): clones_Logged.Logged | undefined => { - return option_map$0y3liwu(rt.u8CheckedSub(clones_Logged.id(x6), 13), (id2: rt.u8): clones_Logged.Logged => { + const it5: rt.Iter = rt.iterSuccessors(logged(40), (x6: Logged.Logged): Logged.Logged | undefined => { + return option_map$0y3liwu(rt.u8CheckedSub(Logged.id(x6), 13), (id2: rt.u8): Logged.Logged => { return logged(id2); }); }, rt.drop); rt.drop(rt.iterToOption(it5.next())); - const clone5: rt.Iter = it5.clone({ v: clones_Logged.clone$Clone }); + const clone5: rt.Iter = it5.clone({ v: Logged.clone$Clone }); flush(log.value, out); - turns$iter_Successors_clones_Logged_clones_owned_closure15_clones_owned_closure16_clones_owned_closure17(clone5, (it11: rt.Iter): clones_Logged.Logged | undefined => { + turns$iter_Successors_clones_Logged_clones_owned_closure15_clones_owned_closure16_clones_owned_closure17(clone5, (it11: rt.Iter): Logged.Logged | undefined => { return rt.iterToOption(it11.next()); - }, plan, (x7: clones_Logged.Logged): rt.u8 => { - const _020: rt.u8 = clones_Logged.id(x7); + }, plan, (x7: Logged.Logged): rt.u8 => { + const _020: rt.u8 = Logged.id(x7); x7[Symbol.dispose](); return _020; }, out); @@ -7494,25 +7494,25 @@ export function owned(data: rt.ByteSlice, plan: Plan.Plan, out: rt.ByteVec): voi */ export function closures(data: rt.ByteSlice, plan: Plan.Plan, out: rt.ByteVec): void { const log: rt.Arc> = new rt.Arc(new rt.RefCell(new rt.ByteVec())); - const logged: (a0: rt.u8) => clones_Logged.Logged = (id: rt.u8): clones_Logged.Logged => { - return new clones_Logged.Logged(id, rt.arcClone(log)); + const logged: (a0: rt.u8) => Logged.Logged = (id: rt.u8): Logged.Logged => { + return new Logged.Logged(id, rt.arcClone(log)); }; - const _11: [clones_Logged.Logged, clones_Logged.Logged] = [logged(1), logged(2)]; - const a: clones_Logged.Logged = _11[0]; - const b: clones_Logged.Logged = _11[1]; + const _11: [Logged.Logged, Logged.Logged] = [logged(1), logged(2)]; + const a: Logged.Logged = _11[0]; + const b: Logged.Logged = _11[1]; const _20: rt.Iter = rt.iterSlice(rt.byteSliceView(data)); - const make = (captured: clones_Logged.Logged): (a0: rt.u8) => rt.u8 => { + const make = (captured: Logged.Logged): (a0: rt.u8) => rt.u8 => { return rt.closure(rt.cloning((_2: rt.u8): rt.u8 => { - return _2 ^ clones_Logged.id(captured); - }, () => make(clones_Logged.clone$Clone(captured))), (): void => { + return _2 ^ Logged.id(captured); + }, () => make(Logged.clone$Clone(captured))), (): void => { captured[Symbol.dispose](); }); }; const _19: rt.Iter = rt.iterMap(_20, make(a)); - const make2 = (captured2: clones_Logged.Logged): (a0: rt.u8) => boolean => { + const make2 = (captured2: Logged.Logged): (a0: rt.u8) => boolean => { return rt.closure(rt.cloning((_23: rt.u8): boolean => { - return _23 !== clones_Logged.id(captured2); - }, () => make2(clones_Logged.clone$Clone(captured2))), (): void => { + return _23 !== Logged.id(captured2); + }, () => make2(Logged.clone$Clone(captured2))), (): void => { captured2[Symbol.dispose](); }); }; @@ -7527,16 +7527,16 @@ export function closures(data: rt.ByteSlice, plan: Plan.Plan, out: rt.ByteVec): return x3; }, out); flush(log.value, out); - const _38: [clones_Logged.Logged, rt.u8] = [logged(3), 0]; - const tag: clones_Logged.Logged = _38[0]; + const _38: [Logged.Logged, rt.u8] = [logged(3), 0]; + const tag: Logged.Logged = _38[0]; const count: rt.u8 = 0; const _43: rt.Iter = rt.iterSlice(rt.byteSliceView(data)); - const make3 = (captured3: rt.u8, captured4: clones_Logged.Logged): (a0: rt.u8) => rt.u8 => { + const make3 = (captured3: rt.u8, captured4: Logged.Logged): (a0: rt.u8) => rt.u8 => { return rt.closure(rt.cloning((_24: rt.u8): rt.u8 => { const x4: rt.u8 = _24; - captured3 = rt.u8WrappingAdd(captured3, clones_Logged.id(captured4)); + captured3 = rt.u8WrappingAdd(captured3, Logged.id(captured4)); return x4 ^ captured3; - }, () => make3(captured3, clones_Logged.clone$Clone(captured4))), (): void => { + }, () => make3(captured3, Logged.clone$Clone(captured4))), (): void => { captured4[Symbol.dispose](); }); }; @@ -7552,22 +7552,22 @@ export function closures(data: rt.ByteSlice, plan: Plan.Plan, out: rt.ByteVec): flush(log.value, out); rt.drop(it2); flush(log.value, out); - const inner: clones_Logged.Logged = logged(5); - const make4 = (captured5: rt.u8, captured6: clones_Logged.Logged): (a0: rt.u8) => rt.u8 => { + const inner: Logged.Logged = logged(5); + const make4 = (captured5: rt.u8, captured6: Logged.Logged): (a0: rt.u8) => rt.u8 => { return rt.closure(rt.cloning((x5: rt.u8): rt.u8 => { - captured5 = rt.u8WrappingAdd(captured5, x5 ^ clones_Logged.id(captured6)); + captured5 = rt.u8WrappingAdd(captured5, x5 ^ Logged.id(captured6)); return captured5; - }, () => make4(captured5, clones_Logged.clone$Clone(captured6))), (): void => { + }, () => make4(captured5, Logged.clone$Clone(captured6))), (): void => { captured6[Symbol.dispose](); }); }; const add: (a0: rt.u8) => rt.u8 = make4(0, inner); rt.byteVecPush(out, add(1)); - const held: clones_Logged.Logged = logged(6); - const make5 = (captured7: (a0: rt.u8) => rt.u8, captured8: clones_Logged.Logged): (a0: rt.u8) => rt.u8 => { + const held: Logged.Logged = logged(6); + const make5 = (captured7: (a0: rt.u8) => rt.u8, captured8: Logged.Logged): (a0: rt.u8) => rt.u8 => { return rt.closure(rt.cloning((x6: rt.u8): rt.u8 => { - return captured7(x6) ^ clones_Logged.id(captured8); - }, () => make5(rt.closureClone(captured7), clones_Logged.clone$Clone(captured8))), (): void => { + return captured7(x6) ^ Logged.id(captured8); + }, () => make5(rt.closureClone(captured7), Logged.clone$Clone(captured8))), (): void => { rt.drop(captured7); captured8[Symbol.dispose](); }); @@ -7581,27 +7581,27 @@ export function closures(data: rt.ByteSlice, plan: Plan.Plan, out: rt.ByteVec): rt.drop(copy); flush(log.value, out); const text: string = "ab"; - const tag2: clones_Logged.Logged = logged(7); - const make6 = (captured9: string, captured10: clones_Logged.Logged): () => [string, clones_Logged.Logged] => { - return rt.closure(rt.cloning((): [string, clones_Logged.Logged] => { + const tag2: Logged.Logged = logged(7); + const make6 = (captured9: string, captured10: Logged.Logged): () => [string, Logged.Logged] => { + return rt.closure(rt.cloning((): [string, Logged.Logged] => { captured9 = captured9 + "c"; - return [captured9, captured10] as [string, clones_Logged.Logged]; - }, () => make6(captured9, clones_Logged.clone$Clone(captured10))), (): void => { + return [captured9, captured10] as [string, Logged.Logged]; + }, () => make6(captured9, Logged.clone$Clone(captured10))), (): void => { captured10[Symbol.dispose](); }); }; - const once: () => [string, clones_Logged.Logged] = make6(text, tag2); - const twice: () => [string, clones_Logged.Logged] = rt.closureClone(once); + const once: () => [string, Logged.Logged] = make6(text, tag2); + const twice: () => [string, Logged.Logged] = rt.closureClone(once); flush(log.value, out); - const _127: [string, clones_Logged.Logged] = once(); + const _127: [string, Logged.Logged] = once(); const text2: string = _127[0]; - const tag3: clones_Logged.Logged = _127[1]; - rt.iterExtendBytes(out, rt.iterChain(rt.strBytes(text2), rt.iterSlice(Uint8Array.of(clones_Logged.id(tag3)))), undefined, true); + const tag3: Logged.Logged = _127[1]; + rt.iterExtendBytes(out, rt.iterChain(rt.strBytes(text2), rt.iterSlice(Uint8Array.of(Logged.id(tag3)))), undefined, true); tag3[Symbol.dispose](); - const _139: [string, clones_Logged.Logged] = twice(); + const _139: [string, Logged.Logged] = twice(); const text3: string = _139[0]; - const tag4: clones_Logged.Logged = _139[1]; - rt.iterExtendBytes(out, rt.iterChain(rt.strBytes(text3), rt.iterSlice(Uint8Array.of(clones_Logged.id(tag4)))), undefined, true); + const tag4: Logged.Logged = _139[1]; + rt.iterExtendBytes(out, rt.iterChain(rt.strBytes(text3), rt.iterSlice(Uint8Array.of(Logged.id(tag4)))), undefined, true); tag4[Symbol.dispose](); flush(log.value, out); const captured11 = data.length & 0xff; diff --git a/ts/fixtures/lang/clones/expected/core/option.ts b/ts/fixtures/lang/clones/expected/core/option.ts new file mode 100644 index 000000000..44168b2c2 --- /dev/null +++ b/ts/fixtures/lang/clones/expected/core/option.ts @@ -0,0 +1,41 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import * as Logged from "../clones.Logged.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$0y3liwu(self: rt.u8 | undefined, f: (a0: rt.u8) => Logged.Logged): Logged.Logged | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function mapOr$1yabfom(self: Logged.Logged | undefined, default_: rt.u8, _: (a0: Logged.Logged) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return Logged.id(self); +} + +export function mapOr$1surhce(self: rt.u8 | undefined, default_: rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$02k4ito(self: rt.usize | undefined, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/clones/expected/harness.ts b/ts/fixtures/lang/clones/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/clones/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/clones/expected/lib.ts b/ts/fixtures/lang/clones/expected/lib.ts new file mode 100644 index 000000000..57af0a268 --- /dev/null +++ b/ts/fixtures/lang/clones/expected/lib.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { iters } from "./clones.ts"; +import type * as Logged from "./clones.Logged.ts"; + +export function drop$Vec_clones_Logged(value: Logged.Logged[]): void { + rt.dropAll(value); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["clones::iters", iters as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/clones.rs b/ts/fixtures/lang/clones/src/clones.rs similarity index 100% rename from ts/fixtures/lang/src/clones.rs rename to ts/fixtures/lang/clones/src/clones.rs diff --git a/ts/fixtures/lang/clones/src/lib.rs b/ts/fixtures/lang/clones/src/lib.rs new file mode 100644 index 000000000..a72e5a500 --- /dev/null +++ b/ts/fixtures/lang/clones/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod clones; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("clones::iters", clones::iters)] +} diff --git a/ts/fixtures/lang/clones/ts.toml b/ts/fixtures/lang/clones/ts.toml new file mode 100644 index 000000000..22cc82704 --- /dev/null +++ b/ts/fixtures/lang/clones/ts.toml @@ -0,0 +1,2 @@ +package = "lang-clones-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/collections/Cargo.toml b/ts/fixtures/lang/collections/Cargo.toml new file mode 100644 index 000000000..eb3b60eba --- /dev/null +++ b/ts/fixtures/lang/collections/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-collections-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/collections/caller.ts b/ts/fixtures/lang/collections/caller.ts new file mode 100644 index 000000000..32227b9dd --- /dev/null +++ b/ts/fixtures/lang/collections/caller.ts @@ -0,0 +1,59 @@ +// The inputs `collections`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `collections::deque_ranges` of each form of range, over no items and over items whose + * front wraps past the buffer's end, at bounds empty, at either end, past it, and backwards. + */ +const dequeRangesOp = op("collections::deque_ranges"); +const dequeRanges = [0, 0x18, 0xa8].flatMap((high) => + Array.from({ length: 8 }, (_, form) => + [[0, 0], [0, 3], [2, 2], [1, 4], [5, 5], [3, 1], [6, 7]].flatMap(([a, b]) => [[], [7, 8, 9]].map((items) => Uint8Array.of(...dequeRangesOp, high | form, a, b, ...items))), + ).flat(), +); + +/** + * `collections::set_ops` of one key against 30, which std's B-tree looks up in the larger + * rather than merging, of each key type: a key below the rest, at either end, between, and + * above. Then `Nibble`s equal to another set's but for their high bits, of hash sets as + * large as each other and one larger, where std's picks which set's to yield by size. + */ +const setOpsOp = op("collections::set_ops"); +const setOps = [ + ...[15, 16, 17, 18, 19].flatMap((kind) => [0x20, 0x21, 0x25, 0x3e, 0x3f].map((single) => Uint8Array.of(...setOpsOp, kind, single, ...Array.from({ length: 30 }, (_, i) => 0x41 + i)))), + ...[ + [0x01, 0x02, 0x13, 0x21, 0x32, 0x44], + [0x01, 0x02, 0x13, 0x21, 0x32, 0x44, 0x55], + [0x01, 0x02, 0x13, 0x55, 0x21, 0x32, 0x44], + ].map((data) => Uint8Array.of(...setOpsOp, 3, ...data)), +]; + +/** + * `collections::unlike_eqs` of every pair of positions where `eq` and `ne` disagree and each + * length the right side may lose, over no items, one, two, a wrapped deque's four, and nine, + * whose positions are all within it. + */ +const unlikeEqsOp = op("collections::unlike_eqs"); +const unlikeEqs = [[], [5], [1, 2], [0, 7, 2, 9], [3, 3, 3, 3, 3, 3, 3, 3, 3]].flatMap((bytes) => + Array.from({ length: 128 }, (_, kind) => Uint8Array.of(...unlikeEqsOp, kind, ...bytes)), +); + +/** `collections::own_nes` of the same positions, lengths, and items as `unlike_eqs`. */ +const ownNesOp = op("collections::own_nes"); +const ownNes = unlikeEqs.map((input) => Uint8Array.of(...ownNesOp, ...input.subarray(2))); + +/** `collections::unlike_compares` of the same positions, lengths, and items as `unlike_eqs`. */ +const unlikeComparesOp = op("collections::unlike_compares"); +const unlikeCompares = unlikeEqs.map((input) => Uint8Array.of(...unlikeComparesOp, ...input.subarray(2))); + +/** + * `collections::ref_orders` of no items, one, repeats, and runs whose remainders by 2, 3, + * 4, and 5 agree and disagree. + */ +const refOrdersOp = op("collections::ref_orders"); +const refOrders = [[], [5], [3, 3, 3], [1, 2], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [7, 2, 9, 4, 4, 11, 15, 6], [12, 6, 0, 30, 60]].map((data) => Uint8Array.of(...refOrdersOp, 0, ...data)); + +export const cases: Uint8Array[] = [...dequeRanges, ...setOps, ...unlikeEqs, ...ownNes, ...unlikeCompares, ...refOrders]; diff --git a/ts/fixtures/lang/expected/collections.Boxed.ts b/ts/fixtures/lang/collections/expected/collections.Boxed.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Boxed.ts rename to ts/fixtures/lang/collections/expected/collections.Boxed.ts diff --git a/ts/fixtures/lang/collections/expected/collections.Bumped.ts b/ts/fixtures/lang/collections/expected/collections.Bumped.ts new file mode 100644 index 000000000..b500fab95 --- /dev/null +++ b/ts/fixtures/lang/collections/expected/collections.Bumped.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; + +/** A `Copy` type whose `Clone` does more than copy. */ +export interface Bumped { + _0: rt.u8; +} + +export function clone$Clone(self: Bumped): Bumped { + return { _0: rt.u8WrappingAdd(self._0, 1) }; +} + +//# sourceMappingURL=collections.Bumped.ts.map diff --git a/ts/fixtures/lang/expected/collections.ByRef.ts b/ts/fixtures/lang/collections/expected/collections.ByRef.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.ByRef.ts rename to ts/fixtures/lang/collections/expected/collections.ByRef.ts diff --git a/ts/fixtures/lang/expected/collections.ByVal.ts b/ts/fixtures/lang/collections/expected/collections.ByVal.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.ByVal.ts rename to ts/fixtures/lang/collections/expected/collections.ByVal.ts diff --git a/ts/fixtures/lang/expected/collections.Clash.ts b/ts/fixtures/lang/collections/expected/collections.Clash.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Clash.ts rename to ts/fixtures/lang/collections/expected/collections.Clash.ts diff --git a/ts/fixtures/lang/expected/collections.Cloned.ts b/ts/fixtures/lang/collections/expected/collections.Cloned.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Cloned.ts rename to ts/fixtures/lang/collections/expected/collections.Cloned.ts diff --git a/ts/fixtures/lang/expected/collections.Dir.ts b/ts/fixtures/lang/collections/expected/collections.Dir.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Dir.ts rename to ts/fixtures/lang/collections/expected/collections.Dir.ts diff --git a/ts/fixtures/lang/expected/collections.Fussy.ts b/ts/fixtures/lang/collections/expected/collections.Fussy.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Fussy.ts rename to ts/fixtures/lang/collections/expected/collections.Fussy.ts diff --git a/ts/fixtures/lang/expected/collections.Holder.ts b/ts/fixtures/lang/collections/expected/collections.Holder.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Holder.ts rename to ts/fixtures/lang/collections/expected/collections.Holder.ts diff --git a/ts/fixtures/lang/expected/collections.Left.ts b/ts/fixtures/lang/collections/expected/collections.Left.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Left.ts rename to ts/fixtures/lang/collections/expected/collections.Left.ts diff --git a/ts/fixtures/lang/expected/collections.Mixed.ts b/ts/fixtures/lang/collections/expected/collections.Mixed.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Mixed.ts rename to ts/fixtures/lang/collections/expected/collections.Mixed.ts diff --git a/ts/fixtures/lang/expected/collections.Nibble.ts b/ts/fixtures/lang/collections/expected/collections.Nibble.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Nibble.ts rename to ts/fixtures/lang/collections/expected/collections.Nibble.ts diff --git a/ts/fixtures/lang/expected/collections.Odd.ts b/ts/fixtures/lang/collections/expected/collections.Odd.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Odd.ts rename to ts/fixtures/lang/collections/expected/collections.Odd.ts diff --git a/ts/fixtures/lang/expected/collections.Pair.ts b/ts/fixtures/lang/collections/expected/collections.Pair.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Pair.ts rename to ts/fixtures/lang/collections/expected/collections.Pair.ts diff --git a/ts/fixtures/lang/expected/collections.Picky.ts b/ts/fixtures/lang/collections/expected/collections.Picky.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Picky.ts rename to ts/fixtures/lang/collections/expected/collections.Picky.ts diff --git a/ts/fixtures/lang/expected/collections.Quirky.ts b/ts/fixtures/lang/collections/expected/collections.Quirky.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Quirky.ts rename to ts/fixtures/lang/collections/expected/collections.Quirky.ts diff --git a/ts/fixtures/lang/expected/collections.Rank.ts b/ts/fixtures/lang/collections/expected/collections.Rank.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Rank.ts rename to ts/fixtures/lang/collections/expected/collections.Rank.ts diff --git a/ts/fixtures/lang/expected/collections.Right.ts b/ts/fixtures/lang/collections/expected/collections.Right.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Right.ts rename to ts/fixtures/lang/collections/expected/collections.Right.ts diff --git a/ts/fixtures/lang/expected/collections.Tally.ts b/ts/fixtures/lang/collections/expected/collections.Tally.ts similarity index 100% rename from ts/fixtures/lang/expected/collections.Tally.ts rename to ts/fixtures/lang/collections/expected/collections.Tally.ts diff --git a/ts/fixtures/lang/collections/expected/collections.Wrap.ts b/ts/fixtures/lang/collections/expected/collections.Wrap.ts new file mode 100644 index 000000000..d236f5708 --- /dev/null +++ b/ts/fixtures/lang/collections/expected/collections.Wrap.ts @@ -0,0 +1,16 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; + +/** A generic `Copy` struct. */ +export class Wrap { + value: T; + count: rt.u8; + + constructor(value: T, count: rt.u8) { + this.value = value; + this.count = count; + } +} + +//# sourceMappingURL=collections.Wrap.ts.map diff --git a/ts/fixtures/lang/expected/collections.ts b/ts/fixtures/lang/collections/expected/collections.ts similarity index 86% rename from ts/fixtures/lang/expected/collections.ts rename to ts/fixtures/lang/collections/expected/collections.ts index 9eb16cc57..3d78d86df 100644 --- a/ts/fixtures/lang/expected/collections.ts +++ b/ts/fixtures/lang/collections/expected/collections.ts @@ -1,30 +1,30 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { copy$Option_collections_Tally, copy$array_collections_Quirky, copy$array_tuple2_u8_u16, copy$array_tuple2_u8_u8, copy$array_u8, copy$collections_Quirky, copy$collections_Tally, copy$generics_Wrap_u8, copy$iters_Bumped, copy$tuple2_u8_collections_Tally, copy$tuple2_u8_u16, copy$tuple2_u8_u8, drop$tuple2_sync_Arc_collections_Picky_u8 } from "./lib.ts"; +import { copy$Option_collections_Tally, copy$array_collections_Quirky, copy$array_tuple2_u8_u16, copy$array_tuple2_u8_u8, copy$array_u8, copy$collections_Bumped, copy$collections_Quirky, copy$collections_Tally, copy$collections_Wrap_u8, copy$tuple2_u8_collections_Tally, copy$tuple2_u8_u16, copy$tuple2_u8_u8, drop$tuple2_sync_Arc_collections_Picky_u8 } from "./lib.ts"; import type * as Boxed from "./collections.Boxed.ts"; +import * as Bumped from "./collections.Bumped.ts"; import * as ByRef from "./collections.ByRef.ts"; import * as ByVal from "./collections.ByVal.ts"; import * as Clash from "./collections.Clash.ts"; import * as Cloned from "./collections.Cloned.ts"; -import * as collections_Dir from "./collections.Dir.ts"; +import * as Dir from "./collections.Dir.ts"; import * as Fussy from "./collections.Fussy.ts"; import type * as Holder from "./collections.Holder.ts"; import * as Left from "./collections.Left.ts"; import * as Mixed from "./collections.Mixed.ts"; -import * as collections_Nibble from "./collections.Nibble.ts"; +import * as Nibble from "./collections.Nibble.ts"; import * as Odd from "./collections.Odd.ts"; -import * as collections_Pair from "./collections.Pair.ts"; -import * as collections_Picky from "./collections.Picky.ts"; +import * as Pair from "./collections.Pair.ts"; +import * as Picky from "./collections.Picky.ts"; import * as Quirky from "./collections.Quirky.ts"; import * as Rank from "./collections.Rank.ts"; import * as Right from "./collections.Right.ts"; -import * as collections_Tally from "./collections.Tally.ts"; +import * as Tally from "./collections.Tally.ts"; +import * as Wrap from "./collections.Wrap.ts"; import { thenSome$0d5am30 } from "./core/bool.ts"; -import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOr$1j4op5y as option_unwrapOr$1j4op5y, map$0ltgf8p as option_map$0ltgf8p, map$1ajptuf as option_map$1ajptuf, map$0i8kclf as option_map$0i8kclf, map$09ua5et as option_map$09ua5et, map$05nbzug as option_map$05nbzug, map$0oc32h1 as option_map$0oc32h1, mapOr$1xztl8h as option_mapOr$1xztl8h, mapOr$1e4a1e0 as option_mapOr$1e4a1e0, mapOr$0q0ymkh as option_mapOr$0q0ymkh, mapOr$1ht002r as option_mapOr$1ht002r, mapOr$1w1gbwl as option_mapOr$1w1gbwl, mapOr$0bnr5nu as option_mapOr$0bnr5nu, mapOr$1surhce as option_mapOr$1surhce, mapOr$1nlkf9b as option_mapOr$1nlkf9b, mapOr$099335t as option_mapOr$099335t, mapOr$0z4mj8g as option_mapOr$0z4mj8g, mapOr$1t0muvr as option_mapOr$1t0muvr, mapOr$02k4ito as option_mapOr$02k4ito, mapOr$1to2ul4 as option_mapOr$1to2ul4, mapOr$0mmpeqx as option_mapOr$0mmpeqx, clone$14nprly as option_clone$14nprly, flatten$1nwzx42 as option_flatten$1nwzx42 } from "./core/option.ts"; +import { unwrapOr$1j4op5y as option_unwrapOr$1j4op5y, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$0ltgf8p as option_map$0ltgf8p, map$1ajptuf as option_map$1ajptuf, map$0i8kclf as option_map$0i8kclf, map$09ua5et as option_map$09ua5et, map$0oc32h1 as option_map$0oc32h1, map$05nbzug as option_map$05nbzug, mapOr$1e4a1e0 as option_mapOr$1e4a1e0, mapOr$0q0ymkh as option_mapOr$0q0ymkh, mapOr$1ht002r as option_mapOr$1ht002r, mapOr$1xztl8h as option_mapOr$1xztl8h, mapOr$1w1gbwl as option_mapOr$1w1gbwl, mapOr$0bnr5nu as option_mapOr$0bnr5nu, mapOr$1nlkf9b as option_mapOr$1nlkf9b, mapOr$099335t as option_mapOr$099335t, mapOr$0z4mj8g as option_mapOr$0z4mj8g, mapOr$1surhce as option_mapOr$1surhce, mapOr$1t0muvr as option_mapOr$1t0muvr, mapOr$02k4ito as option_mapOr$02k4ito, mapOr$1to2ul4 as option_mapOr$1to2ul4, mapOr$0mmpeqx as option_mapOr$0mmpeqx, clone$14nprly as option_clone$14nprly, flatten$1nwzx42 as option_flatten$1nwzx42 } from "./core/option.ts"; import { eq$1dt73ez as result_eq$1dt73ez, eq$163neqy as result_eq$163neqy } from "./core/result.ts"; -import * as Wrap from "./generics.Wrap.ts"; -import * as Bumped from "./iters.Bumped.ts"; /** A 64-bit key: small, or past 2^53, where it is no longer a JS number. */ export function wide(b: rt.u8): rt.u64 { @@ -65,9 +65,9 @@ export function hashMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void let _299!: rt.usize; let _377!: rt.u8; let _429!: rt.u8; - const _443: (a0: collections_Nibble.Nibble) => rt.u64 = (n: collections_Nibble.Nibble): rt.u64 => { + const _443: (a0: Nibble.Nibble) => rt.u64 = (n: Nibble.Nibble): rt.u64 => { const h2: rt.Hasher = rt.hasher(); - collections_Nibble.hash$Hash_hash_DefaultHasher(n, h2); + Nibble.hash$Hash_hash_DefaultHasher(n, h2); return rt.hashFinish(h2); }; const _4: rt.u8 = rt.u8Rem(kind, 4); @@ -159,9 +159,9 @@ export function hashMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void rt.byteVecPush(out, rt.hashIndex(map2, _163)); } } else if (_4 === 2) { - const map3: rt.HashMap = rt.hashNew(rt.hashing(collections_Nibble.hash$Hash_hash_DefaultHasher as (a0: collections_Nibble.Nibble, a1: rt.Hasher) => undefined, collections_Nibble.eq$cmp_PartialEq)) as rt.HashMap; - const pairs: rt.HashMap = rt.hashNew(rt.hashing(collections_Pair.hash$Hash_hash_DefaultHasher as (a0: collections_Pair.Pair, a1: rt.Hasher) => undefined, collections_Pair.eq$cmp_PartialEq)) as rt.HashMap; - const ranks: rt.HashMap = rt.hashNew(rt.hashing(Rank.hash$Hash_hash_DefaultHasher as (a0: Rank.Rank, a1: rt.Hasher) => undefined, Rank.eq$cmp_PartialEq)) as rt.HashMap; + const map3: rt.HashMap = rt.hashNew(rt.hashing(Nibble.hash$Hash_hash_DefaultHasher as (a0: Nibble.Nibble, a1: rt.Hasher) => undefined, Nibble.eq$cmp_PartialEq)) as rt.HashMap; + const pairs: rt.HashMap = rt.hashNew(rt.hashing(Pair.hash$Hash_hash_DefaultHasher as (a0: Pair.Pair, a1: rt.Hasher) => undefined, Pair.eq$cmp_PartialEq)) as rt.HashMap; + const ranks: rt.HashMap = rt.hashNew(rt.hashing(Rank.hash$Hash_hash_DefaultHasher as (a0: Rank.Rank, a1: rt.Hasher) => undefined, Rank.eq$cmp_PartialEq)) as rt.HashMap; const tuples: rt.HashMap<[rt.u8, string], rt.u8> = rt.hashNew(rt.hashing(rt.hashTuple([rt.hash8, rt.hashStr]), rt.eqTuple([rt.same, rt.same]))) as rt.HashMap<[rt.u8, string], rt.u8>; let iterStart: rt.usize = 1; const iterEnd: rt.usize = data.length; @@ -175,11 +175,11 @@ export function hashMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const a: rt.u8 = _181; const b3: rt.u8 = _180[1]; rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.hashInsert(map3, { _0: a }, b3), 204)); - const pair: collections_Pair.Pair = { a: rt.u8Rem(a, 4), b: rt.u16Rem(b3 as rt.u16, 3) }; - const t: collections_Tally.Tally = rt.entryOrInsertWith(rt.entry(pairs, pair), collections_Tally.default$Default); + const pair: Pair.Pair = { a: rt.u8Rem(a, 4), b: rt.u16Rem(b3 as rt.u16, 3) }; + const t: Tally.Tally = rt.entryOrInsertWith(rt.entry(pairs, pair), Tally.default$Default); t.n = rt.u16Add(t.n, 1); const r: Rank.Rank = rank(a, b3); - const _205: collections_Tally.Tally | undefined = rt.hashGet(ranks, r); + const _205: Tally.Tally | undefined = rt.hashGet(ranks, r); if (_205 !== undefined) { _205.n = rt.u16Add(_205.n, 1); } else { @@ -196,7 +196,7 @@ export function hashMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void rt.hashInsert(tuples, t2, a); } } - const _238: rt.Iter<[rt.u8, rt.u8]> = rt.iterMap(rt.hashIter(map3), (_212: [collections_Nibble.Nibble, rt.u8]): [rt.u8, rt.u8] => { + const _238: rt.Iter<[rt.u8, rt.u8]> = rt.iterMap(rt.hashIter(map3), (_212: [Nibble.Nibble, rt.u8]): [rt.u8, rt.u8] => { return [_212[0]._0, _212[1]] as [rt.u8, rt.u8]; }); const iter6: rt.Iter<[rt.u8, rt.u8]> = rt.btreeIter(rt.btreeExtend(rt.btreeNew(rt.cmp) as rt.BTreeMap, _238, true, undefined, undefined, "next", 2)); @@ -210,27 +210,27 @@ export function hashMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void rt.byteVecPush(out, k3); rt.byteVecPush(out, v2); } - const key: collections_Pair.Pair = { a: 9, b: 9 }; - const local: collections_Tally.Tally = { n: 7 }; + const key: Pair.Pair = { a: 9, b: 9 }; + const local: Tally.Tally = { n: 7 }; rt.hashInsert(pairs, key, copy$collections_Tally(local)); local.n = 8; - const before: collections_Tally.Tally = copy$collections_Tally(rt.hashIndex(pairs, key)); - const _259: collections_Tally.Tally | undefined = rt.hashGet(pairs, key); + const before: Tally.Tally = copy$collections_Tally(rt.hashIndex(pairs, key)); + const _259: Tally.Tally | undefined = rt.hashGet(pairs, key); if (_259 !== undefined) { _259.n = rt.u16Add(_259.n, 2); } rt.byteVecPush(out, local.n & 0xff); rt.byteVecPush(out, before.n & 0xff); rt.byteVecPush(out, rt.hashIndex(pairs, key).n & 0xff); - const _278: rt.Iter<[collections_Pair.Pair, collections_Tally.Tally]> = rt.hashIter(pairs); - const iter7: rt.Iter<[collections_Pair.Pair, collections_Tally.Tally]> = rt.btreeIter(rt.btreeExtend(rt.btreeNew(collections_Pair.cmp$cmp_Ord) as rt.BTreeMap, _278, true, undefined, undefined, "next", 6)); + const _278: rt.Iter<[Pair.Pair, Tally.Tally]> = rt.hashIter(pairs); + const iter7: rt.Iter<[Pair.Pair, Tally.Tally]> = rt.btreeIter(rt.btreeExtend(rt.btreeNew(Pair.cmp$cmp_Ord) as rt.BTreeMap, _278, true, undefined, undefined, "next", 6)); while (true) { - const _282: [collections_Pair.Pair, collections_Tally.Tally] | rt.Done = iter7.next(); + const _282: [Pair.Pair, Tally.Tally] | rt.Done = iter7.next(); if (_282 === rt.DONE) { break; } - const p: collections_Pair.Pair = _282[0]; - const t3: collections_Tally.Tally = _282[1]; + const p: Pair.Pair = _282[0]; + const t3: Tally.Tally = _282[1]; rt.byteVecPush(out, p.a); rt.byteVecPush(out, p.b & 0xff); rt.byteVecPush(out, t3.n & 0xff); @@ -247,45 +247,45 @@ export function hashMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const a2: rt.u8 = _306; const b4: rt.u8 = _305[1]; const _318: Rank.Rank = rank(b4, a2); - const t4: collections_Tally.Tally = rt.entryOrInsertWith(rt.entryAndModify(rt.entry(ranks, _318), (t9: collections_Tally.Tally): undefined => { + const t4: Tally.Tally = rt.entryOrInsertWith(rt.entryAndModify(rt.entry(ranks, _318), (t9: Tally.Tally): undefined => { t9.n = t9.n ^ 3; - }), (): collections_Tally.Tally => { + }), (): Tally.Tally => { return { n: b4 as rt.u16 }; }); t4.n = rt.u16WrappingAdd(t4.n, t4.n); rt.idx(data, i4); const _326: Rank.Rank = rank(data.data[data.start + i4], 0); - const e: rt.Entry = rt.entry(ranks, _326); + const e: rt.Entry = rt.entry(ranks, _326); rt.byteVecPush(out, rankByte(rt.entryKey(e))); - rt.byteVecPush(out, rt.entryOrInsertWith(e, (k9: Rank.Rank): collections_Tally.Tally => { + rt.byteVecPush(out, rt.entryOrInsertWith(e, (k9: Rank.Rank): Tally.Tally => { return { n: rankByte(k9) as rt.u16 }; }).n & 0xff); } - const copy: rt.HashMap = rt.hashClone(ranks, undefined, copy$collections_Tally); - const _340: collections_Tally.Tally | undefined = rt.hashGet(copy, { tag: "Low" } as Rank.Rank); + const copy: rt.HashMap = rt.hashClone(ranks, undefined, copy$collections_Tally); + const _340: Tally.Tally | undefined = rt.hashGet(copy, { tag: "Low" } as Rank.Rank); if (_340 !== undefined) { _340.n = 119; } - rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashGet(ranks, { tag: "Low" } as Rank.Rank), 255, (t10: collections_Tally.Tally): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashGet(ranks, { tag: "Low" } as Rank.Rank), 255, (t10: Tally.Tally): rt.u8 => { return t10.n & 0xff; })); - rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashGet(copy, { tag: "Low" } as Rank.Rank), 255, (t11: collections_Tally.Tally): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashGet(copy, { tag: "Low" } as Rank.Rank), 255, (t11: Tally.Tally): rt.u8 => { return t11.n & 0xff; })); - rt.byteVecPush(out, option_mapOr$1to2ul4(rt.hashRemoveEntry(copy, { tag: "Mid", _0: 1 } as Rank.Rank), 255, (_218: [Rank.Rank, collections_Tally.Tally]): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1to2ul4(rt.hashRemoveEntry(copy, { tag: "Mid", _0: 1 } as Rank.Rank), 255, (_218: [Rank.Rank, Tally.Tally]): rt.u8 => { const k10: Rank.Rank = _218[0]; - const t12: collections_Tally.Tally = _218[1]; + const t12: Tally.Tally = _218[1]; return rankByte(k10) ^ (t12.n & 0xff); })); - const _361: rt.Iter<[rt.u8, collections_Tally.Tally]> = rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_227: rt.u8): [rt.u8, collections_Tally.Tally] => { + const _361: rt.Iter<[rt.u8, Tally.Tally]> = rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_227: rt.u8): [rt.u8, Tally.Tally] => { const b8: rt.u8 = _227; - return [rt.u8Rem(b8, 8), { n: b8 as rt.u16 }] as [rt.u8, collections_Tally.Tally]; + return [rt.u8Rem(b8, 8), { n: b8 as rt.u16 }] as [rt.u8, Tally.Tally]; }); - const bytes: rt.HashMap = rt.hashExtend(rt.hashNew() as rt.HashMap, _361, undefined, undefined, undefined, 234881024); - const copy2: rt.HashMap = rt.hashClone(bytes, undefined, copy$collections_Tally); - const iter9: rt.Iter = rt.hashValues(copy2); + const bytes: rt.HashMap = rt.hashExtend(rt.hashNew() as rt.HashMap, _361, undefined, undefined, undefined, 234881024); + const copy2: rt.HashMap = rt.hashClone(bytes, undefined, copy$collections_Tally); + const iter9: rt.Iter = rt.hashValues(copy2); while (true) { - const _369: collections_Tally.Tally | rt.Done = iter9.next(); + const _369: Tally.Tally | rt.Done = iter9.next(); if (_369 === rt.DONE) { break; } @@ -295,25 +295,25 @@ export function hashMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const iterEnd3: rt.u8 = 8; while ((_377 = iterStart3++) < iterEnd3) { const k4: rt.u8 = _377; - rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashGet(bytes, k4), 255, (t13: collections_Tally.Tally): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashGet(bytes, k4), 255, (t13: Tally.Tally): rt.u8 => { return t13.n & 0xff; })); - rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashGet(copy2, k4), 255, (t14: collections_Tally.Tally): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashGet(copy2, k4), 255, (t14: Tally.Tally): rt.u8 => { return t14.n & 0xff; })); } for (const b5 of rt.byteSliceView(data)) { rt.byteVecPush(out, claim(copy2, rt.u8Rem(b5, 8), b5 as rt.u16)); } - const stamped: rt.HashMap = rt.hashNew() as rt.HashMap; + const stamped: rt.HashMap = rt.hashNew() as rt.HashMap; rt.hashShrinkTo(stamp(stamped), 0); rt.hashReserve(stamp(stamped), 2, 234881024); rt.byteVecPush(out, rt.hashLen(stamped) & 0xff); - const extended: rt.HashMap = rt.hashNew() as rt.HashMap; + const extended: rt.HashMap = rt.hashNew() as rt.HashMap; rt.hashExtend(extended, rt.iterMap(rt.hashIter(bytes), copy$tuple2_u8_collections_Tally), undefined, undefined, undefined, 234881024); - const iter12: rt.Iter = rt.hashValues(extended); + const iter12: rt.Iter = rt.hashValues(extended); while (true) { - const _422: collections_Tally.Tally | rt.Done = iter12.next(); + const _422: Tally.Tally | rt.Done = iter12.next(); if (_422 === rt.DONE) { break; } @@ -323,30 +323,30 @@ export function hashMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const iterEnd4: rt.u8 = 8; while ((_429 = iterStart4++) < iterEnd4) { const k5: rt.u8 = _429; - rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashGet(bytes, k5), 255, (t15: collections_Tally.Tally): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashGet(bytes, k5), 255, (t15: Tally.Tally): rt.u8 => { return t15.n & 0xff; })); - rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashGet(extended, k5), 255, (t16: collections_Tally.Tally): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashGet(extended, k5), 255, (t16: Tally.Tally): rt.u8 => { return t16.n & 0xff; })); } const first: rt.u8 = option_unwrapOr$0r2bmpr(rt.byteSliceFirst(data), 0); rt.byteVecPush(out, rt.u64Eq(_443({ _0: first }), _443({ _0: first ^ 240 })) ? 1 : 0); - const _461: [rt.Hasher, collections_Tally.Tally] = [rt.hasher(), { n: first as rt.u16 }]; + const _461: [rt.Hasher, Tally.Tally] = [rt.hasher(), { n: first as rt.u16 }]; const h: rt.Hasher = _461[0]; - const counted: collections_Tally.Tally = copy$collections_Tally(_461[1]); + const counted: Tally.Tally = copy$collections_Tally(_461[1]); const _466: rt.Hasher = countedHasher(h, counted); rt.hash16(counted.n, _466); const want: rt.Hasher = rt.hasher(); rt.hash16(rt.u16Add(first as rt.u16, 1), want); rt.byteVecPush(out, rt.u64Eq(rt.hashFinish(h), rt.hashFinish(want)) ? 1 : 0); - rt.hashRetain(ranks, (r2: Rank.Rank, t17: collections_Tally.Tally): boolean => { + rt.hashRetain(ranks, (r2: Rank.Rank, t17: Tally.Tally): boolean => { if (!(rt.u16Rem(t17.n, 2) === 0)) { return Rank.eq$cmp_PartialEq(r2, { tag: "Low" } as Rank.Rank); } return true; }); - const _486: rt.Iter<[Rank.Rank, rt.u16]> = rt.iterMap(rt.hashIter(ranks), (_230: [Rank.Rank, collections_Tally.Tally]): [Rank.Rank, rt.u16] => { + const _486: rt.Iter<[Rank.Rank, rt.u16]> = rt.iterMap(rt.hashIter(ranks), (_230: [Rank.Rank, Tally.Tally]): [Rank.Rank, rt.u16] => { return [_230[0], _230[1].n] as [Rank.Rank, rt.u16]; }); const iter14: rt.Iter<[Rank.Rank, rt.u16]> = rt.btreeIter(rt.btreeExtend(rt.btreeNew(Rank.cmp$cmp_Ord) as rt.BTreeMap, _486, true, undefined, undefined, "next", 6)); @@ -392,7 +392,7 @@ export function hashMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void return _2[1].length; }), rt.usizeAdd, 0) & 0xff); rt.byteVecPush(out, rt.hashLen(words) === 0 ? 1 : 0); - const clashes: rt.HashMap = rt.hashNew(rt.hashing(Clash.hash$Hash_hash_DefaultHasher as (a0: Clash.Clash, a1: rt.Hasher) => undefined, Clash.eq$cmp_PartialEq)) as rt.HashMap; + const clashes: rt.HashMap = rt.hashNew(rt.hashing(Clash.hash$Hash_hash_DefaultHasher as (a0: Clash.Clash, a1: rt.Hasher) => undefined, Clash.eq$cmp_PartialEq)) as rt.HashMap; const iter18: rt.Iter<[rt.usize, rt.u8]> = rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(data))); while (true) { const _568: [rt.usize, rt.u8] | rt.Done = iter18.next(); @@ -404,20 +404,20 @@ export function hashMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const k6: Clash.Clash = { _0: rt.u8Rem(b7, 8) }; const _576: rt.u8 = rt.u8Rem(rt.u8Div(b7, 8), 4); if (_576 === 0) { - rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashRemove(clashes, k6), 238, (t7: collections_Tally.Tally): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashRemove(clashes, k6), 238, (t7: Tally.Tally): rt.u8 => { return t7.n & 0xff; })); } else if (_576 === 1) { - rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashGet(clashes, k6), 221, (t6: collections_Tally.Tally): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashGet(clashes, k6), 221, (t6: Tally.Tally): rt.u8 => { return t6.n & 0xff; })); } else { - rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashInsert(clashes, k6, { n: i5 & 0xffff }), 204, (t5: collections_Tally.Tally): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1ht002r(rt.hashInsert(clashes, k6, { n: i5 & 0xffff }), 204, (t5: Tally.Tally): rt.u8 => { return t5.n & 0xff; })); } } - rt.hashRetain(clashes, (k7: Clash.Clash, t8: collections_Tally.Tally): boolean => { + rt.hashRetain(clashes, (k7: Clash.Clash, t8: Tally.Tally): boolean => { if (!(rt.u8Rem(k7._0, 3) !== 0)) { return rt.u16Rem(t8.n, 2) === 0; } @@ -427,7 +427,7 @@ export function hashMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void return k8._0; }); rt.iterExtendBytes(out, rt.btreeKeys(rt.btreeExtendKeys(rt.btreeNew(rt.cmp) as rt.BTreeSet, _596, true, undefined, "next", 1)), undefined, true); - const copy3: rt.HashMap = rt.hashClone(clashes, undefined, copy$collections_Tally); + const copy3: rt.HashMap = rt.hashClone(clashes, undefined, copy$collections_Tally); rt.byteVecPush(out, rt.hashLen(copy3) & 0xff); rt.byteVecPush(out, rt.hashContains(copy3, { _0: 1 }) ? 1 : 0); } @@ -437,24 +437,24 @@ export function hashMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void * Matching on an entry: add to an even tally, take out an odd one, or start one. * Counts a write, and gives back the hasher. */ -export function countedHasher(h: rt.Hasher, counted: collections_Tally.Tally): rt.Hasher { +export function countedHasher(h: rt.Hasher, counted: Tally.Tally): rt.Hasher { counted.n = rt.u16Add(counted.n, 1); return h; } /** Inserts a key, and gives back the map. */ -export function stamp(map: rt.HashMap): rt.HashMap { - rt.hashInsert(map, rt.hashLen(map) & 0xff, copy$collections_Tally(collections_Tally.default$Default())); +export function stamp(map: rt.HashMap): rt.HashMap { + rt.hashInsert(map, rt.hashLen(map) & 0xff, copy$collections_Tally(Tally.default$Default())); return map; } -export function claim(map: rt.HashMap, k: rt.u8, n: rt.u16): rt.u8 { - const _4: rt.Entry = rt.entry(map, k); +export function claim(map: rt.HashMap, k: rt.u8, n: rt.u16): rt.u8 { + const _4: rt.Entry = rt.entry(map, k); if (rt.entryOccupied(_4)) { if (!(rt.u16Rem(rt.entryGet(_4).n, 2) === 0)) { return rt.entryRemove(_4).n & 0xff; } - const t: collections_Tally.Tally = rt.entryGet(_4); + const t: Tally.Tally = rt.entryGet(_4); t.n = rt.u16Add(t.n, n); return 1; } @@ -464,13 +464,13 @@ export function claim(map: rt.HashMap, k: rt.u8, /** `HashSet` and `BTreeSet`, each with the same script. */ export function sets(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { - const _159: (a0: collections_Nibble.Nibble | undefined) => rt.u8 = (n2: collections_Nibble.Nibble | undefined): rt.u8 => { - return option_mapOr$0q0ymkh(n2, 238, (n3: collections_Nibble.Nibble): rt.u8 => { + const _159: (a0: Nibble.Nibble | undefined) => rt.u8 = (n2: Nibble.Nibble | undefined): rt.u8 => { + return option_mapOr$0q0ymkh(n2, 238, (n3: Nibble.Nibble): rt.u8 => { return n3._0; }); }; - const _160: (a0: collections_Nibble.Nibble | undefined) => rt.u8 = (n4: collections_Nibble.Nibble | undefined): rt.u8 => { - return option_mapOr$0q0ymkh(n4, 238, (n5: collections_Nibble.Nibble): rt.u8 => { + const _160: (a0: Nibble.Nibble | undefined) => rt.u8 = (n4: Nibble.Nibble | undefined): rt.u8 => { + return option_mapOr$0q0ymkh(n4, 238, (n5: Nibble.Nibble): rt.u8 => { return n5._0; }); }; @@ -537,8 +537,8 @@ export function sets(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { return v7 & 0xff; }), undefined, true); } else if (_4 === 1) { - const nibbles: rt.BTreeSet = rt.btreeNew(collections_Nibble.cmp$cmp_Ord) as rt.BTreeSet; - const seen: rt.HashSet = rt.hashNew(rt.hashing(collections_Nibble.hash$Hash_hash_DefaultHasher as (a0: collections_Nibble.Nibble, a1: rt.Hasher) => undefined, collections_Nibble.eq$cmp_PartialEq)) as rt.HashSet; + const nibbles: rt.BTreeSet = rt.btreeNew(Nibble.cmp$cmp_Ord) as rt.BTreeSet; + const seen: rt.HashSet = rt.hashNew(rt.hashing(Nibble.hash$Hash_hash_DefaultHasher as (a0: Nibble.Nibble, a1: rt.Hasher) => undefined, Nibble.eq$cmp_PartialEq)) as rt.HashSet; for (const b2 of rt.byteSliceView(data)) { rt.byteVecPush(out, rt.btreeAdd(nibbles, { _0: b2 }) ? 1 : 0); rt.byteVecPush(out, rt.hashAdd(seen, { _0: b2 }) ? 1 : 0); @@ -568,23 +568,23 @@ export function sets(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_205, _160(part2))), undefined, true); } } - rt.iterExtendBytes(out, rt.iterOption(option_map$09ua5et(rt.hashKey(seen, { _0: 0 }), (n6: collections_Nibble.Nibble): rt.u8 => { + rt.iterExtendBytes(out, rt.iterOption(option_map$09ua5et(rt.hashKey(seen, { _0: 0 }), (n6: Nibble.Nibble): rt.u8 => { return n6._0; })), undefined, true); - const iter7: rt.Iter = rt.btreeKeys(nibbles); + const iter7: rt.Iter = rt.btreeKeys(nibbles); while (true) { - const _229: collections_Nibble.Nibble | rt.Done = iter7.next(); + const _229: Nibble.Nibble | rt.Done = iter7.next(); if (_229 === rt.DONE) { break; } rt.byteVecPush(out, _229._0); } while (true) { - const _235: collections_Nibble.Nibble | undefined = rt.btreePopKey(nibbles, true); + const _235: Nibble.Nibble | undefined = rt.btreePopKey(nibbles, true); if (_235 !== undefined) { rt.byteVecPush(out, _235._0); if (rt.usizeRem(rt.btreeLen(nibbles), 2) === 0) { - rt.byteVecPush(out, option_mapOr$0q0ymkh(rt.btreePopKey(nibbles), 238, (n7: collections_Nibble.Nibble): rt.u8 => { + rt.byteVecPush(out, option_mapOr$0q0ymkh(rt.btreePopKey(nibbles), 238, (n7: Nibble.Nibble): rt.u8 => { return n7._0; })); } @@ -593,13 +593,13 @@ export function sets(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } } rt.byteVecPush(out, rt.hashLen(seen) & 0xff); - const dirs: rt.HashSet = rt.hashNew(rt.hashing(collections_Dir.hash$Hash_hash_DefaultHasher as (a0: collections_Dir.Dir, a1: rt.Hasher) => undefined, collections_Dir.eq$cmp_PartialEq, true)) as rt.HashSet; + const dirs: rt.HashSet = rt.hashNew(rt.hashing(Dir.hash$Hash_hash_DefaultHasher as (a0: Dir.Dir, a1: rt.Hasher) => undefined, Dir.eq$cmp_PartialEq, true)) as rt.HashSet; for (const _257 of rt.byteSliceView(data)) { const _266: rt.usize = rt.usizeRem(_257 as rt.usize, 3); if (!(_266 < 3)) { rt.panic("index out of bounds: the len is " + 3 + " but the index is " + _266); } - rt.byteVecPush(out, rt.hashAdd(dirs, ["Up" as collections_Dir.Dir, "Top" as collections_Dir.Dir, "Down" as collections_Dir.Dir][_266]) ? 1 : 0); + rt.byteVecPush(out, rt.hashAdd(dirs, ["Up" as Dir.Dir, "Top" as Dir.Dir, "Down" as Dir.Dir][_266]) ? 1 : 0); } rt.byteVecPush(out, rt.hashLen(dirs) & 0xff); } else { @@ -746,7 +746,7 @@ export function btreeMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi rt.byteVecExtendFromSlice(out, rt.byteVecSlice(within)); rt.iterExtendBytes(out, rt.btreeValues(map), undefined, true); } else if (_4 === 1) { - const ranks: rt.BTreeMap = rt.btreeNew(Rank.cmp$cmp_Ord) as rt.BTreeMap; + const ranks: rt.BTreeMap = rt.btreeNew(Rank.cmp$cmp_Ord) as rt.BTreeMap; const pairs: rt.BTreeMap<[rt.u8, rt.u8], rt.u8> = rt.btreeNew(rt.cmpTuple<[rt.u8, rt.u8], rt.Ordering>([rt.cmp, rt.cmp])) as rt.BTreeMap<[rt.u8, rt.u8], rt.u8>; const wides: rt.BTreeMap = rt.btreeNew(rt.cmp) as rt.BTreeMap; let iterStart: rt.usize = 1; @@ -761,22 +761,22 @@ export function btreeMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi const a: rt.u8 = _192; const b: rt.u8 = _191[1]; const _203: Rank.Rank = rank(a, b); - const t: collections_Tally.Tally = rt.entryOrInsertWith(rt.entry(ranks, _203), collections_Tally.default$Default); + const t: Tally.Tally = rt.entryOrInsertWith(rt.entry(ranks, _203), Tally.default$Default); t.n = rt.u16WrappingAdd(t.n, b as rt.u16); const _209: [rt.u8, rt.u8] = [rt.u8Rem(a, 4), rt.u8Rem(b, 4)]; rt.btreeInsert(pairs, _209, a); const _217: rt.u64 = wide(a); rt.entryOrInsertMut(rt.entry(wides, _217), b); } - const _218: collections_Tally.Tally | undefined = rt.btreeGet(ranks, { tag: "Low" } as Rank.Rank); + const _218: Tally.Tally | undefined = rt.btreeGet(ranks, { tag: "Low" } as Rank.Rank); if (_218 !== undefined) { _218.n = _218.n ^ 23130; } for (const b2 of rt.byteSliceView(data)) { const r: Rank.Rank = rank(b2, rt.u8Div(b2, 3)); - const _233: rt.Entry = rt.entry(ranks, r); + const _233: rt.Entry = rt.entry(ranks, r); if (!rt.entryOccupied(_233)) { - const e: rt.Entry = _233; + const e: rt.Entry = _233; rt.byteVecPush(out, rankByte(rt.entryKey(e))); rt.entryOrInsert(e, { n: b2 as rt.u16 }); } else if (!(rt.entryGet(_233).n > 256)) { @@ -785,9 +785,9 @@ export function btreeMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi rt.byteVecPush(out, rankByte(rt.entryRemoveEntry(_233)[0])); } } - const iter7: rt.Iter<[Rank.Rank, collections_Tally.Tally]> = rt.btreeIter(ranks); + const iter7: rt.Iter<[Rank.Rank, Tally.Tally]> = rt.btreeIter(ranks); while (true) { - const _261: [Rank.Rank, collections_Tally.Tally] | rt.Done = iter7.next(); + const _261: [Rank.Rank, Tally.Tally] | rt.Done = iter7.next(); if (_261 === rt.DONE) { break; } @@ -827,20 +827,20 @@ export function btreeMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi rt.byteVecPush(out, _315[0]._0 ^ _315[1]._0); } } else { - const nibbles: rt.BTreeMap = rt.btreeNew(collections_Nibble.cmp$cmp_Ord) as rt.BTreeMap; - const words: rt.BTreeMap = rt.btreeNew(rt.cmpStr) as rt.BTreeMap; + const nibbles: rt.BTreeMap = rt.btreeNew(Nibble.cmp$cmp_Ord) as rt.BTreeMap; + const words: rt.BTreeMap = rt.btreeNew(rt.cmpStr) as rt.BTreeMap; for (const b3 of rt.byteSliceView(data)) { rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeInsert(nibbles, { _0: b3 }, b3), 204)); const _341: rt.usize = rt.usizeRem(b3 as rt.usize, ["", "a", "ab", "b", "é", "", "￿", "𐀀"].length); if (!(_341 < 8)) { rt.panic("index out of bounds: the len is " + 8 + " but the index is " + _341); } - const t2: collections_Tally.Tally = rt.entryOrInsertWith(rt.entry(words, ["", "a", "ab", "b", "é", "", "￿", "𐀀"][_341]), collections_Tally.default$Default); + const t2: Tally.Tally = rt.entryOrInsertWith(rt.entry(words, ["", "a", "ab", "b", "é", "", "￿", "𐀀"][_341]), Tally.default$Default); t2.n = rt.u16Add(t2.n, 1); } - const iter12: rt.Iter<[collections_Nibble.Nibble, rt.u8]> = rt.btreeIter(nibbles); + const iter12: rt.Iter<[Nibble.Nibble, rt.u8]> = rt.btreeIter(nibbles); while (true) { - const _352: [collections_Nibble.Nibble, rt.u8] | rt.Done = iter12.next(); + const _352: [Nibble.Nibble, rt.u8] | rt.Done = iter12.next(); if (_352 === rt.DONE) { break; } @@ -853,11 +853,11 @@ export function btreeMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi const i3: rt.usize = _365; const _374: rt.usize = rt.usizeSub(i3, 1); rt.idx(data, _374); - const _372: collections_Nibble.Nibble = { _0: data.data[data.start + _374] }; + const _372: Nibble.Nibble = { _0: data.data[data.start + _374] }; rt.idx(data, i3); - const _371: [collections_Nibble.Nibble, collections_Nibble.Nibble] = [_372, { _0: data.data[data.start + i3] }]; - const a2: collections_Nibble.Nibble = _372; - const b4: collections_Nibble.Nibble = _371[1]; + const _371: [Nibble.Nibble, Nibble.Nibble] = [_372, { _0: data.data[data.start + i3] }]; + const a2: Nibble.Nibble = _372; + const b4: Nibble.Nibble = _371[1]; const _386: rt.usize = rt.usizeSub(i3, 1); rt.idx(data, _386); const _385: rt.u8 = data.data[data.start + _386]; @@ -865,10 +865,10 @@ export function btreeMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi const _384: [rt.u8, rt.u8] = [_385, data.data[data.start + i3]]; const x: rt.u8 = _385; const y: rt.u8 = _384[1]; - const o: rt.Ordering = rt.orderingThen(rt.orderingReverse(collections_Nibble.cmp$cmp_Ord(a2, b4)), (): rt.Ordering => { + const o: rt.Ordering = rt.orderingThen(rt.orderingReverse(Nibble.cmp$cmp_Ord(a2, b4)), (): rt.Ordering => { return rt.cmp(y, x); }, true); - rt.byteVecPush(out, (o < 0 ? 1 : 0) | (((o >= 0 ? 1 : 0) << 1) & 0xff) | (((rt.orderingThen(collections_Nibble.cmp$cmp_Ord(a2, b4), -1 as rt.Ordering) === 0 ? 1 : 0) << 2) & 0xff)); + rt.byteVecPush(out, (o < 0 ? 1 : 0) | (((o >= 0 ? 1 : 0) << 1) & 0xff) | (((rt.orderingThen(Nibble.cmp$cmp_Ord(a2, b4), -1 as rt.Ordering) === 0 ? 1 : 0) << 2) & 0xff)); if (o === -1) { _422 = 1; } else if (o === 0) { @@ -879,22 +879,22 @@ export function btreeMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi rt.byteVecPush(out, _422); rt.byteVecPush(out, o === 1 ? 1 : 0); } - const _430: rt.Iter<[collections_Nibble.Nibble, rt.u8]> = rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): [collections_Nibble.Nibble, rt.u8] => { + const _430: rt.Iter<[Nibble.Nibble, rt.u8]> = rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): [Nibble.Nibble, rt.u8] => { const b5: rt.u8 = _2; - return [{ _0: b5 }, b5] as [collections_Nibble.Nibble, rt.u8]; + return [{ _0: b5 }, b5] as [Nibble.Nibble, rt.u8]; }); - const collected: rt.BTreeMap = rt.btreeCollect(rt.btreeNew(collections_Nibble.cmp$cmp_Ord) as rt.BTreeMap, rt.iterToArray(_430, undefined, 2, true), 2, true, collections_Nibble.eq$cmp_PartialEq); - const _433: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_216: rt.u8): collections_Nibble.Nibble => { + const collected: rt.BTreeMap = rt.btreeCollect(rt.btreeNew(Nibble.cmp$cmp_Ord) as rt.BTreeMap, rt.iterToArray(_430, undefined, 2, true), 2, true, Nibble.eq$cmp_PartialEq); + const _433: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_216: rt.u8): Nibble.Nibble => { return { _0: _216 }; }); - const keys: rt.BTreeSet = rt.btreeCollectKeys(rt.btreeNew(collections_Nibble.cmp$cmp_Ord) as rt.BTreeSet, rt.iterToArray(_433, undefined, 1, true), 1, true, rt.cmpLt(collections_Nibble.partialCmp$cmp_PartialOrd), collections_Nibble.eq$cmp_PartialEq); - const _437: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_219: rt.u8): collections_Nibble.Nibble => { + const keys: rt.BTreeSet = rt.btreeCollectKeys(rt.btreeNew(Nibble.cmp$cmp_Ord) as rt.BTreeSet, rt.iterToArray(_433, undefined, 1, true), 1, true, rt.cmpLt(Nibble.partialCmp$cmp_PartialOrd), Nibble.eq$cmp_PartialEq); + const _437: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_219: rt.u8): Nibble.Nibble => { return { _0: _219 ^ 48 }; }); rt.btreeExtendKeys(keys, _437); - const iter14: rt.Iter<[[collections_Nibble.Nibble, rt.u8], collections_Nibble.Nibble]> = rt.iterZip(rt.btreeIter(collected), rt.btreeKeys(keys), "len"); + const iter14: rt.Iter<[[Nibble.Nibble, rt.u8], Nibble.Nibble]> = rt.iterZip(rt.btreeIter(collected), rt.btreeKeys(keys), "len"); while (true) { - const _446: [[collections_Nibble.Nibble, rt.u8], collections_Nibble.Nibble] | rt.Done = iter14.next(); + const _446: [[Nibble.Nibble, rt.u8], Nibble.Nibble] | rt.Done = iter14.next(); if (_446 === rt.DONE) { break; } @@ -902,15 +902,15 @@ export function btreeMaps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi rt.byteVecPush(out, _446[0][1]); rt.byteVecPush(out, _446[1]._0); } - rt.btreeRetain(words, (w: string, t3: collections_Tally.Tally): boolean => { + rt.btreeRetain(words, (w: string, t3: Tally.Tally): boolean => { if (!(rt.stringLen(w) > 1)) { return t3.n > 1; } return true; }); - const iter15: rt.Iter<[string, collections_Tally.Tally]> = rt.btreeIter(words); + const iter15: rt.Iter<[string, Tally.Tally]> = rt.btreeIter(words); while (true) { - const _463: [string, collections_Tally.Tally] | rt.Done = iter15.next(); + const _463: [string, Tally.Tally] | rt.Done = iter15.next(); if (_463 === rt.DONE) { break; } @@ -978,43 +978,43 @@ export function deques(data: rt.ByteSlice, out: rt.ByteVec): void { } rt.byteVecExtendFromSlice(out, rt.byteVecSlice(rt.iterToByteVec(rt.dequeDrain(q, undefined), "next"))); rt.byteVecPush(out, q.n === 0 ? 1 : 0); - const tallies: rt.VecDeque = rt.dequeFromVec(rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_25: rt.u8): collections_Tally.Tally => { + const tallies: rt.VecDeque = rt.dequeFromVec(rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_25: rt.u8): Tally.Tally => { return { n: _25 as rt.u16 }; - }), undefined, 2, true), 2) as rt.VecDeque; - const copy: rt.VecDeque = rt.dequeClone(tallies, copy$collections_Tally); - const _115: collections_Tally.Tally | undefined = rt.dequeEnd(copy); + }), undefined, 2, true), 2) as rt.VecDeque; + const copy: rt.VecDeque = rt.dequeClone(tallies, copy$collections_Tally); + const _115: Tally.Tally | undefined = rt.dequeEnd(copy); if (_115 !== undefined) { _115.n = _115.n ^ 255; } - rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(tallies), (t2: collections_Tally.Tally): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(tallies), (t2: Tally.Tally): rt.u8 => { return t2.n & 0xff; }), undefined, true); - rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(copy), (t3: collections_Tally.Tally): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(copy), (t3: Tally.Tally): rt.u8 => { return t3.n & 0xff; }), undefined, true); - const _129: rt.Iter = rt.dequeIter(tallies); + const _129: rt.Iter = rt.dequeIter(tallies); rt.dequeExtend(copy, rt.iterMap(_129, copy$collections_Tally), undefined, true); - const _131: collections_Tally.Tally | undefined = rt.dequeEnd(copy, true); + const _131: Tally.Tally | undefined = rt.dequeEnd(copy, true); if (_131 !== undefined) { _131.n = _131.n ^ 255; } - rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(tallies), (t4: collections_Tally.Tally): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(tallies), (t4: Tally.Tally): rt.u8 => { return t4.n & 0xff; }), undefined, true); - rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(copy), (t5: collections_Tally.Tally): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(copy), (t5: Tally.Tally): rt.u8 => { return t5.n & 0xff; }), undefined, true); - const iter3: rt.Iter = rt.iterSlice([copy$Option_collections_Tally(rt.dequeSwapRemove(copy, at)), copy$Option_collections_Tally(rt.dequeSwapRemove(copy, at, true))]); + const iter3: rt.Iter = rt.iterSlice([copy$Option_collections_Tally(rt.dequeSwapRemove(copy, at)), copy$Option_collections_Tally(rt.dequeSwapRemove(copy, at, true))]); while (true) { - const _150: collections_Tally.Tally | undefined | rt.Done = iter3.next(); + const _150: Tally.Tally | undefined | rt.Done = iter3.next(); if (_150 === rt.DONE) { break; } - rt.byteVecPush(out, option_mapOr$1ht002r(_150, 230, (t6: collections_Tally.Tally): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1ht002r(_150, 230, (t6: Tally.Tally): rt.u8 => { return t6.n & 0xff; })); } - rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(copy), (t7: collections_Tally.Tally): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(copy), (t7: Tally.Tally): rt.u8 => { return t7.n & 0xff; }), undefined, true); const _162: rt.Iter = rt.iterSlice(rt.byteSliceView(data)); @@ -1182,8 +1182,8 @@ export function vecs(data: rt.ByteSlice, out: rt.ByteVec): void { listed[at4][0] = listed[at4][0] ^ 255; const repeated: [rt.u8, rt.u8][] = rt.vecFromElem(copy$tuple2_u8_u8(pair), n, copy$tuple2_u8_u8); const again: [rt.u8, rt.u8][] = rt.vecFromElem(copy$tuple2_u8_u8(pair), n, copy$tuple2_u8_u8); - const bumps: Bumped.Bumped[] = rt.vecFromElem(copy$iters_Bumped(held), n, Bumped.clone$Clone); - const kept: Bumped.Bumped[] = rt.vecFromElem(copy$iters_Bumped(held), n, Bumped.clone$Clone); + const bumps: Bumped.Bumped[] = rt.vecFromElem(copy$collections_Bumped(held), n, Bumped.clone$Clone); + const kept: Bumped.Bumped[] = rt.vecFromElem(copy$collections_Bumped(held), n, Bumped.clone$Clone); if (n > 0) { const at5 = rt.idx(repeated, rt.usizeSub(n, 1)); repeated[at5][1] = repeated[at5][1] ^ 255; @@ -1208,7 +1208,7 @@ export function vecs(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _183.length & 0xff); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(_183)); } - const wrapped: Wrap.Wrap[] = rt.vecFromElem(new Wrap.Wrap(a, b), n, copy$generics_Wrap_u8); + const wrapped: Wrap.Wrap[] = rt.vecFromElem(new Wrap.Wrap(a, b), n, copy$collections_Wrap_u8); if (n > 0) { const _195: Wrap.Wrap[] = wrapped; const _197: rt.usize = rt.usizeSub(n, 1); @@ -1286,20 +1286,20 @@ export function stores(data: rt.ByteSlice, out: rt.ByteVec): void { return Uint8Array.of(p[0], p[1]); }, (value: Uint8Array) => rt.iterSlice(value), false, 2), undefined, true); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(changed[0], changed[1], old[0], old[1]))); - const tally: collections_Tally.Tally = { n: a as rt.u16 }; - const q: rt.VecDeque = rt.dequeNew(2) as rt.VecDeque; + const tally: Tally.Tally = { n: a as rt.u16 }; + const q: rt.VecDeque = rt.dequeNew(2) as rt.VecDeque; rt.dequePushBack(q, copy$collections_Tally(tally)); rt.dequePushFront(q, copy$collections_Tally(tally)); rt.dequeInsert(q, 1, copy$collections_Tally(tally)); - const _68: collections_Tally.Tally | undefined = rt.dequeEnd(q); + const _68: Tally.Tally | undefined = rt.dequeEnd(q); if (_68 !== undefined) { _68.n = _68.n ^ 1; } - const _72: collections_Tally.Tally | undefined = rt.dequeEnd(q, true); + const _72: Tally.Tally | undefined = rt.dequeEnd(q, true); if (_72 !== undefined) { _72.n = _72.n ^ 2; } - rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(q), (t: collections_Tally.Tally): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.dequeIter(q), (t: Tally.Tally): rt.u8 => { return t.n & 0xff; }), undefined, true); rt.byteVecPush(out, tally.n & 0xff); @@ -1808,9 +1808,9 @@ export function setOps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { return option_unwrapOr$0r2bmpr(v2, 238); }, out); } else if (_55 === 3) { - setOpsOf$collections_Nibble(left, right, (a0: rt.u8): collections_Nibble.Nibble => { + setOpsOf$collections_Nibble(left, right, (a0: rt.u8): Nibble.Nibble => { return { _0: a0 }; - }, (n: collections_Nibble.Nibble): rt.u8 => { + }, (n: Nibble.Nibble): rt.u8 => { return n._0; }, out); } else { @@ -2114,18 +2114,18 @@ export function setOpsOf$cmp_Reverse_Option_u8(left: rt.ByteSlice, right: rt.Byt } } -export function setOpsOf$collections_Nibble(left: rt.ByteSlice, right: rt.ByteSlice, make: (a0: rt.u8) => collections_Nibble.Nibble, put: (a0: collections_Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { - const _7: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(left)), (_2: rt.u8): collections_Nibble.Nibble => { +export function setOpsOf$collections_Nibble(left: rt.ByteSlice, right: rt.ByteSlice, make: (a0: rt.u8) => Nibble.Nibble, put: (a0: Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { + const _7: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(left)), (_2: rt.u8): Nibble.Nibble => { return make(_2); }); - const a: rt.BTreeSet = rt.btreeCollectKeys(rt.btreeNew(collections_Nibble.cmp$cmp_Ord) as rt.BTreeSet, rt.iterToArray(_7, undefined, 1, true), 1, true, rt.cmpLt(collections_Nibble.partialCmp$cmp_PartialOrd), collections_Nibble.eq$cmp_PartialEq); - const _12: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(right)), (_22: rt.u8): collections_Nibble.Nibble => { + const a: rt.BTreeSet = rt.btreeCollectKeys(rt.btreeNew(Nibble.cmp$cmp_Ord) as rt.BTreeSet, rt.iterToArray(_7, undefined, 1, true), 1, true, rt.cmpLt(Nibble.partialCmp$cmp_PartialOrd), Nibble.eq$cmp_PartialEq); + const _12: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(right)), (_22: rt.u8): Nibble.Nibble => { return make(_22); }); - const b: rt.BTreeSet = rt.btreeCollectKeys(rt.btreeNew(collections_Nibble.cmp$cmp_Ord) as rt.BTreeSet, rt.iterToArray(_12, undefined, 1, true), 1, true, rt.cmpLt(collections_Nibble.partialCmp$cmp_PartialOrd), collections_Nibble.eq$cmp_PartialEq); - const iter: rt.Iter<[rt.BTreeSet, rt.BTreeSet]> = rt.iterSlice([[a, b] as [rt.BTreeSet, rt.BTreeSet], [b, a] as [rt.BTreeSet, rt.BTreeSet]]); + const b: rt.BTreeSet = rt.btreeCollectKeys(rt.btreeNew(Nibble.cmp$cmp_Ord) as rt.BTreeSet, rt.iterToArray(_12, undefined, 1, true), 1, true, rt.cmpLt(Nibble.partialCmp$cmp_PartialOrd), Nibble.eq$cmp_PartialEq); + const iter: rt.Iter<[rt.BTreeSet, rt.BTreeSet]> = rt.iterSlice([[a, b] as [rt.BTreeSet, rt.BTreeSet], [b, a] as [rt.BTreeSet, rt.BTreeSet]]); while (true) { - const _25: [rt.BTreeSet, rt.BTreeSet] | rt.Done = iter.next(); + const _25: [rt.BTreeSet, rt.BTreeSet] | rt.Done = iter.next(); if (_25 === rt.DONE) { break; } @@ -2142,28 +2142,28 @@ export function setOpsOf$collections_Nibble(left: rt.ByteSlice, right: rt.ByteSl rt.byteVecPush(out, option_mapOr$0q0ymkh(rt.iterToOption(rt.btreeDifference(_25[0], _25[1]).next()), 221, put)); rt.byteVecPush(out, option_mapOr$0q0ymkh(rt.iterToOption(rt.btreeSymmetricDifference(_25[0], _25[1]).next()), 221, put)); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(rt.btreeIsSubset(_25[0], _25[1]) ? 1 : 0, rt.btreeIsSuperset(_25[0], _25[1]) ? 1 : 0, rt.btreeIsDisjoint(_25[0], _25[1]) ? 1 : 0)), undefined, true); - const iter2: rt.Iter> = rt.iterSlice([rt.btreeFromSorted(rt.btreeNew(collections_Nibble.cmp$cmp_Ord) as rt.BTreeSet, rt.btreeUnion(_25[0], _25[1]), collections_Nibble.eq$cmp_PartialEq), rt.btreeFromSorted(rt.btreeNew(collections_Nibble.cmp$cmp_Ord) as rt.BTreeSet, rt.btreeIntersection(_25[0], _25[1]), collections_Nibble.eq$cmp_PartialEq), rt.btreeFromSorted(rt.btreeNew(collections_Nibble.cmp$cmp_Ord) as rt.BTreeSet, rt.btreeDifference(_25[0], _25[1]), collections_Nibble.eq$cmp_PartialEq), rt.btreeFromSorted(rt.btreeNew(collections_Nibble.cmp$cmp_Ord) as rt.BTreeSet, rt.btreeSymmetricDifference(_25[0], _25[1]), collections_Nibble.eq$cmp_PartialEq)]); + const iter2: rt.Iter> = rt.iterSlice([rt.btreeFromSorted(rt.btreeNew(Nibble.cmp$cmp_Ord) as rt.BTreeSet, rt.btreeUnion(_25[0], _25[1]), Nibble.eq$cmp_PartialEq), rt.btreeFromSorted(rt.btreeNew(Nibble.cmp$cmp_Ord) as rt.BTreeSet, rt.btreeIntersection(_25[0], _25[1]), Nibble.eq$cmp_PartialEq), rt.btreeFromSorted(rt.btreeNew(Nibble.cmp$cmp_Ord) as rt.BTreeSet, rt.btreeDifference(_25[0], _25[1]), Nibble.eq$cmp_PartialEq), rt.btreeFromSorted(rt.btreeNew(Nibble.cmp$cmp_Ord) as rt.BTreeSet, rt.btreeSymmetricDifference(_25[0], _25[1]), Nibble.eq$cmp_PartialEq)]); while (true) { - const _81: rt.BTreeSet | rt.Done = iter2.next(); + const _81: rt.BTreeSet | rt.Done = iter2.next(); if (_81 === rt.DONE) { break; } - const built: rt.BTreeSet = _81; + const built: rt.BTreeSet = _81; putAll$collections_Nibble_collections_btree_set_Iter_collections_Nibble(rt.btreeKeys(built), put, out); putAll$collections_Nibble_iter_Rev_collections_btree_set_Iter_collections_Nibble(rt.iterRev(rt.btreeKeys(built)), put, out); } } - const _93: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(left)), (_23: rt.u8): collections_Nibble.Nibble => { + const _93: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(left)), (_23: rt.u8): Nibble.Nibble => { return make(_23); }); - const a2: rt.HashSet = rt.hashExtendKeys(rt.hashNew(rt.hashing(collections_Nibble.hash$Hash_hash_DefaultHasher as (a0: collections_Nibble.Nibble, a1: rt.Hasher) => undefined, collections_Nibble.eq$cmp_PartialEq)) as rt.HashSet, _93, undefined, undefined, 469762048); - const _98: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(right)), (_24: rt.u8): collections_Nibble.Nibble => { + const a2: rt.HashSet = rt.hashExtendKeys(rt.hashNew(rt.hashing(Nibble.hash$Hash_hash_DefaultHasher as (a0: Nibble.Nibble, a1: rt.Hasher) => undefined, Nibble.eq$cmp_PartialEq)) as rt.HashSet, _93, undefined, undefined, 469762048); + const _98: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(right)), (_24: rt.u8): Nibble.Nibble => { return make(_24); }); - const b2: rt.HashSet = rt.hashExtendKeys(rt.hashNew(rt.hashing(collections_Nibble.hash$Hash_hash_DefaultHasher as (a0: collections_Nibble.Nibble, a1: rt.Hasher) => undefined, collections_Nibble.eq$cmp_PartialEq)) as rt.HashSet, _98, undefined, undefined, 469762048); - const iter3: rt.Iter<[rt.HashSet, rt.HashSet]> = rt.iterSlice([[a2, b2] as [rt.HashSet, rt.HashSet], [b2, a2] as [rt.HashSet, rt.HashSet]]); + const b2: rt.HashSet = rt.hashExtendKeys(rt.hashNew(rt.hashing(Nibble.hash$Hash_hash_DefaultHasher as (a0: Nibble.Nibble, a1: rt.Hasher) => undefined, Nibble.eq$cmp_PartialEq)) as rt.HashSet, _98, undefined, undefined, 469762048); + const iter3: rt.Iter<[rt.HashSet, rt.HashSet]> = rt.iterSlice([[a2, b2] as [rt.HashSet, rt.HashSet], [b2, a2] as [rt.HashSet, rt.HashSet]]); while (true) { - const _111: [rt.HashSet, rt.HashSet] | rt.Done = iter3.next(); + const _111: [rt.HashSet, rt.HashSet] | rt.Done = iter3.next(); if (_111 === rt.DONE) { break; } @@ -2175,7 +2175,7 @@ export function setOpsOf$collections_Nibble(left: rt.ByteSlice, right: rt.ByteSl putHints$collections_Nibble_collections_hash_set_Intersection_collections_Nibble_hash_RandomState(rt.hashIntersection(_111[0], _111[1]), 0, out); putHints$collections_Nibble_collections_hash_set_Difference_collections_Nibble_hash_RandomState(rt.hashDifference(_111[0], _111[1]), 0, out); putHints$collections_Nibble_collections_hash_set_SymmetricDifference_collections_Nibble_hash_RandomState(rt.hashSymmetricDifference(_111[0], _111[1]), 0, out); - rt.byteVecPush(out, option_mapOr$0q0ymkh(rt.iterToOption(rt.hashUnion(_111[0], _111[1]).next()), 221, (v: collections_Nibble.Nibble): rt.u8 => { + rt.byteVecPush(out, option_mapOr$0q0ymkh(rt.iterToOption(rt.hashUnion(_111[0], _111[1]).next()), 221, (v: Nibble.Nibble): rt.u8 => { let _3!: boolean; if (!rt.hashContains(_111[0], v)) { _3 = rt.hashContains(_111[1], v); @@ -2184,7 +2184,7 @@ export function setOpsOf$collections_Nibble(left: rt.ByteSlice, right: rt.ByteSl } return _3 ? 1 : 0; })); - rt.byteVecPush(out, option_mapOr$0q0ymkh(rt.iterToOption(rt.hashIntersection(_111[0], _111[1]).next()), 221, (v2: collections_Nibble.Nibble): rt.u8 => { + rt.byteVecPush(out, option_mapOr$0q0ymkh(rt.iterToOption(rt.hashIntersection(_111[0], _111[1]).next()), 221, (v2: Nibble.Nibble): rt.u8 => { let _32!: boolean; if (!rt.hashContains(_111[0], v2)) { _32 = false; @@ -2193,16 +2193,16 @@ export function setOpsOf$collections_Nibble(left: rt.ByteSlice, right: rt.ByteSl } return _32 ? 1 : 0; })); - rt.byteVecPush(out, option_mapOr$0q0ymkh(rt.iterToOption(rt.hashDifference(_111[0], _111[1]).next()), 221, (v3: collections_Nibble.Nibble): rt.u8 => { + rt.byteVecPush(out, option_mapOr$0q0ymkh(rt.iterToOption(rt.hashDifference(_111[0], _111[1]).next()), 221, (v3: Nibble.Nibble): rt.u8 => { return !rt.hashContains(_111[1], v3) ? 1 : 0; })); - rt.byteVecPush(out, option_mapOr$0q0ymkh(rt.iterToOption(rt.hashSymmetricDifference(_111[0], _111[1]).next()), 221, (v4: collections_Nibble.Nibble): rt.u8 => { + rt.byteVecPush(out, option_mapOr$0q0ymkh(rt.iterToOption(rt.hashSymmetricDifference(_111[0], _111[1]).next()), 221, (v4: Nibble.Nibble): rt.u8 => { return rt.hashContains(_111[0], v4) !== rt.hashContains(_111[1], v4) ? 1 : 0; })); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(rt.hashIsSubset(_111[0], _111[1]) ? 1 : 0, rt.hashIsSuperset(_111[0], _111[1]) ? 1 : 0, rt.hashIsDisjoint(_111[0], _111[1]) ? 1 : 0)), undefined, true); - const iter4: rt.Iter> = rt.iterSlice([rt.hashExtendKeys(rt.hashNew(rt.hashing(collections_Nibble.hash$Hash_hash_DefaultHasher as (a0: collections_Nibble.Nibble, a1: rt.Hasher) => undefined, collections_Nibble.eq$cmp_PartialEq)) as rt.HashSet, rt.hashUnion(_111[0], _111[1]), undefined, undefined, 469762048), rt.hashExtendKeys(rt.hashNew(rt.hashing(collections_Nibble.hash$Hash_hash_DefaultHasher as (a0: collections_Nibble.Nibble, a1: rt.Hasher) => undefined, collections_Nibble.eq$cmp_PartialEq)) as rt.HashSet, rt.hashIntersection(_111[0], _111[1]), undefined, undefined, 469762048), rt.hashExtendKeys(rt.hashNew(rt.hashing(collections_Nibble.hash$Hash_hash_DefaultHasher as (a0: collections_Nibble.Nibble, a1: rt.Hasher) => undefined, collections_Nibble.eq$cmp_PartialEq)) as rt.HashSet, rt.hashDifference(_111[0], _111[1]), undefined, undefined, 469762048), rt.hashExtendKeys(rt.hashNew(rt.hashing(collections_Nibble.hash$Hash_hash_DefaultHasher as (a0: collections_Nibble.Nibble, a1: rt.Hasher) => undefined, collections_Nibble.eq$cmp_PartialEq)) as rt.HashSet, rt.hashSymmetricDifference(_111[0], _111[1]), undefined, undefined, 469762048)]); + const iter4: rt.Iter> = rt.iterSlice([rt.hashExtendKeys(rt.hashNew(rt.hashing(Nibble.hash$Hash_hash_DefaultHasher as (a0: Nibble.Nibble, a1: rt.Hasher) => undefined, Nibble.eq$cmp_PartialEq)) as rt.HashSet, rt.hashUnion(_111[0], _111[1]), undefined, undefined, 469762048), rt.hashExtendKeys(rt.hashNew(rt.hashing(Nibble.hash$Hash_hash_DefaultHasher as (a0: Nibble.Nibble, a1: rt.Hasher) => undefined, Nibble.eq$cmp_PartialEq)) as rt.HashSet, rt.hashIntersection(_111[0], _111[1]), undefined, undefined, 469762048), rt.hashExtendKeys(rt.hashNew(rt.hashing(Nibble.hash$Hash_hash_DefaultHasher as (a0: Nibble.Nibble, a1: rt.Hasher) => undefined, Nibble.eq$cmp_PartialEq)) as rt.HashSet, rt.hashDifference(_111[0], _111[1]), undefined, undefined, 469762048), rt.hashExtendKeys(rt.hashNew(rt.hashing(Nibble.hash$Hash_hash_DefaultHasher as (a0: Nibble.Nibble, a1: rt.Hasher) => undefined, Nibble.eq$cmp_PartialEq)) as rt.HashSet, rt.hashSymmetricDifference(_111[0], _111[1]), undefined, undefined, 469762048)]); while (true) { - const _175: rt.HashSet | rt.Done = iter4.next(); + const _175: rt.HashSet | rt.Done = iter4.next(); if (_175 === rt.DONE) { break; } @@ -2645,12 +2645,12 @@ export function putAll$cmp_Reverse_Option_u8_vec_IntoIter_ref_cmp_Reverse_Option } /** How many `items` there are, then each. */ -export function putAll$collections_Nibble_collections_btree_set_Difference_collections_Nibble(items: rt.Iter, put: (a0: collections_Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { +export function putAll$collections_Nibble_collections_btree_set_Difference_collections_Nibble(items: rt.Iter, put: (a0: Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { const at: rt.usize = out.length; rt.byteVecPush(out, 0); - const iter: rt.Iter = items; + const iter: rt.Iter = items; while (true) { - const _9: collections_Nibble.Nibble | rt.Done = iter.next(); + const _9: Nibble.Nibble | rt.Done = iter.next(); if (_9 === rt.DONE) { break; } @@ -2661,12 +2661,12 @@ export function putAll$collections_Nibble_collections_btree_set_Difference_colle } /** How many `items` there are, then each. */ -export function putAll$collections_Nibble_collections_btree_set_Intersection_collections_Nibble(items: rt.Iter, put: (a0: collections_Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { +export function putAll$collections_Nibble_collections_btree_set_Intersection_collections_Nibble(items: rt.Iter, put: (a0: Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { const at: rt.usize = out.length; rt.byteVecPush(out, 0); - const iter: rt.Iter = items; + const iter: rt.Iter = items; while (true) { - const _9: collections_Nibble.Nibble | rt.Done = iter.next(); + const _9: Nibble.Nibble | rt.Done = iter.next(); if (_9 === rt.DONE) { break; } @@ -2677,12 +2677,12 @@ export function putAll$collections_Nibble_collections_btree_set_Intersection_col } /** How many `items` there are, then each. */ -export function putAll$collections_Nibble_collections_btree_set_Iter_collections_Nibble(items: rt.Iter, put: (a0: collections_Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { +export function putAll$collections_Nibble_collections_btree_set_Iter_collections_Nibble(items: rt.Iter, put: (a0: Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { const at: rt.usize = out.length; rt.byteVecPush(out, 0); - const iter: rt.Iter = items; + const iter: rt.Iter = items; while (true) { - const _9: collections_Nibble.Nibble | rt.Done = iter.next(); + const _9: Nibble.Nibble | rt.Done = iter.next(); if (_9 === rt.DONE) { break; } @@ -2693,12 +2693,12 @@ export function putAll$collections_Nibble_collections_btree_set_Iter_collections } /** How many `items` there are, then each. */ -export function putAll$collections_Nibble_collections_btree_set_SymmetricDifference_collections_Nibble(items: rt.Iter, put: (a0: collections_Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { +export function putAll$collections_Nibble_collections_btree_set_SymmetricDifference_collections_Nibble(items: rt.Iter, put: (a0: Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { const at: rt.usize = out.length; rt.byteVecPush(out, 0); - const iter: rt.Iter = items; + const iter: rt.Iter = items; while (true) { - const _9: collections_Nibble.Nibble | rt.Done = iter.next(); + const _9: Nibble.Nibble | rt.Done = iter.next(); if (_9 === rt.DONE) { break; } @@ -2709,12 +2709,12 @@ export function putAll$collections_Nibble_collections_btree_set_SymmetricDiffere } /** How many `items` there are, then each. */ -export function putAll$collections_Nibble_collections_btree_set_Union_collections_Nibble(items: rt.Iter, put: (a0: collections_Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { +export function putAll$collections_Nibble_collections_btree_set_Union_collections_Nibble(items: rt.Iter, put: (a0: Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { const at: rt.usize = out.length; rt.byteVecPush(out, 0); - const iter: rt.Iter = items; + const iter: rt.Iter = items; while (true) { - const _9: collections_Nibble.Nibble | rt.Done = iter.next(); + const _9: Nibble.Nibble | rt.Done = iter.next(); if (_9 === rt.DONE) { break; } @@ -2725,12 +2725,12 @@ export function putAll$collections_Nibble_collections_btree_set_Union_collection } /** How many `items` there are, then each. */ -export function putAll$collections_Nibble_iter_Rev_collections_btree_set_Iter_collections_Nibble(items: rt.Iter, put: (a0: collections_Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { +export function putAll$collections_Nibble_iter_Rev_collections_btree_set_Iter_collections_Nibble(items: rt.Iter, put: (a0: Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { const at: rt.usize = out.length; rt.byteVecPush(out, 0); - const iter: rt.Iter = items; + const iter: rt.Iter = items; while (true) { - const _9: collections_Nibble.Nibble | rt.Done = iter.next(); + const _9: Nibble.Nibble | rt.Done = iter.next(); if (_9 === rt.DONE) { break; } @@ -2741,12 +2741,12 @@ export function putAll$collections_Nibble_iter_Rev_collections_btree_set_Iter_co } /** How many `items` there are, then each. */ -export function putAll$collections_Nibble_vec_IntoIter_ref_collections_Nibble(items: rt.Iter, put: (a0: collections_Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { +export function putAll$collections_Nibble_vec_IntoIter_ref_collections_Nibble(items: rt.Iter, put: (a0: Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { const at: rt.usize = out.length; rt.byteVecPush(out, 0); - const iter: rt.Iter = items; + const iter: rt.Iter = items; while (true) { - const _9: collections_Nibble.Nibble | rt.Done = iter.next(); + const _9: Nibble.Nibble | rt.Done = iter.next(); if (_9 === rt.DONE) { break; } @@ -3301,7 +3301,7 @@ export function putHints$cmp_Reverse_Option_u8_collections_hash_set_Union_cmp_Re } /** The size hint of `items`, and again after each of `read` more. */ -export function putHints$collections_Nibble_collections_btree_set_Difference_collections_Nibble(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { +export function putHints$collections_Nibble_collections_btree_set_Difference_collections_Nibble(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { const iter: rt.RangeInclusive = new rt.RangeInclusive(0, read, rt.usizeStep); while (true) { const _7: rt.usize | rt.Done = iter.next(); @@ -3319,7 +3319,7 @@ export function putHints$collections_Nibble_collections_btree_set_Difference_col } /** The size hint of `items`, and again after each of `read` more. */ -export function putHints$collections_Nibble_collections_btree_set_Intersection_collections_Nibble(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { +export function putHints$collections_Nibble_collections_btree_set_Intersection_collections_Nibble(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { const iter: rt.RangeInclusive = new rt.RangeInclusive(0, read, rt.usizeStep); while (true) { const _7: rt.usize | rt.Done = iter.next(); @@ -3337,7 +3337,7 @@ export function putHints$collections_Nibble_collections_btree_set_Intersection_c } /** The size hint of `items`, and again after each of `read` more. */ -export function putHints$collections_Nibble_collections_btree_set_SymmetricDifference_collections_Nibble(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { +export function putHints$collections_Nibble_collections_btree_set_SymmetricDifference_collections_Nibble(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { const iter: rt.RangeInclusive = new rt.RangeInclusive(0, read, rt.usizeStep); while (true) { const _7: rt.usize | rt.Done = iter.next(); @@ -3355,7 +3355,7 @@ export function putHints$collections_Nibble_collections_btree_set_SymmetricDiffe } /** The size hint of `items`, and again after each of `read` more. */ -export function putHints$collections_Nibble_collections_btree_set_Union_collections_Nibble(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { +export function putHints$collections_Nibble_collections_btree_set_Union_collections_Nibble(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { const iter: rt.RangeInclusive = new rt.RangeInclusive(0, read, rt.usizeStep); while (true) { const _7: rt.usize | rt.Done = iter.next(); @@ -3373,7 +3373,7 @@ export function putHints$collections_Nibble_collections_btree_set_Union_collecti } /** The size hint of `items`, and again after each of `read` more. */ -export function putHints$collections_Nibble_collections_hash_set_Difference_collections_Nibble_hash_RandomState(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { +export function putHints$collections_Nibble_collections_hash_set_Difference_collections_Nibble_hash_RandomState(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { const iter: rt.RangeInclusive = new rt.RangeInclusive(0, read, rt.usizeStep); while (true) { const _7: rt.usize | rt.Done = iter.next(); @@ -3391,7 +3391,7 @@ export function putHints$collections_Nibble_collections_hash_set_Difference_coll } /** The size hint of `items`, and again after each of `read` more. */ -export function putHints$collections_Nibble_collections_hash_set_Intersection_collections_Nibble_hash_RandomState(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { +export function putHints$collections_Nibble_collections_hash_set_Intersection_collections_Nibble_hash_RandomState(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { const iter: rt.RangeInclusive = new rt.RangeInclusive(0, read, rt.usizeStep); while (true) { const _7: rt.usize | rt.Done = iter.next(); @@ -3409,7 +3409,7 @@ export function putHints$collections_Nibble_collections_hash_set_Intersection_co } /** The size hint of `items`, and again after each of `read` more. */ -export function putHints$collections_Nibble_collections_hash_set_SymmetricDifference_collections_Nibble_hash_RandomState(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { +export function putHints$collections_Nibble_collections_hash_set_SymmetricDifference_collections_Nibble_hash_RandomState(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { const iter: rt.RangeInclusive = new rt.RangeInclusive(0, read, rt.usizeStep); while (true) { const _7: rt.usize | rt.Done = iter.next(); @@ -3427,7 +3427,7 @@ export function putHints$collections_Nibble_collections_hash_set_SymmetricDiffer } /** The size hint of `items`, and again after each of `read` more. */ -export function putHints$collections_Nibble_collections_hash_set_Union_collections_Nibble_hash_RandomState(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { +export function putHints$collections_Nibble_collections_hash_set_Union_collections_Nibble_hash_RandomState(items: rt.Iter, read: rt.usize, out: rt.ByteVec): void { const iter: rt.RangeInclusive = new rt.RangeInclusive(0, read, rt.usizeStep); while (true) { const _7: rt.usize | rt.Done = iter.next(); @@ -3607,8 +3607,8 @@ export function putSorted$cmp_Reverse_Option_u8(items: Array, } /** [`put_all`] of `items` in order. */ -export function putSorted$collections_Nibble(items: collections_Nibble.Nibble[], put: (a0: collections_Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { - rt.sliceSort(items, rt.cmpLt(collections_Nibble.partialCmp$cmp_PartialOrd), 4, true); +export function putSorted$collections_Nibble(items: Nibble.Nibble[], put: (a0: Nibble.Nibble) => rt.u8, out: rt.ByteVec): void { + rt.sliceSort(items, rt.cmpLt(Nibble.partialCmp$cmp_PartialOrd), 4, true); putAll$collections_Nibble_vec_IntoIter_ref_collections_Nibble(rt.iterSlice(items), put, out); } @@ -3891,85 +3891,85 @@ export function unlikeEqs(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi * `v` in a deque wrapped around its buffer: the first half pushed to the front backwards, * the rest to the back. */ -export function wrapped$collections_Picky(v: collections_Picky.Picky[]): rt.VecDeque { +export function wrapped$collections_Picky(v: Picky.Picky[]): rt.VecDeque { const half: rt.usize = rt.usizeDiv(v.length, 2); - const q: rt.VecDeque = rt.dequeNew(8) as rt.VecDeque; - const iter: rt.Iter = rt.iterRev(rt.iterSlice(rt.sliceRange(v, 0, half))); + const q: rt.VecDeque = rt.dequeNew(8) as rt.VecDeque; + const iter: rt.Iter = rt.iterRev(rt.iterSlice(rt.sliceRange(v, 0, half))); while (true) { - const _12: collections_Picky.Picky | rt.Done = iter.next(); + const _12: Picky.Picky | rt.Done = iter.next(); if (_12 === rt.DONE) { break; } - const _18: collections_Picky.Picky = collections_Picky.clone$Clone(_12); + const _18: Picky.Picky = Picky.clone$Clone(_12); rt.dequePushFront(q, _18); } - const _21: rt.Iter = rt.iterMap(rt.iterSlice(rt.sliceRange(v, half)), collections_Picky.clone$Clone); + const _21: rt.Iter = rt.iterMap(rt.iterSlice(rt.sliceRange(v, half)), Picky.clone$Clone); rt.dequeExtend(q, _21, undefined, true); return q; } /** `f` of each of `v`. */ -export function each$collections_Picky_Option_collections_Picky_collections_own_nes_closure10(v: collections_Picky.Picky[], f: (a0: collections_Picky.Picky) => collections_Picky.Picky | undefined): Array { +export function each$collections_Picky_Option_collections_Picky_collections_own_nes_closure10(v: Picky.Picky[], f: (a0: Picky.Picky) => Picky.Picky | undefined): Array { return rt.iterToArray(rt.iterMap(rt.iterSlice(v), f), undefined, 8, true); } /** `f` of each of `v`. */ -export function each$collections_Picky_Option_collections_Picky_collections_own_nes_closure11(v: collections_Picky.Picky[], f: (a0: collections_Picky.Picky) => collections_Picky.Picky | undefined): Array { +export function each$collections_Picky_Option_collections_Picky_collections_own_nes_closure11(v: Picky.Picky[], f: (a0: Picky.Picky) => Picky.Picky | undefined): Array { return rt.iterToArray(rt.iterMap(rt.iterSlice(v), f), undefined, 8, true); } /** `f` of each of `v`. */ -export function each$collections_Picky_borrow_Cow_slice_collections_Picky_collections_own_nes_closure18(v: collections_Picky.Picky[], f: (a0: collections_Picky.Picky) => rt.Cow): rt.Cow[] { +export function each$collections_Picky_borrow_Cow_slice_collections_Picky_collections_own_nes_closure18(v: Picky.Picky[], f: (a0: Picky.Picky) => rt.Cow): rt.Cow[] { return rt.iterToArray(rt.iterMap(rt.iterSlice(v), f), undefined, 12, true); } /** `f` of each of `v`. */ -export function each$collections_Picky_boxed_Box_collections_Picky_collections_own_nes_closure14(v: collections_Picky.Picky[], f: (a0: collections_Picky.Picky) => collections_Picky.Picky): collections_Picky.Picky[] { +export function each$collections_Picky_boxed_Box_collections_Picky_collections_own_nes_closure14(v: Picky.Picky[], f: (a0: Picky.Picky) => Picky.Picky): Picky.Picky[] { return rt.iterToArray(rt.iterMap(rt.iterSlice(v), f), undefined, 4, true); } /** `f` of each of `v`. */ -export function each$collections_Picky_boxed_Box_collections_Picky_collections_own_nes_closure15(v: collections_Picky.Picky[], f: (a0: collections_Picky.Picky) => collections_Picky.Picky): collections_Picky.Picky[] { +export function each$collections_Picky_boxed_Box_collections_Picky_collections_own_nes_closure15(v: Picky.Picky[], f: (a0: Picky.Picky) => Picky.Picky): Picky.Picky[] { return rt.iterToArray(rt.iterMap(rt.iterSlice(v), f), undefined, 4, true); } /** `f` of each of `v`. */ -export function each$collections_Picky_cmp_Reverse_collections_Picky_collections_own_nes_closure12(v: collections_Picky.Picky[], f: (a0: collections_Picky.Picky) => collections_Picky.Picky): collections_Picky.Picky[] { +export function each$collections_Picky_cmp_Reverse_collections_Picky_collections_own_nes_closure12(v: Picky.Picky[], f: (a0: Picky.Picky) => Picky.Picky): Picky.Picky[] { return rt.iterToArray(rt.iterMap(rt.iterSlice(v), f), undefined, 8, true); } /** `f` of each of `v`. */ -export function each$collections_Picky_cmp_Reverse_collections_Picky_collections_own_nes_closure13(v: collections_Picky.Picky[], f: (a0: collections_Picky.Picky) => collections_Picky.Picky): collections_Picky.Picky[] { +export function each$collections_Picky_cmp_Reverse_collections_Picky_collections_own_nes_closure13(v: Picky.Picky[], f: (a0: Picky.Picky) => Picky.Picky): Picky.Picky[] { return rt.iterToArray(rt.iterMap(rt.iterSlice(v), f), undefined, 8, true); } /** `f` of each of `v`. */ -export function each$collections_Picky_sync_Arc_collections_Picky_collections_own_nes_closure16(v: collections_Picky.Picky[], f: (a0: collections_Picky.Picky) => rt.Arc): rt.Arc[] { +export function each$collections_Picky_sync_Arc_collections_Picky_collections_own_nes_closure16(v: Picky.Picky[], f: (a0: Picky.Picky) => rt.Arc): rt.Arc[] { return rt.iterToArray(rt.iterMap(rt.iterSlice(v), f), undefined, 4, true); } /** `f` of each of `v`. */ -export function each$collections_Picky_sync_Arc_collections_Picky_collections_own_nes_closure17(v: collections_Picky.Picky[], f: (a0: collections_Picky.Picky) => rt.Arc): rt.Arc[] { +export function each$collections_Picky_sync_Arc_collections_Picky_collections_own_nes_closure17(v: Picky.Picky[], f: (a0: Picky.Picky) => rt.Arc): rt.Arc[] { return rt.iterToArray(rt.iterMap(rt.iterSlice(v), f), undefined, 4, true); } /** `f` of each of `v`. */ -export function each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure6(v: collections_Picky.Picky[], f: (a0: collections_Picky.Picky) => [collections_Picky.Picky, rt.u8]): [collections_Picky.Picky, rt.u8][] { +export function each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure6(v: Picky.Picky[], f: (a0: Picky.Picky) => [Picky.Picky, rt.u8]): [Picky.Picky, rt.u8][] { return rt.iterToArray(rt.iterMap(rt.iterSlice(v), f), undefined, 12, true); } /** `f` of each of `v`. */ -export function each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure7(v: collections_Picky.Picky[], f: (a0: collections_Picky.Picky) => [collections_Picky.Picky, rt.u8]): [collections_Picky.Picky, rt.u8][] { +export function each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure7(v: Picky.Picky[], f: (a0: Picky.Picky) => [Picky.Picky, rt.u8]): [Picky.Picky, rt.u8][] { return rt.iterToArray(rt.iterMap(rt.iterSlice(v), f), undefined, 12, true); } /** `f` of each of `v`. */ -export function each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure8(v: collections_Picky.Picky[], f: (a0: collections_Picky.Picky) => [collections_Picky.Picky, rt.u8]): [collections_Picky.Picky, rt.u8][] { +export function each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure8(v: Picky.Picky[], f: (a0: Picky.Picky) => [Picky.Picky, rt.u8]): [Picky.Picky, rt.u8][] { return rt.iterToArray(rt.iterMap(rt.iterSlice(v), f), undefined, 12, true); } /** `f` of each of `v`. */ -export function each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure9(v: collections_Picky.Picky[], f: (a0: collections_Picky.Picky) => [collections_Picky.Picky, rt.u8]): [collections_Picky.Picky, rt.u8][] { +export function each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure9(v: Picky.Picky[], f: (a0: Picky.Picky) => [Picky.Picky, rt.u8]): [Picky.Picky, rt.u8][] { return rt.iterToArray(rt.iterMap(rt.iterSlice(v), f), undefined, 12, true); } @@ -4001,8 +4001,8 @@ export function each$collections_Quirky_cell_RefCell_collections_Quirky_collecti * `kind` picks. */ export function ownNes(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { - const _34: (a0: collections_Picky.Picky[], a1: rt.usize) => rt.u16 = (v: collections_Picky.Picky[], i: rt.usize): rt.u16 => { - return option_mapOr$0bnr5nu(rt.sliceGet(v, i), 0, (p: collections_Picky.Picky): rt.u16 => { + const _34: (a0: Picky.Picky[], a1: rt.usize) => rt.u16 = (v: Picky.Picky[], i: rt.usize): rt.u16 => { + return option_mapOr$0bnr5nu(rt.sliceGet(v, i), 0, (p: Picky.Picky): rt.u16 => { return p._0; }); }; @@ -4019,259 +4019,259 @@ export function ownNes(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } return 3; }; - const a: collections_Picky.Picky[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): collections_Picky.Picky => { + const a: Picky.Picky[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): Picky.Picky => { return { _0: _2 as rt.u16, _1: log }; }), undefined, 8, true); - const b: collections_Picky.Picky[] = rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(data))), (_22: [rt.usize, rt.u8]): collections_Picky.Picky => { + const b: Picky.Picky[] = rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(data))), (_22: [rt.usize, rt.u8]): Picky.Picky => { return { _0: rt.u16Add(_22[1] as rt.u16, step(_22[0])), _1: log }; }), undefined, 8, true); if ((kind & 64) !== 0) { b.pop(); } - const one: (a0: collections_Picky.Picky[], a1: rt.usize) => collections_Picky.Picky = (v2: collections_Picky.Picky[], i4: rt.usize): collections_Picky.Picky => { + const one: (a0: Picky.Picky[], a1: rt.usize) => Picky.Picky = (v2: Picky.Picky[], i4: rt.usize): Picky.Picky => { return { _0: _34(v2, i4), _1: log }; }; - putEq(rt.eqSlice((a2: collections_Picky.Picky, b2: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a2, b2); + putEq(rt.eqSlice((a2: Picky.Picky, b2: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a2, b2); })(a, b), log, out); - putEq(!rt.eqSlice((a3: collections_Picky.Picky, b3: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a3, b3); + putEq(!rt.eqSlice((a3: Picky.Picky, b3: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a3, b3); })(a, b), log, out); - const _50: collections_Picky.Picky[] = rt.sliceRange(a, 0); - const _52: collections_Picky.Picky[] = rt.sliceRange(b, 0); - putEq(rt.eqSlice((a4: collections_Picky.Picky, b4: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a4, b4); + const _50: Picky.Picky[] = rt.sliceRange(a, 0); + const _52: Picky.Picky[] = rt.sliceRange(b, 0); + putEq(rt.eqSlice((a4: Picky.Picky, b4: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a4, b4); })(_50, _52), log, out); - const _59: collections_Picky.Picky[] = rt.sliceRange(a, 0); - const _63: collections_Picky.Picky[] = rt.sliceRange(b, 0); - putEq(!rt.eqSlice((a5: collections_Picky.Picky, b5: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a5, b5); + const _59: Picky.Picky[] = rt.sliceRange(a, 0); + const _63: Picky.Picky[] = rt.sliceRange(b, 0); + putEq(!rt.eqSlice((a5: Picky.Picky, b5: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a5, b5); })(_59, _63), log, out); - const _69: collections_Picky.Picky[] = []; - const _71: collections_Picky.Picky[] = []; - putEq(rt.eqSlice((a6: collections_Picky.Picky, b6: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a6, b6); + const _69: Picky.Picky[] = []; + const _71: Picky.Picky[] = []; + putEq(rt.eqSlice((a6: Picky.Picky, b6: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a6, b6); })(_69, _71), log, out); - const _76: collections_Picky.Picky[] = []; - putEq(!rt.eqSlice((a7: collections_Picky.Picky, b7: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a7, b7); + const _76: Picky.Picky[] = []; + putEq(!rt.eqSlice((a7: Picky.Picky, b7: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a7, b7); })(_76, b), log, out); - const _81: [collections_Picky.Picky[], collections_Picky.Picky[]] = [[one(a, 0), one(a, 1)], [one(b, 0), one(b, 1)]]; - const pa: collections_Picky.Picky[] = _81[0]; - const pb: collections_Picky.Picky[] = _81[1]; - putEq(rt.eqSlice((a8: collections_Picky.Picky, b8: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a8, b8); + const _81: [Picky.Picky[], Picky.Picky[]] = [[one(a, 0), one(a, 1)], [one(b, 0), one(b, 1)]]; + const pa: Picky.Picky[] = _81[0]; + const pb: Picky.Picky[] = _81[1]; + putEq(rt.eqSlice((a8: Picky.Picky, b8: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a8, b8); })(pa, pb), log, out); - putEq(!rt.eqSlice((a9: collections_Picky.Picky, b9: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a9, b9); + putEq(!rt.eqSlice((a9: Picky.Picky, b9: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a9, b9); })(pa, pb), log, out); - const _117: collections_Picky.Picky[] = rt.sliceRange(b, 0); - putEq(rt.eqSlice((a10: collections_Picky.Picky, b10: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a10, b10); + const _117: Picky.Picky[] = rt.sliceRange(b, 0); + putEq(rt.eqSlice((a10: Picky.Picky, b10: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a10, b10); })(pa, _117), log, out); - const _123: collections_Picky.Picky[][] = [rt.vecExact(a.map(collections_Picky.clone$Clone), 8), rt.vecExact(a.map(collections_Picky.clone$Clone), 8)]; - const _130: collections_Picky.Picky[][] = [rt.vecExact(a.map(collections_Picky.clone$Clone), 8), rt.vecExact(b.map(collections_Picky.clone$Clone), 8)]; - putEq(rt.eqSlice(rt.eqSlice((a11: collections_Picky.Picky, b11: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a11, b11); + const _123: Picky.Picky[][] = [rt.vecExact(a.map(Picky.clone$Clone), 8), rt.vecExact(a.map(Picky.clone$Clone), 8)]; + const _130: Picky.Picky[][] = [rt.vecExact(a.map(Picky.clone$Clone), 8), rt.vecExact(b.map(Picky.clone$Clone), 8)]; + putEq(rt.eqSlice(rt.eqSlice((a11: Picky.Picky, b11: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a11, b11); }))(_123, _130), log, out); - const _139: collections_Picky.Picky[][] = [rt.vecExact(a.map(collections_Picky.clone$Clone), 8), rt.vecExact(b.map(collections_Picky.clone$Clone), 8)]; - const _146: collections_Picky.Picky[][] = [rt.vecExact(a.map(collections_Picky.clone$Clone), 8), rt.vecExact(a.map(collections_Picky.clone$Clone), 8)]; - putEq(!rt.eqSlice(rt.eqSlice((a20: collections_Picky.Picky, b12: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a20, b12); + const _139: Picky.Picky[][] = [rt.vecExact(a.map(Picky.clone$Clone), 8), rt.vecExact(b.map(Picky.clone$Clone), 8)]; + const _146: Picky.Picky[][] = [rt.vecExact(a.map(Picky.clone$Clone), 8), rt.vecExact(a.map(Picky.clone$Clone), 8)]; + putEq(!rt.eqSlice(rt.eqSlice((a20: Picky.Picky, b12: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a20, b12); }))(_139, _146), log, out); - const tuple: (a0: collections_Picky.Picky[]) => [collections_Picky.Picky, rt.u8, collections_Picky.Picky] = (v3: collections_Picky.Picky[]): [collections_Picky.Picky, rt.u8, collections_Picky.Picky] => { - return [one(v3, 0), _34(v3, 2) & 0xff, one(v3, 1)] as [collections_Picky.Picky, rt.u8, collections_Picky.Picky]; + const tuple: (a0: Picky.Picky[]) => [Picky.Picky, rt.u8, Picky.Picky] = (v3: Picky.Picky[]): [Picky.Picky, rt.u8, Picky.Picky] => { + return [one(v3, 0), _34(v3, 2) & 0xff, one(v3, 1)] as [Picky.Picky, rt.u8, Picky.Picky]; }; - const _158: [collections_Picky.Picky, rt.u8, collections_Picky.Picky] = tuple(a); - const _164: [collections_Picky.Picky, rt.u8, collections_Picky.Picky] = tuple(b); - putEq(!rt.eqTuple([(a21: collections_Picky.Picky, b13: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a21, b13); - }, rt.same, (a22: collections_Picky.Picky, b14: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a22, b14); + const _158: [Picky.Picky, rt.u8, Picky.Picky] = tuple(a); + const _164: [Picky.Picky, rt.u8, Picky.Picky] = tuple(b); + putEq(!rt.eqTuple([(a21: Picky.Picky, b13: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a21, b13); + }, rt.same, (a22: Picky.Picky, b14: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a22, b14); }])(_158, _164), log, out); - const _173: [collections_Picky.Picky, rt.u8, collections_Picky.Picky] = tuple(a); - const _179: [collections_Picky.Picky, rt.u8, collections_Picky.Picky] = tuple(b); - putEq(rt.eqTuple([collections_Picky.eq$cmp_PartialEq, rt.same, collections_Picky.eq$cmp_PartialEq])(_173, _179), log, out); - const _188: [[collections_Picky.Picky, rt.u8, collections_Picky.Picky], rt.u8] = [tuple(a), 1]; - const _195: [[collections_Picky.Picky, rt.u8, collections_Picky.Picky], rt.u8] = [tuple(b), 1]; - putEq(!rt.eqTuple([rt.eqTuple([(a23: collections_Picky.Picky, b15: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a23, b15); - }, rt.same, (a24: collections_Picky.Picky, b16: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a24, b16); + const _173: [Picky.Picky, rt.u8, Picky.Picky] = tuple(a); + const _179: [Picky.Picky, rt.u8, Picky.Picky] = tuple(b); + putEq(rt.eqTuple([Picky.eq$cmp_PartialEq, rt.same, Picky.eq$cmp_PartialEq])(_173, _179), log, out); + const _188: [[Picky.Picky, rt.u8, Picky.Picky], rt.u8] = [tuple(a), 1]; + const _195: [[Picky.Picky, rt.u8, Picky.Picky], rt.u8] = [tuple(b), 1]; + putEq(!rt.eqTuple([rt.eqTuple([(a23: Picky.Picky, b15: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a23, b15); + }, rt.same, (a24: Picky.Picky, b16: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a24, b16); }]), rt.same])(_188, _195), log, out); - const _205: [collections_Picky.Picky, rt.u8][] = each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure6(a, (p2: collections_Picky.Picky): [collections_Picky.Picky, rt.u8] => { - return [collections_Picky.clone$Clone(p2), p2._0 & 0xff] as [collections_Picky.Picky, rt.u8]; + const _205: [Picky.Picky, rt.u8][] = each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure6(a, (p2: Picky.Picky): [Picky.Picky, rt.u8] => { + return [Picky.clone$Clone(p2), p2._0 & 0xff] as [Picky.Picky, rt.u8]; }); - const _209: [collections_Picky.Picky, rt.u8][] = each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure7(b, (p3: collections_Picky.Picky): [collections_Picky.Picky, rt.u8] => { - return [collections_Picky.clone$Clone(p3), p3._0 & 0xff] as [collections_Picky.Picky, rt.u8]; + const _209: [Picky.Picky, rt.u8][] = each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure7(b, (p3: Picky.Picky): [Picky.Picky, rt.u8] => { + return [Picky.clone$Clone(p3), p3._0 & 0xff] as [Picky.Picky, rt.u8]; }); - putEq(rt.eqSlice(rt.eqTuple([(a25: collections_Picky.Picky, b17: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a25, b17); + putEq(rt.eqSlice(rt.eqTuple([(a25: Picky.Picky, b17: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a25, b17); }, rt.same]))(_205, _209), log, out); - const _217: [collections_Picky.Picky, rt.u8][] = rt.sliceRange(each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure8(a, (p4: collections_Picky.Picky): [collections_Picky.Picky, rt.u8] => { - return [collections_Picky.clone$Clone(p4), p4._0 & 0xff] as [collections_Picky.Picky, rt.u8]; + const _217: [Picky.Picky, rt.u8][] = rt.sliceRange(each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure8(a, (p4: Picky.Picky): [Picky.Picky, rt.u8] => { + return [Picky.clone$Clone(p4), p4._0 & 0xff] as [Picky.Picky, rt.u8]; }), 0); - const _224: [collections_Picky.Picky, rt.u8][] = rt.sliceRange(each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure9(b, (p5: collections_Picky.Picky): [collections_Picky.Picky, rt.u8] => { - return [collections_Picky.clone$Clone(p5), p5._0 & 0xff] as [collections_Picky.Picky, rt.u8]; + const _224: [Picky.Picky, rt.u8][] = rt.sliceRange(each$collections_Picky_tuple2_collections_Picky_u8_collections_own_nes_closure9(b, (p5: Picky.Picky): [Picky.Picky, rt.u8] => { + return [Picky.clone$Clone(p5), p5._0 & 0xff] as [Picky.Picky, rt.u8]; }), 0); - putEq(!rt.eqSlice(rt.eqTuple([(a26: collections_Picky.Picky, b18: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a26, b18); + putEq(!rt.eqSlice(rt.eqTuple([(a26: Picky.Picky, b18: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a26, b18); }, rt.same]))(_217, _224), log, out); - const _233: [collections_Picky.Picky | undefined] = [one(a, 0)]; - const _241: [collections_Picky.Picky | undefined] = [one(b, 0)]; - putEq(!rt.eqTuple([rt.eqOption(collections_Picky.eq$cmp_PartialEq)])(_233, _241), log, out); - const _252: [collections_Picky.Picky] = [one(a, 0)]; - const _260: [collections_Picky.Picky] = [one(b, 0)]; - putEq(!rt.eqTuple([collections_Picky.eq$cmp_PartialEq])(_252, _260), log, out); - const _271: [collections_Picky.Picky] = [one(a, 0)]; - const _279: [collections_Picky.Picky] = [one(b, 0)]; - putEq(!rt.eqTuple([(a27: collections_Picky.Picky, b19: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a27, b19); + const _233: [Picky.Picky | undefined] = [one(a, 0)]; + const _241: [Picky.Picky | undefined] = [one(b, 0)]; + putEq(!rt.eqTuple([rt.eqOption(Picky.eq$cmp_PartialEq)])(_233, _241), log, out); + const _252: [Picky.Picky] = [one(a, 0)]; + const _260: [Picky.Picky] = [one(b, 0)]; + putEq(!rt.eqTuple([Picky.eq$cmp_PartialEq])(_252, _260), log, out); + const _271: [Picky.Picky] = [one(a, 0)]; + const _279: [Picky.Picky] = [one(b, 0)]; + putEq(!rt.eqTuple([(a27: Picky.Picky, b19: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a27, b19); }])(_271, _279), log, out); - const _290: [collections_Picky.Picky] = [one(a, 0)]; - const _298: [collections_Picky.Picky] = [one(b, 0)]; - putEq(!rt.eqTuple([(a28: collections_Picky.Picky, b20: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a28, b20); + const _290: [Picky.Picky] = [one(a, 0)]; + const _298: [Picky.Picky] = [one(b, 0)]; + putEq(!rt.eqTuple([(a28: Picky.Picky, b20: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a28, b20); }])(_290, _298), log, out); - const _309: Array = each$collections_Picky_Option_collections_Picky_collections_own_nes_closure10(a, (p6: collections_Picky.Picky): collections_Picky.Picky | undefined => { - return collections_Picky.clone$Clone(p6); + const _309: Array = each$collections_Picky_Option_collections_Picky_collections_own_nes_closure10(a, (p6: Picky.Picky): Picky.Picky | undefined => { + return Picky.clone$Clone(p6); }); - const _313: Array = each$collections_Picky_Option_collections_Picky_collections_own_nes_closure11(b, (p7: collections_Picky.Picky): collections_Picky.Picky | undefined => { - return collections_Picky.clone$Clone(p7); + const _313: Array = each$collections_Picky_Option_collections_Picky_collections_own_nes_closure11(b, (p7: Picky.Picky): Picky.Picky | undefined => { + return Picky.clone$Clone(p7); }); - putEq(rt.eqSlice(rt.eqOption(collections_Picky.eq$cmp_PartialEq))(_309, _313), log, out); - const _320: collections_Picky.Picky[] = each$collections_Picky_cmp_Reverse_collections_Picky_collections_own_nes_closure12(a, (p8: collections_Picky.Picky): collections_Picky.Picky => { - return collections_Picky.clone$Clone(p8); + putEq(rt.eqSlice(rt.eqOption(Picky.eq$cmp_PartialEq))(_309, _313), log, out); + const _320: Picky.Picky[] = each$collections_Picky_cmp_Reverse_collections_Picky_collections_own_nes_closure12(a, (p8: Picky.Picky): Picky.Picky => { + return Picky.clone$Clone(p8); }); - const _324: collections_Picky.Picky[] = each$collections_Picky_cmp_Reverse_collections_Picky_collections_own_nes_closure13(b, (p9: collections_Picky.Picky): collections_Picky.Picky => { - return collections_Picky.clone$Clone(p9); + const _324: Picky.Picky[] = each$collections_Picky_cmp_Reverse_collections_Picky_collections_own_nes_closure13(b, (p9: Picky.Picky): Picky.Picky => { + return Picky.clone$Clone(p9); }); - putEq(rt.eqSlice(collections_Picky.eq$cmp_PartialEq)(_320, _324), log, out); - const _331: collections_Picky.Picky[] = each$collections_Picky_boxed_Box_collections_Picky_collections_own_nes_closure14(a, (p10: collections_Picky.Picky): collections_Picky.Picky => { - return collections_Picky.clone$Clone(p10); + putEq(rt.eqSlice(Picky.eq$cmp_PartialEq)(_320, _324), log, out); + const _331: Picky.Picky[] = each$collections_Picky_boxed_Box_collections_Picky_collections_own_nes_closure14(a, (p10: Picky.Picky): Picky.Picky => { + return Picky.clone$Clone(p10); }); - const _335: collections_Picky.Picky[] = each$collections_Picky_boxed_Box_collections_Picky_collections_own_nes_closure15(b, (p11: collections_Picky.Picky): collections_Picky.Picky => { - return collections_Picky.clone$Clone(p11); + const _335: Picky.Picky[] = each$collections_Picky_boxed_Box_collections_Picky_collections_own_nes_closure15(b, (p11: Picky.Picky): Picky.Picky => { + return Picky.clone$Clone(p11); }); - putEq(rt.eqSlice((a29: collections_Picky.Picky, b21: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a29, b21); + putEq(rt.eqSlice((a29: Picky.Picky, b21: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a29, b21); })(_331, _335), log, out); - const arc: rt.Arc = new rt.Arc(one(a, 0)); - const _349: rt.Arc = rt.arcClone(arc); - putEq(!rt.eqArc((a30: collections_Picky.Picky, b22: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a30, b22); + const arc: rt.Arc = new rt.Arc(one(a, 0)); + const _349: rt.Arc = rt.arcClone(arc); + putEq(!rt.eqArc((a30: Picky.Picky, b22: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a30, b22); }, true)(arc, _349), log, out); _349[Symbol.dispose](); - const _356: rt.Arc = rt.arcClone(arc); - putEq(rt.eqArc(collections_Picky.eq$cmp_PartialEq, true)(arc, _356), log, out); + const _356: rt.Arc = rt.arcClone(arc); + putEq(rt.eqArc(Picky.eq$cmp_PartialEq, true)(arc, _356), log, out); _356[Symbol.dispose](); - const _362: rt.Arc = new rt.Arc(one(a, 0)); - const _369: rt.Arc = new rt.Arc(one(b, 0)); - putEq(!rt.eqArc((a31: collections_Picky.Picky, b23: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a31, b23); + const _362: rt.Arc = new rt.Arc(one(a, 0)); + const _369: rt.Arc = new rt.Arc(one(b, 0)); + putEq(!rt.eqArc((a31: Picky.Picky, b23: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a31, b23); }, true)(_362, _369), log, out); _369[Symbol.dispose](); _362[Symbol.dispose](); - const floated: rt.Arc<[collections_Picky.Picky, rt.f32]> = new rt.Arc([one(a, 0), 0.5] as [collections_Picky.Picky, rt.f32]); - const _387: rt.Arc<[collections_Picky.Picky, rt.f32]> = rt.arcClone(floated); - putEq(!rt.eqArc(rt.eqTuple([(a32: collections_Picky.Picky, b24: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a32, b24); + const floated: rt.Arc<[Picky.Picky, rt.f32]> = new rt.Arc([one(a, 0), 0.5] as [Picky.Picky, rt.f32]); + const _387: rt.Arc<[Picky.Picky, rt.f32]> = rt.arcClone(floated); + putEq(!rt.eqArc(rt.eqTuple([(a32: Picky.Picky, b24: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a32, b24); }, rt.same]))(floated, _387), log, out); _387[Symbol.dispose](); - const _394: rt.Arc<[collections_Picky.Picky, rt.f32]> = new rt.Arc([one(b, 0), 0.5] as [collections_Picky.Picky, rt.f32]); - putEq(!rt.eqArc(rt.eqTuple([(a33: collections_Picky.Picky, b25: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a33, b25); + const _394: rt.Arc<[Picky.Picky, rt.f32]> = new rt.Arc([one(b, 0), 0.5] as [Picky.Picky, rt.f32]); + putEq(!rt.eqArc(rt.eqTuple([(a33: Picky.Picky, b25: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a33, b25); }, rt.same]))(floated, _394), log, out); _394[Symbol.dispose](); - const _405: rt.Arc = new rt.Arc(one(a, 1)); - const _412: rt.Arc = new rt.Arc(one(b, 1)); - putEq(!rt.eqArc((a34: collections_Picky.Picky, b26: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a34, b26); + const _405: rt.Arc = new rt.Arc(one(a, 1)); + const _412: rt.Arc = new rt.Arc(one(b, 1)); + putEq(!rt.eqArc((a34: Picky.Picky, b26: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a34, b26); }, true)(_405, _412), log, out); _412[Symbol.dispose](); _405[Symbol.dispose](); - const shared: rt.Arc[] = each$collections_Picky_sync_Arc_collections_Picky_collections_own_nes_closure16(a, (p12: collections_Picky.Picky): rt.Arc => { - return new rt.Arc(collections_Picky.clone$Clone(p12)); + const shared: rt.Arc[] = each$collections_Picky_sync_Arc_collections_Picky_collections_own_nes_closure16(a, (p12: Picky.Picky): rt.Arc => { + return new rt.Arc(Picky.clone$Clone(p12)); }); - const _426: rt.Arc[] = rt.vecExact(shared.map((a041: rt.Arc): rt.Arc => { + const _426: rt.Arc[] = rt.vecExact(shared.map((a041: rt.Arc): rt.Arc => { return rt.arcClone(a041); }), 4); - putEq(rt.eqSlice(rt.eqArc((a35: collections_Picky.Picky, b27: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a35, b27); + putEq(rt.eqSlice(rt.eqArc((a35: Picky.Picky, b27: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a35, b27); }, true))(shared, _426), log, out); rt.dropAll(_426); - const _433: rt.Arc[] = each$collections_Picky_sync_Arc_collections_Picky_collections_own_nes_closure17(b, (p13: collections_Picky.Picky): rt.Arc => { - return new rt.Arc(collections_Picky.clone$Clone(p13)); + const _433: rt.Arc[] = each$collections_Picky_sync_Arc_collections_Picky_collections_own_nes_closure17(b, (p13: Picky.Picky): rt.Arc => { + return new rt.Arc(Picky.clone$Clone(p13)); }); - putEq(rt.eqSlice(rt.eqArc((a36: collections_Picky.Picky, b28: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a36, b28); + putEq(rt.eqSlice(rt.eqArc((a36: Picky.Picky, b28: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a36, b28); }, true))(shared, _433), log, out); rt.dropAll(_433); - const _440: [rt.Arc, rt.u8] = [rt.arcClone(arc), 0]; - const _444: [rt.Arc, rt.u8] = [new rt.Arc(one(b, 0)), 0]; - putEq(!rt.eqTuple([rt.eqArc((a37: collections_Picky.Picky, b29: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a37, b29); + const _440: [rt.Arc, rt.u8] = [rt.arcClone(arc), 0]; + const _444: [rt.Arc, rt.u8] = [new rt.Arc(one(b, 0)), 0]; + putEq(!rt.eqTuple([rt.eqArc((a37: Picky.Picky, b29: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a37, b29); }, true), rt.same])(_440, _444), log, out); drop$tuple2_sync_Arc_collections_Picky_u8(_444); drop$tuple2_sync_Arc_collections_Picky_u8(_440); - const _455: rt.VecDeque = wrapped$collections_Picky(a); - const _459: rt.VecDeque = wrapped$collections_Picky(b); - putEq(rt.eqSeq((a38: collections_Picky.Picky, b30: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a38, b30); + const _455: rt.VecDeque = wrapped$collections_Picky(a); + const _459: rt.VecDeque = wrapped$collections_Picky(b); + putEq(rt.eqSeq((a38: Picky.Picky, b30: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a38, b30); })(_455, _459), log, out); - const _466: rt.VecDeque = wrapped$collections_Picky(a); - const _470: rt.VecDeque = wrapped$collections_Picky(b); - putEq(!rt.eqSeq((a39: collections_Picky.Picky, b31: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a39, b31); + const _466: rt.VecDeque = wrapped$collections_Picky(a); + const _470: rt.VecDeque = wrapped$collections_Picky(b); + putEq(!rt.eqSeq((a39: Picky.Picky, b31: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a39, b31); })(_466, _470), log, out); - const _477: rt.VecDeque = wrapped$collections_Picky(a); - putEq(rt.eqSeq((a40: collections_Picky.Picky, b32: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a40, b32); + const _477: rt.VecDeque = wrapped$collections_Picky(a); + putEq(rt.eqSeq((a40: Picky.Picky, b32: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a40, b32); })(_477, b), log, out); - const _485: rt.VecDeque = wrapped$collections_Picky(a); - const _490: collections_Picky.Picky[] = rt.sliceRange(b, 0); - putEq(rt.eqSeq((a41: collections_Picky.Picky, b33: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a41, b33); + const _485: rt.VecDeque = wrapped$collections_Picky(a); + const _490: Picky.Picky[] = rt.sliceRange(b, 0); + putEq(rt.eqSeq((a41: Picky.Picky, b33: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a41, b33); })(_485, _490), log, out); - const _496: [collections_Picky.Picky] = [one(a, 0)]; - const _504: [collections_Picky.Picky] = [one(b, 0)]; - putEq(!rt.eqTuple([collections_Picky.eq$cmp_PartialEq])(_496, _504), log, out); - putEq(collections_Picky.eq$cmp_PartialEq(one(a, 1), one(b, 1)), log, out); - const _531: [rt.Cow, rt.Cow] = [new rt.Borrowed(rt.sliceRange(a, 0)), rt.vecExact(b.map(collections_Picky.clone$Clone), 8)]; - const ca: rt.Cow = _531[0]; - const cb: rt.Cow = _531[1]; - putEq(rt.eqSlice((a42: collections_Picky.Picky, b34: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a42, b34); + const _496: [Picky.Picky] = [one(a, 0)]; + const _504: [Picky.Picky] = [one(b, 0)]; + putEq(!rt.eqTuple([Picky.eq$cmp_PartialEq])(_496, _504), log, out); + putEq(Picky.eq$cmp_PartialEq(one(a, 1), one(b, 1)), log, out); + const _531: [rt.Cow, rt.Cow] = [new rt.Borrowed(rt.sliceRange(a, 0)), rt.vecExact(b.map(Picky.clone$Clone), 8)]; + const ca: rt.Cow = _531[0]; + const cb: rt.Cow = _531[1]; + putEq(rt.eqSlice((a42: Picky.Picky, b34: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a42, b34); })(rt.cowSlice(ca), rt.cowSlice(cb)), log, out); - putEq(!rt.eqSlice((a43: collections_Picky.Picky, b35: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a43, b35); + putEq(!rt.eqSlice((a43: Picky.Picky, b35: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a43, b35); })(rt.cowSlice(ca), rt.cowSlice(cb)), log, out); - const _553: collections_Picky.Picky[] = rt.sliceRange(b, 0); - putEq(rt.eqSlice((a44: collections_Picky.Picky, b36: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a44, b36); + const _553: Picky.Picky[] = rt.sliceRange(b, 0); + putEq(rt.eqSlice((a44: Picky.Picky, b36: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a44, b36); })(rt.cowSlice(ca), _553), log, out); - putEq(!rt.eqSlice((a45: collections_Picky.Picky, b37: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a45, b37); + putEq(!rt.eqSlice((a45: Picky.Picky, b37: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a45, b37); })(rt.cowSlice(cb), a), log, out); - putEq(rt.eqSlice((a46: collections_Picky.Picky, b38: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a46, b38); + putEq(rt.eqSlice((a46: Picky.Picky, b38: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a46, b38); })(b, rt.cowSlice(ca)), log, out); - const _570: collections_Picky.Picky[] = rt.sliceRange(a, 0); - putEq(!rt.eqSlice((a47: collections_Picky.Picky, b39: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a47, b39); + const _570: Picky.Picky[] = rt.sliceRange(a, 0); + putEq(!rt.eqSlice((a47: Picky.Picky, b39: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a47, b39); })(_570, rt.cowSlice(cb)), log, out); - const _576: collections_Picky.Picky[] = rt.cowSlice(cb); - putEq(rt.eqSlice((a48: collections_Picky.Picky, b40: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a48, b40); + const _576: Picky.Picky[] = rt.cowSlice(cb); + putEq(rt.eqSlice((a48: Picky.Picky, b40: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a48, b40); })(_576, pa), log, out); - const owned: rt.Cow[] = each$collections_Picky_borrow_Cow_slice_collections_Picky_collections_own_nes_closure18(a, (p14: collections_Picky.Picky): rt.Cow => { - return [collections_Picky.clone$Clone(p14)]; + const owned: rt.Cow[] = each$collections_Picky_borrow_Cow_slice_collections_Picky_collections_own_nes_closure18(a, (p14: Picky.Picky): rt.Cow => { + return [Picky.clone$Clone(p14)]; }); - const borrowed: rt.Cow[] = rt.iterToArray(rt.iterMap(rt.sliceChunks(b, 1), (a059: collections_Picky.Picky[]): rt.Cow => { + const borrowed: rt.Cow[] = rt.iterToArray(rt.iterMap(rt.sliceChunks(b, 1), (a059: Picky.Picky[]): rt.Cow => { return new rt.Borrowed(a059); }), undefined, 12, true); - putEq(!rt.eqSlice(rt.cowBy(rt.eqSlice((a49: collections_Picky.Picky, b41: collections_Picky.Picky): boolean => { - return !collections_Picky.ne$cmp_PartialEq(a49, b41); + putEq(!rt.eqSlice(rt.cowBy(rt.eqSlice((a49: Picky.Picky, b41: Picky.Picky): boolean => { + return !Picky.ne$cmp_PartialEq(a49, b41); })))(owned, borrowed), log, out); rt.dropAll(shared); floated[Symbol.dispose](); diff --git a/ts/fixtures/lang/collections/expected/core/bool.ts b/ts/fixtures/lang/collections/expected/core/bool.ts new file mode 100644 index 000000000..2cc2d5775 --- /dev/null +++ b/ts/fixtures/lang/collections/expected/core/bool.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0d5am30(self: boolean, t: rt.u8): rt.u8 | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function then$0wlzj76(self: boolean, f: () => rt.Ordering): rt.Ordering | undefined { + if (!self) { + return undefined; + } + return f(); +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/collections/expected/core/option.ts b/ts/fixtures/lang/collections/expected/core/option.ts new file mode 100644 index 000000000..f45aa2806 --- /dev/null +++ b/ts/fixtures/lang/collections/expected/core/option.ts @@ -0,0 +1,180 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as ByRef from "../collections.ByRef.ts"; +import type * as ByVal from "../collections.ByVal.ts"; +import type * as Mixed from "../collections.Mixed.ts"; +import type * as Nibble from "../collections.Nibble.ts"; +import type * as Picky from "../collections.Picky.ts"; +import type * as Rank from "../collections.Rank.ts"; +import type * as Tally from "../collections.Tally.ts"; + +export function unwrapOr$1j4op5y(self: rt.u16 | undefined, default_: rt.u16): rt.u16 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$0ltgf8p(self: ByRef.ByRef | undefined, f: (a0: ByRef.ByRef) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$1ajptuf(self: ByVal.ByVal | undefined, f: (a0: ByVal.ByVal) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0i8kclf(self: Mixed.Mixed | undefined, f: (a0: Mixed.Mixed) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$09ua5et(self: Nibble.Nibble | undefined, f: (a0: Nibble.Nibble) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0oc32h1(self: rt.u8 | undefined, f: (a0: rt.u8) => string): string | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$05nbzug(self: rt.usize | undefined, f: (a0: rt.usize) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function mapOr$1e4a1e0(self: rt.Ordering | undefined, default_: rt.u8, f: (a0: rt.Ordering) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0q0ymkh(self: Nibble.Nibble | undefined, default_: rt.u8, f: (a0: Nibble.Nibble) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1ht002r(self: Tally.Tally | undefined, default_: rt.u8, f: (a0: Tally.Tally) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1xztl8h(self: rt.u8 | undefined | rt.None, default_: rt.u8, f: (a0: rt.u8 | undefined) => rt.u8): rt.u8 { + if (self === rt.None) { + return default_; + } + return f(self); +} + +export function mapOr$1w1gbwl(self: rt.ByteSlice | undefined, default_: rt.u8, f: (a0: rt.ByteSlice) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0bnr5nu(self: Picky.Picky | undefined, default_: rt.u16, f: (a0: Picky.Picky) => rt.u16): rt.u16 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1nlkf9b(self: [rt.u8, rt.u8] | undefined, default_: Uint8Array, f: (a0: [rt.u8, rt.u8]) => Uint8Array): Uint8Array { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$099335t(self: rt.u16 | undefined, default_: rt.u8, f: (a0: rt.u16) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0z4mj8g(self: rt.u8 | undefined, default_: rt.u16, f: (a0: rt.u8) => rt.u16): rt.u16 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1surhce(self: rt.u8 | undefined, default_: rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1t0muvr(self: rt.u8 | undefined, default_: rt.usize, f: (a0: rt.u8) => rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$02k4ito(self: rt.usize | undefined, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1to2ul4(self: [Rank.Rank, Tally.Tally] | undefined, default_: rt.u8, f: (a0: [Rank.Rank, Tally.Tally]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0mmpeqx(self: [rt.u8, rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u8, rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function clone$14nprly(self: string | undefined): string | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function flatten$1nwzx42(self: rt.u8 | undefined | rt.None): rt.u8 | undefined { + if (self === rt.None) { + return undefined; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/collections/expected/core/result.ts b/ts/fixtures/lang/collections/expected/core/result.ts new file mode 100644 index 000000000..4d5345cb0 --- /dev/null +++ b/ts/fixtures/lang/collections/expected/core/result.ts @@ -0,0 +1,27 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import * as ByRef from "../collections.ByRef.ts"; +import * as ByVal from "../collections.ByVal.ts"; + +export function eq$1dt73ez(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return ByRef.eq$cmp_PartialEq_ref(self.value, (other as { ok: true; value: ByRef.ByRef }).value); + } + return self.error === (other as { ok: false; error: rt.u8 }).error; +} + +export function eq$163neqy(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return ByVal.eq$cmp_PartialEq(self.value, (other as { ok: true; value: ByVal.ByVal }).value); + } + return self.error === (other as { ok: false; error: rt.u8 }).error; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/collections/expected/harness.ts b/ts/fixtures/lang/collections/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/collections/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/collections/expected/lib.ts b/ts/fixtures/lang/collections/expected/lib.ts new file mode 100644 index 000000000..cb390a238 --- /dev/null +++ b/ts/fixtures/lang/collections/expected/lib.ts @@ -0,0 +1,77 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { hashMaps, sets, btreeMaps, deques, dequeRanges, vecs, stores, optionals, setOps, unlikeEqs, ownNes, cellEqs, unlikeCompares, refOrders } from "./collections.ts"; +import type * as Bumped from "./collections.Bumped.ts"; +import type * as Picky from "./collections.Picky.ts"; +import type * as Quirky from "./collections.Quirky.ts"; +import type * as Tally from "./collections.Tally.ts"; +import * as Wrap from "./collections.Wrap.ts"; + +export function copy$Option_collections_Tally(v: Tally.Tally | undefined): Tally.Tally | undefined { + return v === undefined ? v : copy$collections_Tally(v); +} + +export function copy$array_collections_Quirky(v: Quirky.Quirky[]): Quirky.Quirky[] { + return v.map(copy$collections_Quirky); +} + +export function copy$array_tuple2_u8_u16(v: [rt.u8, rt.u16][]): [rt.u8, rt.u16][] { + return v.map(copy$tuple2_u8_u16); +} + +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_u8(v: Uint8Array): Uint8Array { + return v.slice(); +} + +export function copy$collections_Bumped(v: Bumped.Bumped): Bumped.Bumped { + return { _0: v._0 }; +} + +export function copy$collections_Quirky(v: Quirky.Quirky): Quirky.Quirky { + return { _0: v._0, _1: v._1 }; +} + +export function copy$collections_Tally(v: Tally.Tally): Tally.Tally { + return { n: v.n }; +} + +export function copy$collections_Wrap_u8(v: Wrap.Wrap): Wrap.Wrap { + return new Wrap.Wrap(v.value, v.count); +} + +export function copy$tuple2_u8_collections_Tally(v: [rt.u8, Tally.Tally]): [rt.u8, Tally.Tally] { + return [v[0], copy$collections_Tally(v[1])]; +} + +export function copy$tuple2_u8_u16(v: [rt.u8, rt.u16]): [rt.u8, rt.u16] { + return [v[0], v[1]]; +} + +export function copy$tuple2_u8_u8(v: [rt.u8, rt.u8]): [rt.u8, rt.u8] { + return [v[0], v[1]]; +} + +export function drop$tuple2_sync_Arc_collections_Picky_u8(_1: [rt.Arc, rt.u8]): void { + _1[0][Symbol.dispose](); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["collections::hash_maps", hashMaps as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::sets", sets as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::btree_maps", btreeMaps as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::deques", (_210: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + deques(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::vecs", (_211: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + vecs(data2, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::stores", (_212: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + stores(data3, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::optionals", optionals as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::set_ops", setOps as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::unlike_eqs", unlikeEqs as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::own_nes", ownNes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::cell_eqs", cellEqs as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::unlike_compares", unlikeCompares as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::ref_orders", refOrders as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::deque_ranges", dequeRanges as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/collections.rs b/ts/fixtures/lang/collections/src/collections.rs similarity index 99% rename from ts/fixtures/lang/src/collections.rs rename to ts/fixtures/lang/collections/src/collections.rs index 2eaaaa45e..9617ea76e 100644 --- a/ts/fixtures/lang/src/collections.rs +++ b/ts/fixtures/lang/collections/src/collections.rs @@ -10,9 +10,6 @@ use std::hash::{DefaultHasher, Hash, Hasher}; use std::num::Wrapping; use std::ops::Bound; -use crate::generics::Wrap; -use crate::iters::Bumped; - /// A key whose `Eq`, `Hash`, and `Ord` see only its low nibble, so two keys can be equal /// while their bytes differ, and which sorts by that nibble, descending. #[derive(Clone, Copy)] @@ -852,6 +849,23 @@ pub fn vecs(data: &[u8], out: &mut Vec) { out.extend(names.as_slice().iter().map(|s| s.len() as u8)); } +/// A `Copy` type whose `Clone` does more than copy. +#[derive(Copy)] +struct Bumped(u8); + +impl Clone for Bumped { + fn clone(&self) -> Self { + Bumped(self.0.wrapping_add(1)) + } +} + +/// A generic `Copy` struct. +#[derive(Clone, Copy)] +struct Wrap { + value: T, + count: u8, +} + /// A struct that is not `Copy` holding a `Copy` aggregate by value. struct Holder { pair: (u8, u8), diff --git a/ts/fixtures/lang/collections/src/lib.rs b/ts/fixtures/lang/collections/src/lib.rs new file mode 100644 index 000000000..04d8de931 --- /dev/null +++ b/ts/fixtures/lang/collections/src/lib.rs @@ -0,0 +1,34 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod collections; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("collections::hash_maps", collections::hash_maps), + ("collections::sets", collections::sets), + ("collections::btree_maps", collections::btree_maps), + ("collections::deques", |_, data, out| collections::deques(data, out)), + ("collections::vecs", |_, data, out| collections::vecs(data, out)), + ("collections::stores", |_, data, out| collections::stores(data, out)), + ("collections::optionals", collections::optionals), + ("collections::set_ops", collections::set_ops), + ("collections::unlike_eqs", collections::unlike_eqs), + ("collections::own_nes", collections::own_nes), + ("collections::cell_eqs", collections::cell_eqs), + ("collections::unlike_compares", collections::unlike_compares), + ("collections::ref_orders", collections::ref_orders), + ("collections::deque_ranges", collections::deque_ranges), + ] +} diff --git a/ts/fixtures/lang/collections/ts.toml b/ts/fixtures/lang/collections/ts.toml new file mode 100644 index 000000000..750211e31 --- /dev/null +++ b/ts/fixtures/lang/collections/ts.toml @@ -0,0 +1,2 @@ +package = "lang-collections-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/combinators/Cargo.toml b/ts/fixtures/lang/combinators/Cargo.toml new file mode 100644 index 000000000..3ee5d88b0 --- /dev/null +++ b/ts/fixtures/lang/combinators/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-combinators-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/expected/combinators.ts b/ts/fixtures/lang/combinators/expected/combinators.ts similarity index 96% rename from ts/fixtures/lang/expected/combinators.ts rename to ts/fixtures/lang/combinators/expected/combinators.ts index 4af277ba7..ef8d54943 100644 --- a/ts/fixtures/lang/expected/combinators.ts +++ b/ts/fixtures/lang/combinators/expected/combinators.ts @@ -2,8 +2,8 @@ import * as rt from "./rt.ts"; import { copy$Result_array2_u32_u16, copy$array_u32 } from "./lib.ts"; -import { isSomeAnd$09tpccf, isNoneOr$1s1o3ss, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOrElse$1badkpb as option_unwrapOrElse$1badkpb, unwrapOrElse$13moxzl as option_unwrapOrElse$13moxzl, unwrapOrDefault$165pyh5 as option_unwrapOrDefault$165pyh5, unwrapOrDefault$0wx44sw as option_unwrapOrDefault$0wx44sw, unwrapOrDefault$1q0ps0j as option_unwrapOrDefault$1q0ps0j, map$0oc32h1 as option_map$0oc32h1, map$0ejznqm as option_map$0ejznqm, map$0jg2jop as option_map$0jg2jop, map$0cs071d as option_map$0cs071d, inspect$0di0vx1 as option_inspect$0di0vx1, mapOr$1surhce as option_mapOr$1surhce, mapOr$099335t as option_mapOr$099335t, mapOr$0mmpeqx as option_mapOr$0mmpeqx, mapOrElse$1g6d36t as option_mapOrElse$1g6d36t, okOr$07zal2e as option_okOr$07zal2e, okOr$0m6xlfp as option_okOr$0m6xlfp, okOr$1vxk0yk as option_okOr$1vxk0yk, okOrElse$0awp3vn as option_okOrElse$0awp3vn, okOrElse$1v98j0a as option_okOrElse$1v98j0a, and$06om98g as option_and$06om98g, andThen$17ch833 as option_andThen$17ch833, filter$1855tjj, filter$0v80fk8, or$1loyskh as option_or$1loyskh, orElse$05gzawv as option_orElse$05gzawv, orElse$15bv4ho as option_orElse$15bv4ho, xor$0kctyix, zip$1deudzj, clone$14nprly as option_clone$14nprly } from "./core/option.ts"; -import { isOkAnd$0jj0nkw, isErrAnd$0b01a39, ok$1c77lmd, err$05f656d, asRef$1glrxiq, map$1qqg34g as result_map$1qqg34g, map$132mdj8 as result_map$132mdj8, mapOr$1mu5bvh as result_mapOr$1mu5bvh, mapOrElse$0jxx67n as result_mapOrElse$0jxx67n, mapErr$12w1s5x as result_mapErr$12w1s5x, mapErr$1lsqfgi as result_mapErr$1lsqfgi, inspect$16o3gle as result_inspect$16o3gle, inspectErr$06tv5sa, unwrapOrDefault$1exw7nd as result_unwrapOrDefault$1exw7nd, and$0l7ltae as result_and$0l7ltae, andThen$0hd6ik8 as result_andThen$0hd6ik8, or$1xcfx3w as result_or$1xcfx3w, orElse$13ay4um as result_orElse$13ay4um, unwrapOr$0a4h2e7 as result_unwrapOr$0a4h2e7, unwrapOrElse$1reohq9 as result_unwrapOrElse$1reohq9, unwrapOrElse$009ibtw as result_unwrapOrElse$009ibtw, copied$0ma6p21 as result_copied$0ma6p21, clone$04fntvl as result_clone$04fntvl } from "./core/result.ts"; +import { isSomeAnd$09tpccf, isNoneOr$1s1o3ss, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOrElse$1badkpb as option_unwrapOrElse$1badkpb, unwrapOrElse$13moxzl as option_unwrapOrElse$13moxzl, unwrapOrDefault$165pyh5 as option_unwrapOrDefault$165pyh5, unwrapOrDefault$0wx44sw as option_unwrapOrDefault$0wx44sw, unwrapOrDefault$1q0ps0j as option_unwrapOrDefault$1q0ps0j, map$0oc32h1 as option_map$0oc32h1, map$0ejznqm as option_map$0ejznqm, map$0jg2jop as option_map$0jg2jop, map$0cs071d as option_map$0cs071d, inspect$0di0vx1 as option_inspect$0di0vx1, mapOr$0mmpeqx as option_mapOr$0mmpeqx, mapOr$099335t as option_mapOr$099335t, mapOr$1surhce as option_mapOr$1surhce, mapOrElse$1g6d36t as option_mapOrElse$1g6d36t, okOr$07zal2e as option_okOr$07zal2e, okOr$0m6xlfp as option_okOr$0m6xlfp, okOr$1vxk0yk as option_okOr$1vxk0yk, okOrElse$0awp3vn as option_okOrElse$0awp3vn, okOrElse$1v98j0a as option_okOrElse$1v98j0a, and$06om98g as option_and$06om98g, andThen$17ch833 as option_andThen$17ch833, filter$1855tjj, filter$0v80fk8, or$1loyskh as option_or$1loyskh, orElse$05gzawv as option_orElse$05gzawv, orElse$15bv4ho as option_orElse$15bv4ho, xor$0kctyix, zip$1deudzj, clone$14nprly as option_clone$14nprly } from "./core/option.ts"; +import { isOkAnd$0jj0nkw, isErrAnd$0b01a39, ok$1c77lmd, err$05f656d, asRef$1glrxiq, map$1qqg34g as result_map$1qqg34g, map$132mdj8 as result_map$132mdj8, mapOr$1mu5bvh as result_mapOr$1mu5bvh, mapOrElse$0jxx67n as result_mapOrElse$0jxx67n, mapErr$12w1s5x as result_mapErr$12w1s5x, mapErr$1lsqfgi as result_mapErr$1lsqfgi, inspect$16o3gle as result_inspect$16o3gle, inspectErr$06tv5sa, unwrapOrDefault$1exw7nd as result_unwrapOrDefault$1exw7nd, and$0l7ltae as result_and$0l7ltae, andThen$0hd6ik8 as result_andThen$0hd6ik8, or$1xcfx3w as result_or$1xcfx3w, orElse$13ay4um as result_orElse$13ay4um, unwrapOr$0a4h2e7 as result_unwrapOr$0a4h2e7, unwrapOrElse$1reohq9 as result_unwrapOrElse$1reohq9, unwrapOrElse$009ibtw as result_unwrapOrElse$009ibtw, copied$0ma6p21, clone$04fntvl as result_clone$04fntvl } from "./core/result.ts"; /** Run case `kind % 4` over `data`, whose bytes pick each `Some` or `None`, `Ok` or `Err`. */ export function combinators(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { @@ -127,7 +127,7 @@ export function results(a: rt.u8 | undefined, b: rt.u8 | undefined, limit: rt.u8 }), (e7: rt.u16): undefined => { rt.byteVecPush(out, e7 & 0xff); }).ok ? 1 : 0); - rt.byteVecPush(out, result_unwrapOr$0a4h2e7(result_copied$0ma6p21(result_mapErr$1lsqfgi(asRef$1glrxiq(r), (e8: rt.u16): rt.u16 => { + rt.byteVecPush(out, result_unwrapOr$0a4h2e7(copied$0ma6p21(result_mapErr$1lsqfgi(asRef$1glrxiq(r), (e8: rt.u16): rt.u16 => { return e8; })), 34)); } diff --git a/ts/fixtures/lang/combinators/expected/core/option.ts b/ts/fixtures/lang/combinators/expected/core/option.ts new file mode 100644 index 000000000..51a5cfe35 --- /dev/null +++ b/ts/fixtures/lang/combinators/expected/core/option.ts @@ -0,0 +1,252 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function isSomeAnd$09tpccf(self: rt.u8 | undefined, f: (a0: rt.u8) => boolean): boolean { + if (self === undefined) { + return false; + } + return f(self); +} + +export function isNoneOr$1s1o3ss(self: rt.u8 | undefined, f: (a0: rt.u8) => boolean): boolean { + if (self === undefined) { + return true; + } + return f(self); +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOrElse$1badkpb(self: string | undefined, f: () => string): string { + if (self === undefined) { + return f(); + } + return self; +} + +export function unwrapOrElse$13moxzl(self: rt.u8 | undefined, f: () => rt.u8): rt.u8 { + if (self === undefined) { + return f(); + } + return self; +} + +export function unwrapOrDefault$165pyh5(self: string | undefined): string { + if (self === undefined) { + return ""; + } + return self; +} + +export function unwrapOrDefault$0wx44sw(self: rt.ByteVec | undefined): rt.ByteVec { + if (self === undefined) { + return new rt.ByteVec(); + } + return self; +} + +export function unwrapOrDefault$1q0ps0j(self: rt.u8 | undefined): rt.u8 { + if (self === undefined) { + return 0; + } + return self; +} + +export function map$0oc32h1(self: rt.u8 | undefined, f: (a0: rt.u8) => string): string | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0ejznqm(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.ByteVec): rt.ByteVec | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0jg2jop(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u32[]): rt.u32[] | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0cs071d(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function inspect$0di0vx1(self: rt.u8 | undefined, f: (a0: rt.u8) => undefined): rt.u8 | undefined { + if (self !== undefined) { + f(self); + } + return self; +} + +export function mapOr$0mmpeqx(self: [rt.u8, rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u8, rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$099335t(self: rt.u16 | undefined, default_: rt.u8, f: (a0: rt.u16) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1surhce(self: rt.u8 | undefined, default_: rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOrElse$1g6d36t(self: rt.u8 | undefined, default_: () => rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { + if (self === undefined) { + return default_(); + } + return f(self); +} + +export function okOr$07zal2e(self: rt.u32[] | undefined, err: rt.u8): rt.Result { + if (self === undefined) { + return rt.Err(err); + } + return rt.Ok(self); +} + +export function okOr$0m6xlfp(self: rt.u8 | undefined, err: rt.u16): rt.Result { + if (self === undefined) { + return rt.Err(err); + } + return rt.Ok(self); +} + +export function okOr$1vxk0yk(self: rt.u8 | undefined, err: rt.u8): rt.Result { + if (self === undefined) { + return rt.Err(err); + } + return rt.Ok(self); +} + +export function okOrElse$0awp3vn(self: rt.ByteVec | undefined, err: () => string): rt.Result { + if (self === undefined) { + return rt.Err(err()); + } + return rt.Ok(self); +} + +export function okOrElse$1v98j0a(self: rt.u8 | undefined, err: () => rt.u16): rt.Result { + if (self === undefined) { + return rt.Err(err()); + } + return rt.Ok(self); +} + +export function and$06om98g(self: rt.u8 | undefined, optb: rt.u8 | undefined): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return optb; +} + +export function andThen$17ch833(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8 | undefined): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function filter$1855tjj(self: string | undefined, predicate: (a0: string) => boolean): string | undefined { + if (self !== undefined) { + const x: string = self; + if (predicate(x)) { + return x; + } + } + return undefined; +} + +export function filter$0v80fk8(self: rt.u8 | undefined, predicate: (a0: rt.u8) => boolean): rt.u8 | undefined { + if (self !== undefined) { + const x: rt.u8 = self; + if (predicate(x)) { + return x; + } + } + return undefined; +} + +export function or$1loyskh(self: rt.u8 | undefined, optb: rt.u8 | undefined): rt.u8 | undefined { + if (self === undefined) { + return optb; + } + return self; +} + +export function orElse$05gzawv(self: string | undefined, f: () => string | undefined): string | undefined { + if (self === undefined) { + return f(); + } + return self; +} + +export function orElse$15bv4ho(self: rt.u8 | undefined, f: () => rt.u8 | undefined): rt.u8 | undefined { + if (self === undefined) { + return f(); + } + return self; +} + +export function xor$0kctyix(self: rt.u8 | undefined, optb: rt.u8 | undefined): rt.u8 | undefined { + let _0!: rt.u8 | undefined; + b0: { + if (self === undefined) { + if (optb !== undefined) { + _0 = optb; + break b0; + } + } else if (optb === undefined) { + _0 = self; + break b0; + } + _0 = undefined; + } + return _0; +} + +export function zip$1deudzj(self: rt.u8 | undefined, other: rt.u8 | undefined): [rt.u8, rt.u8] | undefined { + let _0!: [rt.u8, rt.u8] | undefined; + b0: { + if (self !== undefined) { + if (other !== undefined) { + _0 = [self, other] as [rt.u8, rt.u8]; + break b0; + } + } + _0 = undefined; + } + return _0; +} + +export function clone$14nprly(self: string | undefined): string | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/combinators/expected/core/result.ts b/ts/fixtures/lang/combinators/expected/core/result.ts new file mode 100644 index 000000000..3374c9a05 --- /dev/null +++ b/ts/fixtures/lang/combinators/expected/core/result.ts @@ -0,0 +1,166 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function isOkAnd$0jj0nkw(self: rt.Result, f: (a0: rt.u8) => boolean): boolean { + if (self.ok) { + return f(self.value); + } + return false; +} + +export function isErrAnd$0b01a39(self: rt.Result, f: (a0: rt.u16) => boolean): boolean { + if (self.ok) { + return false; + } + return f(self.error); +} + +export function ok$1c77lmd(self: rt.Result): rt.u8 | undefined { + if (self.ok) { + return self.value; + } + return undefined; +} + +export function err$05f656d(self: rt.Result): rt.u16 | undefined { + if (self.ok) { + return undefined; + } + return self.error; +} + +export function asRef$1glrxiq(self: rt.Result): rt.Result { + if (self.ok) { + return rt.Ok(self.value); + } + return rt.Err(self.error); +} + +export function map$1qqg34g(self: rt.Result, op: (a0: rt.ByteVec) => rt.ByteVec): rt.Result { + if (self.ok) { + return rt.Ok(op(self.value)); + } + return self; +} + +export function map$132mdj8(self: rt.Result, op: (a0: rt.u8) => rt.u8): rt.Result { + if (self.ok) { + return rt.Ok(op(self.value)); + } + return self; +} + +export function mapOr$1mu5bvh(self: rt.Result, default_: rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { + if (self.ok) { + return f(self.value); + } + return default_; +} + +export function mapOrElse$0jxx67n(self: rt.Result, default_: (a0: rt.u16) => rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { + if (self.ok) { + return f(self.value); + } + return default_(self.error); +} + +export function mapErr$12w1s5x(self: rt.Result, _: (a0: rt.u8) => rt.u16): rt.Result { + if (self.ok) { + return self as rt.Result; + } + return rt.Err(self.error as rt.u16); +} + +export function mapErr$1lsqfgi(self: rt.Result, op: (a0: rt.u16) => rt.u16): rt.Result { + if (self.ok) { + return self; + } + return rt.Err(op(self.error)); +} + +export function inspect$16o3gle(self: rt.Result, f: (a0: rt.u8) => undefined): rt.Result { + if (self.ok) { + f(self.value); + } + return self; +} + +export function inspectErr$06tv5sa(self: rt.Result, f: (a0: rt.u16) => undefined): rt.Result { + if (!self.ok) { + f(self.error); + } + return self; +} + +export function unwrapOrDefault$1exw7nd(self: rt.Result): rt.u8 { + if (self.ok) { + return self.value; + } + return 0; +} + +export function and$0l7ltae(self: rt.Result, res: rt.Result): rt.Result { + if (self.ok) { + return res; + } + return self; +} + +export function andThen$0hd6ik8(self: rt.Result, op: (a0: rt.u8) => rt.Result): rt.Result { + if (self.ok) { + return op(self.value); + } + return self; +} + +export function or$1xcfx3w(self: rt.Result, res: rt.Result): rt.Result { + if (self.ok) { + return self; + } + return res; +} + +export function orElse$13ay4um(self: rt.Result, op: (a0: rt.u16) => rt.Result): rt.Result { + if (self.ok) { + return self; + } + return op(self.error); +} + +export function unwrapOr$0a4h2e7(self: rt.Result, default_: rt.u8): rt.u8 { + if (self.ok) { + return self.value; + } + return default_; +} + +export function unwrapOrElse$1reohq9(self: rt.Result, op: (a0: rt.u16) => rt.u8): rt.u8 { + if (self.ok) { + return self.value; + } + return op(self.error); +} + +export function unwrapOrElse$009ibtw(self: rt.Result, op: (a0: rt.u8) => rt.u8): rt.u8 { + if (self.ok) { + return self.value; + } + return op(self.error); +} + +export function copied$0ma6p21(self: rt.Result): rt.Result { + if (self.ok) { + return rt.Ok(self.value); + } + return self; +} + +export function clone$04fntvl(self: rt.Result): rt.Result { + if (self.ok) { + return rt.Ok(rt.byteVecFrom(rt.byteVecView(self.value))); + } + return rt.Err(self.error); +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/combinators/expected/harness.ts b/ts/fixtures/lang/combinators/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/combinators/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/combinators/expected/lib.ts b/ts/fixtures/lang/combinators/expected/lib.ts new file mode 100644 index 000000000..13630dd9a --- /dev/null +++ b/ts/fixtures/lang/combinators/expected/lib.ts @@ -0,0 +1,22 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { combinators } from "./combinators.ts"; + +export function copy$Result_array2_u32_u16(v: rt.Result): rt.Result { + return v.ok ? rt.Ok(copy$array_u32(v.value)) : rt.Err(v.error); +} + +export function copy$array_u32(v: rt.u32[]): rt.u32[] { + return v.slice(); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["combinators::combinators", combinators as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/combinators.rs b/ts/fixtures/lang/combinators/src/combinators.rs similarity index 100% rename from ts/fixtures/lang/src/combinators.rs rename to ts/fixtures/lang/combinators/src/combinators.rs diff --git a/ts/fixtures/lang/combinators/src/lib.rs b/ts/fixtures/lang/combinators/src/lib.rs new file mode 100644 index 000000000..2c396f806 --- /dev/null +++ b/ts/fixtures/lang/combinators/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod combinators; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("combinators::combinators", combinators::combinators)] +} diff --git a/ts/fixtures/lang/combinators/ts.toml b/ts/fixtures/lang/combinators/ts.toml new file mode 100644 index 000000000..722c3fe49 --- /dev/null +++ b/ts/fixtures/lang/combinators/ts.toml @@ -0,0 +1,2 @@ +package = "lang-combinators-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/conversions/Cargo.toml b/ts/fixtures/lang/conversions/Cargo.toml new file mode 100644 index 000000000..47ef653fa --- /dev/null +++ b/ts/fixtures/lang/conversions/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-conversions-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/expected/conversions.Held.ts b/ts/fixtures/lang/conversions/expected/conversions.Held.ts similarity index 100% rename from ts/fixtures/lang/expected/conversions.Held.ts rename to ts/fixtures/lang/conversions/expected/conversions.Held.ts diff --git a/ts/fixtures/lang/expected/conversions.Logged.ts b/ts/fixtures/lang/conversions/expected/conversions.Logged.ts similarity index 87% rename from ts/fixtures/lang/expected/conversions.Logged.ts rename to ts/fixtures/lang/conversions/expected/conversions.Logged.ts index d85077ce0..a140f01bf 100644 --- a/ts/fixtures/lang/expected/conversions.Logged.ts +++ b/ts/fixtures/lang/conversions/expected/conversions.Logged.ts @@ -1,7 +1,7 @@ // 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"; +import { byte, 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 @@ -45,9 +45,9 @@ export function partialCmp$cmp_PartialOrd(self: Logged, other: Logged): rt.Order /** 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 new Logged(byte(data, at) & 127, ((a0: rt.Arc>): rt.Arc> => { return rt.arcClone(a0); - })(conversions_LOG.get())); + })(LOG.get())); } /** Its bytes. */ diff --git a/ts/fixtures/lang/expected/conversions.Named.ts b/ts/fixtures/lang/conversions/expected/conversions.Named.ts similarity index 74% rename from ts/fixtures/lang/expected/conversions.Named.ts rename to ts/fixtures/lang/conversions/expected/conversions.Named.ts index a588e2bbb..fc02f4d9e 100644 --- a/ts/fixtures/lang/expected/conversions.Named.ts +++ b/ts/fixtures/lang/conversions/expected/conversions.Named.ts @@ -1,7 +1,7 @@ // 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"; +import { byte, 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 }; @@ -27,7 +27,7 @@ export interface Named { /** 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)) }; + return { id: rt.u8Rem(byte(data, at), 4) as rt.u16, name: make$conversions_Value_String(data, rt.usizeAdd(at, 1)) }; } /** Its bytes. */ diff --git a/ts/fixtures/lang/expected/conversions.ts b/ts/fixtures/lang/conversions/expected/conversions.ts similarity index 87% rename from ts/fixtures/lang/expected/conversions.ts rename to ts/fixtures/lang/conversions/expected/conversions.ts index 34d170b04..f5af8959a 100644 --- a/ts/fixtures/lang/expected/conversions.ts +++ b/ts/fixtures/lang/conversions/expected/conversions.ts @@ -1,10 +1,10 @@ // 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, drop$tuple2_conversions_Logged_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 { copy$array_array0_u8, copy$array_array1_u8, copy$array_array2_u32, copy$array_array3_u8, copy$array_array40_u8, copy$array_u32, copy$array_u8, drop$tuple2_conversions_Logged_u8 } from "./lib.ts"; +import * as Held from "./conversions.Held.ts"; +import * as Logged from "./conversions.Logged.ts"; +import * as Named from "./conversions.Named.ts"; import { thenSome$0b23a33 } from "./core/bool.ts"; import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr } from "./core/option.ts"; @@ -355,13 +355,13 @@ export function cloneFromParam$array40_u8(to: rt.ByteSlice, from: rt.ByteSlice): } /** `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](); +export function cloneFromParam$conversions_Logged(to: Logged.Logged, from: Logged.Logged): void { + rt.replaceIn(to, 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)); +export function cloneFromParam$conversions_Named(to: Named.Named, from: Named.Named): void { + rt.replaceIn(to, Named.clone$Clone(from)); } /** `clone_from` through a `&mut` whose place only the caller knows. */ @@ -425,13 +425,13 @@ export function cloneIntoParam$array40_u8(from: rt.ByteSlice, to: rt.ByteSlice): } /** `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](); +export function cloneIntoParam$conversions_Logged(from: Logged.Logged, to: Logged.Logged): void { + rt.replaceIn(to, 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)); +export function cloneIntoParam$conversions_Named(from: Named.Named, to: Named.Named): void { + rt.replaceIn(to, Named.clone$Clone(from)); } /** `clone_into` through a `&mut` whose place only the caller knows. */ @@ -573,13 +573,13 @@ export function writeFirst$array40_u8(s: Uint8Array[], value: Uint8Array): Uint8 } /** 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 { +export function writeFirst$conversions_Logged(s: Logged.Logged[], value: Logged.Logged): Logged.Logged { rt.idx(s, 0); - const _8: conversions_Logged.Logged = conversions_Logged.clone$Clone(value); + const _8: Logged.Logged = Logged.clone$Clone(value); const old2 = s[0]; s[0] = _8; - const old: conversions_Logged.Logged = old2; - const _10: conversions_Logged.Logged = value; + const old: Logged.Logged = old2; + const _10: Logged.Logged = value; rt.idx(s, 0); s[0][Symbol.dispose](); s[0] = _10; @@ -587,13 +587,13 @@ export function writeFirst$conversions_Logged(s: conversions_Logged.Logged[], va } /** 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 { +export function writeFirst$conversions_Named(s: Named.Named[], value: Named.Named): Named.Named { rt.idx(s, 0); - const _8: conversions_Named.Named = conversions_Named.clone$Clone(value); + const _8: Named.Named = Named.clone$Clone(value); const old2 = s[0]; s[0] = _8; - const old: conversions_Named.Named = old2; - const _10: conversions_Named.Named = value; + const old: Named.Named = old2; + const _10: Named.Named = value; rt.idx(s, 0); s[0] = _10; return old; @@ -741,12 +741,12 @@ export function setThrough$array40_u8(to: rt.ByteSlice, value: Uint8Array): Uint } /** 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 { +export function setThrough$conversions_Logged(to: Logged.Logged, value: Logged.Logged): 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 { +export function setThrough$conversions_Named(to: Named.Named, value: Named.Named): Named.Named { return rt.cellReplace(rt.cellIn(to), value); } @@ -780,7 +780,7 @@ export function converted$Option_u16(data: rt.ByteSlice, out: rt.ByteVec): void 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)); + const held: Held.Held = new 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; @@ -841,7 +841,7 @@ export function converted$String(data: rt.ByteSlice, out: rt.ByteVec): void { 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)); + const held: Held.Held = new 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; @@ -902,7 +902,7 @@ export function converted$Vec_u32(data: rt.ByteSlice, out: rt.ByteVec): void { 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)); + const held: Held.Held = new Held.Held(make$conversions_Value_Vec_u32(data, 1)); held.value = rt.vecClonedInto(rt.vecExact(c.slice(), 4), held.value, 4); const v: rt.u32[][] = [make$conversions_Value_Vec_u32(data, 2), make$conversions_Value_Vec_u32(data, 4)]; const at = rt.idx(v, 1); @@ -965,7 +965,7 @@ export function converted$Vec_u8(data: rt.ByteSlice, out: rt.ByteVec): void { 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)); + const held: Held.Held = new Held.Held(make$conversions_Value_Vec_u8(data, 1)); held.value = rt.byteVecClonedInto(rt.byteVecFrom(rt.byteVecView(c)), held.value); const v: rt.ByteVec[] = [make$conversions_Value_Vec_u8(data, 2), make$conversions_Value_Vec_u8(data, 4)]; const at = rt.idx(v, 1); @@ -1032,7 +1032,7 @@ export function converted$array0_u8(data: rt.ByteSlice, out: rt.ByteVec): void { 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 held: Held.Held = new Held.Held(copy$array_u8(make$conversions_Value_array0_u8(data, 1))); const _34: rt.ByteSlice = rt.byteSliceFrom(c); const _33: rt.ByteSlice = rt.byteSliceFrom(held.value); _33.data.set(rt.byteSliceToArray(_34), _33.start); @@ -1111,7 +1111,7 @@ export function converted$array1_u8(data: rt.ByteSlice, out: rt.ByteVec): void { 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 held: Held.Held = new Held.Held(copy$array_u8(make$conversions_Value_array1_u8(data, 1))); const _34: rt.ByteSlice = rt.byteSliceFrom(c); const _33: rt.ByteSlice = rt.byteSliceFrom(held.value); _33.data.set(rt.byteSliceToArray(_34), _33.start); @@ -1187,7 +1187,7 @@ export function converted$array2_u32(data: rt.ByteSlice, out: rt.ByteVec): void 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))); + const held: Held.Held = new 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); @@ -1252,7 +1252,7 @@ export function converted$array3_u8(data: rt.ByteSlice, out: rt.ByteVec): void { 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 held: Held.Held = new Held.Held(copy$array_u8(make$conversions_Value_array3_u8(data, 1))); const _34: rt.ByteSlice = rt.byteSliceFrom(c); const _33: rt.ByteSlice = rt.byteSliceFrom(held.value); _33.data.set(rt.byteSliceToArray(_34), _33.start); @@ -1332,7 +1332,7 @@ export function converted$array40_u8(data: rt.ByteSlice, out: rt.ByteVec): void 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 held: Held.Held = new Held.Held(copy$array_u8(make$conversions_Value_array40_u8(data, 1))); const _34: rt.ByteSlice = rt.byteSliceFrom(c); const _33: rt.ByteSlice = rt.byteSliceFrom(held.value); _33.data.set(rt.byteSliceToArray(_34), _33.start); @@ -1395,85 +1395,85 @@ export function converted$array40_u8(data: rt.ByteSlice, out: rt.ByteVec): void /** 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); + let a: Logged.Logged = Logged.make$conversions_Value(data, 0); + const b: Logged.Logged = Logged.make$conversions_Value(data, 3); + const owned: Logged.Logged = Logged.clone$Clone(a); const old2 = a; - a = conversions_Logged.clone$Clone(b); + a = 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); + Logged.put$conversions_Value(owned, out); + Logged.put$conversions_Value(a, out); + let c: Logged.Logged = Logged.make$conversions_Value(data, 6); const old3 = c; - c = conversions_Logged.clone$Clone(owned); + c = Logged.clone$Clone(owned); old3[Symbol.dispose](); - conversions_Logged.put$conversions_Value(c, out); + 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)); + Logged.put$conversions_Value(c, out); + Logged.put$conversions_Value(a, out); + const held: Held.Held = new Held.Held(Logged.make$conversions_Value(data, 1)); const old4 = held.value; - held.value = conversions_Logged.clone$Clone(c); + held.value = 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 v: Logged.Logged[] = [Logged.make$conversions_Value(data, 2), Logged.make$conversions_Value(data, 4)]; const at = rt.idx(v, 1); const old5 = v[at]; - v[at] = conversions_Logged.clone$Clone(held.value); + v[at] = 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); + v[at2] = 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]; + Logged.put$conversions_Value(held.value, out); + Logged.put$conversions_Value(v[rt.idx(v, 0)], out); + Logged.put$conversions_Value(v[rt.idx(v, 1)], out); + const one: 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 copied: Logged.Logged = Logged.clone$Clone(one[0]); + Logged.put$conversions_Value(one[0], out); const old7 = a; - a = conversions_Logged.clone$Clone(copied); + a = 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); + Logged.put$conversions_Value(copied, out); + Logged.put$conversions_Value(a, out); + const cell: rt.Cell = rt.cellOfPlace(rt.place(() => c, (value) => c = value)); + const old: Logged.Logged = rt.cellReplace(cell, Logged.make$conversions_Value(data, 10)); + rt.cellSet(cell, Logged.make$conversions_Value(data, 11), rt.drop); + Logged.put$conversions_Value(old, out); + 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); + const _91: Logged.Logged = Logged.make$conversions_Value(data, 12); + const _88: Logged.Logged = setThrough$conversions_Logged(v[at5], _91); + Logged.put$conversions_Value(_88, out); _88[Symbol.dispose](); - conversions_Logged.put$conversions_Value(v[rt.idx(v, 0)], out); + 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.cellSet(rt.cellOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), Logged.make$conversions_Value(data, 17), rt.drop); + Logged.put$conversions_Value(held.value, out); + const array: Logged.Logged[] = [Logged.make$conversions_Value(data, 13), Logged.make$conversions_Value(data, 14), 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; + const _114: Logged.Logged = Logged.clone$Clone(b); + const _116: Logged.Logged[] = array; rt.idx(_116, 0); _116[0][Symbol.dispose](); _116[0] = _114; - const _124: conversions_Logged.Logged[] = array; + const _124: Logged.Logged[] = array; rt.idx(_124, 2); const old8 = _124[2]; - _124[2] = conversions_Logged.clone$Clone(c); + _124[2] = Logged.clone$Clone(c); old8[Symbol.dispose](); for (const _134 of array) { - conversions_Logged.put$conversions_Value(_134, out); + 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); + Logged.put$conversions_Value(b, out); + const q: Logged.Logged = c; + const _145: Logged.Logged = Logged.make$conversions_Value(data, 16); q[Symbol.dispose](); rt.ptrWrite(q, _145); - conversions_Logged.put$conversions_Value(c, out); + Logged.put$conversions_Value(c, out); rt.dropAll(array); old[Symbol.dispose](); copied[Symbol.dispose](); @@ -1487,63 +1487,63 @@ export function converted$conversions_Logged(data: rt.ByteSlice, out: rt.ByteVec /** 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); + let a: Named.Named = Named.make$conversions_Value(data, 0); + const b: Named.Named = Named.make$conversions_Value(data, 3); + const owned: Named.Named = Named.clone$Clone(a); + a = Named.clone$Clone(b); + Named.put$conversions_Value(owned, out); + Named.put$conversions_Value(a, out); + let c: Named.Named = Named.make$conversions_Value(data, 6); + c = Named.clone$Clone(owned); + 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]; + Named.put$conversions_Value(c, out); + Named.put$conversions_Value(a, out); + const held: Held.Held = new Held.Held(Named.make$conversions_Value(data, 1)); + held.value = Named.clone$Clone(c); + const v: Named.Named[] = [Named.make$conversions_Value(data, 2), Named.make$conversions_Value(data, 4)]; + v[rt.idx(v, 1)] = Named.clone$Clone(held.value); + v[rt.idx(v, 0)] = Named.clone$Clone(b); + Named.put$conversions_Value(held.value, out); + Named.put$conversions_Value(v[rt.idx(v, 0)], out); + Named.put$conversions_Value(v[rt.idx(v, 1)], out); + const one: 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 copied: Named.Named = Named.clone$Clone(one[0]); + Named.put$conversions_Value(one[0], out); + a = Named.clone$Clone(copied); + Named.put$conversions_Value(copied, out); + Named.put$conversions_Value(a, out); + const cell: rt.Cell = rt.cellOfPlace(rt.place(() => c, (value) => c = value)); + const old: Named.Named = rt.cellReplace(cell, Named.make$conversions_Value(data, 10)); + rt.cellSet(cell, Named.make$conversions_Value(data, 11)); + Named.put$conversions_Value(old, out); + 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 _91: Named.Named = Named.make$conversions_Value(data, 12); + Named.put$conversions_Value(setThrough$conversions_Named(v[at5], _91), out); + 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.cellSet(rt.cellOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), Named.make$conversions_Value(data, 17)); + Named.put$conversions_Value(held.value, out); + const array: Named.Named[] = [Named.make$conversions_Value(data, 13), Named.make$conversions_Value(data, 14), 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; + const _114: Named.Named = Named.clone$Clone(b); + const _116: Named.Named[] = array; rt.idx(_116, 0); _116[0] = _114; - const _124: conversions_Named.Named[] = array; + const _124: Named.Named[] = array; rt.idx(_124, 2); - _124[2] = conversions_Named.clone$Clone(c); + _124[2] = Named.clone$Clone(c); for (const _134 of array) { - conversions_Named.put$conversions_Value(_134, out); + 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); + Named.put$conversions_Value(b, out); + rt.ptrWrite(c, Named.make$conversions_Value(data, 16)); + Named.put$conversions_Value(c, out); } /** Each conversion of a `T`, its copies put after a write to what they copied. */ @@ -1561,7 +1561,7 @@ export function converted$u32(data: rt.ByteSlice, out: rt.ByteVec): void { 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)); + const held: Held.Held = new 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; @@ -1622,7 +1622,7 @@ export function converted$u64(data: rt.ByteSlice, out: rt.ByteVec): void { 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)); + const held: Held.Held = new 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; @@ -1683,7 +1683,7 @@ export function converted$u8(data: rt.ByteSlice, out: rt.ByteVec): void { 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)); + const held: Held.Held = new 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; @@ -1738,7 +1738,7 @@ export function lentOne$Option_u16(data: rt.ByteSlice, out: rt.ByteVec): void { 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 held: Held.Held = new 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); @@ -1778,7 +1778,7 @@ export function lentOne$String(data: rt.ByteSlice, out: rt.ByteVec): void { 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 held: Held.Held = new 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); @@ -1818,7 +1818,7 @@ export function lentOne$Vec_u32(data: rt.ByteSlice, out: rt.ByteVec): void { 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 held: Held.Held = new 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); @@ -1855,7 +1855,7 @@ export function lentOne$Vec_u8(data: rt.ByteSlice, out: rt.ByteVec): void { 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 held: Held.Held = new 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); @@ -1892,7 +1892,7 @@ export function lentOne$array0_u8(data: rt.ByteSlice, out: rt.ByteVec): void { 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 held: Held.Held = new 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); @@ -1926,7 +1926,7 @@ export function lentOne$array1_u8(data: rt.ByteSlice, out: rt.ByteVec): void { 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 held: Held.Held = new 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); @@ -1963,7 +1963,7 @@ export function lentOne$array2_u32(data: rt.ByteSlice, out: rt.ByteVec): void { 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 held: Held.Held = new 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); @@ -1998,7 +1998,7 @@ export function lentOne$array3_u8(data: rt.ByteSlice, out: rt.ByteVec): void { 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 held: Held.Held = new 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); @@ -2035,7 +2035,7 @@ export function lentOne$array40_u8(data: rt.ByteSlice, out: rt.ByteVec): void { 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 held: Held.Held = new 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); @@ -2068,39 +2068,39 @@ export function lentOne$array40_u8(data: rt.ByteSlice, out: rt.ByteVec): void { * 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)); + const _6: [Logged.Logged, Logged.Logged, Logged.Logged] = [Logged.make$conversions_Value(data, 0), Logged.make$conversions_Value(data, 3), Logged.make$conversions_Value(data, 6)]; + let a: Logged.Logged = _6[0]; + const b: Logged.Logged = _6[1]; + let c: Logged.Logged = _6[2]; + const held: Held.Held = new Held.Held(Logged.make$conversions_Value(data, 1)); + const v: Logged.Logged[] = [Logged.make$conversions_Value(data, 2), Logged.make$conversions_Value(data, 4)]; + const s: 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 _28: Logged.Logged = 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 old: Logged.Logged = old4; + Logged.put$conversions_Value(old, out); + 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 old2: Logged.Logged = writeFirst$conversions_Logged(rt.sliceOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), Logged.make$conversions_Value(data, 7)); + Logged.put$conversions_Value(old2, out); + 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); + const old3: Logged.Logged = writeFirst$conversions_Logged(rt.sliceOfPlace(rt.place(() => borrowed2[borrowed3], (value3) => borrowed2[borrowed3] = value3)), Logged.make$conversions_Value(data, 8)); + Logged.put$conversions_Value(old3, out); + Logged.put$conversions_Value(v[rt.idx(v, 1)], out); + rt.sliceFill(rt.sliceOfPlace(rt.place(() => c, (value4) => c = value4)), Logged.clone$Clone(b), 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); + const _65: Logged.Logged = 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); + Logged.put$conversions_Value(c, out); + Logged.put$conversions_Value(a, out); old3[Symbol.dispose](); old2[Symbol.dispose](); old[Symbol.dispose](); @@ -2116,34 +2116,34 @@ export function lentOne$conversions_Logged(data: rt.ByteSlice, out: rt.ByteVec): * 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)); + const _6: [Named.Named, Named.Named, Named.Named] = [Named.make$conversions_Value(data, 0), Named.make$conversions_Value(data, 3), Named.make$conversions_Value(data, 6)]; + let a: Named.Named = _6[0]; + const b: Named.Named = _6[1]; + let c: Named.Named = _6[2]; + const held: Held.Held = new Held.Held(Named.make$conversions_Value(data, 1)); + const v: Named.Named[] = [Named.make$conversions_Value(data, 2), Named.make$conversions_Value(data, 4)]; + const s: 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 _28: Named.Named = 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); + Named.put$conversions_Value(old4, out); + 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); + Named.put$conversions_Value(writeFirst$conversions_Named(rt.sliceOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), Named.make$conversions_Value(data, 7)), out); + 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); + Named.put$conversions_Value(writeFirst$conversions_Named(rt.sliceOfPlace(rt.place(() => borrowed2[borrowed3], (value3) => borrowed2[borrowed3] = value3)), Named.make$conversions_Value(data, 8)), out); + Named.put$conversions_Value(v[rt.idx(v, 1)], out); + rt.sliceFill(rt.sliceOfPlace(rt.place(() => c, (value4) => c = value4)), Named.clone$Clone(b), 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)); + Object.assign(_61, Named.make$conversions_Value(data, 9)); } - conversions_Named.put$conversions_Value(c, out); - conversions_Named.put$conversions_Value(a, out); + Named.put$conversions_Value(c, out); + Named.put$conversions_Value(a, out); } /** @@ -2155,7 +2155,7 @@ export function lentOne$u32(data: rt.ByteSlice, out: rt.ByteVec): void { 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 held: Held.Held = new 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); @@ -2195,7 +2195,7 @@ export function lentOne$u64(data: rt.ByteSlice, out: rt.ByteVec): void { 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 held: Held.Held = new 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); @@ -2762,19 +2762,19 @@ export function searched$array40_u8(data: rt.ByteSlice, out: rt.ByteVec): void { export function searched$conversions_Logged(data: rt.ByteSlice, out: rt.ByteVec): void { let _45!: rt.usize; let _75!: [rt.u8, rt.usize]; - const v: conversions_Logged.Logged[] = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): conversions_Logged.Logged => { - return conversions_Logged.make$conversions_Value(data, i2); + const v: Logged.Logged[] = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): Logged.Logged => { + return Logged.make$conversions_Value(data, i2); }), undefined, 8, true); - rt.sliceSort(v, rt.cmpLt(conversions_Logged.partialCmp$cmp_PartialOrd), 8, true); - const tagged: [conversions_Logged.Logged, rt.u8][] = rt.iterToArray(rt.iterZip(rt.iterMap(rt.iterSlice(v), conversions_Logged.clone$Clone), new rt.RangeFrom(0, rt.u8Step), "len", rt.drop), undefined, 12, true); + rt.sliceSort(v, rt.cmpLt(Logged.partialCmp$cmp_PartialOrd), 8, true); + const tagged: [Logged.Logged, rt.u8][] = rt.iterToArray(rt.iterZip(rt.iterMap(rt.iterSlice(v), Logged.clone$Clone), new rt.RangeFrom(0, rt.u8Step), "len", rt.drop), undefined, 12, true); const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); l1: while (true) { const _24: rt.usize | rt.Done = iter.next(); if (_24 === rt.DONE) { break; } - const s: conversions_Logged.Logged[] = rt.sliceRange(v, 0, rt.min(_24, v.length)); - const t: [conversions_Logged.Logged, rt.u8][] = rt.sliceRange(tagged, 0, s.length); + const s: Logged.Logged[] = rt.sliceRange(v, 0, rt.min(_24, v.length)); + const t: [Logged.Logged, rt.u8][] = rt.sliceRange(tagged, 0, s.length); const _40: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); let iterStart: rt.usize = 0; const iterEnd: rt.usize = _40; @@ -2782,16 +2782,16 @@ export function searched$conversions_Logged(data: rt.ByteSlice, out: rt.ByteVec) if (!((_45 = iterStart++) < iterEnd)) { continue l1; } - const x: conversions_Logged.Logged = conversions_Logged.make$conversions_Value(data, rt.usizeAdd(rt.usizeMul(_45, 2), 1)); - const iter3: rt.Iter> = rt.iterSlice([rt.sliceBinarySearch(s, x, conversions_Logged.cmp$cmp_Ord), rt.sliceBinarySearchBy(s, (e: conversions_Logged.Logged): rt.Ordering => { - conversions_Logged.put$conversions_Value(e, out); - return conversions_Logged.cmp$cmp_Ord(e, x); - }), rt.sliceBinarySearchByKey(t, x, (_2: [conversions_Logged.Logged, rt.u8]): conversions_Logged.Logged => { + const x: Logged.Logged = Logged.make$conversions_Value(data, rt.usizeAdd(rt.usizeMul(_45, 2), 1)); + const iter3: rt.Iter> = rt.iterSlice([rt.sliceBinarySearch(s, x, Logged.cmp$cmp_Ord), rt.sliceBinarySearchBy(s, (e: Logged.Logged): rt.Ordering => { + Logged.put$conversions_Value(e, out); + return Logged.cmp$cmp_Ord(e, x); + }), rt.sliceBinarySearchByKey(t, x, (_2: [Logged.Logged, rt.u8]): Logged.Logged => { rt.byteVecPush(out, _2[1]); - return conversions_Logged.clone$Clone(_2[0]); - }, conversions_Logged.cmp$cmp_Ord, rt.drop), rt.Ok(rt.slicePartitionPoint(s, (e2: conversions_Logged.Logged): boolean => { - conversions_Logged.put$conversions_Value(e2, out); - return conversions_Logged.partialCmp$cmp_PartialOrd(e2, x) === -1; + return Logged.clone$Clone(_2[0]); + }, Logged.cmp$cmp_Ord, rt.drop), rt.Ok(rt.slicePartitionPoint(s, (e2: Logged.Logged): boolean => { + Logged.put$conversions_Value(e2, out); + return Logged.partialCmp$cmp_PartialOrd(e2, x) === -1; }))]); while (true) { const _69: rt.Result | rt.Done = iter3.next(); @@ -2821,19 +2821,19 @@ export function searched$conversions_Logged(data: rt.ByteSlice, out: rt.ByteVec) export function searched$conversions_Named(data: rt.ByteSlice, out: rt.ByteVec): void { let _45!: rt.usize; let _75!: [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); + const v: Named.Named[] = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): Named.Named => { + return Named.make$conversions_Value(data, i2); }), undefined, 16, true); - rt.sliceSort(v, rt.cmpLt(conversions_Named.partialCmp$cmp_PartialOrd), 16, true); - const tagged: [conversions_Named.Named, rt.u8][] = rt.iterToArray(rt.iterZip(rt.iterMap(rt.iterSlice(v), conversions_Named.clone$Clone), new rt.RangeFrom(0, rt.u8Step), "len"), undefined, 20, true); + rt.sliceSort(v, rt.cmpLt(Named.partialCmp$cmp_PartialOrd), 16, true); + const tagged: [Named.Named, rt.u8][] = rt.iterToArray(rt.iterZip(rt.iterMap(rt.iterSlice(v), Named.clone$Clone), new rt.RangeFrom(0, rt.u8Step), "len"), undefined, 20, true); const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); l1: while (true) { const _24: rt.usize | rt.Done = iter.next(); if (_24 === rt.DONE) { break; } - const s: conversions_Named.Named[] = rt.sliceRange(v, 0, rt.min(_24, v.length)); - const t: [conversions_Named.Named, rt.u8][] = rt.sliceRange(tagged, 0, s.length); + const s: Named.Named[] = rt.sliceRange(v, 0, rt.min(_24, v.length)); + const t: [Named.Named, rt.u8][] = rt.sliceRange(tagged, 0, s.length); const _40: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); let iterStart: rt.usize = 0; const iterEnd: rt.usize = _40; @@ -2841,16 +2841,16 @@ export function searched$conversions_Named(data: rt.ByteSlice, out: rt.ByteVec): if (!((_45 = iterStart++) < iterEnd)) { continue l1; } - const x: conversions_Named.Named = conversions_Named.make$conversions_Value(data, rt.usizeAdd(rt.usizeMul(_45, 2), 1)); - const iter3: rt.Iter> = rt.iterSlice([rt.sliceBinarySearch(s, x, conversions_Named.cmp$cmp_Ord), rt.sliceBinarySearchBy(s, (e: conversions_Named.Named): rt.Ordering => { - conversions_Named.put$conversions_Value(e, out); - return conversions_Named.cmp$cmp_Ord(e, x); - }), rt.sliceBinarySearchByKey(t, x, (_2: [conversions_Named.Named, rt.u8]): conversions_Named.Named => { + const x: Named.Named = Named.make$conversions_Value(data, rt.usizeAdd(rt.usizeMul(_45, 2), 1)); + const iter3: rt.Iter> = rt.iterSlice([rt.sliceBinarySearch(s, x, Named.cmp$cmp_Ord), rt.sliceBinarySearchBy(s, (e: Named.Named): rt.Ordering => { + Named.put$conversions_Value(e, out); + return Named.cmp$cmp_Ord(e, x); + }), rt.sliceBinarySearchByKey(t, x, (_2: [Named.Named, rt.u8]): Named.Named => { rt.byteVecPush(out, _2[1]); - return conversions_Named.clone$Clone(_2[0]); - }, conversions_Named.cmp$cmp_Ord), rt.Ok(rt.slicePartitionPoint(s, (e2: conversions_Named.Named): boolean => { - conversions_Named.put$conversions_Value(e2, out); - return conversions_Named.partialCmp$cmp_PartialOrd(e2, x) === -1; + return Named.clone$Clone(_2[0]); + }, Named.cmp$cmp_Ord), rt.Ok(rt.slicePartitionPoint(s, (e2: Named.Named): boolean => { + Named.put$conversions_Value(e2, out); + return Named.partialCmp$cmp_PartialOrd(e2, x) === -1; }))]); while (true) { const _69: rt.Result | rt.Done = iter3.next(); @@ -3052,7 +3052,7 @@ export function measured(data: rt.ByteSlice, out: rt.ByteVec): void { 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); + 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]; @@ -3074,7 +3074,7 @@ export function measured(data: rt.ByteSlice, out: rt.ByteVec): void { }); 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]])); + const iter: rt.Iter<[rt.usize, rt.usize]> = rt.iterSlice([_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 => { @@ -3095,9 +3095,9 @@ 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]; + const _10: [Named.Named, Named.Named] = [Named.make$conversions_Value(data, 0), Named.make$conversions_Value(data, 3)]; + const x: Named.Named = _10[0]; + const y: 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); diff --git a/ts/fixtures/lang/conversions/expected/core/bool.ts b/ts/fixtures/lang/conversions/expected/core/bool.ts new file mode 100644 index 000000000..a30c8f5aa --- /dev/null +++ b/ts/fixtures/lang/conversions/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0b23a33(self: boolean, t: rt.u16): rt.u16 | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/conversions/expected/core/option.ts b/ts/fixtures/lang/conversions/expected/core/option.ts new file mode 100644 index 000000000..0fb1b6278 --- /dev/null +++ b/ts/fixtures/lang/conversions/expected/core/option.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/conversions/expected/harness.ts b/ts/fixtures/lang/conversions/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/conversions/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/conversions/expected/lib.ts b/ts/fixtures/lang/conversions/expected/lib.ts new file mode 100644 index 000000000..d45b8bc71 --- /dev/null +++ b/ts/fixtures/lang/conversions/expected/lib.ts @@ -0,0 +1,47 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { conversions } from "./conversions.ts"; +import type * as Logged from "./conversions.Logged.ts"; + +export function copy$array_array0_u8(v: Uint8Array[]): Uint8Array[] { + return v.map(copy$array_u8); +} + +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_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_u32(v: rt.u32[]): rt.u32[] { + return v.slice(); +} + +export function copy$array_u8(v: Uint8Array): Uint8Array { + return v.slice(); +} + +export function drop$tuple2_conversions_Logged_u8(_1: [Logged.Logged, rt.u8]): void { + _1[0][Symbol.dispose](); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["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]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/conversions.rs b/ts/fixtures/lang/conversions/src/conversions.rs similarity index 100% rename from ts/fixtures/lang/src/conversions.rs rename to ts/fixtures/lang/conversions/src/conversions.rs diff --git a/ts/fixtures/lang/conversions/src/lib.rs b/ts/fixtures/lang/conversions/src/lib.rs new file mode 100644 index 000000000..e18de1007 --- /dev/null +++ b/ts/fixtures/lang/conversions/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod conversions; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("conversions::conversions", conversions::conversions)] +} diff --git a/ts/fixtures/lang/conversions/ts.toml b/ts/fixtures/lang/conversions/ts.toml new file mode 100644 index 000000000..6a19b532a --- /dev/null +++ b/ts/fixtures/lang/conversions/ts.toml @@ -0,0 +1,2 @@ +package = "lang-conversions-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/counts/Cargo.toml b/ts/fixtures/lang/counts/Cargo.toml new file mode 100644 index 000000000..cf8c203e8 --- /dev/null +++ b/ts/fixtures/lang/counts/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-counts-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/counts/expected/core/bool.ts b/ts/fixtures/lang/counts/expected/core/bool.ts new file mode 100644 index 000000000..17d957542 --- /dev/null +++ b/ts/fixtures/lang/counts/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0d5am30(self: boolean, t: rt.u8): rt.u8 | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/counts/expected/core/option.ts b/ts/fixtures/lang/counts/expected/core/option.ts new file mode 100644 index 000000000..f601c213c --- /dev/null +++ b/ts/fixtures/lang/counts/expected/core/option.ts @@ -0,0 +1,218 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as ArcNode from "../counts.ArcNode.ts"; +import type * as ArcShared from "../counts.ArcShared.ts"; +import type * as Counted from "../counts.Counted.ts"; +import type * as Id from "../counts.Id.ts"; +import type * as Noisy from "../counts.Noisy.ts"; +import type * as RcNode from "../counts.RcNode.ts"; +import type * as RcShared from "../counts.RcShared.ts"; +import type * as Twin from "../counts.Twin.ts"; + +export function unwrapOr$0ujf6zi(self: Twin.Twin | undefined, default_: Twin.Twin): Twin.Twin { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$1srhyy0(self: rt.Arc | undefined, _: (a0: rt.Arc) => rt.Arc): rt.Arc | undefined { + if (self === undefined) { + return undefined; + } + return rt.arcClone(self); +} + +export function map$13pnxtn(self: rt.Arc | undefined, _: (a0: rt.Arc) => Noisy.Noisy): Noisy.Noisy | undefined { + if (self === undefined) { + return undefined; + } + return self.value; +} + +export function map$0ufgkyq(self: rt.Arc | undefined, _: (a0: rt.Arc) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return self.value; +} + +export function mapOr$1xztl8h(self: rt.u8 | undefined | rt.None, default_: rt.u8, f: (a0: rt.u8 | undefined) => rt.u8): rt.u8 { + if (self === rt.None) { + return default_; + } + return f(self); +} + +export function mapOr$036yrbw(self: rt.Arc | undefined, default_: rt.u8, f: (a0: rt.Arc) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1ndy2gq(self: rt.Arc | undefined, default_: rt.u8, f: (a0: rt.Arc) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1qmxzyf(self: rt.Arc | undefined, default_: rt.u8, f: (a0: rt.Arc) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1q3ff8g(self: rt.Arc | undefined, default_: rt.u8, f: (a0: rt.Arc) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1ailw2a(self: Counted.Counted | undefined, default_: rt.u8, f: (a0: Counted.Counted) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1unqgn7(self: rt.Arc[] | undefined, default_: rt.u8, f: (a0: rt.Arc[]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1hh0iyl(self: ArcShared.ArcShared | undefined, default_: rt.u8, f: (a0: ArcShared.ArcShared) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1iuqai4(self: Noisy.Noisy | undefined, default_: rt.u8, f: (a0: Noisy.Noisy) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1kfudqo(self: RcShared.RcShared | undefined, default_: rt.u8, f: (a0: RcShared.RcShared) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1surhce(self: rt.u8 | undefined, default_: rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0dgmbpi(self: rt.Arc | undefined, default_: rt.u8, f: (a0: rt.Arc) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$06rr3sb(self: rt.u8 | undefined, default_: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8 | undefined): rt.u8 | undefined { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function asDeref$0hypa7g(self: rt.Arc | undefined): Noisy.Noisy | undefined { + return map$13pnxtn(self, (a0: rt.Arc): Noisy.Noisy => { + return a0.value; + }); +} + +export function asDeref$0s3650c(self: rt.Arc | undefined): rt.u8 | undefined { + return map$0ufgkyq(self, (a0: rt.Arc): rt.u8 => { + return a0.value; + }); +} + +export function filter$1qg98un(self: rt.Arc | undefined, predicate: (a0: rt.Arc) => boolean): rt.Arc | undefined { + if (self !== undefined) { + const x: rt.Arc = self; + if (!predicate(x)) { + x[Symbol.dispose](); + } else { + return x; + } + } + return undefined; +} + +export function filter$16q8euf(self: rt.Arc[] | undefined, predicate: (a0: rt.Arc[]) => boolean): rt.Arc[] | undefined { + if (self !== undefined) { + const x: rt.Arc[] = self; + if (!predicate(x)) { + rt.dropAll(x); + } else { + return x; + } + } + return undefined; +} + +export function filter$1asvriw(self: ArcShared.ArcShared | undefined, predicate: (a0: ArcShared.ArcShared) => boolean): ArcShared.ArcShared | undefined { + if (self !== undefined) { + const x: ArcShared.ArcShared = self; + if (!predicate(x)) { + x[Symbol.dispose](); + } else { + return x; + } + } + return undefined; +} + +export function filter$1gka6nq(self: Noisy.Noisy | undefined, predicate: (a0: Noisy.Noisy) => boolean): Noisy.Noisy | undefined { + if (self !== undefined) { + const x: Noisy.Noisy = self; + if (!predicate(x)) { + x[Symbol.dispose](); + } else { + return x; + } + } + return undefined; +} + +export function filter$14b5774(self: RcShared.RcShared | undefined, predicate: (a0: RcShared.RcShared) => boolean): RcShared.RcShared | undefined { + if (self !== undefined) { + const x: RcShared.RcShared = self; + if (!predicate(x)) { + x[Symbol.dispose](); + } else { + return x; + } + } + return undefined; +} + +export function or$1loyskh(self: rt.u8 | undefined, optb: rt.u8 | undefined): rt.u8 | undefined { + if (self === undefined) { + return optb; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/expected/counts.ArcHolder.ts b/ts/fixtures/lang/counts/expected/counts.ArcHolder.ts similarity index 100% rename from ts/fixtures/lang/expected/counts.ArcHolder.ts rename to ts/fixtures/lang/counts/expected/counts.ArcHolder.ts diff --git a/ts/fixtures/lang/expected/counts.ArcNode.ts b/ts/fixtures/lang/counts/expected/counts.ArcNode.ts similarity index 83% rename from ts/fixtures/lang/expected/counts.ArcNode.ts rename to ts/fixtures/lang/counts/expected/counts.ArcNode.ts index 9071c5773..f835637b5 100644 --- a/ts/fixtures/lang/expected/counts.ArcNode.ts +++ b/ts/fixtures/lang/counts/expected/counts.ArcNode.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import type * as counts_Noisy from "./counts.Noisy.ts"; +import type * as Noisy from "./counts.Noisy.ts"; /** * Holds handles to itself, which `new_cyclic` gives it before it exists, and what @@ -10,10 +10,10 @@ import type * as counts_Noisy from "./counts.Noisy.ts"; export class ArcNode { this: rt.Weak; more: rt.Weak[]; - noisy: counts_Noisy.Noisy; + noisy: Noisy.Noisy; seen: Uint8Array; - constructor(this_: rt.Weak, more: rt.Weak[], noisy: counts_Noisy.Noisy, seen: Uint8Array) { + constructor(this_: rt.Weak, more: rt.Weak[], noisy: Noisy.Noisy, seen: Uint8Array) { this.this = this_; this.more = more; this.noisy = noisy; @@ -27,7 +27,7 @@ export class ArcNode { } } -function new_(this_: rt.Weak, noisy: counts_Noisy.Noisy, more: rt.u8): ArcNode { +function new_(this_: rt.Weak, noisy: Noisy.Noisy, more: rt.u8): ArcNode { const _4: rt.Weak = rt.weakClone(this_); const _5: rt.Weak[] = rt.iterToArray(rt.iterMap(new rt.Range(0, more), (_2: rt.u8): rt.Weak => { return rt.weakClone(this_); diff --git a/ts/fixtures/lang/expected/counts.ArcReleasing.ts b/ts/fixtures/lang/counts/expected/counts.ArcReleasing.ts similarity index 100% rename from ts/fixtures/lang/expected/counts.ArcReleasing.ts rename to ts/fixtures/lang/counts/expected/counts.ArcReleasing.ts diff --git a/ts/fixtures/lang/expected/counts.ArcShared.ts b/ts/fixtures/lang/counts/expected/counts.ArcShared.ts similarity index 74% rename from ts/fixtures/lang/expected/counts.ArcShared.ts rename to ts/fixtures/lang/counts/expected/counts.ArcShared.ts index f548e282e..9eca8d749 100644 --- a/ts/fixtures/lang/expected/counts.ArcShared.ts +++ b/ts/fixtures/lang/counts/expected/counts.ArcShared.ts @@ -1,14 +1,14 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import type * as counts_Noisy from "./counts.Noisy.ts"; +import type * as Noisy from "./counts.Noisy.ts"; /** Holds a handle, and clones it with a derived `Clone`. */ export class ArcShared { - noisy: rt.Arc; + noisy: rt.Arc; tag: rt.u8; - constructor(noisy: rt.Arc, tag: rt.u8) { + constructor(noisy: rt.Arc, tag: rt.u8) { this.noisy = noisy; this.tag = tag; } diff --git a/ts/fixtures/lang/expected/counts.Counted.ts b/ts/fixtures/lang/counts/expected/counts.Counted.ts similarity index 100% rename from ts/fixtures/lang/expected/counts.Counted.ts rename to ts/fixtures/lang/counts/expected/counts.Counted.ts diff --git a/ts/fixtures/lang/expected/counts.Id.ts b/ts/fixtures/lang/counts/expected/counts.Id.ts similarity index 67% rename from ts/fixtures/lang/expected/counts.Id.ts rename to ts/fixtures/lang/counts/expected/counts.Id.ts index a473f0ec1..380f9191f 100644 --- a/ts/fixtures/lang/expected/counts.Id.ts +++ b/ts/fixtures/lang/counts/expected/counts.Id.ts @@ -1,15 +1,15 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import * as counts_Noisy from "./counts.Noisy.ts"; +import * as Noisy from "./counts.Noisy.ts"; /** What a trait object of a `Noisy` reads. */ export type Id = { id$Id: () => rt.u8 }; export class of$counts_Noisy { - v: counts_Noisy.Noisy; + v: Noisy.Noisy; - constructor(v: counts_Noisy.Noisy) { + constructor(v: Noisy.Noisy) { this.v = v; } @@ -18,7 +18,7 @@ export class of$counts_Noisy { } id$Id(): rt.u8 { - return counts_Noisy.id$counts_Id(this.v); + return Noisy.id$counts_Id(this.v); } } diff --git a/ts/fixtures/lang/expected/counts.Noisy.ts b/ts/fixtures/lang/counts/expected/counts.Noisy.ts similarity index 100% rename from ts/fixtures/lang/expected/counts.Noisy.ts rename to ts/fixtures/lang/counts/expected/counts.Noisy.ts diff --git a/ts/fixtures/lang/expected/counts.RcHolder.ts b/ts/fixtures/lang/counts/expected/counts.RcHolder.ts similarity index 100% rename from ts/fixtures/lang/expected/counts.RcHolder.ts rename to ts/fixtures/lang/counts/expected/counts.RcHolder.ts diff --git a/ts/fixtures/lang/expected/counts.RcNode.ts b/ts/fixtures/lang/counts/expected/counts.RcNode.ts similarity index 83% rename from ts/fixtures/lang/expected/counts.RcNode.ts rename to ts/fixtures/lang/counts/expected/counts.RcNode.ts index 2c768fd1f..2b25a362f 100644 --- a/ts/fixtures/lang/expected/counts.RcNode.ts +++ b/ts/fixtures/lang/counts/expected/counts.RcNode.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import type * as counts_Noisy from "./counts.Noisy.ts"; +import type * as Noisy from "./counts.Noisy.ts"; /** * Holds handles to itself, which `new_cyclic` gives it before it exists, and what @@ -10,10 +10,10 @@ import type * as counts_Noisy from "./counts.Noisy.ts"; export class RcNode { this: rt.Weak; more: rt.Weak[]; - noisy: counts_Noisy.Noisy; + noisy: Noisy.Noisy; seen: Uint8Array; - constructor(this_: rt.Weak, more: rt.Weak[], noisy: counts_Noisy.Noisy, seen: Uint8Array) { + constructor(this_: rt.Weak, more: rt.Weak[], noisy: Noisy.Noisy, seen: Uint8Array) { this.this = this_; this.more = more; this.noisy = noisy; @@ -27,7 +27,7 @@ export class RcNode { } } -function new_(this_: rt.Weak, noisy: counts_Noisy.Noisy, more: rt.u8): RcNode { +function new_(this_: rt.Weak, noisy: Noisy.Noisy, more: rt.u8): RcNode { const _4: rt.Weak = rt.weakClone(this_); const _5: rt.Weak[] = rt.iterToArray(rt.iterMap(new rt.Range(0, more), (_2: rt.u8): rt.Weak => { return rt.weakClone(this_); diff --git a/ts/fixtures/lang/expected/counts.RcReleasing.ts b/ts/fixtures/lang/counts/expected/counts.RcReleasing.ts similarity index 100% rename from ts/fixtures/lang/expected/counts.RcReleasing.ts rename to ts/fixtures/lang/counts/expected/counts.RcReleasing.ts diff --git a/ts/fixtures/lang/expected/counts.RcShared.ts b/ts/fixtures/lang/counts/expected/counts.RcShared.ts similarity index 74% rename from ts/fixtures/lang/expected/counts.RcShared.ts rename to ts/fixtures/lang/counts/expected/counts.RcShared.ts index 14a35a584..1945288be 100644 --- a/ts/fixtures/lang/expected/counts.RcShared.ts +++ b/ts/fixtures/lang/counts/expected/counts.RcShared.ts @@ -1,14 +1,14 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import type * as counts_Noisy from "./counts.Noisy.ts"; +import type * as Noisy from "./counts.Noisy.ts"; /** Holds a handle, and clones it with a derived `Clone`. */ export class RcShared { - noisy: rt.Arc; + noisy: rt.Arc; tag: rt.u8; - constructor(noisy: rt.Arc, tag: rt.u8) { + constructor(noisy: rt.Arc, tag: rt.u8) { this.noisy = noisy; this.tag = tag; } diff --git a/ts/fixtures/lang/expected/counts.Twin.ts b/ts/fixtures/lang/counts/expected/counts.Twin.ts similarity index 100% rename from ts/fixtures/lang/expected/counts.Twin.ts rename to ts/fixtures/lang/counts/expected/counts.Twin.ts diff --git a/ts/fixtures/lang/expected/counts.ts b/ts/fixtures/lang/counts/expected/counts.ts similarity index 77% rename from ts/fixtures/lang/expected/counts.ts rename to ts/fixtures/lang/counts/expected/counts.ts index d9a46b6d8..c82e37ed9 100644 --- a/ts/fixtures/lang/expected/counts.ts +++ b/ts/fixtures/lang/counts/expected/counts.ts @@ -8,14 +8,14 @@ import * as ArcHolder from "./counts.ArcHolder.ts"; import * as ArcNode from "./counts.ArcNode.ts"; import * as ArcReleasing from "./counts.ArcReleasing.ts"; import * as ArcShared from "./counts.ArcShared.ts"; -import * as counts_Counted from "./counts.Counted.ts"; +import * as Counted from "./counts.Counted.ts"; import * as Id from "./counts.Id.ts"; -import * as counts_Noisy from "./counts.Noisy.ts"; +import * as Noisy from "./counts.Noisy.ts"; import * as RcHolder from "./counts.RcHolder.ts"; import * as RcNode from "./counts.RcNode.ts"; import * as RcReleasing from "./counts.RcReleasing.ts"; import * as RcShared from "./counts.RcShared.ts"; -import type * as counts_Twin from "./counts.Twin.ts"; +import type * as Twin from "./counts.Twin.ts"; /** Puts what dropped since the last flush. */ export function flush(log: rt.Mutex, out: rt.ByteVec): void { @@ -31,19 +31,19 @@ export function flush(log: rt.Mutex, out: rt.ByteVec): void { */ export function arcs(data: rt.ByteSlice, out: rt.ByteVec): void { const log: rt.Arc> = new rt.Arc(new rt.Mutex(new rt.ByteVec())); - const strong: rt.Arc[] = []; - const weak: rt.Weak[] = []; + const strong: rt.Arc[] = []; + const weak: rt.Weak[] = []; l1: for (const op of rt.byteSliceView(data)) { const pick: rt.usize = op >> 4 as rt.usize; const _19: rt.u8 = rt.u8Rem(op, 12); if (_19 === 0) { - const _22: rt.Arc = new rt.Arc(new counts_Noisy.Noisy(op, rt.arcClone(log))); + const _22: rt.Arc = new rt.Arc(new Noisy.Noisy(op, rt.arcClone(log))); strong.push(_22); continue; } if (_19 === 1) { if (!((strong.length === 0))) { - const again: rt.Arc = rt.arcClone(strong[rt.idx(strong, rt.usizeRem(pick, strong.length))]); + const again: rt.Arc = rt.arcClone(strong[rt.idx(strong, rt.usizeRem(pick, strong.length))]); strong.push(again); continue; } @@ -55,25 +55,25 @@ export function arcs(data: rt.ByteSlice, out: rt.ByteVec): void { } } if (!((strong.length === 0))) { - const _49: counts_Noisy.Noisy | undefined = rt.arcIntoInner(rt.vecSwapRemove(strong, rt.usizeRem(pick, strong.length))); + const _49: Noisy.Noisy | undefined = rt.arcIntoInner(rt.vecSwapRemove(strong, rt.usizeRem(pick, strong.length))); if (_49 === undefined) { rt.byteVecPush(out, 251); continue; } - const noisy: counts_Noisy.Noisy = _49; + const noisy: Noisy.Noisy = _49; rt.byteVecPush(out, noisy.id); noisy[Symbol.dispose](); continue; } } else if (_19 === 3) { if (!((strong.length === 0))) { - const _62: rt.Weak = new rt.Weak(strong[rt.idx(strong, rt.usizeRem(pick, strong.length))]); + const _62: rt.Weak = new rt.Weak(strong[rt.idx(strong, rt.usizeRem(pick, strong.length))]); weak.push(_62); continue; } } else if (_19 === 4) { if (!((weak.length === 0))) { - const again2: rt.Weak = rt.weakClone(weak[rt.idx(weak, rt.usizeRem(pick, weak.length))]); + const again2: rt.Weak = rt.weakClone(weak[rt.idx(weak, rt.usizeRem(pick, weak.length))]); weak.push(again2); continue; } @@ -84,30 +84,30 @@ export function arcs(data: rt.ByteSlice, out: rt.ByteVec): void { } } else if (_19 === 6) { if (!((weak.length === 0))) { - const _90: rt.Arc | undefined = rt.weakUpgrade(weak[rt.idx(weak, rt.usizeRem(pick, weak.length))]); + const _90: rt.Arc | undefined = rt.weakUpgrade(weak[rt.idx(weak, rt.usizeRem(pick, weak.length))]); if (_90 === undefined) { rt.byteVecPush(out, 254); continue; } - const up: rt.Arc = _90; + const up: rt.Arc = _90; rt.byteVecPush(out, up.value.id); strong.push(up); continue; } } else { if (_19 === 7) { - const _106: rt.Weak = new rt.Weak(); + const _106: rt.Weak = new rt.Weak(); weak.push(_106); continue; } if (_19 === 8) { if (!((strong.length === 0))) { const at3 = rt.idx(strong, rt.usizeRem(pick, strong.length)); - const held: rt.Weak | undefined = new rt.Weak(strong[at3]); - const kept: ArcHolder.ArcHolder = new ArcHolder.ArcHolder(new rt.Weak(strong[at3])); + const held: rt.Weak | undefined = new rt.Weak(strong[at3]); + const kept: ArcHolder.ArcHolder = new ArcHolder.ArcHolder(new rt.Weak(strong[at3])); const captured2 = new rt.Weak(strong[at3]); const read: () => rt.u8 = rt.closure((): rt.u8 => { - return option_mapOr$036yrbw(rt.weakUpgrade(captured2), 253, (s: rt.Arc): rt.u8 => { + return option_mapOr$036yrbw(rt.weakUpgrade(captured2), 253, (s: rt.Arc): rt.u8 => { const _02: rt.u8 = s.value.id; s[Symbol.dispose](); return _02; @@ -126,7 +126,7 @@ export function arcs(data: rt.ByteSlice, out: rt.ByteVec): void { } } else if (_19 === 9) { if (!((strong.length === 0))) { - const _140: counts_Noisy.Noisy | undefined = rt.arcGetMut(strong[rt.idx(strong, rt.usizeRem(pick, strong.length))]); + const _140: Noisy.Noisy | undefined = rt.arcGetMut(strong[rt.idx(strong, rt.usizeRem(pick, strong.length))]); if (_140 === undefined) { rt.byteVecPush(out, 252); continue; @@ -138,7 +138,7 @@ export function arcs(data: rt.ByteSlice, out: rt.ByteVec): void { } else if (_19 === 10) { if (!((strong.length === 0))) { const at = rt.idx(strong, rt.usizeRem(pick, strong.length)); - const noisy2: counts_Noisy.Noisy = rt.arcMakeMut(rt.place(() => strong[at], (value) => strong[at] = value), counts_Noisy.clone$Clone, rt.drop); + const noisy2: Noisy.Noisy = rt.arcMakeMut(rt.place(() => strong[at], (value) => strong[at] = value), Noisy.clone$Clone, rt.drop); noisy2.id = noisy2.id ^ 32; rt.byteVecPush(out, noisy2.id); rt.byteVecPush(out, strong[at].strong & 0xff); @@ -151,10 +151,10 @@ export function arcs(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _171.strong & 0xff); rt.byteVecPush(out, _171.weak & 0xff); } - const iterS3: rt.Weak[] = weak; + const iterS3: rt.Weak[] = weak; let iterI3: number = 0; while (true) { - const _184: rt.Weak | rt.Done = iterI3 < iterS3.length ? iterS3[iterI3++] : rt.DONE; + const _184: rt.Weak | rt.Done = iterI3 < iterS3.length ? iterS3[iterI3++] : rt.DONE; if (_184 === rt.DONE) { continue l1; } @@ -162,9 +162,9 @@ export function arcs(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, rt.weakWeakCount(_184) & 0xff); } } - const _194: rt.Arc | undefined = rt.sliceLast(strong); + const _194: rt.Arc | undefined = rt.sliceLast(strong); if (_194 !== undefined) { - const _200: rt.Arc = rt.arcClone(_194); + const _200: rt.Arc = rt.arcClone(_194); const object: rt.Arc = new rt.ArcDyn(_200, new Id.of$counts_Noisy(_200.value)); const weakObject: rt.Weak = new rt.Weak(object); rt.byteVecPush(out, _194.weak & 0xff); @@ -178,22 +178,22 @@ export function arcs(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, weakObject.arc.strong & 0xff); weakObject[Symbol.dispose](); } - new rt.Arc(new counts_Noisy.Noisy(224, rt.arcClone(log)))[Symbol.dispose](); - const _228: rt.Arc | undefined = option_map$1srhyy0(rt.sliceFirst(strong), (a02: rt.Arc): rt.Arc => { + new rt.Arc(new Noisy.Noisy(224, rt.arcClone(log)))[Symbol.dispose](); + const _228: rt.Arc | undefined = option_map$1srhyy0(rt.sliceFirst(strong), (a02: rt.Arc): rt.Arc => { return rt.arcClone(a02); }); - rt.byteVecPush(out, option_mapOr$1iuqai4(option_asDeref$0hypa7g(_228), 253, (noisy3: counts_Noisy.Noisy): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1iuqai4(option_asDeref$0hypa7g(_228), 253, (noisy3: Noisy.Noisy): rt.u8 => { return noisy3.id; })); rt.drop(_228); rt.dropAll(strong); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(weak), (w: rt.Weak): rt.u8 => { - const _54: rt.Arc | undefined = rt.weakUpgrade(w); + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(weak), (w: rt.Weak): rt.u8 => { + const _54: rt.Arc | undefined = rt.weakUpgrade(w); const _05: rt.u8 = _54 === undefined ? 1 : 0; rt.drop(_54); return _05; }), undefined, true); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(weak), (w2: rt.Weak): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(weak), (w2: rt.Weak): rt.u8 => { return rt.weakWeakCount(w2) & 0xff; }), undefined, true); rt.dropAll(weak); @@ -213,13 +213,13 @@ export function clonedArcs(data: rt.ByteSlice, out: rt.ByteVec): void { let _191: boolean = false; let _192: boolean = false; const log: rt.Arc> = new rt.Arc(new rt.Mutex(new rt.ByteVec())); - const handles: rt.Arc[] = rt.iterToArray(rt.iterMap(new rt.Range(0, 3), (id: rt.u8): rt.Arc => { - return new rt.Arc(new counts_Noisy.Noisy(rt.u8Mul(id, 16), rt.arcClone(log))); + const handles: rt.Arc[] = rt.iterToArray(rt.iterMap(new rt.Range(0, 3), (id: rt.u8): rt.Arc => { + return new rt.Arc(new Noisy.Noisy(rt.u8Mul(id, 16), rt.arcClone(log))); }), undefined, 4, true); - const kept: rt.Arc[] = []; + const kept: rt.Arc[] = []; const shared: ArcShared.ArcShared[] = []; - const noisy: counts_Noisy.Noisy[] = []; - const lists: rt.Arc[][] = []; + const noisy: Noisy.Noisy[] = []; + const lists: rt.Arc[][] = []; for (const op of rt.byteSliceView(data)) { const pick: rt.usize = op >> 4 as rt.usize; const at = rt.idx(handles, rt.usizeRem(pick, handles.length)); @@ -227,18 +227,18 @@ export function clonedArcs(data: rt.ByteSlice, out: rt.ByteVec): void { b2: { const _34: rt.u8 = rt.u8Rem(op, 8); if (_34 === 0) { - const _37: rt.Arc | undefined = rt.sliceGet(handles, rt.usizeRem(pick, 4)); - const again: rt.Arc | undefined = _37 === undefined ? undefined : rt.arcClone(_37); - rt.byteVecPush(out, option_mapOr$036yrbw(again, 253, (h: rt.Arc): rt.u8 => { + const _37: rt.Arc | undefined = rt.sliceGet(handles, rt.usizeRem(pick, 4)); + const again: rt.Arc | undefined = _37 === undefined ? undefined : rt.arcClone(_37); + rt.byteVecPush(out, option_mapOr$036yrbw(again, 253, (h: rt.Arc): rt.u8 => { return h.value.id; })); - const _48: rt.Arc | undefined = filter$1qg98un(again, (_210: rt.Arc): boolean => { + const _48: rt.Arc | undefined = filter$1qg98un(again, (_210: rt.Arc): boolean => { return keep; }); rt.iterExtend(kept, rt.iterOption(_48, rt.drop), "fold", 4, true); } else if (_34 === 1) { - const _54: rt.Place> | undefined = rt.sliceGetMut(handles, rt.usizeRem(pick, handles.length)); - const _61: rt.Arc | undefined = filter$1qg98un(_54 === undefined ? undefined : rt.arcClone(_54.v), (_29: rt.Arc): boolean => { + const _54: rt.Place> | undefined = rt.sliceGetMut(handles, rt.usizeRem(pick, handles.length)); + const _61: rt.Arc | undefined = filter$1qg98un(_54 === undefined ? undefined : rt.arcClone(_54.v), (_29: rt.Arc): boolean => { return keep; }); rt.iterExtend(kept, rt.iterOption(_61, rt.drop), "fold", 4, true); @@ -255,19 +255,19 @@ export function clonedArcs(data: rt.ByteSlice, out: rt.ByteVec): void { }); rt.iterExtend(shared, rt.iterOption(_77, rt.drop), "fold", 8, true); } else if (_34 === 3) { - const made2: counts_Noisy.Noisy = new counts_Noisy.Noisy(op, rt.arcClone(log)); - const _84: counts_Noisy.Noisy | undefined = made2; - const one2: counts_Noisy.Noisy | undefined = _84 === undefined ? undefined : counts_Noisy.clone$Clone(_84); - rt.byteVecPush(out, option_mapOr$1iuqai4(one2, 253, (n2: counts_Noisy.Noisy): rt.u8 => { + const made2: Noisy.Noisy = new Noisy.Noisy(op, rt.arcClone(log)); + const _84: Noisy.Noisy | undefined = made2; + const one2: Noisy.Noisy | undefined = _84 === undefined ? undefined : Noisy.clone$Clone(_84); + rt.byteVecPush(out, option_mapOr$1iuqai4(one2, 253, (n2: Noisy.Noisy): rt.u8 => { return n2.id; })); - const _92: counts_Noisy.Noisy | undefined = filter$1gka6nq(one2, (_25: counts_Noisy.Noisy): boolean => { + const _92: Noisy.Noisy | undefined = filter$1gka6nq(one2, (_25: Noisy.Noisy): boolean => { return keep; }); rt.iterExtend(noisy, rt.iterOption(_92, rt.drop), "fold", 8, true); made2[Symbol.dispose](); } else if (_34 === 4) { - const all: rt.Arc[] = rt.iterToArray(rt.iterMap(rt.iterSlice(handles), (a04: rt.Arc): rt.Arc => { + const all: rt.Arc[] = rt.iterToArray(rt.iterMap(rt.iterSlice(handles), (a04: rt.Arc): rt.Arc => { return rt.arcClone(a04); }), undefined, 4, true); _191 = true; @@ -283,8 +283,8 @@ export function clonedArcs(data: rt.ByteSlice, out: rt.ByteVec): void { } else if (_34 === 5) { const again3: ArcShared.ArcShared[] = rt.iterToArray(rt.iterMap(rt.iterSlice(shared), ArcShared.clone$Clone), undefined, 8, true); _192 = true; - const ids: counts_Noisy.Noisy[] = rt.iterToArray(rt.iterMap(rt.iterSlice(noisy), counts_Noisy.clone$Clone), undefined, 8, true); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(ids), (n: counts_Noisy.Noisy): rt.u8 => { + const ids: Noisy.Noisy[] = rt.iterToArray(rt.iterMap(rt.iterSlice(noisy), Noisy.clone$Clone), undefined, 8, true); + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(ids), (n: Noisy.Noisy): rt.u8 => { return n.id; }), undefined, true); if (keep) { @@ -297,14 +297,14 @@ export function clonedArcs(data: rt.ByteSlice, out: rt.ByteVec): void { } _192 = false; } else if (_34 === 6) { - const _125: rt.Arc[] | undefined = rt.sliceFirst(lists); - const list: rt.Arc[] | undefined = _125 === undefined ? undefined : rt.vecExact(_125.map((a0: rt.Arc): rt.Arc => { + const _125: rt.Arc[] | undefined = rt.sliceFirst(lists); + const list: rt.Arc[] | undefined = _125 === undefined ? undefined : rt.vecExact(_125.map((a0: rt.Arc): rt.Arc => { return rt.arcClone(a0); }), 4); - rt.byteVecPush(out, option_mapOr$1unqgn7(list, 253, (l: rt.Arc[]): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1unqgn7(list, 253, (l: rt.Arc[]): rt.u8 => { return l.length & 0xff; })); - const _134: rt.Arc[] | undefined = filter$16q8euf(list, (_2: rt.Arc[]): boolean => { + const _134: rt.Arc[] | undefined = filter$16q8euf(list, (_2: rt.Arc[]): boolean => { return keep; }); rt.iterExtend(lists, rt.iterOption(_134, drop$Vec_sync_Arc_counts_Noisy), "fold", 12, true); @@ -337,10 +337,10 @@ export function clonedArcs(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, handles[rt.idx(handles, rt.usizeRem(pick, handles.length))].strong & 0xff); flush(log.value, out); } - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(handles), (h2: rt.Arc): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(handles), (h2: rt.Arc): rt.u8 => { return h2.strong & 0xff; }), undefined, true); - drop$tuple5_Vec_sync_Arc_counts_Noisy_Vec_sync_Arc_counts_Noisy_Vec_counts_ArcShared_Vec_counts_Noisy_Vec_Vec_sync_Arc_counts_Noisy([handles, kept, shared, noisy, lists] as [rt.Arc[], rt.Arc[], ArcShared.ArcShared[], counts_Noisy.Noisy[], rt.Arc[][]]); + drop$tuple5_Vec_sync_Arc_counts_Noisy_Vec_sync_Arc_counts_Noisy_Vec_counts_ArcShared_Vec_counts_Noisy_Vec_Vec_sync_Arc_counts_Noisy([handles, kept, shared, noisy, lists] as [rt.Arc[], rt.Arc[], ArcShared.ArcShared[], Noisy.Noisy[], rt.Arc[][]]); flush(log.value, out); log[Symbol.dispose](); } @@ -360,7 +360,7 @@ export function cyclicArcs(data: rt.ByteSlice, out: rt.ByteVec): void { for (const op of rt.byteSliceView(data)) { const _15: rt.Arc> = rt.arcClone(log); _95 = true; - const noisy: counts_Noisy.Noisy = new counts_Noisy.Noisy(op, _15); + const noisy: Noisy.Noisy = new Noisy.Noisy(op, _15); const more: rt.u8 = rt.u8Rem(op >> 2, 4); const _23: rt.u8 = rt.u8Rem(op, 4); if (_23 === 0) { @@ -377,7 +377,7 @@ export function cyclicArcs(data: rt.ByteSlice, out: rt.ByteVec): void { const captured3 = noisy; const captured4 = more; node = rt.arcNewCyclic(rt.closure((this_3: rt.Weak): ArcNode.ArcNode => { - const _03: ArcNode.ArcNode = ArcNode.new(this_3, new counts_Noisy.Noisy(captured3.id ^ 128, rt.arcClone(captured3.log)), captured4); + const _03: ArcNode.ArcNode = ArcNode.new(this_3, new Noisy.Noisy(captured3.id ^ 128, rt.arcClone(captured3.log)), captured4); captured3[Symbol.dispose](); return _03; }, (): void => { @@ -388,13 +388,13 @@ export function cyclicArcs(data: rt.ByteSlice, out: rt.ByteVec): void { const captured = noisy; const captured2 = more; node = rt.arcNewCyclic(rt.once(rt.closure((this_2: rt.Weak): ArcNode.ArcNode => { - return ArcNode.new(this_2, new counts_Noisy.Noisy(captured.id ^ 64, rt.arcClone(captured.log)), captured2); + return ArcNode.new(this_2, new Noisy.Noisy(captured.id ^ 64, rt.arcClone(captured.log)), captured2); }, (): void => { captured[Symbol.dispose](); }))); } else { node = rt.arcNewCyclic((this_: rt.Weak): ArcNode.ArcNode => { - return ArcNode.new(this_, new counts_Noisy.Noisy(238, rt.arcClone(log)), more); + return ArcNode.new(this_, new Noisy.Noisy(238, rt.arcClone(log)), more); }); } rt.iterExtendBytes(out, rt.iterSlice(node.value.seen), undefined, true); @@ -570,13 +570,13 @@ export function clonedRcs(data: rt.ByteSlice, out: rt.ByteVec): void { let _191: boolean = false; let _192: boolean = false; const log: rt.Arc> = new rt.Arc(new rt.Mutex(new rt.ByteVec())); - const handles: rt.Arc[] = rt.iterToArray(rt.iterMap(new rt.Range(0, 3), (id: rt.u8): rt.Arc => { - return new rt.Arc(new counts_Noisy.Noisy(rt.u8Mul(id, 16), rt.arcClone(log))); + const handles: rt.Arc[] = rt.iterToArray(rt.iterMap(new rt.Range(0, 3), (id: rt.u8): rt.Arc => { + return new rt.Arc(new Noisy.Noisy(rt.u8Mul(id, 16), rt.arcClone(log))); }), undefined, 4, true); - const kept: rt.Arc[] = []; + const kept: rt.Arc[] = []; const shared: RcShared.RcShared[] = []; - const noisy: counts_Noisy.Noisy[] = []; - const lists: rt.Arc[][] = []; + const noisy: Noisy.Noisy[] = []; + const lists: rt.Arc[][] = []; for (const op of rt.byteSliceView(data)) { const pick: rt.usize = op >> 4 as rt.usize; const at = rt.idx(handles, rt.usizeRem(pick, handles.length)); @@ -584,18 +584,18 @@ export function clonedRcs(data: rt.ByteSlice, out: rt.ByteVec): void { b2: { const _34: rt.u8 = rt.u8Rem(op, 8); if (_34 === 0) { - const _37: rt.Arc | undefined = rt.sliceGet(handles, rt.usizeRem(pick, 4)); - const again: rt.Arc | undefined = _37 === undefined ? undefined : rt.arcClone(_37); - rt.byteVecPush(out, option_mapOr$036yrbw(again, 253, (h: rt.Arc): rt.u8 => { + const _37: rt.Arc | undefined = rt.sliceGet(handles, rt.usizeRem(pick, 4)); + const again: rt.Arc | undefined = _37 === undefined ? undefined : rt.arcClone(_37); + rt.byteVecPush(out, option_mapOr$036yrbw(again, 253, (h: rt.Arc): rt.u8 => { return h.value.id; })); - const _48: rt.Arc | undefined = filter$1qg98un(again, (_210: rt.Arc): boolean => { + const _48: rt.Arc | undefined = filter$1qg98un(again, (_210: rt.Arc): boolean => { return keep; }); rt.iterExtend(kept, rt.iterOption(_48, rt.drop), "fold", 4, true); } else if (_34 === 1) { - const _54: rt.Place> | undefined = rt.sliceGetMut(handles, rt.usizeRem(pick, handles.length)); - const _61: rt.Arc | undefined = filter$1qg98un(_54 === undefined ? undefined : rt.arcClone(_54.v), (_29: rt.Arc): boolean => { + const _54: rt.Place> | undefined = rt.sliceGetMut(handles, rt.usizeRem(pick, handles.length)); + const _61: rt.Arc | undefined = filter$1qg98un(_54 === undefined ? undefined : rt.arcClone(_54.v), (_29: rt.Arc): boolean => { return keep; }); rt.iterExtend(kept, rt.iterOption(_61, rt.drop), "fold", 4, true); @@ -612,19 +612,19 @@ export function clonedRcs(data: rt.ByteSlice, out: rt.ByteVec): void { }); rt.iterExtend(shared, rt.iterOption(_77, rt.drop), "fold", 8, true); } else if (_34 === 3) { - const made2: counts_Noisy.Noisy = new counts_Noisy.Noisy(op, rt.arcClone(log)); - const _84: counts_Noisy.Noisy | undefined = made2; - const one2: counts_Noisy.Noisy | undefined = _84 === undefined ? undefined : counts_Noisy.clone$Clone(_84); - rt.byteVecPush(out, option_mapOr$1iuqai4(one2, 253, (n2: counts_Noisy.Noisy): rt.u8 => { + const made2: Noisy.Noisy = new Noisy.Noisy(op, rt.arcClone(log)); + const _84: Noisy.Noisy | undefined = made2; + const one2: Noisy.Noisy | undefined = _84 === undefined ? undefined : Noisy.clone$Clone(_84); + rt.byteVecPush(out, option_mapOr$1iuqai4(one2, 253, (n2: Noisy.Noisy): rt.u8 => { return n2.id; })); - const _92: counts_Noisy.Noisy | undefined = filter$1gka6nq(one2, (_25: counts_Noisy.Noisy): boolean => { + const _92: Noisy.Noisy | undefined = filter$1gka6nq(one2, (_25: Noisy.Noisy): boolean => { return keep; }); rt.iterExtend(noisy, rt.iterOption(_92, rt.drop), "fold", 8, true); made2[Symbol.dispose](); } else if (_34 === 4) { - const all: rt.Arc[] = rt.iterToArray(rt.iterMap(rt.iterSlice(handles), (a04: rt.Arc): rt.Arc => { + const all: rt.Arc[] = rt.iterToArray(rt.iterMap(rt.iterSlice(handles), (a04: rt.Arc): rt.Arc => { return rt.arcClone(a04); }), undefined, 4, true); _191 = true; @@ -640,8 +640,8 @@ export function clonedRcs(data: rt.ByteSlice, out: rt.ByteVec): void { } else if (_34 === 5) { const again3: RcShared.RcShared[] = rt.iterToArray(rt.iterMap(rt.iterSlice(shared), RcShared.clone$Clone), undefined, 8, true); _192 = true; - const ids: counts_Noisy.Noisy[] = rt.iterToArray(rt.iterMap(rt.iterSlice(noisy), counts_Noisy.clone$Clone), undefined, 8, true); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(ids), (n: counts_Noisy.Noisy): rt.u8 => { + const ids: Noisy.Noisy[] = rt.iterToArray(rt.iterMap(rt.iterSlice(noisy), Noisy.clone$Clone), undefined, 8, true); + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(ids), (n: Noisy.Noisy): rt.u8 => { return n.id; }), undefined, true); if (keep) { @@ -654,14 +654,14 @@ export function clonedRcs(data: rt.ByteSlice, out: rt.ByteVec): void { } _192 = false; } else if (_34 === 6) { - const _125: rt.Arc[] | undefined = rt.sliceFirst(lists); - const list: rt.Arc[] | undefined = _125 === undefined ? undefined : rt.vecExact(_125.map((a0: rt.Arc): rt.Arc => { + const _125: rt.Arc[] | undefined = rt.sliceFirst(lists); + const list: rt.Arc[] | undefined = _125 === undefined ? undefined : rt.vecExact(_125.map((a0: rt.Arc): rt.Arc => { return rt.arcClone(a0); }), 4); - rt.byteVecPush(out, option_mapOr$1unqgn7(list, 253, (l: rt.Arc[]): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1unqgn7(list, 253, (l: rt.Arc[]): rt.u8 => { return l.length & 0xff; })); - const _134: rt.Arc[] | undefined = filter$16q8euf(list, (_2: rt.Arc[]): boolean => { + const _134: rt.Arc[] | undefined = filter$16q8euf(list, (_2: rt.Arc[]): boolean => { return keep; }); rt.iterExtend(lists, rt.iterOption(_134, drop$Vec_Rc_counts_Noisy), "fold", 12, true); @@ -694,10 +694,10 @@ export function clonedRcs(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, handles[rt.idx(handles, rt.usizeRem(pick, handles.length))].strong & 0xff); flush(log.value, out); } - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(handles), (h2: rt.Arc): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(handles), (h2: rt.Arc): rt.u8 => { return h2.strong & 0xff; }), undefined, true); - drop$tuple5_Vec_Rc_counts_Noisy_Vec_Rc_counts_Noisy_Vec_counts_RcShared_Vec_counts_Noisy_Vec_Vec_Rc_counts_Noisy([handles, kept, shared, noisy, lists] as [rt.Arc[], rt.Arc[], RcShared.RcShared[], counts_Noisy.Noisy[], rt.Arc[][]]); + drop$tuple5_Vec_Rc_counts_Noisy_Vec_Rc_counts_Noisy_Vec_counts_RcShared_Vec_counts_Noisy_Vec_Vec_Rc_counts_Noisy([handles, kept, shared, noisy, lists] as [rt.Arc[], rt.Arc[], RcShared.RcShared[], Noisy.Noisy[], rt.Arc[][]]); flush(log.value, out); log[Symbol.dispose](); } @@ -717,7 +717,7 @@ export function cyclicRcs(data: rt.ByteSlice, out: rt.ByteVec): void { for (const op of rt.byteSliceView(data)) { const _15: rt.Arc> = rt.arcClone(log); _95 = true; - const noisy: counts_Noisy.Noisy = new counts_Noisy.Noisy(op, _15); + const noisy: Noisy.Noisy = new Noisy.Noisy(op, _15); const more: rt.u8 = rt.u8Rem(op >> 2, 4); const _23: rt.u8 = rt.u8Rem(op, 4); if (_23 === 0) { @@ -734,7 +734,7 @@ export function cyclicRcs(data: rt.ByteSlice, out: rt.ByteVec): void { const captured3 = noisy; const captured4 = more; node = rt.arcNewCyclic(rt.closure((this_3: rt.Weak): RcNode.RcNode => { - const _03: RcNode.RcNode = RcNode.new(this_3, new counts_Noisy.Noisy(captured3.id ^ 128, rt.arcClone(captured3.log)), captured4); + const _03: RcNode.RcNode = RcNode.new(this_3, new Noisy.Noisy(captured3.id ^ 128, rt.arcClone(captured3.log)), captured4); captured3[Symbol.dispose](); return _03; }, (): void => { @@ -745,13 +745,13 @@ export function cyclicRcs(data: rt.ByteSlice, out: rt.ByteVec): void { const captured = noisy; const captured2 = more; node = rt.arcNewCyclic(rt.once(rt.closure((this_2: rt.Weak): RcNode.RcNode => { - return RcNode.new(this_2, new counts_Noisy.Noisy(captured.id ^ 64, rt.arcClone(captured.log)), captured2); + return RcNode.new(this_2, new Noisy.Noisy(captured.id ^ 64, rt.arcClone(captured.log)), captured2); }, (): void => { captured[Symbol.dispose](); }))); } else { node = rt.arcNewCyclic((this_: rt.Weak): RcNode.RcNode => { - return RcNode.new(this_, new counts_Noisy.Noisy(238, rt.arcClone(log)), more); + return RcNode.new(this_, new Noisy.Noisy(238, rt.arcClone(log)), more); }); } rt.iterExtendBytes(out, rt.iterSlice(node.value.seen), undefined, true); @@ -799,19 +799,19 @@ export function cyclicRcs(data: rt.ByteSlice, out: rt.ByteVec): void { */ export function rcs(data: rt.ByteSlice, out: rt.ByteVec): void { const log: rt.Arc> = new rt.Arc(new rt.Mutex(new rt.ByteVec())); - const strong: rt.Arc[] = []; - const weak: rt.Weak[] = []; + const strong: rt.Arc[] = []; + const weak: rt.Weak[] = []; l1: for (const op of rt.byteSliceView(data)) { const pick: rt.usize = op >> 4 as rt.usize; const _19: rt.u8 = rt.u8Rem(op, 12); if (_19 === 0) { - const _22: rt.Arc = new rt.Arc(new counts_Noisy.Noisy(op, rt.arcClone(log))); + const _22: rt.Arc = new rt.Arc(new Noisy.Noisy(op, rt.arcClone(log))); strong.push(_22); continue; } if (_19 === 1) { if (!((strong.length === 0))) { - const again: rt.Arc = rt.arcClone(strong[rt.idx(strong, rt.usizeRem(pick, strong.length))]); + const again: rt.Arc = rt.arcClone(strong[rt.idx(strong, rt.usizeRem(pick, strong.length))]); strong.push(again); continue; } @@ -823,25 +823,25 @@ export function rcs(data: rt.ByteSlice, out: rt.ByteVec): void { } } if (!((strong.length === 0))) { - const _49: counts_Noisy.Noisy | undefined = rt.arcIntoInner(rt.vecSwapRemove(strong, rt.usizeRem(pick, strong.length))); + const _49: Noisy.Noisy | undefined = rt.arcIntoInner(rt.vecSwapRemove(strong, rt.usizeRem(pick, strong.length))); if (_49 === undefined) { rt.byteVecPush(out, 251); continue; } - const noisy: counts_Noisy.Noisy = _49; + const noisy: Noisy.Noisy = _49; rt.byteVecPush(out, noisy.id); noisy[Symbol.dispose](); continue; } } else if (_19 === 3) { if (!((strong.length === 0))) { - const _62: rt.Weak = new rt.Weak(strong[rt.idx(strong, rt.usizeRem(pick, strong.length))]); + const _62: rt.Weak = new rt.Weak(strong[rt.idx(strong, rt.usizeRem(pick, strong.length))]); weak.push(_62); continue; } } else if (_19 === 4) { if (!((weak.length === 0))) { - const again2: rt.Weak = rt.weakClone(weak[rt.idx(weak, rt.usizeRem(pick, weak.length))]); + const again2: rt.Weak = rt.weakClone(weak[rt.idx(weak, rt.usizeRem(pick, weak.length))]); weak.push(again2); continue; } @@ -852,30 +852,30 @@ export function rcs(data: rt.ByteSlice, out: rt.ByteVec): void { } } else if (_19 === 6) { if (!((weak.length === 0))) { - const _90: rt.Arc | undefined = rt.weakUpgrade(weak[rt.idx(weak, rt.usizeRem(pick, weak.length))]); + const _90: rt.Arc | undefined = rt.weakUpgrade(weak[rt.idx(weak, rt.usizeRem(pick, weak.length))]); if (_90 === undefined) { rt.byteVecPush(out, 254); continue; } - const up: rt.Arc = _90; + const up: rt.Arc = _90; rt.byteVecPush(out, up.value.id); strong.push(up); continue; } } else { if (_19 === 7) { - const _106: rt.Weak = new rt.Weak(); + const _106: rt.Weak = new rt.Weak(); weak.push(_106); continue; } if (_19 === 8) { if (!((strong.length === 0))) { const at3 = rt.idx(strong, rt.usizeRem(pick, strong.length)); - const held: rt.Weak | undefined = new rt.Weak(strong[at3]); - const kept: RcHolder.RcHolder = new RcHolder.RcHolder(new rt.Weak(strong[at3])); + const held: rt.Weak | undefined = new rt.Weak(strong[at3]); + const kept: RcHolder.RcHolder = new RcHolder.RcHolder(new rt.Weak(strong[at3])); const captured2 = new rt.Weak(strong[at3]); const read: () => rt.u8 = rt.closure((): rt.u8 => { - return option_mapOr$036yrbw(rt.weakUpgrade(captured2), 253, (s: rt.Arc): rt.u8 => { + return option_mapOr$036yrbw(rt.weakUpgrade(captured2), 253, (s: rt.Arc): rt.u8 => { const _02: rt.u8 = s.value.id; s[Symbol.dispose](); return _02; @@ -894,7 +894,7 @@ export function rcs(data: rt.ByteSlice, out: rt.ByteVec): void { } } else if (_19 === 9) { if (!((strong.length === 0))) { - const _140: counts_Noisy.Noisy | undefined = rt.arcGetMut(strong[rt.idx(strong, rt.usizeRem(pick, strong.length))]); + const _140: Noisy.Noisy | undefined = rt.arcGetMut(strong[rt.idx(strong, rt.usizeRem(pick, strong.length))]); if (_140 === undefined) { rt.byteVecPush(out, 252); continue; @@ -906,7 +906,7 @@ export function rcs(data: rt.ByteSlice, out: rt.ByteVec): void { } else if (_19 === 10) { if (!((strong.length === 0))) { const at = rt.idx(strong, rt.usizeRem(pick, strong.length)); - const noisy2: counts_Noisy.Noisy = rt.arcMakeMut(rt.place(() => strong[at], (value) => strong[at] = value), counts_Noisy.clone$Clone, rt.drop); + const noisy2: Noisy.Noisy = rt.arcMakeMut(rt.place(() => strong[at], (value) => strong[at] = value), Noisy.clone$Clone, rt.drop); noisy2.id = noisy2.id ^ 32; rt.byteVecPush(out, noisy2.id); rt.byteVecPush(out, strong[at].strong & 0xff); @@ -919,10 +919,10 @@ export function rcs(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _171.strong & 0xff); rt.byteVecPush(out, _171.weak & 0xff); } - const iterS3: rt.Weak[] = weak; + const iterS3: rt.Weak[] = weak; let iterI3: number = 0; while (true) { - const _184: rt.Weak | rt.Done = iterI3 < iterS3.length ? iterS3[iterI3++] : rt.DONE; + const _184: rt.Weak | rt.Done = iterI3 < iterS3.length ? iterS3[iterI3++] : rt.DONE; if (_184 === rt.DONE) { continue l1; } @@ -930,9 +930,9 @@ export function rcs(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, rt.weakWeakCount(_184) & 0xff); } } - const _194: rt.Arc | undefined = rt.sliceLast(strong); + const _194: rt.Arc | undefined = rt.sliceLast(strong); if (_194 !== undefined) { - const _200: rt.Arc = rt.arcClone(_194); + const _200: rt.Arc = rt.arcClone(_194); const object: rt.Arc = new rt.ArcDyn(_200, new Id.of$counts_Noisy(_200.value)); const weakObject: rt.Weak = new rt.Weak(object); rt.byteVecPush(out, _194.weak & 0xff); @@ -946,22 +946,22 @@ export function rcs(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, weakObject.arc.strong & 0xff); weakObject[Symbol.dispose](); } - new rt.Arc(new counts_Noisy.Noisy(224, rt.arcClone(log)))[Symbol.dispose](); - const _228: rt.Arc | undefined = option_map$1srhyy0(rt.sliceFirst(strong), (a02: rt.Arc): rt.Arc => { + new rt.Arc(new Noisy.Noisy(224, rt.arcClone(log)))[Symbol.dispose](); + const _228: rt.Arc | undefined = option_map$1srhyy0(rt.sliceFirst(strong), (a02: rt.Arc): rt.Arc => { return rt.arcClone(a02); }); - rt.byteVecPush(out, option_mapOr$1iuqai4(option_asDeref$0hypa7g(_228), 253, (noisy3: counts_Noisy.Noisy): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1iuqai4(option_asDeref$0hypa7g(_228), 253, (noisy3: Noisy.Noisy): rt.u8 => { return noisy3.id; })); rt.drop(_228); rt.dropAll(strong); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(weak), (w: rt.Weak): rt.u8 => { - const _54: rt.Arc | undefined = rt.weakUpgrade(w); + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(weak), (w: rt.Weak): rt.u8 => { + const _54: rt.Arc | undefined = rt.weakUpgrade(w); const _05: rt.u8 = _54 === undefined ? 1 : 0; rt.drop(_54); return _05; }), undefined, true); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(weak), (w2: rt.Weak): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(weak), (w2: rt.Weak): rt.u8 => { return rt.weakWeakCount(w2) & 0xff; }), undefined, true); rt.dropAll(weak); @@ -1102,10 +1102,10 @@ export function uniqueRcs(data: rt.ByteSlice, out: rt.ByteVec): void { */ export function copies(data: rt.ByteSlice, out: rt.ByteVec): void { const clones: rt.Cell = new rt.Cell(0); - const counted: counts_Counted.Counted[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): counts_Counted.Counted => { + const counted: Counted.Counted[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): Counted.Counted => { return { id: _2, clones }; }), undefined, 8, true); - const twins: counts_Twin.Twin[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_22: rt.u8): counts_Twin.Twin => { + const twins: Twin.Twin[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_22: rt.u8): Twin.Twin => { const b: rt.u8 = _22; return { _0: b, _1: ~b & 0xff }; }), undefined, 2, true); @@ -1154,26 +1154,26 @@ export function copies(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.byteSliceGet(data, pick), 253)); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.byteSliceGet(data, i), 253)); } else if (_33 === 1) { - const twin: counts_Twin.Twin = option_unwrapOr$0ujf6zi(rt.sliceGet(twins, pick), { _0: 0, _1: 0 }); + const twin: Twin.Twin = option_unwrapOr$0ujf6zi(rt.sliceGet(twins, pick), { _0: 0, _1: 0 }); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(twin._0, twin._1)), undefined, true); } else if (_33 === 2) { - const _95: counts_Counted.Counted | undefined = rt.sliceGet(counted, pick); - rt.byteVecPush(out, option_mapOr$1ailw2a(_95 === undefined ? undefined : counts_Counted.clone$Clone(_95), 253, (c4: counts_Counted.Counted): rt.u8 => { + const _95: Counted.Counted | undefined = rt.sliceGet(counted, pick); + rt.byteVecPush(out, option_mapOr$1ailw2a(_95 === undefined ? undefined : Counted.clone$Clone(_95), 253, (c4: Counted.Counted): rt.u8 => { return c4.id; })); } else if (_33 === 3) { - rt.byteVecPush(out, option_mapOr$1ailw2a(rt.sliceGet(counted, pick), 253, (c3: counts_Counted.Counted): rt.u8 => { + rt.byteVecPush(out, option_mapOr$1ailw2a(rt.sliceGet(counted, pick), 253, (c3: Counted.Counted): rt.u8 => { return c3.id; })); } else if (_33 === 4) { - rt.iterExtendBytes(out, rt.iterMap(rt.iterMap(rt.iterSlice(counted), counts_Counted.clone$Clone), (c2: counts_Counted.Counted): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterMap(rt.iterSlice(counted), Counted.clone$Clone), (c2: Counted.Counted): rt.u8 => { return c2.id; }), undefined, true); } else { - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(counted), (c: counts_Counted.Counted): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(counted), (c: Counted.Counted): rt.u8 => { return c.id; }), undefined, true); - rt.iterExtendBytes(out, rt.iterMap(rt.iterCloned(rt.iterSlice(twins)), (t: counts_Twin.Twin): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterCloned(rt.iterSlice(twins)), (t: Twin.Twin): rt.u8 => { return t._0 ^ t._1; }), undefined, true); } diff --git a/ts/fixtures/lang/counts/expected/harness.ts b/ts/fixtures/lang/counts/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/counts/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/counts/expected/lib.ts b/ts/fixtures/lang/counts/expected/lib.ts new file mode 100644 index 000000000..e7e35afe4 --- /dev/null +++ b/ts/fixtures/lang/counts/expected/lib.ts @@ -0,0 +1,69 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { arcs, clonedArcs, cyclicArcs, uniqueArcs, clonedRcs, cyclicRcs, rcs, uniqueRcs, copies } from "./counts.ts"; +import type * as ArcReleasing from "./counts.ArcReleasing.ts"; +import type * as ArcShared from "./counts.ArcShared.ts"; +import type * as Noisy from "./counts.Noisy.ts"; +import type * as RcReleasing from "./counts.RcReleasing.ts"; +import type * as RcShared from "./counts.RcShared.ts"; + +export function drop$Vec_Rc_counts_Noisy(value: rt.Arc[]): void { + rt.dropAll(value); +} + +export function drop$Vec_sync_Arc_counts_Noisy(value: rt.Arc[]): void { + rt.dropAll(value); +} + +export function drop$cell_RefCell_Vec_Rc_counts_RcReleasing(value: rt.RefCell[]>): void { + rt.dropAll(value.value); +} + +export function drop$cell_RefCell_Vec_sync_Arc_counts_ArcReleasing(value: rt.RefCell[]>): void { + rt.dropAll(value.value); +} + +export function drop$tuple5_Vec_Rc_counts_Noisy_Vec_Rc_counts_Noisy_Vec_counts_RcShared_Vec_counts_Noisy_Vec_Vec_Rc_counts_Noisy(_1: [rt.Arc[], rt.Arc[], RcShared.RcShared[], Noisy.Noisy[], rt.Arc[][]]): void { + rt.dropAll(_1[0]); + rt.dropAll(_1[1]); + rt.dropAll(_1[2]); + rt.dropAll(_1[3]); + rt.dropAll(_1[4], drop$Vec_Rc_counts_Noisy); +} + +export function drop$tuple5_Vec_sync_Arc_counts_Noisy_Vec_sync_Arc_counts_Noisy_Vec_counts_ArcShared_Vec_counts_Noisy_Vec_Vec_sync_Arc_counts_Noisy(_1: [rt.Arc[], rt.Arc[], ArcShared.ArcShared[], Noisy.Noisy[], rt.Arc[][]]): void { + rt.dropAll(_1[0]); + rt.dropAll(_1[1]); + rt.dropAll(_1[2]); + rt.dropAll(_1[3]); + rt.dropAll(_1[4], drop$Vec_sync_Arc_counts_Noisy); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["counts::arcs", (_210: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + arcs(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::rcs", (_211: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + rcs(data2, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::cyclic_arcs", (_212: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + cyclicArcs(data3, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::cyclic_rcs", (_213: rt.u8, data4: rt.ByteSlice, out4: rt.ByteVec): undefined => { + cyclicRcs(data4, out4); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::unique_arcs", (_214: rt.u8, data5: rt.ByteSlice, out5: rt.ByteVec): undefined => { + uniqueArcs(data5, out5); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::unique_rcs", (_215: rt.u8, data6: rt.ByteSlice, out6: rt.ByteVec): undefined => { + uniqueRcs(data6, out6); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::cloned_arcs", (_216: rt.u8, data7: rt.ByteSlice, out7: rt.ByteVec): undefined => { + clonedArcs(data7, out7); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::cloned_rcs", (_217: rt.u8, data8: rt.ByteSlice, out8: rt.ByteVec): undefined => { + clonedRcs(data8, out8); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::copies", (_218: rt.u8, data9: rt.ByteSlice, out9: rt.ByteVec): undefined => { + copies(data9, out9); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/counts.rs b/ts/fixtures/lang/counts/src/counts.rs similarity index 100% rename from ts/fixtures/lang/src/counts.rs rename to ts/fixtures/lang/counts/src/counts.rs diff --git a/ts/fixtures/lang/counts/src/lib.rs b/ts/fixtures/lang/counts/src/lib.rs new file mode 100644 index 000000000..64e7330b9 --- /dev/null +++ b/ts/fixtures/lang/counts/src/lib.rs @@ -0,0 +1,29 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod counts; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("counts::arcs", |_, data, out| counts::arcs(data, out)), + ("counts::rcs", |_, data, out| counts::rcs(data, out)), + ("counts::cyclic_arcs", |_, data, out| counts::cyclic_arcs(data, out)), + ("counts::cyclic_rcs", |_, data, out| counts::cyclic_rcs(data, out)), + ("counts::unique_arcs", |_, data, out| counts::unique_arcs(data, out)), + ("counts::unique_rcs", |_, data, out| counts::unique_rcs(data, out)), + ("counts::cloned_arcs", |_, data, out| counts::cloned_arcs(data, out)), + ("counts::cloned_rcs", |_, data, out| counts::cloned_rcs(data, out)), + ("counts::copies", |_, data, out| counts::copies(data, out)), + ] +} diff --git a/ts/fixtures/lang/counts/ts.toml b/ts/fixtures/lang/counts/ts.toml new file mode 100644 index 000000000..935f21041 --- /dev/null +++ b/ts/fixtures/lang/counts/ts.toml @@ -0,0 +1,2 @@ +package = "lang-counts-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/cows/Cargo.toml b/ts/fixtures/lang/cows/Cargo.toml new file mode 100644 index 000000000..26feb7101 --- /dev/null +++ b/ts/fixtures/lang/cows/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-cows-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/cows/expected/core/option.ts b/ts/fixtures/lang/cows/expected/core/option.ts new file mode 100644 index 000000000..478ebb9be --- /dev/null +++ b/ts/fixtures/lang/cows/expected/core/option.ts @@ -0,0 +1,33 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$1iemzn8(self: string | undefined, default_: string): string { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$1j4op5y(self: rt.u16 | undefined, default_: rt.u16): rt.u16 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$1uo1d4o(self: string | undefined, _: (a0: string) => string): string | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/expected/cows.Named.ts b/ts/fixtures/lang/cows/expected/cows.Named.ts similarity index 100% rename from ts/fixtures/lang/expected/cows.Named.ts rename to ts/fixtures/lang/cows/expected/cows.Named.ts diff --git a/ts/fixtures/lang/expected/cows.Run.ts b/ts/fixtures/lang/cows/expected/cows.Run.ts similarity index 100% rename from ts/fixtures/lang/expected/cows.Run.ts rename to ts/fixtures/lang/cows/expected/cows.Run.ts diff --git a/ts/fixtures/lang/expected/cows.Tally.ts b/ts/fixtures/lang/cows/expected/cows.Tally.ts similarity index 100% rename from ts/fixtures/lang/expected/cows.Tally.ts rename to ts/fixtures/lang/cows/expected/cows.Tally.ts diff --git a/ts/fixtures/lang/expected/cows.ts b/ts/fixtures/lang/cows/expected/cows.ts similarity index 78% rename from ts/fixtures/lang/expected/cows.ts rename to ts/fixtures/lang/cows/expected/cows.ts index 5659f6c47..9f31ae5a2 100644 --- a/ts/fixtures/lang/expected/cows.ts +++ b/ts/fixtures/lang/cows/expected/cows.ts @@ -1,12 +1,11 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { unwrapOr$1iemzn8 as option_unwrapOr$1iemzn8, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOr$1j4op5y as option_unwrapOr$1j4op5y, map$1uo1d4o as option_map$1uo1d4o } from "./core/option.ts"; -import * as cows_Named from "./cows.Named.ts"; -import * as cows_Run from "./cows.Run.ts"; -import * as cows_Tally from "./cows.Tally.ts"; -import { put as fmt_put } from "./fmt.ts"; -import { text as strs_text } from "./strs.ts"; +import { unwrapOr$1iemzn8 as option_unwrapOr$1iemzn8, unwrapOr$1j4op5y as option_unwrapOr$1j4op5y, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$1uo1d4o as option_map$1uo1d4o } from "./core/option.ts"; +import * as Named from "./cows.Named.ts"; +import * as Run from "./cows.Run.ts"; +import * as Tally from "./cows.Tally.ts"; +import { put, text } from "./harness.ts"; /** `to_mut` of a `Result`'s payload, which the store rebuilds the `Result` around. */ export function exclaimed(r: rt.Result): rt.Result { @@ -25,7 +24,7 @@ export function cow(s: string, owned: boolean): string { export function cows(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { let r!: rt.Result; - const s: string = strs_text(data); + const s: string = text(data); const owned: boolean = (kind & 128) !== 0; const first: string = option_unwrapOr$1iemzn8(rt.iterToOption(rt.strSplit(s, "/").next()), ""); const _14: rt.u8 = rt.u8Rem(kind, 6); @@ -34,36 +33,36 @@ export function cows(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, rt.stringLen(c) & 0xff); rt.byteVecPush(out, c.length === 0 ? 1 : 0); rt.byteVecPush(out, rt.iterCount(rt.strChars(c)) & 0xff); - fmt_put(out, c); - fmt_put(out, c); - fmt_put(out, c); - fmt_put(out, c); - fmt_put(out, c); - fmt_put(out, ""); - fmt_put(out, "fallback"); - fmt_put(out, s); + put(out, c); + put(out, c); + put(out, c); + put(out, c); + put(out, c); + put(out, ""); + put(out, "fallback"); + put(out, s); const shared: rt.Arc = new rt.Arc(s); - fmt_put(out, shared.value); - fmt_put(out, option_unwrapOr$1iemzn8(option_map$1uo1d4o(rt.iterNth(rt.strSplit(s, "\\"), 1), (a03: string): string => { + put(out, shared.value); + put(out, option_unwrapOr$1iemzn8(option_map$1uo1d4o(rt.iterNth(rt.strSplit(s, "\\"), 1), (a03: string): string => { return a03; }), "fallback")); - fmt_put(out, cow(first, owned)); - fmt_put(out, first); + put(out, cow(first, owned)); + put(out, first); shared[Symbol.dispose](); } else if (_14 === 1) { let c2: string = cow(s, owned); c2 = c2 + "!"; c2 = c2 + "?"; c2 = c2 + "𐀀"; - fmt_put(out, c2); - fmt_put(out, s); + put(out, c2); + put(out, s); const v: string[] = [cow(first, owned), cow(s, !owned)]; const at = rt.idx(v, 1); v[at] = v[at] + "v"; for (const _124 of v) { - fmt_put(out, _124); + put(out, _124); } - fmt_put(out, c2); + put(out, c2); if ((kind & 64) === 0) { r = rt.Ok(cow(first, owned)); } else { @@ -71,7 +70,7 @@ export function cows(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } const _138: rt.Result = exclaimed(r); if (_138.ok) { - fmt_put(out, _138.value); + put(out, _138.value); } else { rt.byteVecPush(out, _138.error); } @@ -88,19 +87,19 @@ export function cows(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } rt.byteVecPush(out, rt.ordMax(a, b, rt.cmpLt(rt.cmpStr)) === b ? 1 : 0); } else if (_14 === 3) { - const n: cows_Named.Named = cows_Named.new(first, kind); - const m2: cows_Named.Named = cows_Named.clone$Clone(n); - cows_Named.tag(n, 120); - const args2: rt.Fmt[] = [(f: rt.Formatter) => cows_Named.fmt$fmt_Debug(n, f), (f: rt.Formatter) => cows_Named.fmt$fmt_Debug(m2, f)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1]])); - rt.byteVecPush(out, cows_Named.eq$cmp_PartialEq(n, m2) ? 1 : 0); - rt.byteVecPush(out, cows_Named.cmp$cmp_Ord(n, m2) > 0 ? 1 : 0); - rt.byteVecPush(out, cows_Named.partialCmp$cmp_PartialOrd(n, m2) === -1 ? 1 : 0); - fmt_put(out, cows_Named.intoOwned(n).name); - const _252: cows_Named.Named = cows_Named.default$Default(); - const _254: cows_Named.Named = cows_Named.new("", kind); - const args4: rt.Fmt[] = [(f: rt.Formatter) => cows_Named.fmt$fmt_Debug(_252, f), (f: rt.Formatter) => cows_Named.fmt$fmt_Debug(_254, f)]; - fmt_put(out, rt.fmtFormat([args4[0], " ", args4[1]])); + const n: Named.Named = Named.new(first, kind); + const m2: Named.Named = Named.clone$Clone(n); + Named.tag(n, 120); + const args2: rt.Fmt[] = [(f: rt.Formatter) => Named.fmt$fmt_Debug(n, f), (f: rt.Formatter) => Named.fmt$fmt_Debug(m2, f)]; + put(out, rt.fmtFormat([args2[0], " ", args2[1]])); + rt.byteVecPush(out, Named.eq$cmp_PartialEq(n, m2) ? 1 : 0); + rt.byteVecPush(out, Named.cmp$cmp_Ord(n, m2) > 0 ? 1 : 0); + rt.byteVecPush(out, Named.partialCmp$cmp_PartialOrd(n, m2) === -1 ? 1 : 0); + put(out, Named.intoOwned(n).name); + const _252: Named.Named = Named.default$Default(); + const _254: Named.Named = Named.new("", kind); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Named.fmt$fmt_Debug(_252, f), (f: rt.Formatter) => Named.fmt$fmt_Debug(_254, f)]; + put(out, rt.fmtFormat([args4[0], " ", args4[1]])); } else if (_14 === 4) { const counts: rt.BTreeMap = rt.btreeNew(rt.cmpStr) as rt.BTreeMap; const iter3: rt.Iter<[rt.usize, string]> = rt.iterEnumerate(rt.strSplit(s, "/")); @@ -119,30 +118,30 @@ export function cows(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (_285 === rt.DONE) { break; } - fmt_put(out, _285[0]); + put(out, _285[0]); rt.byteVecPush(out, _285[1]); } rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeGet(counts, first), 255)); - const names: rt.HashSet = rt.hashNew(rt.hashing(cows_Named.hash$Hash_hash_DefaultHasher as (a0: cows_Named.Named, a1: rt.Hasher) => undefined, cows_Named.eq$cmp_PartialEq)) as rt.HashSet; + const names: rt.HashSet = rt.hashNew(rt.hashing(Named.hash$Hash_hash_DefaultHasher as (a0: Named.Named, a1: rt.Hasher) => undefined, Named.eq$cmp_PartialEq)) as rt.HashSet; const iter5: rt.Iter = rt.strSplit(s, "/"); while (true) { const _305: string | rt.Done = iter5.next(); if (_305 === rt.DONE) { break; } - const _311: cows_Named.Named = cows_Named.new(_305, 0); + const _311: Named.Named = Named.new(_305, 0); rt.hashAdd(names, _311); } rt.byteVecPush(out, rt.hashLen(names) & 0xff); - const _321: cows_Named.Named = cows_Named.new(first, 0); + const _321: Named.Named = Named.new(first, 0); rt.byteVecPush(out, rt.hashContains(names, _321) ? 1 : 0); } else { const c4: string = cow(s, owned); const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, c4), (f: rt.Formatter) => rt.fmtStr(c4, f)]; - fmt_put(out, rt.fmtFormat(["[", args6[0], "|", rt.fmtSpec({ align: ">", width: 6 }, args6[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args6[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args6[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 3 }, args6[0]), "|", args6[1], "]"])); + put(out, rt.fmtFormat(["[", args6[0], "|", rt.fmtSpec({ align: ">", width: 6 }, args6[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args6[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args6[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 3 }, args6[0]), "|", args6[1], "]"])); const part2 = cow(first, owned); const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part2, f, rt.fmtStr)]; - fmt_put(out, rt.fmtFormat([args8[0]])); + put(out, rt.fmtFormat([args8[0]])); } } @@ -205,7 +204,7 @@ export function hashed$slice_u8(v: rt.ByteSlice): rt.u64 { export function slices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { let made!: rt.u16[]; let _359!: rt.Cow; - let c4!: rt.Cow; + let c4!: rt.Cow; const v: rt.u16[] = words(data); const owned: boolean = (kind & 128) !== 0; const half: rt.u16[] = rt.sliceRange(v, 0, rt.usizeDiv(v.length, 2)); @@ -222,7 +221,7 @@ export function slices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { putWords(out, rt.cowSlice(c)); putWords(out, rt.cowSlice(rt.cowClone(c))); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.cowSlice(c), f, rt.u16Debug)]; - fmt_put(out, rt.fmtFormat([args2[0]])); + put(out, rt.fmtFormat([args2[0]])); putWords(out, rt.cowIntoOwned(c)); const empty: rt.Cow = []; putWords(out, rt.cowSlice(empty)); @@ -258,11 +257,11 @@ export function slices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { for (const _144 of cs) { putWords(out, rt.cowSlice(_144)); } - const run: cows_Run.Run = { words: cowOf(half, owned) }; - const before: cows_Run.Run = cows_Run.clone$Clone(run); - cows_Run.bump(run); - const args4: rt.Fmt[] = [(f: rt.Formatter) => cows_Run.fmt$fmt_Debug(run, f), (f: rt.Formatter) => cows_Run.fmt$fmt_Debug(before, f)]; - fmt_put(out, rt.fmtFormat([args4[0], " ", args4[1]])); + const run: Run.Run = { words: cowOf(half, owned) }; + const before: Run.Run = Run.clone$Clone(run); + Run.bump(run); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Run.fmt$fmt_Debug(run, f), (f: rt.Formatter) => Run.fmt$fmt_Debug(before, f)]; + put(out, rt.fmtFormat([args4[0], " ", args4[1]])); putWords(out, half); putWords(out, rt.cowIntoOwned(c2)); } else if (_15 === 2) { @@ -384,68 +383,68 @@ export function slices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } const _411: rt.Cow = cowOf(half, owned); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeGet(counts, _411), 255)); - const runs: rt.HashSet = rt.hashNew(rt.hashing(cows_Run.hash$Hash_hash_DefaultHasher as (a0: cows_Run.Run, a1: rt.Hasher) => undefined, cows_Run.eq$cmp_PartialEq)) as rt.HashSet; + const runs: rt.HashSet = rt.hashNew(rt.hashing(Run.hash$Hash_hash_DefaultHasher as (a0: Run.Run, a1: rt.Hasher) => undefined, Run.eq$cmp_PartialEq)) as rt.HashSet; const iter6: rt.Iter = rt.sliceChunks(v, 3); while (true) { const _418: rt.u16[] | rt.Done = iter6.next(); if (_418 === rt.DONE) { break; } - const _424: cows_Run.Run = { words: cowOf(_418, owned) }; + const _424: Run.Run = { words: cowOf(_418, owned) }; rt.hashAdd(runs, _424); } rt.byteVecPush(out, rt.hashLen(runs) & 0xff); - const _435: cows_Run.Run = { words: cowOf(rt.sliceRange(v, 0, rt.min(v.length, 3)), !owned) }; + const _435: Run.Run = { words: cowOf(rt.sliceRange(v, 0, rt.min(v.length, 3)), !owned) }; rt.byteVecPush(out, rt.hashContains(runs, _435) ? 1 : 0); - const part4 = cows_Run.default$Default(); - const args6: rt.Fmt[] = [(f: rt.Formatter) => cows_Run.fmt$fmt_Debug(part4, f)]; - fmt_put(out, rt.fmtFormat([args6[0]])); + const part4 = Run.default$Default(); + const args6: rt.Fmt[] = [(f: rt.Formatter) => Run.fmt$fmt_Debug(part4, f)]; + put(out, rt.fmtFormat([args6[0]])); } else { const log: rt.Cell = new rt.Cell(0); - const items: cows_Tally.Tally[] = rt.iterToArray(rt.iterMap(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 4), (_2: rt.u8): cows_Tally.Tally => { - return new cows_Tally.Tally(_2, log); + const items: Tally.Tally[] = rt.iterToArray(rt.iterMap(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 4), (_2: rt.u8): Tally.Tally => { + return new Tally.Tally(_2, log); }), undefined, 8, true); if (!owned) { c4 = new rt.Borrowed(rt.sliceRange(items, 0)); } else { - c4 = rt.vecExact(items.map(cows_Tally.clone$Clone), 8); + c4 = rt.vecExact(items.map(Tally.clone$Clone), 8); } rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u32ToBeBytes(rt.cellReplace(log, 0)))); - const copy: rt.Cow = rt.cowClone(c4, cows_Tally.clone$Clone); + const copy: rt.Cow = rt.cowClone(c4, Tally.clone$Clone); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u32ToBeBytes(rt.cellReplace(log, 0)))); rt.cowDrop(copy); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u32ToBeBytes(rt.cellReplace(log, 0)))); - const _490: rt.Place> = rt.place(() => c4, (value) => c4 = value); + const _490: rt.Place> = rt.place(() => c4, (value) => c4 = value); if (_490.v instanceof rt.Borrowed) { - const _493: cows_Tally.Tally[] = rt.sliceRange(items, rt.min(items.length, 1)); - (_490.v as rt.Borrowed).slice = _493; + const _493: Tally.Tally[] = rt.sliceRange(items, rt.min(items.length, 1)); + (_490.v as rt.Borrowed).slice = _493; } rt.byteVecPush(out, rt.cowSlice(c4).length & 0xff); - const _506: rt.Place> = rt.place(() => c4, (value2) => c4 = value2); - const owned2 = rt.cowIntoOwned(_506.v, cows_Tally.clone$Clone); + const _506: rt.Place> = rt.place(() => c4, (value2) => c4 = value2); + const owned2 = rt.cowIntoOwned(_506.v, Tally.clone$Clone); _506.v = owned2; rt.drop(owned2.pop()); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u32ToBeBytes(rt.cellReplace(log, 0)))); - const _515: rt.Place> = rt.place(() => c4, (value3) => c4 = value3); - const owned3 = rt.cowIntoOwned(_515.v, cows_Tally.clone$Clone); + const _515: rt.Place> = rt.place(() => c4, (value3) => c4 = value3); + const owned3 = rt.cowIntoOwned(_515.v, Tally.clone$Clone); _515.v = owned3; - owned3.push(new cows_Tally.Tally(9, log)); + owned3.push(new Tally.Tally(9, log)); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u32ToBeBytes(rt.cellReplace(log, 0)))); - const _524: rt.Place> = rt.place(() => c4, (value4) => c4 = value4); + const _524: rt.Place> = rt.place(() => c4, (value4) => c4 = value4); if (!(_524.v instanceof rt.Borrowed)) { - const _527: cows_Tally.Tally[] = [new cows_Tally.Tally(7, log), new cows_Tally.Tally(8, log)]; - rt.dropAll(_524.v as cows_Tally.Tally[]); - (_524.v as cows_Tally.Tally[]) = _527; + const _527: Tally.Tally[] = [new Tally.Tally(7, log), new Tally.Tally(8, log)]; + rt.dropAll(_524.v as Tally.Tally[]); + (_524.v as Tally.Tally[]) = _527; } rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u32ToBeBytes(rt.cellReplace(log, 0)))); - const kept3: cows_Tally.Tally[] = rt.cowIntoOwned(c4, cows_Tally.clone$Clone); + const kept3: Tally.Tally[] = rt.cowIntoOwned(c4, Tally.clone$Clone); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u32ToBeBytes(rt.cellReplace(log, 0)))); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(kept3), (t: cows_Tally.Tally): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(kept3), (t: Tally.Tally): rt.u8 => { return t._0; }), undefined, true); rt.dropAll(kept3); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u32ToBeBytes(rt.cellReplace(log, 0)))); - const cloned: cows_Tally.Tally[] = rt.cowIntoOwned(new rt.Borrowed(rt.sliceRange(items, 0)), cows_Tally.clone$Clone); + const cloned: Tally.Tally[] = rt.cowIntoOwned(new rt.Borrowed(rt.sliceRange(items, 0)), Tally.clone$Clone); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u32ToBeBytes(rt.cellReplace(log, 0)))); rt.dropAll(cloned); rt.dropAll(items); @@ -485,7 +484,7 @@ export function bytes(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecExtendFromSlice(out, rt.byteSliceRange(rt.byteCowSlice(c), 0, part2)); const _35: rt.ByteCow = made(half, !owned); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(rt.byteCowSlice(c)), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(rt.byteCowSlice(_35)), f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1]])); const _47: rt.ByteCow = made(half, !owned); const _44: boolean = rt.eqBytes(c, _47); const _49: boolean = rt.eqBytes(c, data); diff --git a/ts/fixtures/lang/cows/expected/harness.ts b/ts/fixtures/lang/cows/expected/harness.ts new file mode 100644 index 000000000..7c19e53ff --- /dev/null +++ b/ts/fixtures/lang/cows/expected/harness.ts @@ -0,0 +1,64 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +/** A char of the alphabet for each byte, by its low bits. */ +export function text(data: rt.ByteSlice): string { + let s: string = ""; + const iterS: Uint8Array = rt.byteSliceView(data); + let iterI: number = 0; + while (true) { + const _5: rt.u8 | rt.Done = iterI < iterS.length ? iterS[iterI++] : rt.DONE; + if (_5 === rt.DONE) { + return s; + } + const _13: rt.usize = rt.u8Rem(_5, 16) as rt.usize; + if (!(_13 < 16)) { + rt.panic("index out of bounds: the len is " + 16 + " but the index is " + _13); + } + s = s + String.fromCodePoint([47, 92, 97, 48, 57, 127, 128, 233, 2047, 2048, 55295, 57344, 65535, 65536, 128512, 1114111][_13]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/cows/expected/lib.ts b/ts/fixtures/lang/cows/expected/lib.ts new file mode 100644 index 000000000..51040dee5 --- /dev/null +++ b/ts/fixtures/lang/cows/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cows, slices, bytes } from "./cows.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["cows::cows", cows as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["cows::slices", slices as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["cows::bytes", bytes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/cows.rs b/ts/fixtures/lang/cows/src/cows.rs similarity index 99% rename from ts/fixtures/lang/src/cows.rs rename to ts/fixtures/lang/cows/src/cows.rs index d51dc5ad3..b228616db 100644 --- a/ts/fixtures/lang/src/cows.rs +++ b/ts/fixtures/lang/cows/src/cows.rs @@ -10,8 +10,7 @@ use std::collections::{BTreeMap, HashSet}; use std::hash::{DefaultHasher, Hash, Hasher}; use std::sync::Arc; -use crate::fmt::put; -use crate::strs::text; +use crate::harness::{put, text}; const FALLBACK: Cow<'static, str> = Cow::Borrowed("fallback"); diff --git a/ts/fixtures/lang/cows/src/lib.rs b/ts/fixtures/lang/cows/src/lib.rs new file mode 100644 index 000000000..f5e73a345 --- /dev/null +++ b/ts/fixtures/lang/cows/src/lib.rs @@ -0,0 +1,23 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod cows; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("cows::cows", cows::cows), + ("cows::slices", cows::slices), + ("cows::bytes", cows::bytes), + ] +} diff --git a/ts/fixtures/lang/cows/ts.toml b/ts/fixtures/lang/cows/ts.toml new file mode 100644 index 000000000..7f06de03d --- /dev/null +++ b/ts/fixtures/lang/cows/ts.toml @@ -0,0 +1,2 @@ +package = "lang-cows-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/cycles/Cargo.toml b/ts/fixtures/lang/cycles/Cargo.toml new file mode 100644 index 000000000..e733b4b0f --- /dev/null +++ b/ts/fixtures/lang/cycles/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-cycles-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/cycles/expected/core/bool.ts b/ts/fixtures/lang/cycles/expected/core/bool.ts new file mode 100644 index 000000000..17d957542 --- /dev/null +++ b/ts/fixtures/lang/cycles/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0d5am30(self: boolean, t: rt.u8): rt.u8 | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/cycles/expected/core/option.ts b/ts/fixtures/lang/cycles/expected/core/option.ts new file mode 100644 index 000000000..5b8107486 --- /dev/null +++ b/ts/fixtures/lang/cycles/expected/core/option.ts @@ -0,0 +1,62 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Logged from "../cycles.Logged.ts"; + +export function unwrapOr$1rbuegs(self: rt.ByteSlice | undefined, default_: rt.ByteSlice): rt.ByteSlice { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$1u07cey(self: Logged.Logged | undefined, f: (a0: Logged.Logged) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$05nbzug(self: rt.usize | undefined, f: (a0: rt.usize) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function mapOr$0djjvgl(self: Logged.Logged | undefined, default_: rt.u8, f: (a0: Logged.Logged) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1surhce(self: rt.u8 | undefined, default_: rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$06gg5x7(self: [rt.usize, rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.usize, rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$02k4ito(self: rt.usize | undefined, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/expected/cycles.Countdown.ts b/ts/fixtures/lang/cycles/expected/cycles.Countdown.ts similarity index 100% rename from ts/fixtures/lang/expected/cycles.Countdown.ts rename to ts/fixtures/lang/cycles/expected/cycles.Countdown.ts diff --git a/ts/fixtures/lang/expected/cycles.Logged.ts b/ts/fixtures/lang/cycles/expected/cycles.Logged.ts similarity index 100% rename from ts/fixtures/lang/expected/cycles.Logged.ts rename to ts/fixtures/lang/cycles/expected/cycles.Logged.ts diff --git a/ts/fixtures/lang/expected/cycles.ts b/ts/fixtures/lang/cycles/expected/cycles.ts similarity index 92% rename from ts/fixtures/lang/expected/cycles.ts rename to ts/fixtures/lang/cycles/expected/cycles.ts index b87c7ad48..b70511bd2 100644 --- a/ts/fixtures/lang/expected/cycles.ts +++ b/ts/fixtures/lang/cycles/expected/cycles.ts @@ -2,9 +2,9 @@ import * as rt from "./rt.ts"; import { thenSome$0d5am30 } from "./core/bool.ts"; -import { unwrapOr$1rbuegs as option_unwrapOr$1rbuegs, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$1u07cey as option_map$1u07cey, map$05nbzug as option_map$05nbzug, mapOr$0djjvgl as option_mapOr$0djjvgl, mapOr$1surhce as option_mapOr$1surhce, mapOr$02k4ito as option_mapOr$02k4ito, mapOr$06gg5x7 as option_mapOr$06gg5x7 } from "./core/option.ts"; -import * as cycles_Countdown from "./cycles.Countdown.ts"; -import * as cycles_Logged from "./cycles.Logged.ts"; +import { unwrapOr$1rbuegs as option_unwrapOr$1rbuegs, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$1u07cey as option_map$1u07cey, map$05nbzug as option_map$05nbzug, mapOr$0djjvgl as option_mapOr$0djjvgl, mapOr$1surhce as option_mapOr$1surhce, mapOr$06gg5x7 as option_mapOr$06gg5x7, mapOr$02k4ito as option_mapOr$02k4ito } from "./core/option.ts"; +import * as Countdown from "./cycles.Countdown.ts"; +import * as Logged from "./cycles.Logged.ts"; /** Puts what was logged since the last flush, after a marker. */ export function flush(log: rt.RefCell, out: rt.ByteVec): void { @@ -19,9 +19,9 @@ export function flush(log: rt.RefCell, out: rt.ByteVec): void { * or `find` or `position` of the item a count picks, each item as `put` makes it, or * 0xee for none. */ -export function read$cycles_Countdown_cycles_cycles_closure4(it: cycles_Countdown.Countdown, steps: rt.ByteSlice, put: (a0: rt.u8) => rt.u8, out: rt.ByteVec): void { +export function read$cycles_Countdown_cycles_cycles_closure4(it: Countdown.Countdown, steps: rt.ByteSlice, put: (a0: rt.u8) => rt.u8, out: rt.ByteVec): void { let item!: rt.u8 | undefined; - const it2: rt.Iter = rt.iterCycle(rt.iterFrom(it, (it: cycles_Countdown.Countdown) => cycles_Countdown.next$iter_Iterator(it)), { v: cycles_Countdown.clone$Clone }); + const it2: rt.Iter = rt.iterCycle(rt.iterFrom(it, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it)), { v: Countdown.clone$Clone }); const _8: [rt.usize, rt.usize | undefined] = it2.sizeHint(); const lower: rt.usize = _8[0]; rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(lower & 0xff, (lower >>> 24) & 0xff, option_mapOr$02k4ito(_8[1], 254, (n2: rt.usize): rt.u8 => { @@ -163,9 +163,9 @@ export function read$iter_Cycle_slice_Iter_u8_cycles_cycles_closure1(it: rt.Iter * or `find` or `position` of the item a count picks, each item as `put` makes it, or * 0xee for none. */ -export function read$iter_Cycle_vec_IntoIter_cycles_Logged_cycles_owned_closure6(it: rt.Iter, steps: rt.ByteSlice, put: (a0: cycles_Logged.Logged) => rt.u8, out: rt.ByteVec): void { - let item!: cycles_Logged.Logged | undefined; - const it2: rt.Iter = rt.iterCycle(it, { i: { v: cycles_Logged.clone$Clone } }); +export function read$iter_Cycle_vec_IntoIter_cycles_Logged_cycles_owned_closure6(it: rt.Iter, steps: rt.ByteSlice, put: (a0: Logged.Logged) => rt.u8, out: rt.ByteVec): void { + let item!: Logged.Logged | undefined; + const it2: rt.Iter = rt.iterCycle(it, { i: { v: Logged.clone$Clone } }); const _8: [rt.usize, rt.usize | undefined] = it2.sizeHint(); const lower: rt.usize = _8[0]; rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(lower & 0xff, (lower >>> 24) & 0xff, option_mapOr$02k4ito(_8[1], 254, (n2: rt.usize): rt.u8 => { @@ -180,7 +180,7 @@ export function read$iter_Cycle_vec_IntoIter_cycles_Logged_cycles_owned_closure6 const step: rt.u8 = _22; const n: rt.usize = rt.usizeRem(step >> 2 as rt.usize, 9); let left: rt.usize = n; - const nth: (a0: cycles_Logged.Logged) => boolean = (_2: cycles_Logged.Logged): boolean => { + const nth: (a0: Logged.Logged) => boolean = (_2: Logged.Logged): boolean => { const hit: boolean = left === 0; left = rt.usizeWrappingSub(left, 1); return hit; @@ -191,11 +191,11 @@ export function read$iter_Cycle_vec_IntoIter_cycles_Logged_cycles_owned_closure6 } else if (_36 === 1) { item = rt.iterNth(it2, n, rt.drop); } else if (_36 === 2) { - item = rt.iterFind(it2, (item3: cycles_Logged.Logged): boolean => { + item = rt.iterFind(it2, (item3: Logged.Logged): boolean => { return nth(item3); }, rt.drop); } else { - rt.byteVecPush(out, option_mapOr$02k4ito(rt.iterPosition(it2, (item2: cycles_Logged.Logged): boolean => { + rt.byteVecPush(out, option_mapOr$02k4ito(rt.iterPosition(it2, (item2: Logged.Logged): boolean => { const _02: boolean = nth(item2); item2[Symbol.dispose](); return _02; @@ -1059,15 +1059,15 @@ export function cycles(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { */ export function closures(data: rt.ByteSlice, steps: rt.ByteSlice, out: rt.ByteVec): void { const log: rt.Arc> = new rt.Arc(new rt.RefCell(new rt.ByteVec())); - const logged: (a0: rt.u8) => cycles_Logged.Logged = (id: rt.u8): cycles_Logged.Logged => { - return new cycles_Logged.Logged(id, rt.arcClone(log)); + const logged: (a0: rt.u8) => Logged.Logged = (id: rt.u8): Logged.Logged => { + return new Logged.Logged(id, rt.arcClone(log)); }; - const tag: cycles_Logged.Logged = logged(16); + const tag: Logged.Logged = logged(16); const _13: rt.Iter = rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 3); - const make = (captured: cycles_Logged.Logged): (a0: rt.u8) => rt.u8 => { + const make = (captured: Logged.Logged): (a0: rt.u8) => rt.u8 => { return rt.closure(rt.cloning((_2: rt.u8): rt.u8 => { - return cycles_Logged.called(captured, _2); - }, () => make(cycles_Logged.clone$Clone(captured))), (): void => { + return Logged.called(captured, _2); + }, () => make(Logged.clone$Clone(captured))), (): void => { captured[Symbol.dispose](); }); }; @@ -1099,25 +1099,25 @@ export function closures(data: rt.ByteSlice, steps: rt.ByteSlice, out: rt.ByteVe flush(log.value, out); rt.drop(it2); flush(log.value, out); - const _71: [cycles_Logged.Logged, rt.u8] = [logged(32), 0]; - const tag2: cycles_Logged.Logged = _71[0]; + const _71: [Logged.Logged, rt.u8] = [logged(32), 0]; + const tag2: Logged.Logged = _71[0]; const count: rt.u8 = 0; const _76: rt.Iter = rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 4); - const make2 = (captured2: rt.u8, captured3: cycles_Logged.Logged): (a0: rt.u8) => rt.u8 => { + const make2 = (captured2: rt.u8, captured3: Logged.Logged): (a0: rt.u8) => rt.u8 => { return rt.closure(rt.cloning((_27: rt.u8): rt.u8 => { const x2: rt.u8 = _27; captured2 = rt.u8WrappingAdd(captured2, 1); - return cycles_Logged.called(captured3, x2) ^ captured2; - }, () => make2(captured2, cycles_Logged.clone$Clone(captured3))), (): void => { + return Logged.called(captured3, x2) ^ captured2; + }, () => make2(captured2, Logged.clone$Clone(captured3))), (): void => { captured3[Symbol.dispose](); }); }; const it3: rt.Iter = rt.iterMap(_76, make2(count, tag2)); - const gate: cycles_Logged.Logged = logged(48); - const make3 = (captured4: cycles_Logged.Logged): (a0: rt.u8) => boolean => { + const gate: Logged.Logged = logged(48); + const make3 = (captured4: Logged.Logged): (a0: rt.u8) => boolean => { return rt.closure(rt.cloning((_28: rt.u8): boolean => { - return (cycles_Logged.called(captured4, _28) & 3) !== 0; - }, () => make3(cycles_Logged.clone$Clone(captured4))), (): void => { + return (Logged.called(captured4, _28) & 3) !== 0; + }, () => make3(Logged.clone$Clone(captured4))), (): void => { captured4[Symbol.dispose](); }); }; @@ -1126,19 +1126,19 @@ export function closures(data: rt.ByteSlice, steps: rt.ByteSlice, out: rt.ByteVe }, out); flush(log.value, out); const left3: rt.Arc> = new rt.Arc(new rt.Cell(rt.usizeRem(data.length, 4))); - const tag3: cycles_Logged.Logged = logged(56); - const make4 = (captured5: rt.Arc>, captured6: cycles_Logged.Logged): () => rt.u8 | undefined => { + const tag3: Logged.Logged = logged(56); + const make4 = (captured5: rt.Arc>, captured6: Logged.Logged): () => rt.u8 | undefined => { return rt.closure(rt.cloning((): rt.u8 | undefined => { const _29: rt.usize | undefined = rt.usizeCheckedSub(captured5.value.v, 1); if (_29 !== undefined) { const l: rt.usize = _29; rt.cellSet(captured5.value, l); - return cycles_Logged.called(captured6, l & 0xff); + return Logged.called(captured6, l & 0xff); } return undefined; }, () => make4(((a04: rt.Arc>): rt.Arc> => { return rt.arcClone(a04); - })(captured5), cycles_Logged.clone$Clone(captured6))), (): void => { + })(captured5), Logged.clone$Clone(captured6))), (): void => { captured5[Symbol.dispose](); captured6[Symbol.dispose](); }); @@ -1164,54 +1164,54 @@ export function closures(data: rt.ByteSlice, steps: rt.ByteSlice, out: rt.ByteVe */ export function owned(data: rt.ByteSlice, n: rt.usize, steps: rt.ByteSlice, out: rt.ByteVec): void { const log: rt.Arc> = new rt.Arc(new rt.RefCell(new rt.ByteVec())); - const logged: (a0: rt.u8) => cycles_Logged.Logged = (id: rt.u8): cycles_Logged.Logged => { - return new cycles_Logged.Logged(id, rt.arcClone(log)); + const logged: (a0: rt.u8) => Logged.Logged = (id: rt.u8): Logged.Logged => { + return new Logged.Logged(id, rt.arcClone(log)); }; - const it: rt.Iter = rt.iterSlice(rt.iterToArray(rt.iterMap(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 4), (_2: rt.u8): cycles_Logged.Logged => { + const it: rt.Iter = rt.iterSlice(rt.iterToArray(rt.iterMap(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 4), (_2: rt.u8): Logged.Logged => { return logged(_2 & 112); }), undefined, 8, true), rt.drop); rt.drop(rt.iterToOption(it.next())); flush(log.value, out); - const it2: rt.Iter = rt.iterCycle(it, { v: cycles_Logged.clone$Clone }); + const it2: rt.Iter = rt.iterCycle(it, { v: Logged.clone$Clone }); flush(log.value, out); - rt.iterExtendBytes(out, rt.iterOption(option_map$1u07cey(rt.iterNth(it2, n, rt.drop), (x: cycles_Logged.Logged): rt.u8 => { - const _03: rt.u8 = cycles_Logged.id(x); + rt.iterExtendBytes(out, rt.iterOption(option_map$1u07cey(rt.iterNth(it2, n, rt.drop), (x: Logged.Logged): rt.u8 => { + const _03: rt.u8 = Logged.id(x); x[Symbol.dispose](); return _03; })), undefined, true); flush(log.value, out); - rt.iterExtendBytes(out, rt.iterOption(option_map$1u07cey(rt.iterNth(it2, rt.usizeAdd(n, 3), rt.drop), (x2: cycles_Logged.Logged): rt.u8 => { - const _04: rt.u8 = cycles_Logged.id(x2); + rt.iterExtendBytes(out, rt.iterOption(option_map$1u07cey(rt.iterNth(it2, rt.usizeAdd(n, 3), rt.drop), (x2: Logged.Logged): rt.u8 => { + const _04: rt.u8 = Logged.id(x2); x2[Symbol.dispose](); return _04; })), undefined, true); flush(log.value, out); let left: rt.usize = rt.usizeMul(n, 2); - rt.iterExtendBytes(out, rt.iterOption(option_map$1u07cey(rt.iterFind(it2, (_22: cycles_Logged.Logged): boolean => { + rt.iterExtendBytes(out, rt.iterOption(option_map$1u07cey(rt.iterFind(it2, (_22: Logged.Logged): boolean => { left = rt.usizeWrappingSub(left, 1); return left === 4294967295; - }, rt.drop), (x3: cycles_Logged.Logged): rt.u8 => { - const _06: rt.u8 = cycles_Logged.id(x3); + }, rt.drop), (x3: Logged.Logged): rt.u8 => { + const _06: rt.u8 = Logged.id(x3); x3[Symbol.dispose](); return _06; })), undefined, true); flush(log.value, out); - const clone: rt.Iter = it2.clone({ i: { v: cycles_Logged.clone$Clone } }); + const clone: rt.Iter = it2.clone({ i: { v: Logged.clone$Clone } }); flush(log.value, out); rt.drop(it2); flush(log.value, out); - read$iter_Cycle_vec_IntoIter_cycles_Logged_cycles_owned_closure6(clone, steps, (x4: cycles_Logged.Logged): rt.u8 => { - const _07: rt.u8 = cycles_Logged.id(x4); + read$iter_Cycle_vec_IntoIter_cycles_Logged_cycles_owned_closure6(clone, steps, (x4: Logged.Logged): rt.u8 => { + const _07: rt.u8 = Logged.id(x4); x4[Symbol.dispose](); return _07; }, out); flush(log.value, out); - const empty: cycles_Logged.Logged[] = []; - const it3: rt.Iter = rt.iterCycle(rt.iterSlice(empty, rt.drop), { v: cycles_Logged.clone$Clone }); - const _75: cycles_Logged.Logged | undefined = rt.iterNth(it3, 3, rt.drop); + const empty: Logged.Logged[] = []; + const it3: rt.Iter = rt.iterCycle(rt.iterSlice(empty, rt.drop), { v: Logged.clone$Clone }); + const _75: Logged.Logged | undefined = rt.iterNth(it3, 3, rt.drop); rt.byteVecPush(out, _75 === undefined ? 1 : 0); rt.drop(_75); - const _81: cycles_Logged.Logged | undefined = rt.iterFind(it3, (_24: cycles_Logged.Logged): boolean => { + const _81: Logged.Logged | undefined = rt.iterFind(it3, (_24: Logged.Logged): boolean => { return true; }, rt.drop); rt.byteVecPush(out, _81 === undefined ? 1 : 0); diff --git a/ts/fixtures/lang/cycles/expected/harness.ts b/ts/fixtures/lang/cycles/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/cycles/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/cycles/expected/lib.ts b/ts/fixtures/lang/cycles/expected/lib.ts new file mode 100644 index 000000000..09aecc2bb --- /dev/null +++ b/ts/fixtures/lang/cycles/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cycles } from "./cycles.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["cycles::cycles", cycles as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/cycles.rs b/ts/fixtures/lang/cycles/src/cycles.rs similarity index 100% rename from ts/fixtures/lang/src/cycles.rs rename to ts/fixtures/lang/cycles/src/cycles.rs diff --git a/ts/fixtures/lang/cycles/src/lib.rs b/ts/fixtures/lang/cycles/src/lib.rs new file mode 100644 index 000000000..aaa505637 --- /dev/null +++ b/ts/fixtures/lang/cycles/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod cycles; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("cycles::cycles", cycles::cycles)] +} diff --git a/ts/fixtures/lang/cycles/ts.toml b/ts/fixtures/lang/cycles/ts.toml new file mode 100644 index 000000000..b4f8f7c61 --- /dev/null +++ b/ts/fixtures/lang/cycles/ts.toml @@ -0,0 +1,2 @@ +package = "lang-cycles-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/defaults/Cargo.toml b/ts/fixtures/lang/defaults/Cargo.toml new file mode 100644 index 000000000..abe665af9 --- /dev/null +++ b/ts/fixtures/lang/defaults/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-defaults-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/defaults/expected/core/bool.ts b/ts/fixtures/lang/defaults/expected/core/bool.ts new file mode 100644 index 000000000..088964177 --- /dev/null +++ b/ts/fixtures/lang/defaults/expected/core/bool.ts @@ -0,0 +1,20 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import * as Made from "../defaults.Made.ts"; + +export function then$1j955kq(self: boolean, _: () => Made.Made): Made.Made | undefined { + if (!self) { + return undefined; + } + return Made.default$Default(); +} + +export function then$1t2ieki(self: boolean, f: () => [rt.u64 | undefined, Made.Made]): [rt.u64 | undefined, Made.Made] | undefined { + if (!self) { + return undefined; + } + return f(); +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/defaults/expected/core/option.ts b/ts/fixtures/lang/defaults/expected/core/option.ts new file mode 100644 index 000000000..e5cf68221 --- /dev/null +++ b/ts/fixtures/lang/defaults/expected/core/option.ts @@ -0,0 +1,20 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import * as Made from "../defaults.Made.ts"; + +export function unwrapOrDefault$0k1p6nh(self: [rt.u64 | undefined, Made.Made] | undefined): [rt.u64 | undefined, Made.Made] { + if (self === undefined) { + return [undefined, Made.default$Default()]; + } + return self; +} + +export function map$155qrdr(self: rt.Arc | undefined, f: (a0: rt.Arc) => rt.u64): rt.u64 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/expected/defaults.Bare.ts b/ts/fixtures/lang/defaults/expected/defaults.Bare.ts similarity index 100% rename from ts/fixtures/lang/expected/defaults.Bare.ts rename to ts/fixtures/lang/defaults/expected/defaults.Bare.ts diff --git a/ts/fixtures/lang/expected/defaults.Made.ts b/ts/fixtures/lang/defaults/expected/defaults.Made.ts similarity index 100% rename from ts/fixtures/lang/expected/defaults.Made.ts rename to ts/fixtures/lang/defaults/expected/defaults.Made.ts diff --git a/ts/fixtures/lang/expected/defaults.Slot.ts b/ts/fixtures/lang/defaults/expected/defaults.Slot.ts similarity index 77% rename from ts/fixtures/lang/expected/defaults.Slot.ts rename to ts/fixtures/lang/defaults/expected/defaults.Slot.ts index dd2c41531..914911e71 100644 --- a/ts/fixtures/lang/expected/defaults.Slot.ts +++ b/ts/fixtures/lang/defaults/expected/defaults.Slot.ts @@ -2,7 +2,7 @@ import * as rt from "./rt.ts"; import { map$155qrdr as option_map$155qrdr } from "./core/option.ts"; -import type * as defaults_Made from "./defaults.Made.ts"; +import type * as Made from "./defaults.Made.ts"; export function default$Default(): Slot { return new Slot(new rt.Weak()); @@ -10,9 +10,9 @@ export function default$Default(): Slot { /** A placeholder that upgrades once it points at something. */ export class Slot { - weak: rt.Weak; + weak: rt.Weak; - constructor(weak: rt.Weak) { + constructor(weak: rt.Weak) { this.weak = weak; } @@ -22,7 +22,7 @@ export class Slot { } export function get(self: Slot): rt.u64 | undefined { - return option_map$155qrdr(rt.weakUpgrade(self.weak), (made: rt.Arc): rt.u64 => { + return option_map$155qrdr(rt.weakUpgrade(self.weak), (made: rt.Arc): rt.u64 => { const _02: rt.u64 = made.value.n; made[Symbol.dispose](); return _02; diff --git a/ts/fixtures/lang/expected/defaults.ts b/ts/fixtures/lang/defaults/expected/defaults.ts similarity index 58% rename from ts/fixtures/lang/expected/defaults.ts rename to ts/fixtures/lang/defaults/expected/defaults.ts index c39d7d4e9..8f3f73be9 100644 --- a/ts/fixtures/lang/expected/defaults.ts +++ b/ts/fixtures/lang/defaults/expected/defaults.ts @@ -4,34 +4,34 @@ import * as rt from "./rt.ts"; import { copy$array_u8 } from "./lib.ts"; import { then$1j955kq, then$1t2ieki } from "./core/bool.ts"; import { unwrapOrDefault$0k1p6nh as option_unwrapOrDefault$0k1p6nh } from "./core/option.ts"; -import * as defaults_Bare from "./defaults.Bare.ts"; -import * as defaults_Made from "./defaults.Made.ts"; -import * as defaults_Slot from "./defaults.Slot.ts"; +import * as Bare from "./defaults.Bare.ts"; +import * as Made from "./defaults.Made.ts"; +import * as Slot from "./defaults.Slot.ts"; /** What a generic caller makes, as kio's `Producer::default` makes its `T`. */ -export function made$array2_defaults_Made(): defaults_Made.Made[] { - return Array.from({ length: 2 }, (): defaults_Made.Made => { - return defaults_Made.default$Default(); +export function made$array2_defaults_Made(): Made.Made[] { + return Array.from({ length: 2 }, (): Made.Made => { + return Made.default$Default(); }); } /** What a generic caller makes, as kio's `Producer::default` makes its `T`. */ -export function made$defaults_Made(): defaults_Made.Made { - return defaults_Made.default$Default(); +export function made$defaults_Made(): Made.Made { + return Made.default$Default(); } /** What a generic caller makes, as kio's `Producer::default` makes its `T`. */ -export function made$sync_Arc_defaults_Made(): rt.Arc { - return new rt.Arc(defaults_Made.default$Default()); +export function made$sync_Arc_defaults_Made(): rt.Arc { + return new rt.Arc(Made.default$Default()); } /** What a generic caller makes, as kio's `Producer::default` makes its `T`. */ -export function made$sync_Weak_defaults_Made(): rt.Weak { +export function made$sync_Weak_defaults_Made(): rt.Weak { return new rt.Weak(); } /** What a generic caller makes, as kio's `Producer::default` makes its `T`. */ -export function made$tuple4_unit_tuple2_u8_bool_array0_defaults_Made_array0_defaults_Bare(): [undefined, [rt.u8, boolean], defaults_Made.Made[], defaults_Bare.Bare[]] { +export function made$tuple4_unit_tuple2_u8_bool_array0_defaults_Made_array0_defaults_Bare(): [undefined, [rt.u8, boolean], Made.Made[], Bare.Bare[]] { return [undefined, [0, false], [], []]; } @@ -47,19 +47,19 @@ export function defaults(data: rt.ByteSlice, out: rt.ByteVec): void { const _10: rt.u8 = rt.u8Rem(op, 9); if (_10 === 0) { made$unit(); - const pair: [rt.u64 | undefined, defaults_Made.Made] = [undefined, defaults_Made.default$Default()]; - const nested: [undefined, [rt.u8, boolean], defaults_Made.Made[], defaults_Bare.Bare[]] = made$tuple4_unit_tuple2_u8_bool_array0_defaults_Made_array0_defaults_Bare(); - const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtUnit(undefined, f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(pair[0], f, rt.u64Debug), (f: rt.Formatter) => defaults_Made.fmt$fmt_Debug(pair[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtUnit(nested[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(nested[1][0], f), (f: rt.Formatter) => rt.fmtBool(nested[1][1], f)], f), (f: rt.Formatter) => rt.fmtList(nested[2], f, (value: defaults_Made.Made, f: rt.Formatter) => defaults_Made.fmt$fmt_Debug(value, f)), (f: rt.Formatter) => rt.fmtList(nested[3], f, (value: defaults_Bare.Bare, f: rt.Formatter) => defaults_Bare.fmt$fmt_Debug(value, f))], f)]; + const pair: [rt.u64 | undefined, Made.Made] = [undefined, Made.default$Default()]; + const nested: [undefined, [rt.u8, boolean], Made.Made[], Bare.Bare[]] = made$tuple4_unit_tuple2_u8_bool_array0_defaults_Made_array0_defaults_Bare(); + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtUnit(undefined, f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(pair[0], f, rt.u64Debug), (f: rt.Formatter) => Made.fmt$fmt_Debug(pair[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtUnit(nested[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(nested[1][0], f), (f: rt.Formatter) => rt.fmtBool(nested[1][1], f)], f), (f: rt.Formatter) => rt.fmtList(nested[2], f, (value: Made.Made, f: rt.Formatter) => Made.fmt$fmt_Debug(value, f)), (f: rt.Formatter) => rt.fmtList(nested[3], f, (value: Bare.Bare, f: rt.Formatter) => Bare.fmt$fmt_Debug(value, f))], f)]; s = rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2]]); } else if (_10 === 1) { - const made: defaults_Made.Made[] = made$array2_defaults_Made(); + const made: Made.Made[] = made$array2_defaults_Made(); const grid: rt.u64[][] = Array.from({ length: 3 }, (): rt.u64[] => { return Array.from({ length: 2 }, (): rt.u64 => { return 0; }); }); const _35: rt.ByteSlice = rt.byteSliceFrom(madeBytes(op)); - const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(made, f, (value: defaults_Made.Made, f: rt.Formatter) => defaults_Made.fmt$fmt_Debug(value, f)), (f: rt.Formatter) => rt.fmtList(grid, f, (value: rt.u64[], f: rt.Formatter) => rt.fmtList(value, f, rt.u64Debug)), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_35), f, rt.u8Debug)]; + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(made, f, (value: Made.Made, f: rt.Formatter) => Made.fmt$fmt_Debug(value, f)), (f: rt.Formatter) => rt.fmtList(grid, f, (value: rt.u64[], f: rt.Formatter) => rt.fmtList(value, f, rt.u64Debug)), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_35), f, rt.u8Debug)]; s = rt.fmtFormat([args4[0], " ", args4[1], " ", args4[2]]); } else if (_10 === 2) { const counts: rt.Atomic[] = Array.from({ length: 4 }, (): rt.Atomic => { @@ -77,36 +77,36 @@ export function defaults(data: rt.ByteSlice, out: rt.ByteVec): void { const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(part2, f, rt.u64Debug)]; s = rt.fmtFormat([args6[0]]); } else if (_10 === 3) { - const boxed: defaults_Made.Made = defaults_Made.default$Default(); - const shared: rt.Arc = made$sync_Arc_defaults_Made(); - const again: rt.Arc = rt.arcClone(shared); - const _76: defaults_Made.Made = shared.value; + const boxed: Made.Made = Made.default$Default(); + const shared: rt.Arc = made$sync_Arc_defaults_Made(); + const again: rt.Arc = rt.arcClone(shared); + const _76: Made.Made = shared.value; const _79: rt.usize = again.strong; - const args8: rt.Fmt[] = [(f: rt.Formatter) => defaults_Made.fmt$fmt_Debug(boxed, f), (f: rt.Formatter) => defaults_Made.fmt$fmt_Debug(_76, f), (f: rt.Formatter) => rt.usizeDisplay(_79, f)]; + const args8: rt.Fmt[] = [(f: rt.Formatter) => Made.fmt$fmt_Debug(boxed, f), (f: rt.Formatter) => Made.fmt$fmt_Debug(_76, f), (f: rt.Formatter) => rt.usizeDisplay(_79, f)]; s = rt.fmtFormat([args8[0], " ", args8[1], " ", args8[2]]); again[Symbol.dispose](); shared[Symbol.dispose](); } else if (_10 === 4) { - const part = option_unwrapOrDefault$0k1p6nh(then$1t2ieki(rt.u8Rem(op, 3) === 0, (): [rt.u64 | undefined, defaults_Made.Made] => { - return [op as rt.u64, defaults_Made.default$Default()] as [rt.u64 | undefined, defaults_Made.Made]; + const part = option_unwrapOrDefault$0k1p6nh(then$1t2ieki(rt.u8Rem(op, 3) === 0, (): [rt.u64 | undefined, Made.Made] => { + return [op as rt.u64, Made.default$Default()] as [rt.u64 | undefined, Made.Made]; })); - const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(part[0], f, rt.u64Debug), (f: rt.Formatter) => defaults_Made.fmt$fmt_Debug(part[1], f)], f)]; + const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(part[0], f, rt.u64Debug), (f: rt.Formatter) => Made.fmt$fmt_Debug(part[1], f)], f)]; s = rt.fmtFormat([args10[0]]); } else if (_10 === 5) { - const empty: rt.Weak = new rt.Weak(); - const default_: rt.Weak = made$sync_Weak_defaults_Made(); - const arc: rt.Arc = new rt.Arc(defaults_Made.default$Default()); - const live: rt.Weak = new rt.Weak(arc); - const copy: rt.Weak = rt.weakClone(empty); - const _117: rt.Arc | undefined = rt.weakUpgrade(empty); + const empty: rt.Weak = new rt.Weak(); + const default_: rt.Weak = made$sync_Weak_defaults_Made(); + const arc: rt.Arc = new rt.Arc(Made.default$Default()); + const live: rt.Weak = new rt.Weak(arc); + const copy: rt.Weak = rt.weakClone(empty); + const _117: rt.Arc | undefined = rt.weakUpgrade(empty); const _115: boolean = _117 === undefined; const _120: rt.usize = default_.arc.strong; const _123: boolean = empty.arc === default_.arc; const _127: boolean = empty.arc === copy.arc; const _131: boolean = empty.arc === live.arc; - const _137: rt.Arc | undefined = rt.weakUpgrade(copy); + const _137: rt.Arc | undefined = rt.weakUpgrade(copy); const _135: boolean = _137 === undefined; - const _142: rt.Arc | undefined = rt.weakUpgrade(live); + const _142: rt.Arc | undefined = rt.weakUpgrade(live); const _140: boolean = _142 !== undefined; const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(_115, f), (f: rt.Formatter) => rt.usizeDisplay(_120, f), (f: rt.Formatter) => rt.fmtBool(_123, f), (f: rt.Formatter) => rt.fmtBool(_127, f), (f: rt.Formatter) => rt.fmtBool(_131, f), (f: rt.Formatter) => rt.fmtBool(_135, f), (f: rt.Formatter) => rt.fmtBool(_140, f)]; const _111: string = rt.fmtFormat([args12[0], " ", args12[1], " ", args12[2], " ", args12[3], " ", args12[4], " ", args12[5], " ", args12[6]]); @@ -120,26 +120,26 @@ export function defaults(data: rt.ByteSlice, out: rt.ByteVec): void { default_[Symbol.dispose](); empty[Symbol.dispose](); } else if (_10 === 6) { - const slot: defaults_Slot.Slot = defaults_Slot.default$Default(); - const before: rt.u64 | undefined = defaults_Slot.get(slot); - const arc2: rt.Arc = new rt.Arc({ n: op as rt.u64, tag: defaults_Made.default$Default().tag }); - const _161: rt.Weak = new rt.Weak(arc2); + const slot: Slot.Slot = Slot.default$Default(); + const before: rt.u64 | undefined = Slot.get(slot); + const arc2: rt.Arc = new rt.Arc({ n: op as rt.u64, tag: Made.default$Default().tag }); + const _161: rt.Weak = new rt.Weak(arc2); slot.weak[Symbol.dispose](); slot.weak = _161; - const _167: rt.u64 | undefined = defaults_Slot.get(slot); + const _167: rt.u64 | undefined = Slot.get(slot); const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(before, f, rt.u64Debug), (f: rt.Formatter) => rt.fmtOption(_167, f, rt.u64Debug)]; s = rt.fmtFormat([args14[0], " ", args14[1]]); arc2[Symbol.dispose](); slot[Symbol.dispose](); } else if (_10 === 7) { - let boxed2: defaults_Made.Made | undefined = then$1j955kq(rt.u8Rem(op, 3) === 0, (): defaults_Made.Made => { - return defaults_Made.default$Default(); + let boxed2: Made.Made | undefined = then$1j955kq(rt.u8Rem(op, 3) === 0, (): Made.Made => { + return Made.default$Default(); }); const _179: rt.u64 = op as rt.u64; if (boxed2 === undefined) { - boxed2 = defaults_Made.default$Default(); + boxed2 = Made.default$Default(); } - (boxed2 as defaults_Made.Made).n = rt.u64Add((boxed2 as defaults_Made.Made).n, _179); + (boxed2 as Made.Made).n = rt.u64Add((boxed2 as Made.Made).n, _179); let slots = undefined as Array | undefined; const _184: rt.u8 | undefined = op; if (slots === undefined) { @@ -152,13 +152,13 @@ export function defaults(data: rt.ByteSlice, out: rt.ByteVec): void { rt.panic("index out of bounds: the len is " + 3 + " but the index is " + _187); } (slots as Array)[_187] = _184; - const cell: rt.OnceCell> = new rt.OnceCell(undefined); - const shared2: rt.Arc = rt.arcClone(rt.onceGetOrInit(cell, (): rt.Arc => { - return new rt.Arc(defaults_Made.default$Default()); + const cell: rt.OnceCell> = new rt.OnceCell(undefined); + const shared2: rt.Arc = rt.arcClone(rt.onceGetOrInit(cell, (): rt.Arc => { + return new rt.Arc(Made.default$Default()); })); - const _199: defaults_Made.Made = shared2.value; + const _199: Made.Made = shared2.value; const _202: rt.usize = shared2.strong; - const _207: rt.Fmt = (f: rt.Formatter) => rt.fmtOption(boxed2, f, (value: defaults_Made.Made, f: rt.Formatter) => defaults_Made.fmt$fmt_Debug(value, f)); + const _207: rt.Fmt = (f: rt.Formatter) => rt.fmtOption(boxed2, f, (value: Made.Made, f: rt.Formatter) => Made.fmt$fmt_Debug(value, f)); const _208: rt.Fmt = (f: rt.Formatter) => rt.fmtOption(slots, f, (value: Array, f: rt.Formatter) => rt.fmtList(value, f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug))); const arg2 = _199.n; const args16: rt.Fmt[] = [_207, _208, (f: rt.Formatter) => rt.u64Display(arg2, f), (f: rt.Formatter) => rt.usizeDisplay(_202, f)]; @@ -166,7 +166,7 @@ export function defaults(data: rt.ByteSlice, out: rt.ByteVec): void { shared2[Symbol.dispose](); cell[Symbol.dispose](); } else { - const made2: defaults_Made.Made = made$defaults_Made(); + const made2: Made.Made = made$defaults_Made(); const _218: rt.u64 = rt.u64Add(made2.n, op as rt.u64); const _224: rt.Fmt = (f: rt.Formatter) => rt.u64Display(_218, f); const arg = made2.tag; diff --git a/ts/fixtures/lang/defaults/expected/harness.ts b/ts/fixtures/lang/defaults/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/defaults/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/defaults/expected/lib.ts b/ts/fixtures/lang/defaults/expected/lib.ts new file mode 100644 index 000000000..7f4704595 --- /dev/null +++ b/ts/fixtures/lang/defaults/expected/lib.ts @@ -0,0 +1,20 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { defaults } from "./defaults.ts"; + +export function copy$array_u8(v: Uint8Array): Uint8Array { + return v.slice(); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["defaults::defaults", (_22: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + defaults(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/defaults.rs b/ts/fixtures/lang/defaults/src/defaults.rs similarity index 100% rename from ts/fixtures/lang/src/defaults.rs rename to ts/fixtures/lang/defaults/src/defaults.rs diff --git a/ts/fixtures/lang/defaults/src/lib.rs b/ts/fixtures/lang/defaults/src/lib.rs new file mode 100644 index 000000000..7f38b12a7 --- /dev/null +++ b/ts/fixtures/lang/defaults/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod defaults; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("defaults::defaults", |_, data, out| defaults::defaults(data, out))] +} diff --git a/ts/fixtures/lang/defaults/ts.toml b/ts/fixtures/lang/defaults/ts.toml new file mode 100644 index 000000000..c7bf8ef59 --- /dev/null +++ b/ts/fixtures/lang/defaults/ts.toml @@ -0,0 +1,2 @@ +package = "lang-defaults-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/durations/Cargo.toml b/ts/fixtures/lang/durations/Cargo.toml new file mode 100644 index 000000000..040dfcb93 --- /dev/null +++ b/ts/fixtures/lang/durations/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-durations-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/durations/caller.ts b/ts/fixtures/lang/durations/caller.ts new file mode 100644 index 000000000..0f32117f8 --- /dev/null +++ b/ts/fixtures/lang/durations/caller.ts @@ -0,0 +1,44 @@ +// The inputs `durations`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** A `Duration`'s bytes as `durations` takes them: its seconds, then its nanoseconds. */ +function duration(secs: bigint, nanos: number): number[] { + const bytes = new Uint8Array(12); + const view = new DataView(bytes.buffer); + view.setBigUint64(0, secs); + view.setUint32(8, nanos); + return [...bytes]; +} + +/** + * `durations` where seconds leave a safe integer or reach `u64::MAX`, nanoseconds carry, + * a sum carries them past it, and a factor makes the nanoseconds' product or a + * quotient's remainder pass 2^53. + */ +const edges = [0n, 1n, (1n << 53n) - 1n, 1n << 53n, (1n << 64n) - 1n].flatMap((secs) => [0, 1, 999_999_999].map((nanos) => duration(secs, nanos))); +const factors = [0, 1, 3, 1000, 9_007_199, 1_000_000_000, 0xffffffff].map((n) => [n >>> 24, (n >>> 16) & 0xff, (n >>> 8) & 0xff, n & 0xff]); +const durationsOp = op("durations::durations"); +const durations = [ + ...[0n, 1n, 1n << 32n, (1n << 53n) - 1n, 1n << 53n, (1n << 64n) - 2n, (1n << 64n) - 1n].flatMap((secs) => + [0, 1, 999_999_999, 1_000_000_000, 0xffffffff].flatMap((nanos) => [0, 1].map((kind) => Uint8Array.of(...durationsOp, kind, ...duration(secs, nanos)))), + ), + ...edges.flatMap((a) => edges.flatMap((b) => factors.flatMap((n) => [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13].map((kind) => Uint8Array.of(...durationsOp, kind, ...a, ...b, ...n))))), + // Each side of where minutes, hours, and a `u128` of nanoseconds pass `u64::MAX` seconds. + ...[2n ** 64n / 60n, 2n ** 64n / 3600n].flatMap((units) => [units, units + 1n].map((n) => wide(n << 64n))), + ...[(7n << 64n) + 999_999_999n, 2n ** 64n * 1_000_000_000n - 1n, 2n ** 64n * 1_000_000_000n, 2n ** 128n - 1n].map((n) => wide(n)), +]; + +/** `durations`' larger units, of a `u128` whose high half is also its `u64`. */ +function wide(n: bigint): Uint8Array { + const bytes = new Uint8Array(19); + bytes.set([...durationsOp, 12]); + const view = new DataView(bytes.buffer); + view.setBigUint64(3, n >> 64n); + view.setBigUint64(11, n & 0xffff_ffff_ffff_ffffn); + return bytes; +} + +export const cases: Uint8Array[] = [...durations]; diff --git a/ts/fixtures/lang/durations/expected/core/bool.ts b/ts/fixtures/lang/durations/expected/core/bool.ts new file mode 100644 index 000000000..f2c0f81f2 --- /dev/null +++ b/ts/fixtures/lang/durations/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$1jqdi5p(self: boolean, t: rt.Duration): rt.Duration | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/expected/durations.Twice.ts b/ts/fixtures/lang/durations/expected/durations.Twice.ts similarity index 100% rename from ts/fixtures/lang/expected/durations.Twice.ts rename to ts/fixtures/lang/durations/expected/durations.Twice.ts diff --git a/ts/fixtures/lang/expected/durations.Window.ts b/ts/fixtures/lang/durations/expected/durations.Window.ts similarity index 100% rename from ts/fixtures/lang/expected/durations.Window.ts rename to ts/fixtures/lang/durations/expected/durations.Window.ts diff --git a/ts/fixtures/lang/expected/durations.ts b/ts/fixtures/lang/durations/expected/durations.ts similarity index 81% rename from ts/fixtures/lang/expected/durations.ts rename to ts/fixtures/lang/durations/expected/durations.ts index b9fb7878d..568c57a05 100644 --- a/ts/fixtures/lang/expected/durations.ts +++ b/ts/fixtures/lang/durations/expected/durations.ts @@ -3,9 +3,9 @@ import * as rt from "./rt.ts"; import { copy$durations_Window } from "./lib.ts"; import { thenSome$1jqdi5p } from "./core/bool.ts"; -import type * as durations_Twice from "./durations.Twice.ts"; -import * as durations_Window from "./durations.Window.ts"; -import { put as fmt_put } from "./fmt.ts"; +import type * as Twice from "./durations.Twice.ts"; +import * as Window from "./durations.Window.ts"; +import { put } from "./harness.ts"; /** A `u64` and a `u32` from the front of `data`, big-endian and zero-padded. */ export function take(data: rt.ByteSlice): [rt.u64, rt.u32, rt.ByteSlice] { @@ -48,7 +48,7 @@ export function putOpt(out: rt.ByteVec, d: rt.Duration | undefined): void { } } -export function addAssign$ops_AddAssign_durations_Twice_time_Duration(self: rt.Place, by: durations_Twice.Twice): void { +export function addAssign$ops_AddAssign_durations_Twice_time_Duration(self: rt.Place, by: Twice.Twice): void { self.v = rt.durationAdd(self.v, by._0); self.v = rt.durationAdd(self.v, by._0); } @@ -154,11 +154,11 @@ export function durations(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi const c: rt.Duration = rt.durationNew(0, rt.durationSubsecNanos(b)); const d2: rt.Duration = rt.durationFromNanos(rt.u32Rem(n, 1000000) as rt.u64); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.durationDebug(a, f), (f: rt.Formatter) => rt.durationDebug(c, f), (f: rt.Formatter) => rt.durationDebug(d2, f), (f: rt.Formatter) => rt.fmtOption(b, f, rt.durationDebug)]; - fmt_put(out, rt.fmtFormat([args2[0], "|", args2[1], "|", args2[2], "|", rt.fmtSpec({ align: ">", width: 16 }, args2[1]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 14 }, args2[2]), "|", rt.fmtSpec({ align: "<", width: 12 }, args2[1]), "|", rt.fmtSpec({ zero: true, width: 8 }, args2[0]), "|", args2[3]])); + put(out, rt.fmtFormat([args2[0], "|", args2[1], "|", args2[2], "|", rt.fmtSpec({ align: ">", width: 16 }, args2[1]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 14 }, args2[2]), "|", rt.fmtSpec({ align: "<", width: 12 }, args2[1]), "|", rt.fmtSpec({ zero: true, width: 8 }, args2[0]), "|", args2[3]])); const _234: rt.Duration | undefined = b; const p: rt.usize = rt.u32Rem(n, 13) as rt.usize; const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.durationDebug(a, f), (f: rt.Formatter) => rt.durationDebug(c, f), (f: rt.Formatter) => rt.durationDebug(d2, f), rt.fmtCount(p), (f: rt.Formatter) => rt.fmtOption(_234, f, rt.durationDebug)]; - fmt_put(out, rt.fmtFormat([rt.fmtSpec({ precision: 0 }, args4[0]), "|", rt.fmtSpec({ precision: 3 }, args4[0]), "|", rt.fmtSpec({ precision: 1 }, args4[1]), "|", rt.fmtSpec({ precision: 12 }, args4[2]), "|", rt.fmtSpec({ plus: true }, args4[0]), "|", rt.fmtSpec({ plus: true, width: 12, precision: 2 }, args4[1]), "|", rt.fmtSpec({ align: "<", width: 10, precision: 1 }, args4[2]), "|", rt.fmtSpec({ precision: rt.fmtCountOf(args4[3]) }, args4[0]), "|", rt.fmtSpec({ precision: 1 }, args4[4])])); + put(out, rt.fmtFormat([rt.fmtSpec({ precision: 0 }, args4[0]), "|", rt.fmtSpec({ precision: 3 }, args4[0]), "|", rt.fmtSpec({ precision: 1 }, args4[1]), "|", rt.fmtSpec({ precision: 12 }, args4[2]), "|", rt.fmtSpec({ plus: true }, args4[0]), "|", rt.fmtSpec({ plus: true, width: 12, precision: 2 }, args4[1]), "|", rt.fmtSpec({ align: "<", width: 10, precision: 1 }, args4[2]), "|", rt.fmtSpec({ precision: rt.fmtCountOf(args4[3]) }, args4[0]), "|", rt.fmtSpec({ precision: 1 }, args4[4])])); const iter4: rt.Iter = rt.iterSlice([1500000000, 2500000000, 1250000, 1350000, 999500, 1999999999]); while (true) { const _250: rt.u64 | rt.Done = iter4.next(); @@ -167,13 +167,13 @@ export function durations(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi } const part = rt.durationFromNanos(_250); const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.durationDebug(part, f)]; - fmt_put(out, rt.fmtFormat([rt.fmtSpec({ precision: 0 }, args6[0]), " ", rt.fmtSpec({ precision: 1 }, args6[0]), " ", rt.fmtSpec({ precision: 2 }, args6[0])])); + put(out, rt.fmtFormat([rt.fmtSpec({ precision: 0 }, args6[0]), " ", rt.fmtSpec({ precision: 1 }, args6[0]), " ", rt.fmtSpec({ precision: 2 }, args6[0])])); } } else if (_24 === 10) { let c2: rt.Duration = a; c2 = rt.durationAdd(c2, b); putDuration(out, c2); - const w: durations_Window.Window = { start: c2, len: b }; + const w: Window.Window = { start: c2, len: b }; w.start = rt.durationSub(w.start, b); putDuration(out, w.start); if (w.len !== undefined) { @@ -187,7 +187,7 @@ export function durations(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi shrink(rt.place(() => v[0], (value) => v[0] = value), b); putDuration(out, v[0]); let d5: rt.Duration = a; - const _306: durations_Twice.Twice = { _0: b }; + const _306: Twice.Twice = { _0: b }; addAssign$ops_AddAssign_durations_Twice_time_Duration(rt.place(() => d5, (value2) => d5 = value2), _306); putDuration(out, d5); } else if (_24 === 11) { @@ -227,16 +227,16 @@ export function durations(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi putDuration(out, { secs: 0, nanos: 0 }); putOpt(out, rt.durationCheckedAdd({ secs: { hi: 0xffffffff, lo: 0xffffffff } as rt.u64, nanos: 999999999 }, rt.durationFromNanos(1))); const _379: rt.Duration | undefined = thenSome$1jqdi5p(rt.durationCmp(b, { secs: 1, nanos: 500000000 }) === 1, b); - const w2: durations_Window.Window = { start: a, len: _379 }; - const _388: durations_Window.Window = durations_Window.default$Default(); - rt.byteVecPush(out, durations_Window.eq$cmp_PartialEq(w2, _388) ? 1 : 0); - rt.byteVecPush(out, durations_Window.cmp$cmp_Ord(w2, { start: b, len: undefined }) < 0 ? 1 : 0); - const _400: durations_Window.Window = copy$durations_Window(durations_Window.default$Default()); - const _398: rt.Iter = rt.iterSlice([copy$durations_Window(w2), copy$durations_Window(w2), _400]); - rt.byteVecPush(out, rt.hashLen(rt.hashExtendKeys(rt.hashNew(rt.hashing(durations_Window.hash$Hash_hash_DefaultHasher as (a0: durations_Window.Window, a1: rt.Hasher) => undefined, durations_Window.eq$cmp_PartialEq)) as rt.HashSet, _398, undefined, undefined, 29360128)) & 0xff); - const _413: durations_Window.Window = durations_Window.default$Default(); - const args8: rt.Fmt[] = [(f: rt.Formatter) => durations_Window.fmt$fmt_Debug(w2, f), (f: rt.Formatter) => durations_Window.fmt$fmt_Debug(_413, f)]; - fmt_put(out, rt.fmtFormat([args8[0], "|", rt.fmtSpec({ alternate: true }, args8[1])])); + const w2: Window.Window = { start: a, len: _379 }; + const _388: Window.Window = Window.default$Default(); + rt.byteVecPush(out, Window.eq$cmp_PartialEq(w2, _388) ? 1 : 0); + rt.byteVecPush(out, Window.cmp$cmp_Ord(w2, { start: b, len: undefined }) < 0 ? 1 : 0); + const _400: Window.Window = copy$durations_Window(Window.default$Default()); + const _398: rt.Iter = rt.iterSlice([copy$durations_Window(w2), copy$durations_Window(w2), _400]); + rt.byteVecPush(out, rt.hashLen(rt.hashExtendKeys(rt.hashNew(rt.hashing(Window.hash$Hash_hash_DefaultHasher as (a0: Window.Window, a1: rt.Hasher) => undefined, Window.eq$cmp_PartialEq)) as rt.HashSet, _398, undefined, undefined, 29360128)) & 0xff); + const _413: Window.Window = Window.default$Default(); + const args8: rt.Fmt[] = [(f: rt.Formatter) => Window.fmt$fmt_Debug(w2, f), (f: rt.Formatter) => Window.fmt$fmt_Debug(_413, f)]; + put(out, rt.fmtFormat([args8[0], "|", rt.fmtSpec({ alternate: true }, args8[1])])); } } diff --git a/ts/fixtures/lang/durations/expected/harness.ts b/ts/fixtures/lang/durations/expected/harness.ts new file mode 100644 index 000000000..3b7bbcfb0 --- /dev/null +++ b/ts/fixtures/lang/durations/expected/harness.ts @@ -0,0 +1,46 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/durations/expected/lib.ts b/ts/fixtures/lang/durations/expected/lib.ts new file mode 100644 index 000000000..6a3c2f783 --- /dev/null +++ b/ts/fixtures/lang/durations/expected/lib.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { durations } from "./durations.ts"; +import type * as Window from "./durations.Window.ts"; + +export function copy$durations_Window(v: Window.Window): Window.Window { + return { start: v.start, len: v.len }; +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["durations::durations", durations as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/durations.rs b/ts/fixtures/lang/durations/src/durations.rs similarity index 99% rename from ts/fixtures/lang/src/durations.rs rename to ts/fixtures/lang/durations/src/durations.rs index 62eecc6df..46c47e583 100644 --- a/ts/fixtures/lang/src/durations.rs +++ b/ts/fixtures/lang/durations/src/durations.rs @@ -7,7 +7,7 @@ use std::cmp::Ordering; use std::collections::{BTreeMap, HashSet}; use std::time::Duration; -use crate::fmt::put; +use crate::harness::put; const TIMEOUT: Duration = Duration::from_millis(1500); const LIMITS: [Duration; 3] = [Duration::ZERO, Duration::MAX, Duration::from_nanos(999)]; diff --git a/ts/fixtures/lang/durations/src/lib.rs b/ts/fixtures/lang/durations/src/lib.rs new file mode 100644 index 000000000..9ccc46135 --- /dev/null +++ b/ts/fixtures/lang/durations/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod durations; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("durations::durations", durations::durations)] +} diff --git a/ts/fixtures/lang/durations/ts.toml b/ts/fixtures/lang/durations/ts.toml new file mode 100644 index 000000000..7398dad38 --- /dev/null +++ b/ts/fixtures/lang/durations/ts.toml @@ -0,0 +1,2 @@ +package = "lang-durations-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/dyns/Cargo.toml b/ts/fixtures/lang/dyns/Cargo.toml new file mode 100644 index 000000000..c084df380 --- /dev/null +++ b/ts/fixtures/lang/dyns/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-dyns-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/dyns/caller.ts b/ts/fixtures/lang/dyns/caller.ts new file mode 100644 index 000000000..63150528f --- /dev/null +++ b/ts/fixtures/lang/dyns/caller.ts @@ -0,0 +1,23 @@ +// The inputs `dyns`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `dyns::dyns` too short to run, with a `Tri` of each variant, at the ends of each side and + * count, and boxing each kind of shape. + */ +const dyns = [[], [1, 2], [3, 0, 7], [255, 1, 255, 0, 1, 2, 3, 4, 5], [0, 3, 2, 9, 255, 6, 128]].map((bytes) => + Uint8Array.of(...op("dyns::dyns"), 0, ...bytes), +); + +/** + * `dyns::shared` too short to run, and with `Arc`s of each type, the last count of each at + * zero and at the top of its range. + */ +const shared = [[], [1], [0, 0], [255, 255, 0, 1, 2, 3, 4, 5], [7, 0xff, 255, 254, 253]].map((bytes) => + Uint8Array.of(...op("dyns::shared"), 0, ...bytes), +); + +export const cases: Uint8Array[] = [...dyns, ...shared]; diff --git a/ts/fixtures/lang/expected/core/any.Any.ts b/ts/fixtures/lang/dyns/expected/core/any.Any.ts similarity index 80% rename from ts/fixtures/lang/expected/core/any.Any.ts rename to ts/fixtures/lang/dyns/expected/core/any.Any.ts index 9fb0450a3..5319ab214 100644 --- a/ts/fixtures/lang/expected/core/any.Any.ts +++ b/ts/fixtures/lang/dyns/expected/core/any.Any.ts @@ -1,10 +1,9 @@ // Generated by rust2-ts. Do not edit. import * as rt from "../rt.ts"; -import type * as dyns_Noisy from "../dyns.Noisy.ts"; +import type * as Noisy from "../dyns.Noisy.ts"; import type * as Square from "../dyns.Square.ts"; import type * as Tri from "../dyns.Tri.ts"; -import type * as fmt_Fault from "../fmt.Fault.ts"; export type Any = object; @@ -17,9 +16,9 @@ export class of$Option_u8 { } export class of$dyns_Noisy { - v: dyns_Noisy.Noisy; + v: Noisy.Noisy; - constructor(v: dyns_Noisy.Noisy) { + constructor(v: Noisy.Noisy) { this.v = v; } @@ -44,14 +43,6 @@ export class of$dyns_Tri { } } -export class of$fmt_Fault { - v: fmt_Fault.Fault; - - constructor(v: fmt_Fault.Fault) { - this.v = v; - } -} - export class of$ref_str { v: string; @@ -108,14 +99,6 @@ export class ofPlace$dyns_Tri { } } -export class ofPlace$fmt_Fault { - v: rt.Place; - - constructor(v: rt.Place) { - this.v = v; - } -} - export class ofPlace$u32 { v: rt.Place; diff --git a/ts/fixtures/lang/dyns/expected/core/bool.ts b/ts/fixtures/lang/dyns/expected/core/bool.ts new file mode 100644 index 000000000..17d957542 --- /dev/null +++ b/ts/fixtures/lang/dyns/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0d5am30(self: boolean, t: rt.u8): rt.u8 | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/dyns/expected/core/option.ts b/ts/fixtures/lang/dyns/expected/core/option.ts new file mode 100644 index 000000000..64e6b386c --- /dev/null +++ b/ts/fixtures/lang/dyns/expected/core/option.ts @@ -0,0 +1,77 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Shape from "../dyns.Shape.ts"; +import type * as Tagged from "../dyns.Tagged.ts"; + +export function unwrapOr$1iemzn8(self: string | undefined, default_: string): string { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$1i542n2(self: rt.Arc | undefined, f: (a0: rt.Arc) => rt.u32): rt.u32 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0oedb57(self: rt.Arc> | undefined, f: (a0: rt.Arc>) => [rt.usize, rt.usize | undefined]): [rt.usize, rt.usize | undefined] | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$08a6hpg(self: Tagged.Tagged | undefined, f: (a0: Tagged.Tagged) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$1qfllpb(self: rt.Iter | undefined, f: (a0: rt.Iter) => rt.u8 | undefined): rt.u8 | undefined | rt.None { + if (self === undefined) { + return rt.None; + } + return f(self); +} + +export function map$0j05j69(self: rt.Arc | undefined, f: (a0: rt.Arc) => rt.u32): rt.u32 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function mapOr$06rr3sb(self: rt.u8 | undefined, default_: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8 | undefined): rt.u8 | undefined { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function andThen$0v0bj8w(self: rt.Iter | undefined, f: (a0: rt.Iter) => Tagged.Tagged | undefined): Tagged.Tagged | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function andThen$0ntiuws(self: rt.Iter | undefined, f: (a0: rt.Iter) => rt.u8 | undefined): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/dyns/expected/core/result.ts b/ts/fixtures/lang/dyns/expected/core/result.ts new file mode 100644 index 000000000..fb0366389 --- /dev/null +++ b/ts/fixtures/lang/dyns/expected/core/result.ts @@ -0,0 +1,42 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import { drop$Result_sync_Arc_u32_sync_Arc_dyn_Any_marker_Sync_marker_Send, drop$Result_tuple2_usize_u8_sync_Arc_dyn_Any_marker_Sync_marker_Send } from "../lib.ts"; +import type * as Any from "../core/any.Any.ts"; + +export function ok$00p9ap8(self: rt.Result, rt.Arc>): rt.Arc | undefined { + let _0!: rt.Arc | undefined; + if (self.ok) { + _0 = self.value; + } else { + _0 = undefined; + } + if (!self.ok) { + drop$Result_sync_Arc_u32_sync_Arc_dyn_Any_marker_Sync_marker_Send(self); + return _0; + } + return _0; +} + +export function ok$0lceojf(self: rt.Result<[rt.usize, rt.u8], rt.Arc>): [rt.usize, rt.u8] | undefined { + let _0!: [rt.usize, rt.u8] | undefined; + if (self.ok) { + _0 = self.value; + } else { + _0 = undefined; + } + if (!self.ok) { + drop$Result_tuple2_usize_u8_sync_Arc_dyn_Any_marker_Sync_marker_Send(self); + return _0; + } + return _0; +} + +export function map$0zujxcv(self: rt.Result, rt.Arc>, op: (a0: rt.Arc<[rt.u8, rt.u8]>) => [rt.usize, rt.u8]): rt.Result<[rt.usize, rt.u8], rt.Arc> { + if (self.ok) { + return rt.Ok(op(self.value)); + } + return self as rt.Result<[rt.usize, rt.u8], rt.Arc>; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/expected/dyns.Chunks.ts b/ts/fixtures/lang/dyns/expected/dyns.Chunks.ts similarity index 100% rename from ts/fixtures/lang/expected/dyns.Chunks.ts rename to ts/fixtures/lang/dyns/expected/dyns.Chunks.ts diff --git a/ts/fixtures/lang/expected/dyns.Countdown.ts b/ts/fixtures/lang/dyns/expected/dyns.Countdown.ts similarity index 100% rename from ts/fixtures/lang/expected/dyns.Countdown.ts rename to ts/fixtures/lang/dyns/expected/dyns.Countdown.ts diff --git a/ts/fixtures/lang/expected/dyns.Erased.ts b/ts/fixtures/lang/dyns/expected/dyns.Erased.ts similarity index 100% rename from ts/fixtures/lang/expected/dyns.Erased.ts rename to ts/fixtures/lang/dyns/expected/dyns.Erased.ts diff --git a/ts/fixtures/lang/expected/dyns.Hits.ts b/ts/fixtures/lang/dyns/expected/dyns.Hits.ts similarity index 100% rename from ts/fixtures/lang/expected/dyns.Hits.ts rename to ts/fixtures/lang/dyns/expected/dyns.Hits.ts diff --git a/ts/fixtures/lang/expected/dyns.Hook.ts b/ts/fixtures/lang/dyns/expected/dyns.Hook.ts similarity index 100% rename from ts/fixtures/lang/expected/dyns.Hook.ts rename to ts/fixtures/lang/dyns/expected/dyns.Hook.ts diff --git a/ts/fixtures/lang/expected/dyns.Lease.ts b/ts/fixtures/lang/dyns/expected/dyns.Lease.ts similarity index 100% rename from ts/fixtures/lang/expected/dyns.Lease.ts rename to ts/fixtures/lang/dyns/expected/dyns.Lease.ts diff --git a/ts/fixtures/lang/expected/dyns.Looped.ts b/ts/fixtures/lang/dyns/expected/dyns.Looped.ts similarity index 89% rename from ts/fixtures/lang/expected/dyns.Looped.ts rename to ts/fixtures/lang/dyns/expected/dyns.Looped.ts index 43b89b6a9..76133d5d0 100644 --- a/ts/fixtures/lang/expected/dyns.Looped.ts +++ b/ts/fixtures/lang/dyns/expected/dyns.Looped.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import type * as dyns_Shape from "./dyns.Shape.ts"; +import type * as Shape from "./dyns.Shape.ts"; /** Provided, and overridden by one impl. */ export function sides$dyns_Shape(_self: Looped): rt.u8 { @@ -27,9 +27,9 @@ export function tally$dyns_Shape(self: Looped, sum: rt.Place): void { /** A shape holding a `Weak` of itself as a trait object, made inside `Rc::new_cyclic`. */ export class Looped { side: rt.u8; - me: rt.Weak; + me: rt.Weak; - constructor(side: rt.u8, me: rt.Weak) { + constructor(side: rt.u8, me: rt.Weak) { this.side = side; this.me = me; } diff --git a/ts/fixtures/lang/expected/dyns.Named.ts b/ts/fixtures/lang/dyns/expected/dyns.Named.ts similarity index 100% rename from ts/fixtures/lang/expected/dyns.Named.ts rename to ts/fixtures/lang/dyns/expected/dyns.Named.ts diff --git a/ts/fixtures/lang/expected/dyns.Noisy.ts b/ts/fixtures/lang/dyns/expected/dyns.Noisy.ts similarity index 100% rename from ts/fixtures/lang/expected/dyns.Noisy.ts rename to ts/fixtures/lang/dyns/expected/dyns.Noisy.ts diff --git a/ts/fixtures/lang/expected/dyns.Resuming.ts b/ts/fixtures/lang/dyns/expected/dyns.Resuming.ts similarity index 100% rename from ts/fixtures/lang/expected/dyns.Resuming.ts rename to ts/fixtures/lang/dyns/expected/dyns.Resuming.ts diff --git a/ts/fixtures/lang/expected/dyns.Shape.ts b/ts/fixtures/lang/dyns/expected/dyns.Shape.ts similarity index 88% rename from ts/fixtures/lang/expected/dyns.Shape.ts rename to ts/fixtures/lang/dyns/expected/dyns.Shape.ts index ea0792c61..95a44ad09 100644 --- a/ts/fixtures/lang/expected/dyns.Shape.ts +++ b/ts/fixtures/lang/dyns/expected/dyns.Shape.ts @@ -1,10 +1,10 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { sides$dyns_Shape_u32, intoArea$dyns_Shape_u32, larger$dyns_Shape_u32, tally$dyns_Shape_u32 as dyns_tally$dyns_Shape_u32, area$dyns_Shape_u32, grow$dyns_Shape_u32 } from "./dyns.ts"; +import { sides$dyns_Shape_u32, intoArea$dyns_Shape_u32, larger$dyns_Shape_u32, tally$dyns_Shape_u32, area$dyns_Shape_u32, grow$dyns_Shape_u32 } from "./dyns.ts"; import * as Hits from "./dyns.Hits.ts"; import * as Looped from "./dyns.Looped.ts"; -import * as dyns_Noisy from "./dyns.Noisy.ts"; +import * as Noisy from "./dyns.Noisy.ts"; import * as Square from "./dyns.Square.ts"; import * as Tri from "./dyns.Tri.ts"; @@ -80,9 +80,9 @@ export class of$dyns_Looped { } export class of$dyns_Noisy { - v: dyns_Noisy.Noisy; + v: Noisy.Noisy; - constructor(v: dyns_Noisy.Noisy) { + constructor(v: Noisy.Noisy) { this.v = v; } @@ -91,27 +91,27 @@ export class of$dyns_Noisy { } area$Shape(): rt.u32 { - return dyns_Noisy.area$dyns_Shape(this.v); + return Noisy.area$dyns_Shape(this.v); } grow$Shape(a: rt.u8): void { - return dyns_Noisy.grow$dyns_Shape(this.v, a); + return Noisy.grow$dyns_Shape(this.v, a); } intoArea$Shape(): rt.u32 { - return dyns_Noisy.intoArea$dyns_Shape(this.v); + return Noisy.intoArea$dyns_Shape(this.v); } larger$Shape(a: rt.u32): rt.u32 { - return dyns_Noisy.larger$dyns_Shape(this.v, a); + return Noisy.larger$dyns_Shape(this.v, a); } sides$Shape(): rt.u8 { - return dyns_Noisy.sides$dyns_Shape(this.v); + return Noisy.sides$dyns_Shape(this.v); } tally$Shape(a: rt.Place): void { - return dyns_Noisy.tally$dyns_Shape(this.v, a); + return Noisy.tally$dyns_Shape(this.v, a); } } @@ -207,7 +207,7 @@ export class of$u32 { } tally$Shape(a: rt.Place): void { - return dyns_tally$dyns_Shape_u32(this.v, a); + return tally$dyns_Shape_u32(this.v, a); } } @@ -271,7 +271,7 @@ export class ofPlace$u32 { } tally$Shape(a: rt.Place): void { - return dyns_tally$dyns_Shape_u32(this.v.v, a); + return tally$dyns_Shape_u32(this.v.v, a); } } diff --git a/ts/fixtures/lang/expected/dyns.Shown.ts b/ts/fixtures/lang/dyns/expected/dyns.Shown.ts similarity index 100% rename from ts/fixtures/lang/expected/dyns.Shown.ts rename to ts/fixtures/lang/dyns/expected/dyns.Shown.ts diff --git a/ts/fixtures/lang/expected/dyns.Square.ts b/ts/fixtures/lang/dyns/expected/dyns.Square.ts similarity index 100% rename from ts/fixtures/lang/expected/dyns.Square.ts rename to ts/fixtures/lang/dyns/expected/dyns.Square.ts diff --git a/ts/fixtures/lang/expected/dyns.Tagged.ts b/ts/fixtures/lang/dyns/expected/dyns.Tagged.ts similarity index 100% rename from ts/fixtures/lang/expected/dyns.Tagged.ts rename to ts/fixtures/lang/dyns/expected/dyns.Tagged.ts diff --git a/ts/fixtures/lang/expected/dyns.Tri.ts b/ts/fixtures/lang/dyns/expected/dyns.Tri.ts similarity index 100% rename from ts/fixtures/lang/expected/dyns.Tri.ts rename to ts/fixtures/lang/dyns/expected/dyns.Tri.ts diff --git a/ts/fixtures/lang/expected/dyns.ts b/ts/fixtures/lang/dyns/expected/dyns.ts similarity index 76% rename from ts/fixtures/lang/expected/dyns.ts rename to ts/fixtures/lang/dyns/expected/dyns.ts index 3000dca26..509ad3052 100644 --- a/ts/fixtures/lang/expected/dyns.ts +++ b/ts/fixtures/lang/dyns/expected/dyns.ts @@ -5,22 +5,22 @@ import { drop$Result_Rc_dyns_Noisy_Rc_dyn_Any, drop$Result_Rc_dyns_Square_Rc_dyn import * as Any from "./core/any.Any.ts"; import { thenSome$0d5am30 } from "./core/bool.ts"; import { unwrapOr$1iemzn8 as option_unwrapOr$1iemzn8, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$1i542n2 as option_map$1i542n2, map$0oedb57 as option_map$0oedb57, map$08a6hpg as option_map$08a6hpg, map$1qfllpb as option_map$1qfllpb, map$0j05j69 as option_map$0j05j69, mapOr$06rr3sb as option_mapOr$06rr3sb, andThen$0v0bj8w as option_andThen$0v0bj8w, andThen$0ntiuws as option_andThen$0ntiuws } from "./core/option.ts"; -import { ok$00p9ap8, ok$0lceojf, map$0zzqmaz as result_map$0zzqmaz } from "./core/result.ts"; +import { ok$00p9ap8, ok$0lceojf, map$0zujxcv as result_map$0zujxcv } from "./core/result.ts"; import * as Chunks from "./dyns.Chunks.ts"; -import * as dyns_Countdown from "./dyns.Countdown.ts"; +import * as Countdown from "./dyns.Countdown.ts"; import * as dyns_Erased from "./dyns.Erased.ts"; import type * as Hits from "./dyns.Hits.ts"; import * as Hook from "./dyns.Hook.ts"; import * as Looped from "./dyns.Looped.ts"; -import * as dyns_Named from "./dyns.Named.ts"; -import * as dyns_Noisy from "./dyns.Noisy.ts"; +import * as Named from "./dyns.Named.ts"; +import * as Noisy from "./dyns.Noisy.ts"; import * as Resuming from "./dyns.Resuming.ts"; -import * as dyns_Shape from "./dyns.Shape.ts"; +import * as Shape from "./dyns.Shape.ts"; import * as Shown from "./dyns.Shown.ts"; import * as Square from "./dyns.Square.ts"; -import * as dyns_Tagged from "./dyns.Tagged.ts"; +import * as Tagged from "./dyns.Tagged.ts"; import * as Tri from "./dyns.Tri.ts"; -import { put as fmt_put } from "./fmt.ts"; +import { put } from "./harness.ts"; /** Provided, and overridden by one impl. */ export function sides$dyns_Shape_u32(_self: rt.u32): rt.u8 { @@ -49,19 +49,19 @@ export function grow$dyns_Shape_u32(self: rt.Place, by: rt.u8): void { self.v = rt.u32WrappingMul(self.v, by as rt.u32); } -export function total(shapes: dyns_Shape.Shape[]): rt.u32 { - return rt.iterFold(rt.iterSlice(shapes), 0, (sum: rt.u32, s: dyns_Shape.Shape): rt.u32 => { +export function total(shapes: Shape.Shape[]): rt.u32 { + return rt.iterFold(rt.iterSlice(shapes), 0, (sum: rt.u32, s: Shape.Shape): rt.u32 => { return rt.u32WrappingAdd(sum, s.area$Shape()); }); } -export function growTwice(s: dyns_Shape.Shape, by: rt.u8): void { +export function growTwice(s: Shape.Shape, by: rt.u8): void { s.grow$Shape(by); s.grow$Shape(rt.u8WrappingAdd(by, 1)); } /** Over a type parameter that the trait object instantiates. */ -export function sidesOf$dyn_dyns_Shape(s: dyns_Shape.Shape): rt.u8 { +export function sidesOf$dyn_dyns_Shape(s: Shape.Shape): rt.u8 { return s.sides$Shape(); } @@ -70,21 +70,21 @@ export function sidesOf$dyns_Square(s: Square.Square): rt.u8 { return Square.sides$dyns_Shape(s); } -export function upcast(n: dyns_Named.Named): dyns_Shape.Shape { +export function upcast(n: Named.Named): Shape.Shape { return n; } -export function make(kind: rt.u8, n: rt.u8): dyns_Named.Named { +export function make(kind: rt.u8, n: rt.u8): Named.Named { let _10!: Tri.Tri; if (rt.u8Rem(kind, 2) === 0) { - return new dyns_Named.of$dyns_Square({ side: n as rt.u16 }); + return new Named.of$dyns_Square({ side: n as rt.u16 }); } if (!(rt.u8Rem(n, 3) === 0)) { _10 = { tag: "Tall", _0: n } as Tri.Tri; } else { _10 = { tag: "Flat" } as Tri.Tri; } - return new dyns_Named.of$dyns_Tri(_10); + return new Named.of$dyns_Tri(_10); } export function dyns(dataData: Uint8Array, dataStart: number, dataLen: number, out: rt.ByteVec): void { @@ -102,20 +102,20 @@ export function dyns(dataData: Uint8Array, dataStart: number, dataLen: number, o tri = { tag: "Flat" } as Tri.Tri; } let n: rt.u32 = c as rt.u32; - const part = total([new dyns_Shape.of$dyns_Square(sq), new dyns_Shape.of$dyns_Tri(tri), new dyns_Shape.of$u32(n)]); + const part = total([new Shape.of$dyns_Square(sq), new Shape.of$dyns_Tri(tri), new Shape.of$u32(n)]); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part, f)]; - fmt_put(out, rt.fmtFormat([args2[0], " "])); - growTwice(new dyns_Shape.of$dyns_Square(sq), b); - growTwice(new dyns_Shape.ofPlace$dyns_Tri(rt.place(() => tri, (value) => tri = value)), c); - growTwice(new dyns_Shape.ofPlace$u32(rt.place(() => n, (value2) => n = value2)), a); + put(out, rt.fmtFormat([args2[0], " "])); + growTwice(new Shape.of$dyns_Square(sq), b); + growTwice(new Shape.ofPlace$dyns_Tri(rt.place(() => tri, (value) => tri = value)), c); + growTwice(new Shape.ofPlace$u32(rt.place(() => n, (value2) => n = value2)), a); const arg = sq.side; const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.u16Display(arg, f), (f: rt.Formatter) => Tri.fmt$fmt_Debug(tri, f), (f: rt.Formatter) => rt.u32Display(n, f)]; - fmt_put(out, rt.fmtFormat([args4[0], " ", args4[1], " ", args4[2], " "])); - const _78: rt.u8 = sidesOf$dyn_dyns_Shape(new dyns_Shape.of$dyns_Tri(tri)); + put(out, rt.fmtFormat([args4[0], " ", args4[1], " ", args4[2], " "])); + const _78: rt.u8 = sidesOf$dyn_dyns_Shape(new Shape.of$dyns_Tri(tri)); const _82: rt.u8 = sidesOf$dyns_Square(sq); const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(_78, f), (f: rt.Formatter) => rt.u8Display(_82, f)]; - fmt_put(out, rt.fmtFormat([args6[0], " ", args6[1], " "])); - const shapes: dyns_Named.Named[] = []; + put(out, rt.fmtFormat([args6[0], " ", args6[1], " "])); + const shapes: Named.Named[] = []; const iter: rt.Iter<[rt.usize, rt.u8]> = rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(new rt.ByteSlice(dataData, dataStart + 3, dataLen - 3)))); while (true) { const _94: [rt.usize, rt.u8] | rt.Done = iter.next(); @@ -124,7 +124,7 @@ export function dyns(dataData: Uint8Array, dataStart: number, dataLen: number, o } const i: rt.usize = _94[0]; const x: rt.u8 = _94[1]; - const _101: dyns_Named.Named = make(rt.u8WrappingAdd(x, i & 0xff), x); + const _101: Named.Named = make(rt.u8WrappingAdd(x, i & 0xff), x); shapes.push(_101); } const _106: rt.usize = shapes.length; @@ -133,7 +133,7 @@ export function dyns(dataData: Uint8Array, dataStart: number, dataLen: number, o while ((_109 = iterStart++) < iterEnd) { const i2: rt.usize = _109; const at = rt.idx(shapes, i2); - const s: rt.Place = rt.place(() => shapes[at], (value3) => shapes[at] = value3); + const s: rt.Place = rt.place(() => shapes[at], (value3) => shapes[at] = value3); if (rt.usizeRem(i2, 2) === 0) { s.v.grow$Shape(a); } @@ -141,7 +141,7 @@ export function dyns(dataData: Uint8Array, dataStart: number, dataLen: number, o const _132: rt.u32 = s.v.area$Shape(); const _135: rt.u8 = sidesOf$dyn_dyns_Shape(upcast(s.v)); const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, _129), (f: rt.Formatter) => rt.u32Display(_132, f), (f: rt.Formatter) => rt.u8Display(_135, f), (f: rt.Formatter) => s.v.fmt$Debug(f)]; - fmt_put(out, rt.fmtFormat([args8[0], ":", args8[1], ":", args8[2], ":", args8[3], " "])); + put(out, rt.fmtFormat([args8[0], ":", args8[1], ":", args8[2], ":", args8[3], " "])); } let sum: rt.u32 = 0; for (const _150 of shapes) { @@ -153,26 +153,26 @@ export function dyns(dataData: Uint8Array, dataStart: number, dataLen: number, o const _165: Shown.Shown = { _0: (f: rt.Formatter) => Tri.fmt$fmt_Debug(_167, f) }; const _169: rt.u32 = shapes[at2].larger$Shape(b as rt.u32); const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_175, f), (f: rt.Formatter) => Shown.fmt$fmt_Debug(_165, f), (f: rt.Formatter) => rt.u32Display(_169, f)]; - fmt_put(out, rt.fmtFormat([args10[0], " ", args10[1], " ", args10[2], " "])); + put(out, rt.fmtFormat([args10[0], " ", args10[1], " ", args10[2], " "])); for (const s2 of shapes) { sum = rt.u32WrappingAdd(sum, s2.intoArea$Shape()); } const _204: rt.u32 = sum; - const _203: rt.u32 = new dyns_Shape.of$u32(n).intoArea$Shape(); + const _203: rt.u32 = new Shape.of$u32(n).intoArea$Shape(); const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_204, f), (f: rt.Formatter) => rt.u32Display(_203, f)]; - fmt_put(out, rt.fmtFormat([args12[0], " ", args12[1]])); + put(out, rt.fmtFormat([args12[0], " ", args12[1]])); } } -export function counts$dyn_dyns_Named(arcs: rt.Arc[]): string { - return rt.strsJoin(rt.iterToArray(rt.iterMap(rt.iterSlice(arcs), (a: rt.Arc): string => { +export function counts$dyn_dyns_Named(arcs: rt.Arc[]): string { + return rt.strsJoin(rt.iterToArray(rt.iterMap(rt.iterSlice(arcs), (a: rt.Arc): string => { const _42: rt.usize = a.strong; return rt.fmtToString((f: rt.Formatter) => rt.usizeDisplay(_42, f)); }), undefined, 12, true), ","); } -export function counts$dyn_dyns_Shape(arcs: rt.Arc[]): string { - return rt.strsJoin(rt.iterToArray(rt.iterMap(rt.iterSlice(arcs), (a: rt.Arc): string => { +export function counts$dyn_dyns_Shape(arcs: rt.Arc[]): string { + return rt.strsJoin(rt.iterToArray(rt.iterMap(rt.iterSlice(arcs), (a: rt.Arc): string => { const _42: rt.usize = a.strong; return rt.fmtToString((f: rt.Formatter) => rt.usizeDisplay(_42, f)); }), undefined, 12, true), ","); @@ -196,35 +196,35 @@ export function shared(dataData: Uint8Array, dataStart: number, dataLen: number, if (dataLen >= 2) { const sq: rt.Arc = new rt.Arc({ side: dataData[dataStart] as rt.u16 }); const _13: rt.Arc = rt.arcClone(sq); - const named: rt.Arc = new rt.ArcDyn(_13, new dyns_Named.of$dyns_Square(_13.value)); + const named: rt.Arc = new rt.ArcDyn(_13, new Named.of$dyns_Square(_13.value)); const _16: rt.Arc = rt.arcClone(sq); - const again: rt.Arc = new rt.ArcDyn(_16, new dyns_Named.of$dyns_Square(_16.value)); - const shape: rt.Arc = rt.arcClone(named); - const up: rt.Arc = rt.arcClone(again); + const again: rt.Arc = new rt.ArcDyn(_16, new Named.of$dyns_Square(_16.value)); + const shape: rt.Arc = rt.arcClone(named); + const up: rt.Arc = rt.arcClone(again); const part = counts$dyns_Square([sq]); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, part)]; - fmt_put(out, rt.fmtFormat([args2[0], " "])); + put(out, rt.fmtFormat([args2[0], " "])); const _49: string = named.value.label$Named(); const _53: rt.u32 = shape.value.area$Shape(); const _57: rt.u8 = sidesOf$dyn_dyns_Shape(up.value); - const _62: dyns_Named.Named = named.value; + const _62: Named.Named = named.value; const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, _49), (f: rt.Formatter) => rt.u32Display(_53, f), (f: rt.Formatter) => rt.u8Display(_57, f), (f: rt.Formatter) => _62.fmt$Debug(f)]; - fmt_put(out, rt.fmtFormat([args4[0], " ", args4[1], " ", args4[2], " ", args4[3], " "])); - const _73: [rt.Weak, rt.Weak] = [new rt.Weak(shape), new rt.Weak(up)]; - const weak: rt.Weak = _73[0]; - const other: rt.Weak = _73[1]; + put(out, rt.fmtFormat([args4[0], " ", args4[1], " ", args4[2], " ", args4[3], " "])); + const _73: [rt.Weak, rt.Weak] = [new rt.Weak(shape), new rt.Weak(up)]; + const weak: rt.Weak = _73[0]; + const other: rt.Weak = _73[1]; const _86: boolean = rt.arcPtrEq(named, again); const _90: boolean = rt.arcPtrEq(shape, up); const _94: boolean = rt.arcPtrEq(weak.arc, other.arc); const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(_86, f), (f: rt.Formatter) => rt.fmtBool(_90, f), (f: rt.Formatter) => rt.fmtBool(_94, f)]; - fmt_put(out, rt.fmtFormat([args6[0], " ", args6[1], " ", args6[2], " "])); + put(out, rt.fmtFormat([args6[0], " ", args6[1], " ", args6[2], " "])); sq[Symbol.dispose](); named[Symbol.dispose](); const _113: string = counts$dyn_dyns_Named([again]); const _119: rt.usize = weak.arc.strong; const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, _113), (f: rt.Formatter) => rt.usizeDisplay(_119, f)]; - fmt_put(out, rt.fmtFormat([args8[0], " ", args8[1], " "])); - const upgraded: rt.u32 | undefined = option_map$1i542n2(rt.weakUpgrade(weak), (s: rt.Arc): rt.u32 => { + put(out, rt.fmtFormat([args8[0], " ", args8[1], " "])); + const upgraded: rt.u32 | undefined = option_map$1i542n2(rt.weakUpgrade(weak), (s: rt.Arc): rt.u32 => { const _0: rt.u32 = s.value.area$Shape(); s[Symbol.dispose](); return _0; @@ -232,62 +232,62 @@ export function shared(dataData: Uint8Array, dataStart: number, dataLen: number, again[Symbol.dispose](); const part2 = counts$dyn_dyns_Shape([up]); const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, part2)]; - fmt_put(out, rt.fmtFormat([args10[0], " "])); + put(out, rt.fmtFormat([args10[0], " "])); up[Symbol.dispose](); const _156: string = counts$dyn_dyns_Shape([shape]); - const _164: rt.Arc | undefined = rt.weakUpgrade(weak); + const _164: rt.Arc | undefined = rt.weakUpgrade(weak); const _162: boolean = _164 !== undefined; const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, _156), (f: rt.Formatter) => rt.fmtBool(_162, f), (f: rt.Formatter) => rt.fmtOption(upgraded, f, rt.u32Debug)]; const _152: string = rt.fmtFormat([args12[0], " ", args12[1], " ", args12[2], " "]); rt.drop(_164); - fmt_put(out, _152); + put(out, _152); shape[Symbol.dispose](); - const _184: rt.Arc | undefined = rt.weakUpgrade(weak); + const _184: rt.Arc | undefined = rt.weakUpgrade(weak); const _182: boolean = _184 === undefined; const _187: rt.usize = other.arc.strong; const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(_182, f), (f: rt.Formatter) => rt.usizeDisplay(_187, f)]; const _178: string = rt.fmtFormat([args14[0], " ", args14[1], " "]); rt.drop(_184); - fmt_put(out, _178); + put(out, _178); const hits: rt.Arc = new rt.Arc({ _0: new rt.Atomic(dataData[dataStart + 1] as rt.u32) }); - const objects: rt.Arc[] = rt.iterToArray(rt.iterMap(new rt.Range(0, 3), (_2: rt.i32): rt.Arc => { + const objects: rt.Arc[] = rt.iterToArray(rt.iterMap(new rt.Range(0, 3), (_2: rt.i32): rt.Arc => { const _34: rt.Arc = rt.arcClone(hits); - return new rt.ArcDyn(_34, new dyns_Shape.of$dyns_Hits(_34.value)); + return new rt.ArcDyn(_34, new Shape.of$dyns_Hits(_34.value)); }), undefined, 8, true); - const sum: rt.u32 = rt.iterFold(rt.iterSlice(objects), 0, (sum2: rt.u32, s2: rt.Arc): rt.u32 => { + const sum: rt.u32 = rt.iterFold(rt.iterSlice(objects), 0, (sum2: rt.u32, s2: rt.Arc): rt.u32 => { return rt.u32WrappingAdd(sum2, s2.value.area$Shape()); }); const _216: rt.u32 = rt.atomicLoad(hits.value._0, 0); const _222: string = counts$dyns_Hits([hits]); const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(sum, f), (f: rt.Formatter) => rt.u32Display(_216, f), (f: rt.Formatter) => rt.fmtPad(f, _222)]; - fmt_put(out, rt.fmtFormat([args16[0], " ", args16[1], " ", args16[2], " "])); + put(out, rt.fmtFormat([args16[0], " ", args16[1], " ", args16[2], " "])); rt.dropAll(objects); const part3 = counts$dyns_Hits([hits]); const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, part3)]; - fmt_put(out, rt.fmtFormat([args18[0], " "])); + put(out, rt.fmtFormat([args18[0], " "])); const _253: rt.Arc = new rt.Arc(dataData[dataStart + 1] as rt.u32); - const n: rt.Arc = new rt.ArcDyn(_253, new dyns_Shape.of$u32(_253.value)); + const n: rt.Arc = new rt.ArcDyn(_253, new Shape.of$u32(_253.value)); const _257: rt.Arc = new rt.Arc(dataData[dataStart + 1] as rt.u32); - const m: rt.Arc = new rt.ArcDyn(_257, new dyns_Shape.of$u32(_257.value)); + const m: rt.Arc = new rt.ArcDyn(_257, new Shape.of$u32(_257.value)); const _268: rt.u32 = n.value.area$Shape(); const _272: boolean = rt.arcPtrEq(n, m); const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_268, f), (f: rt.Formatter) => rt.fmtBool(_272, f)]; - fmt_put(out, rt.fmtFormat([args20[0], " ", args20[1], " "])); - const tris: rt.Arc[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(new rt.ByteSlice(dataData, dataStart + 2, dataLen - 2))), (_23: rt.u8): rt.Arc => { + put(out, rt.fmtFormat([args20[0], " ", args20[1], " "])); + const tris: rt.Arc[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(new rt.ByteSlice(dataData, dataStart + 2, dataLen - 2))), (_23: rt.u8): rt.Arc => { const x: rt.u8 = _23; const _43: rt.u8 = rt.u8Rem(x, 3); if (_43 === 0) { const _72: rt.Arc = new rt.Arc({ tag: "Flat" } as Tri.Tri); - return new rt.ArcDyn(_72, new dyns_Named.of$dyns_Tri(_72.value)); + return new rt.ArcDyn(_72, new Named.of$dyns_Tri(_72.value)); } if (_43 === 1) { const _92: rt.Arc = new rt.Arc({ tag: "Tall", _0: x } as Tri.Tri); - return new rt.ArcDyn(_92, new dyns_Named.of$dyns_Tri(_92.value)); + return new rt.ArcDyn(_92, new Named.of$dyns_Tri(_92.value)); } const _112: rt.Arc = new rt.Arc({ side: x as rt.u16 }); - return new rt.ArcDyn(_112, new dyns_Named.of$dyns_Square(_112.value)); + return new rt.ArcDyn(_112, new Named.of$dyns_Square(_112.value)); }), undefined, 8, true); - const kept: rt.Arc[] = rt.iterToArray(rt.iterMap(rt.iterStepBy(rt.iterSlice(tris), 2), (a0: rt.Arc): rt.Arc => { + const kept: rt.Arc[] = rt.iterToArray(rt.iterMap(rt.iterStepBy(rt.iterSlice(tris), 2), (a0: rt.Arc): rt.Arc => { return rt.arcClone(a0); }), undefined, 8, true); for (const _292 of tris) { @@ -295,7 +295,7 @@ export function shared(dataData: Uint8Array, dataStart: number, dataLen: number, const _307: rt.u32 = _292.value.area$Shape(); const _310: rt.usize = _292.strong; const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, _304), (f: rt.Formatter) => rt.u32Display(_307, f), (f: rt.Formatter) => rt.usizeDisplay(_310, f)]; - fmt_put(out, rt.fmtFormat([args22[0], ":", args22[1], ":", args22[2], " "])); + put(out, rt.fmtFormat([args22[0], ":", args22[1], ":", args22[2], " "])); } rt.dropAll(tris); let total: rt.u32 = 0; @@ -304,7 +304,7 @@ export function shared(dataData: Uint8Array, dataStart: number, dataLen: number, } const _337: string = counts$dyn_dyns_Named(rt.iterToArray(rt.iterSlice(kept), undefined, 4, true)); const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(total, f), (f: rt.Formatter) => rt.fmtPad(f, _337)]; - fmt_put(out, rt.fmtFormat([args24[0], " ", args24[1]])); + put(out, rt.fmtFormat([args24[0], " ", args24[1]])); rt.dropAll(kept); m[Symbol.dispose](); n[Symbol.dispose](); @@ -400,7 +400,7 @@ export function anys(dataData: Uint8Array, dataStart: number, dataLen: number, o } const part = kind(_33); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, part)]; - fmt_put(out, rt.fmtFormat([args2[0], " "])); + put(out, rt.fmtFormat([args2[0], " "])); } const _51: boolean = bump(new Any.of$dyns_Square(sq), a); const _54: boolean = bump(new Any.ofPlace$dyns_Tri(rt.place(() => tri, (value) => tri = value)), b); @@ -410,7 +410,7 @@ export function anys(dataData: Uint8Array, dataStart: number, dataLen: number, o const hit: [boolean, boolean, boolean, boolean] = [_51, _54, _57, bump(new Any.ofPlace$u8(rt.place(() => _63, (value3) => _63 = value3)), a)]; const arg = sq.side; const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.u16Display(arg, f), (f: rt.Formatter) => Tri.fmt$fmt_Debug(_72, f), (f: rt.Formatter) => rt.u32Display(n, f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtBool(hit[0], f), (f: rt.Formatter) => rt.fmtBool(hit[1], f), (f: rt.Formatter) => rt.fmtBool(hit[2], f), (f: rt.Formatter) => rt.fmtBool(hit[3], f)], f)]; - fmt_put(out, rt.fmtFormat([args4[0], " ", args4[1], " ", args4[2], " ", args4[3], " "])); + put(out, rt.fmtFormat([args4[0], " ", args4[1], " ", args4[2], " ", args4[3], " "])); const iter2: rt.Iter = rt.iterSlice([new dyns_Erased.of$dyns_Square(sq), new dyns_Erased.of$dyns_Tri(tri), new dyns_Erased.of$u32(n)]); while (true) { const _91: dyns_Erased.Erased | rt.Done = iter2.next(); @@ -421,7 +421,7 @@ export function anys(dataData: Uint8Array, dataStart: number, dataLen: number, o const _105: boolean = isA$u32(_91); const _107: string = kind(_91.asAny$Erased()); const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(_103, f), (f: rt.Formatter) => rt.fmtBool(_105, f), (f: rt.Formatter) => rt.fmtPad(f, _107)]; - fmt_put(out, rt.fmtFormat([args6[0], args6[1], args6[2], " "])); + put(out, rt.fmtFormat([args6[0], args6[1], args6[2], " "])); } let m: rt.u32 = a as rt.u32; const _119: Any.Any = new dyns_Erased.ofPlace$u32(rt.place(() => m, (value4) => m = value4)).asAnyMut$Erased(); @@ -430,11 +430,11 @@ export function anys(dataData: Uint8Array, dataStart: number, dataLen: number, o _118.v = rt.u32WrappingMul(_118.v, 3); } const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(m, f)]; - fmt_put(out, rt.fmtFormat([args8[0], " "])); + put(out, rt.fmtFormat([args8[0], " "])); const unit: Any.Any = new Any.of$unit(undefined); const part2 = [unit instanceof Any.of$unit ? unit.v : unit instanceof Any.ofPlace$unit ? unit.v.v : rt.None, unit instanceof Any.of$Option_u8 || unit instanceof Any.ofPlace$Option_u8] as [undefined | rt.None, boolean]; const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(part2[0], f, rt.fmtUnit, rt.None), (f: rt.Formatter) => rt.fmtBool(part2[1], f)], f)]; - fmt_put(out, rt.fmtFormat([args10[0], " "])); + put(out, rt.fmtFormat([args10[0], " "])); let some: rt.u8 | undefined = a; let none: rt.u8 | undefined = undefined; const iter3: rt.Iter = rt.iterSlice([new Any.ofPlace$Option_u8(rt.place(() => some, (value5) => some = value5)), new Any.ofPlace$Option_u8(rt.place(() => none, (value6) => none = value6)), new Any.ofPlace$u32(rt.place(() => n, (value7) => n = value7))]); @@ -445,7 +445,7 @@ export function anys(dataData: Uint8Array, dataStart: number, dataLen: number, o } const part3 = [_167 instanceof Any.of$unit ? _167.v : _167 instanceof Any.ofPlace$unit ? _167.v.v : rt.None, _167 instanceof Any.of$Option_u8 ? _167.v : _167 instanceof Any.ofPlace$Option_u8 ? _167.v.v : rt.None] as [undefined | rt.None, rt.u8 | undefined | rt.None]; const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(part3[0], f, rt.fmtUnit, rt.None), (f: rt.Formatter) => rt.fmtOption(part3[1], f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug), rt.None)], f)]; - fmt_put(out, rt.fmtFormat([args12[0]])); + put(out, rt.fmtFormat([args12[0]])); const _189: rt.Place | undefined = _167 instanceof Any.of$Option_u8 ? _167 : _167 instanceof Any.ofPlace$Option_u8 ? _167.v : undefined; if (_189 !== undefined) { _189.v = option_mapOr$06rr3sb(_189.v, b, (_2: rt.u8): rt.u8 | undefined => { @@ -454,10 +454,10 @@ export function anys(dataData: Uint8Array, dataStart: number, dataLen: number, o } const arg2 = ((_167 instanceof Any.of$unit ? _167 : _167 instanceof Any.ofPlace$unit ? _167.v : undefined)) !== undefined; const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(arg2, f)]; - fmt_put(out, rt.fmtFormat([args14[0], " "])); + put(out, rt.fmtFormat([args14[0], " "])); } const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(some, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(none, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args16[0], " ", args16[1], " "])); + put(out, rt.fmtFormat([args16[0], " ", args16[1], " "])); const boxes: Any.Any[] = []; const iter4: rt.Iter<[rt.usize, rt.u8]> = rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(new rt.ByteSlice(dataData, dataStart + 2, dataLen - 2)))); while (true) { @@ -492,19 +492,19 @@ export function anys(dataData: Uint8Array, dataStart: number, dataLen: number, o if (_261.ok) { const part5 = _261.value; const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part5, f)]; - fmt_put(out, rt.fmtFormat(["n", args18[0], " "])); + put(out, rt.fmtFormat(["n", args18[0], " "])); } else if (!(rt.usizeRem(i2, 2) === 0)) { const other2: Any.Any = _261.error; const _282: rt.Result = other2 instanceof Any.of$u8 ? rt.Ok(other2.v) : rt.Err(other2); if (_282.ok) { const arg3 = _282.value; const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(arg3, f)]; - fmt_put(out, rt.fmtFormat(["u8 ", args20[0], " "])); + put(out, rt.fmtFormat(["u8 ", args20[0], " "])); } else { const other3: Any.Any = _282.error; const part4 = kind(other3); const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, part4)]; - fmt_put(out, rt.fmtFormat([args22[0], " "])); + put(out, rt.fmtFormat([args22[0], " "])); rt.drop(other3); } } else { @@ -521,7 +521,7 @@ export function anys(dataData: Uint8Array, dataStart: number, dataLen: number, o const _328: string = kind(_316.v); const _331: boolean = bump(_316.v, a); const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, _328), (f: rt.Formatter) => rt.fmtBool(_331, f)]; - fmt_put(out, rt.fmtFormat([args24[0], ":", args24[1], " "])); + put(out, rt.fmtFormat([args24[0], ":", args24[1], " "])); } const _339: rt.Arc<[rt.u8, rt.u8]> = new rt.Arc([a, b] as [rt.u8, rt.u8]); const hold: rt.Arc = new rt.ArcDyn(_339, new Any.of$tuple2_u8_u8(_339.value)); @@ -530,22 +530,22 @@ export function anys(dataData: Uint8Array, dataStart: number, dataLen: number, o const _354: rt.usize = hold.strong; const _357: [rt.u8, rt.u8] | undefined = _358 instanceof Any.of$tuple2_u8_u8 ? _358.v : undefined; const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_354, f), (f: rt.Formatter) => rt.fmtOption(_357, f, (value: [rt.u8, rt.u8], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(value[0], f), (f: rt.Formatter) => rt.u8Debug(value[1], f)], f))]; - fmt_put(out, rt.fmtFormat([args26[0], " ", args26[1], " "])); + put(out, rt.fmtFormat([args26[0], " ", args26[1], " "])); rt.dropAll(held); const part6 = hold.strong; const args28: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(part6, f)]; - fmt_put(out, rt.fmtFormat([args28[0], " "])); + put(out, rt.fmtFormat([args28[0], " "])); const _381: rt.Result, rt.Arc> = rt.arcDowncast(hold, Any.of$u8, (object) => object.v); if (_381.ok) { rt.panic("internal error: entered unreachable code"); } else { - const part7 = ok$0lceojf(result_map$0zzqmaz(rt.arcDowncast(_381.error, Any.of$tuple2_u8_u8, (object) => object.v), (t: rt.Arc<[rt.u8, rt.u8]>): [rt.usize, rt.u8] => { + const part7 = ok$0lceojf(result_map$0zujxcv(rt.arcDowncast(_381.error, Any.of$tuple2_u8_u8, (object) => object.v), (t: rt.Arc<[rt.u8, rt.u8]>): [rt.usize, rt.u8] => { const _02: [rt.usize, rt.u8] = [t.strong, t.value[0]]; t[Symbol.dispose](); return _02; })); const args30: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part7, f, (value: [rt.usize, rt.u8], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(value[0], f), (f: rt.Formatter) => rt.u8Debug(value[1], f)], f))]; - fmt_put(out, rt.fmtFormat([args30[0]])); + put(out, rt.fmtFormat([args30[0]])); rt.dropAll(kept); } } @@ -599,12 +599,12 @@ export function fns(data: rt.ByteSlice, out: rt.ByteVec): void { const _31: rt.u8 = twice(halve, a); const _35: rt.u8 = twice(ptr, a); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(_27, f), (f: rt.Formatter) => rt.u8Display(_31, f), (f: rt.Formatter) => rt.u8Display(_35, f)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " "])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " "])); const part = firstWord((s: string): string => { return option_unwrapOr$1iemzn8(rt.iterToOption(rt.strSplit(s, " ").next()), ""); }, "ab cd"); const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(part, f)]; - fmt_put(out, rt.fmtFormat([args4[0], " "])); + put(out, rt.fmtFormat([args4[0], " "])); let sum: rt.u32 = 0; const seen: rt.ByteVec = new rt.ByteVec(); bumpAll((x2: rt.u8): undefined => { @@ -612,7 +612,7 @@ export function fns(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(seen, x2); }, rt.byteSliceRange(data, 2)); const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(sum, f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(seen), f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args6[0], " ", args6[1], " "])); + put(out, rt.fmtFormat([args6[0], " ", args6[1], " "])); const fs: Array<(a0: rt.u8) => rt.u8> = [adder(a), halve, mul, ptr]; const captured = a; const _94: (a0: rt.u8) => rt.u8 = (x3: rt.u8): rt.u8 => { @@ -635,7 +635,7 @@ export function fns(data: rt.ByteSlice, out: rt.ByteVec): void { const y: rt.u8 = _115[1](option_unwrapOr$0r2bmpr(rt.byteSliceGet(rt.byteSliceRange(data, 2), i), b)); const _133: rt.u32 = hook.f(y); const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(y, f), (f: rt.Formatter) => rt.u32Display(_133, f)]; - fmt_put(out, rt.fmtFormat([args8[0], ":", args8[1], " "])); + put(out, rt.fmtFormat([args8[0], ":", args8[1], " "])); } const _142: (a0: rt.u8) => rt.u32 = (x5: rt.u8): rt.u32 => { return x5 as rt.u32; @@ -644,7 +644,7 @@ export function fns(data: rt.ByteSlice, out: rt.ByteVec): void { hook.f = _142; const part4 = hook.f(a); const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part4, f)]; - fmt_put(out, rt.fmtFormat([args10[0], " "])); + put(out, rt.fmtFormat([args10[0], " "])); const captured3 = rt.byteVecFrom(Uint8Array.of(a)); const part6 = (((x6: rt.u8): rt.ByteVec => { const list2: rt.ByteVec = captured3; @@ -652,10 +652,10 @@ export function fns(data: rt.ByteSlice, out: rt.ByteVec): void { return list2; }))(b); const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteVecView(part6), f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args12[0], " "])); + put(out, rt.fmtFormat([args12[0], " "])); const part7 = rt.once(rt.optionUnwrap(fs.pop()))(a); const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(part7, f)]; - fmt_put(out, rt.fmtFormat([args14[0], " "])); + put(out, rt.fmtFormat([args14[0], " "])); const captured4 = b; const _196: rt.Arc<(a0: rt.u8) => rt.u8> = new rt.Arc((x7: rt.u8): rt.u8 => { return x7 ^ captured4; @@ -666,7 +666,7 @@ export function fns(data: rt.ByteSlice, out: rt.ByteVec): void { const _213: rt.u8 = other.value(b); const _218: rt.usize = other.strong; const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(_208, f), (f: rt.Formatter) => rt.u8Display(_213, f), (f: rt.Formatter) => rt.usizeDisplay(_218, f)]; - fmt_put(out, rt.fmtFormat([args16[0], " ", args16[1], " ", args16[2]])); + put(out, rt.fmtFormat([args16[0], " ", args16[1], " ", args16[2]])); other[Symbol.dispose](); shared[Symbol.dispose](); hook[Symbol.dispose](); @@ -686,7 +686,7 @@ export function dropped(out: rt.ByteVec): void { return rt.replaceIn(d, new rt.ByteVec()); }); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteVecView(part), f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " "])); + put(out, rt.fmtFormat([args2[0], " "])); } /** Each of the vtable's methods, then std's adaptors over the borrow, then by value. */ @@ -699,7 +699,7 @@ export function read(it: rt.Iter, out: rt.ByteVec): void { return a0 as rt.u32; }), rt.u32Add, 0); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(hint[0], f), (f: rt.Formatter) => rt.fmtOption(hint[1], f, rt.usizeDebug)], f), (f: rt.Formatter) => rt.fmtOption(first, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(third, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(pair), f, rt.u8Debug), (f: rt.Formatter) => rt.u32Display(rest, f)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " "])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " "])); } /** @@ -731,9 +731,9 @@ export function lens(it: rt.Iter): string { return rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3]]); } -export function tagged(tags: rt.ByteSlice): dyns_Tagged.Tagged[] { - return rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(tags)), (_22: rt.u8): dyns_Tagged.Tagged => { - return new dyns_Tagged.Tagged(_22); +export function tagged(tags: rt.ByteSlice): Tagged.Tagged[] { + return rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(tags)), (_22: rt.u8): Tagged.Tagged => { + return new Tagged.Tagged(_22); }), undefined, 1, true); } @@ -744,8 +744,8 @@ export function iters(data: rt.ByteSlice, out: rt.ByteVec): void { const b: rt.u8 = _10[1]; read(rt.iterDyn(rt.iterBorrow(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 2))))), out); read(rt.iterDyn(rt.iterBorrow(new rt.Range(a, b))), out); - const down: dyns_Countdown.Countdown = new dyns_Countdown.Countdown(rt.u8Rem(a, 16)); - read(rt.iterDyn(rt.iterFrom(down, (it: dyns_Countdown.Countdown) => dyns_Countdown.next$iter_Iterator(it))), out); + const down: Countdown.Countdown = new Countdown.Countdown(rt.u8Rem(a, 16)); + read(rt.iterDyn(rt.iterFrom(down, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it))), out); dropped(out); down[Symbol.dispose](); dropped(out); @@ -760,10 +760,10 @@ export function iters(data: rt.ByteSlice, out: rt.ByteVec): void { return thenSome$0d5am30(rt.u8Rem(v2, 2) === 1, v2); }); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_44, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(_50, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " "])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " "])); const part = lens(rt.iterDyn(rt.iterBorrow(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 2)))))); const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, part)]; - fmt_put(out, rt.fmtFormat([args4[0], " "])); + put(out, rt.fmtFormat([args4[0], " "])); const _79: rt.usize = rt.usizeRem(a as rt.usize, rt.usizeAdd(rt.byteSliceRange(data, 2).length, 1)); const slice: rt.ByteSlice = rt.byteSliceRange(data, 2); if (_79 > slice.length) { @@ -771,39 +771,39 @@ export function iters(data: rt.ByteSlice, out: rt.ByteVec): void { } const front: rt.ByteSlice = new rt.ByteSlice(slice.data, slice.start, _79); const back: rt.ByteSlice = new rt.ByteSlice(slice.data, slice.start + _79, slice.length - _79); - const boxed: rt.Iter = rt.iterDyn(rt.iterSlice(tagged(front), rt.drop)); - const ends: [rt.u8 | undefined, rt.u8 | undefined] = [option_map$08a6hpg(rt.iterToOption(boxed.next()), (t: dyns_Tagged.Tagged): rt.u8 => { + const boxed: rt.Iter = rt.iterDyn(rt.iterSlice(tagged(front), rt.drop)); + const ends: [rt.u8 | undefined, rt.u8 | undefined] = [option_map$08a6hpg(rt.iterToOption(boxed.next()), (t: Tagged.Tagged): rt.u8 => { const _04: rt.u8 = t._0; t[Symbol.dispose](); return _04; - }), option_map$08a6hpg(rt.iterToOption(boxed.nextBack()), (t2: dyns_Tagged.Tagged): rt.u8 => { + }), option_map$08a6hpg(rt.iterToOption(boxed.nextBack()), (t2: Tagged.Tagged): rt.u8 => { const _05: rt.u8 = t2._0; t2[Symbol.dispose](); return _05; })]; - const nth: rt.u8 | undefined = option_map$08a6hpg(rt.iterNth(boxed, 1, rt.drop), (t3: dyns_Tagged.Tagged): rt.u8 => { + const nth: rt.u8 | undefined = option_map$08a6hpg(rt.iterNth(boxed, 1, rt.drop), (t3: Tagged.Tagged): rt.u8 => { const _06: rt.u8 = t3._0; t3[Symbol.dispose](); return _06; }); dropped(out); const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(ends[0], f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(ends[1], f, rt.u8Debug)], f), (f: rt.Formatter) => rt.fmtOption(nth, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args6[0], " ", args6[1], " "])); + put(out, rt.fmtFormat([args6[0], " ", args6[1], " "])); rt.drop(boxed); dropped(out); - const last: rt.u8 | undefined = option_map$08a6hpg(rt.ownedLast(rt.iterDyn(rt.iterChain(rt.iterSlice(tagged(front), rt.drop), rt.iterSlice(tagged(back), rt.drop))), rt.drop), (t4: dyns_Tagged.Tagged): rt.u8 => { + const last: rt.u8 | undefined = option_map$08a6hpg(rt.ownedLast(rt.iterDyn(rt.iterChain(rt.iterSlice(tagged(front), rt.drop), rt.iterSlice(tagged(back), rt.drop))), rt.drop), (t4: Tagged.Tagged): rt.u8 => { const _07: rt.u8 = t4._0; t4[Symbol.dispose](); return _07; }); dropped(out); const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(last, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args8[0], " "])); + put(out, rt.fmtFormat([args8[0], " "])); const part2 = rt.ownedCount(rt.iterDyn(rt.iterChain(rt.iterSlice(tagged(back), rt.drop), rt.iterSlice(tagged(front), rt.drop))), rt.drop); const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(part2, f)]; - fmt_put(out, rt.fmtFormat([args10[0], " "])); + put(out, rt.fmtFormat([args10[0], " "])); dropped(out); - const own: rt.Iter = rt.iterDyn(rt.iterFrom(new dyns_Countdown.Countdown(rt.u8Rem(b, 16)), (it: dyns_Countdown.Countdown) => dyns_Countdown.next$iter_Iterator(it), rt.drop)); + const own: rt.Iter = rt.iterDyn(rt.iterFrom(new Countdown.Countdown(rt.u8Rem(b, 16)), (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it), rt.drop)); let sum: rt.u32 = 0; const iter: rt.Iter = own; while (true) { @@ -815,41 +815,41 @@ export function iters(data: rt.ByteSlice, out: rt.ByteVec): void { } rt.drop(iter); const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(sum, f)]; - fmt_put(out, rt.fmtFormat([args12[0], " "])); + put(out, rt.fmtFormat([args12[0], " "])); dropped(out); - const nested: rt.Iter = rt.iterDyn(rt.iterFrom(new dyns_Countdown.Countdown(rt.u8Rem(a, 8)), (it: dyns_Countdown.Countdown) => dyns_Countdown.next$iter_Iterator(it), rt.drop)); - const inner: dyns_Countdown.Countdown = new dyns_Countdown.Countdown(rt.u8Rem(b, 8)); - const first: rt.u8 | undefined = rt.iterToOption(rt.iterDyn(rt.iterFrom(inner, (it: dyns_Countdown.Countdown) => dyns_Countdown.next$iter_Iterator(it))).next()); - const second: rt.u8 | undefined = rt.iterToOption(dyns_Countdown.next$iter_Iterator(inner)); + const nested: rt.Iter = rt.iterDyn(rt.iterFrom(new Countdown.Countdown(rt.u8Rem(a, 8)), (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it), rt.drop)); + const inner: Countdown.Countdown = new Countdown.Countdown(rt.u8Rem(b, 8)); + const first: rt.u8 | undefined = rt.iterToOption(rt.iterDyn(rt.iterFrom(inner, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it))).next()); + const second: rt.u8 | undefined = rt.iterToOption(Countdown.next$iter_Iterator(inner)); const erased: rt.Iter = rt.iterDyn(new rt.Range(rt.u8Rem(a, 4), rt.u8Rem(b, 8))); const third: rt.u8 | undefined = rt.iterToOption(rt.iterDyn(rt.iterBorrow(erased)).next()); - const doubled: dyns_Countdown.Countdown = new dyns_Countdown.Countdown(rt.u8Rem(a, 8)); - const fourth: rt.u8 | undefined = rt.iterToOption(rt.iterDyn(rt.iterFrom(doubled, (it: dyns_Countdown.Countdown) => dyns_Countdown.next$iter_Iterator(it))).next()); - const mapped: rt.ByteVec = rt.iterToByteVec(rt.iterMap(rt.iterFrom(new dyns_Countdown.Countdown(rt.u8Rem(b, 8)), (it: dyns_Countdown.Countdown) => dyns_Countdown.next$iter_Iterator(it), rt.drop), (x3: rt.u8): rt.u8 => { + const doubled: Countdown.Countdown = new Countdown.Countdown(rt.u8Rem(a, 8)); + const fourth: rt.u8 | undefined = rt.iterToOption(rt.iterDyn(rt.iterFrom(doubled, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it))).next()); + const mapped: rt.ByteVec = rt.iterToByteVec(rt.iterMap(rt.iterFrom(new Countdown.Countdown(rt.u8Rem(b, 8)), (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it), rt.drop), (x3: rt.u8): rt.u8 => { return x3 ^ 1; }), "next"); const _233: rt.ByteVec = rt.iterToByteVec(nested, "next"); const _235: rt.usize = rt.ownedCount(erased); - const _238: rt.usize = rt.ownedCount(rt.iterFrom(doubled, (it: dyns_Countdown.Countdown) => dyns_Countdown.next$iter_Iterator(it), rt.drop)); + const _238: rt.usize = rt.ownedCount(rt.iterFrom(doubled, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it), rt.drop)); const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteVecView(_233), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(first, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(second, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(third, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(fourth, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(mapped), f, rt.u8Debug), (f: rt.Formatter) => rt.usizeDisplay(_235, f), (f: rt.Formatter) => rt.usizeDisplay(_238, f)]; - fmt_put(out, rt.fmtFormat([args14[0], " ", args14[1], " ", args14[2], " ", args14[3], " ", args14[4], " ", args14[5], " ", args14[6], " ", args14[7], " "])); + put(out, rt.fmtFormat([args14[0], " ", args14[1], " ", args14[2], " ", args14[3], " ", args14[4], " ", args14[5], " ", args14[6], " ", args14[7], " "])); dropped(out); inner[Symbol.dispose](); dropped(out); - const _262: [dyns_Countdown.Countdown, rt.Range] = [new dyns_Countdown.Countdown(rt.u8Rem(a, 8)), new rt.Range(rt.u8Rem(a, 4), rt.u8Rem(b, 8))]; - const own2: dyns_Countdown.Countdown = _262[0]; + const _262: [Countdown.Countdown, rt.Range] = [new Countdown.Countdown(rt.u8Rem(a, 8)), new rt.Range(rt.u8Rem(a, 4), rt.u8Rem(b, 8))]; + const own2: Countdown.Countdown = _262[0]; const range: rt.Range = _262[1]; - const hints: [rt.usize, rt.usize | undefined][] = rt.arrayMap([rt.iterDyn(rt.iterFrom(own2, (it: dyns_Countdown.Countdown) => dyns_Countdown.next$iter_Iterator(it))), rt.iterDyn(rt.iterBorrow(range))], (it: rt.Iter): [rt.usize, rt.usize | undefined] => { + const hints: [rt.usize, rt.usize | undefined][] = rt.arrayMap([rt.iterDyn(rt.iterFrom(own2, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it))), rt.iterDyn(rt.iterBorrow(range))], (it: rt.Iter): [rt.usize, rt.usize | undefined] => { return it.sizeHint(); }); - let held: dyns_Countdown.Countdown = new dyns_Countdown.Countdown(rt.u8Rem(b, 8)); - let lent2: rt.Place = rt.place(() => held, (value4) => held = value4); - const layered: rt.Place> = rt.place(() => lent2, (value5) => lent2 = value5); - const fifth: rt.u8 | undefined = rt.iterToOption(rt.iterDyn(rt.iterFrom(layered.v.v, (it: dyns_Countdown.Countdown) => dyns_Countdown.next$iter_Iterator(it))).next()); - const sixth: rt.u8 | undefined = rt.iterToOption(dyns_Countdown.next$iter_Iterator(layered.v.v)); - const _301: rt.usize = rt.ownedCount(rt.iterFrom(held, (it: dyns_Countdown.Countdown) => dyns_Countdown.next$iter_Iterator(it), rt.drop)); + let held: Countdown.Countdown = new Countdown.Countdown(rt.u8Rem(b, 8)); + let lent2: rt.Place = rt.place(() => held, (value4) => held = value4); + const layered: rt.Place> = rt.place(() => lent2, (value5) => lent2 = value5); + const fifth: rt.u8 | undefined = rt.iterToOption(rt.iterDyn(rt.iterFrom(layered.v.v, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it))).next()); + const sixth: rt.u8 | undefined = rt.iterToOption(Countdown.next$iter_Iterator(layered.v.v)); + const _301: rt.usize = rt.ownedCount(rt.iterFrom(held, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it), rt.drop)); const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(hints, f, (value: [rt.usize, rt.usize | undefined], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(value[0], f), (f: rt.Formatter) => rt.fmtOption(value[1], f, rt.usizeDebug)], f)), (f: rt.Formatter) => rt.fmtOption(fifth, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(sixth, f, rt.u8Debug), (f: rt.Formatter) => rt.usizeDisplay(_301, f)]; - fmt_put(out, rt.fmtFormat([args16[0], " ", args16[1], " ", args16[2], " ", args16[3], " "])); + put(out, rt.fmtFormat([args16[0], " ", args16[1], " ", args16[2], " ", args16[3], " "])); dropped(out); own2[Symbol.dispose](); dropped(out); @@ -868,48 +868,48 @@ export function iters(data: rt.ByteSlice, out: rt.ByteVec): void { const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(owned, f, (value: [rt.u8, rt.u8], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(value[0], f), (f: rt.Formatter) => rt.u8Debug(value[1], f)], f)), (f: rt.Formatter) => rt.fmtList(lent3, f, (value: [rt.u8, rt.u8], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(value[0], f), (f: rt.Formatter) => rt.u8Debug(value[1], f)], f)), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(_339.value), f, rt.u8Debug)]; const _335: string = rt.fmtFormat([args18[0], " ", args18[1], " ", args18[2], " "]); rt.refRelease(_339); - fmt_put(out, _335); + put(out, _335); const split: Chunks.Chunks = new Chunks.of$dyns_Lease({ _0: rt.byteSliceToByteVec(rt.byteSliceRange(data, 2)), _1: rt.usizeAdd(rt.u8Rem(b, 4) as rt.usize, 1) }); const lens_: rt.usize[] = rt.iterToArray(rt.iterMap(split.chunks$Chunks(), (a0: rt.ByteSlice): rt.usize => { return a0.length; }), "next", 4); const _369: rt.usize = rt.ownedCount(split.chunks$Chunks()); const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(lens_, f, rt.usizeDebug), (f: rt.Formatter) => rt.usizeDisplay(_369, f)]; - fmt_put(out, rt.fmtFormat([args20[0], " ", args20[1], " "])); + put(out, rt.fmtFormat([args20[0], " ", args20[1], " "])); const part3 = drain(rt.iterDyn(rt.iterBorrow(rt.iterFuse(rt.iterFrom({ _0: rt.u8Rem(a, 4) }, (it: Resuming.Resuming) => Resuming.next$iter_Iterator(it)))))); const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, part3)]; - fmt_put(out, rt.fmtFormat([args22[0], " "])); + put(out, rt.fmtFormat([args22[0], " "])); const resuming: Resuming.Resuming = { _0: rt.u8Rem(b, 4) }; const up: rt.Iter = rt.iterDyn(rt.iterFrom(resuming, (it: Resuming.Resuming) => Resuming.next$iter_Iterator(it))); const part4 = [rt.iterToOption(up.next()), rt.iterToOption(up.next()), rt.iterToOption(up.next()), rt.iterToOption(up.next()), rt.iterToOption(up.next())] as [rt.u8 | undefined, rt.u8 | undefined, rt.u8 | undefined, rt.u8 | undefined, rt.u8 | undefined]; const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(part4[0], f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(part4[1], f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(part4[2], f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(part4[3], f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(part4[4], f, rt.u8Debug)], f)]; - fmt_put(out, rt.fmtFormat([args24[0], " "])); - const boxed3: rt.Iter = rt.iterDyn(rt.iterFrom(new dyns_Countdown.Countdown(rt.u8Rem(a, 8)), (it: dyns_Countdown.Countdown) => dyns_Countdown.next$iter_Iterator(it), rt.drop)); + put(out, rt.fmtFormat([args24[0], " "])); + const boxed3: rt.Iter = rt.iterDyn(rt.iterFrom(new Countdown.Countdown(rt.u8Rem(a, 8)), (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it), rt.drop)); const part5 = drain(boxed3); const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, part5)]; - fmt_put(out, rt.fmtFormat([args26[0], " "])); + put(out, rt.fmtFormat([args26[0], " "])); rt.drop(boxed3); dropped(out); - const concrete: rt.Arc> = new rt.Arc(rt.iterSlice(tagged(front), rt.drop)); - const shared: rt.Arc> = new rt.ArcDyn(concrete, rt.iterDyn(concrete.value)); - const other: rt.Arc> = rt.arcClone(shared); - const weak: rt.Weak> = new rt.Weak(other); + const concrete: rt.Arc> = new rt.Arc(rt.iterSlice(tagged(front), rt.drop)); + const shared: rt.Arc> = new rt.ArcDyn(concrete, rt.iterDyn(concrete.value)); + const other: rt.Arc> = rt.arcClone(shared); + const weak: rt.Weak> = new rt.Weak(other); const _456: [rt.usize, rt.usize | undefined] = other.value.sizeHint(); const _460: boolean = rt.arcGetMut(shared) === undefined; const args28: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(_456[0], f), (f: rt.Formatter) => rt.fmtOption(_456[1], f, rt.usizeDebug)], f), (f: rt.Formatter) => rt.fmtBool(_460, f)]; - fmt_put(out, rt.fmtFormat([args28[0], " ", args28[1], " "])); + put(out, rt.fmtFormat([args28[0], " ", args28[1], " "])); other[Symbol.dispose](); weak[Symbol.dispose](); - const taken: rt.u8 | undefined = option_map$08a6hpg(option_andThen$0v0bj8w(rt.arcGetMut(shared), (it2: rt.Iter): dyns_Tagged.Tagged | undefined => { + const taken: rt.u8 | undefined = option_map$08a6hpg(option_andThen$0v0bj8w(rt.arcGetMut(shared), (it2: rt.Iter): Tagged.Tagged | undefined => { return rt.iterToOption(it2.next()); - }), (t5: dyns_Tagged.Tagged): rt.u8 => { + }), (t5: Tagged.Tagged): rt.u8 => { const _013: rt.u8 = t5._0; t5[Symbol.dispose](); return _013; }); dropped(out); const args30: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(taken, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args30[0], " "])); + put(out, rt.fmtFormat([args30[0], " "])); shared[Symbol.dispose](); dropped(out); const _492: rt.Arc> = new rt.Arc(rt.byteVecIntoIter(rt.byteSliceToByteVec(back))); @@ -920,25 +920,25 @@ export function iters(data: rt.ByteSlice, out: rt.ByteVec): void { return rt.iterToOption(it3.next()); }); const args32: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_506, f), (f: rt.Formatter) => rt.fmtOption(_510, f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug), rt.None)]; - fmt_put(out, rt.fmtFormat([args32[0], " ", args32[1], " "])); + put(out, rt.fmtFormat([args32[0], " ", args32[1], " "])); exact[Symbol.dispose](); const next: rt.u8 | undefined = option_andThen$0ntiuws(rt.arcGetMut(up2), (it4: rt.Iter): rt.u8 | undefined => { return rt.iterToOption(it4.next()); }); const _530: [rt.usize, rt.usize | undefined] = up2.value.sizeHint(); const args34: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(next, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(_530[0], f), (f: rt.Formatter) => rt.fmtOption(_530[1], f, rt.usizeDebug)], f)]; - fmt_put(out, rt.fmtFormat([args34[0], " ", args34[1], " "])); - const fromBox: rt.Arc> = new rt.Arc(rt.iterDyn(rt.iterFrom(new dyns_Countdown.Countdown(rt.u8Rem(b, 8)), (it: dyns_Countdown.Countdown) => dyns_Countdown.next$iter_Iterator(it), rt.drop))); + put(out, rt.fmtFormat([args34[0], " ", args34[1], " "])); + const fromBox: rt.Arc> = new rt.Arc(rt.iterDyn(rt.iterFrom(new Countdown.Countdown(rt.u8Rem(b, 8)), (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it), rt.drop))); const part6 = option_andThen$0ntiuws(rt.arcGetMut(fromBox), (it5: rt.Iter): rt.u8 | undefined => { return rt.iterToOption(it5.next()); }); const args36: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part6, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args36[0], " "])); + put(out, rt.fmtFormat([args36[0], " "])); fromBox[Symbol.dispose](); dropped(out); - const counted2: rt.Arc = new rt.Arc(new dyns_Countdown.Countdown(rt.u8Rem(a, 8))); - const weak3: rt.Weak> = rt.weakDyn(new rt.Weak(counted2), (arc: rt.Arc): rt.Arc> => { - return new rt.ArcDyn(arc, rt.iterDyn(rt.iterFrom(arc.value, (it: dyns_Countdown.Countdown) => dyns_Countdown.next$iter_Iterator(it), rt.drop))); + const counted2: rt.Arc = new rt.Arc(new Countdown.Countdown(rt.u8Rem(a, 8))); + const weak3: rt.Weak> = rt.weakDyn(new rt.Weak(counted2), (arc: rt.Arc): rt.Arc> => { + return new rt.ArcDyn(arc, rt.iterDyn(rt.iterFrom(arc.value, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it), rt.drop))); }); const part7 = option_map$0oedb57(rt.weakUpgrade(weak3), (it6: rt.Arc>): [rt.usize, rt.usize | undefined] => { const _017: [rt.usize, rt.usize | undefined] = it6.value.sizeHint(); @@ -946,19 +946,19 @@ export function iters(data: rt.ByteSlice, out: rt.ByteVec): void { return _017; }); const args38: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part7, f, (value: [rt.usize, rt.usize | undefined], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(value[0], f), (f: rt.Formatter) => rt.fmtOption(value[1], f, rt.usizeDebug)], f))]; - fmt_put(out, rt.fmtFormat([args38[0], " "])); + put(out, rt.fmtFormat([args38[0], " "])); counted2[Symbol.dispose](); const _596: rt.Arc> | undefined = rt.weakUpgrade(weak3); const part8 = _596 === undefined; const args40: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(part8, f)]; const _590: string = rt.fmtFormat([args40[0], " "]); rt.drop(_596); - fmt_put(out, _590); + put(out, _590); dropped(out); - const pinned: rt.Iter = rt.iterDyn(rt.iterFrom(new dyns_Countdown.Countdown(rt.u8Rem(b, 8)), (it: dyns_Countdown.Countdown) => dyns_Countdown.next$iter_Iterator(it), rt.drop)); + const pinned: rt.Iter = rt.iterDyn(rt.iterFrom(new Countdown.Countdown(rt.u8Rem(b, 8)), (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it), rt.drop)); const part9 = rt.iterToOption(pinned.next()); const args42: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part9, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args42[0]])); + put(out, rt.fmtFormat([args42[0]])); rt.drop(pinned); dropped(out); weak3[Symbol.dispose](); @@ -986,13 +986,13 @@ export function pointers(dataData: Uint8Array, dataStart: number, dataLen: numbe if (dataLen >= 2) { const log: rt.Arc> = new rt.Arc(new rt.RefCell(new rt.ByteVec())); const sq: rt.Arc = new rt.Arc({ side: dataData[dataStart] as rt.u16 }); - const weak2: rt.Weak = rt.weakDyn(new rt.Weak(sq), (arc: rt.Arc): rt.Arc => { - return new rt.ArcDyn(arc, new dyns_Shape.of$dyns_Square(arc.value)); + const weak2: rt.Weak = rt.weakDyn(new rt.Weak(sq), (arc: rt.Arc): rt.Arc => { + return new rt.ArcDyn(arc, new Shape.of$dyns_Square(arc.value)); }); const _19: rt.Arc = rt.arcClone(sq); - const named: rt.Arc = new rt.ArcDyn(_19, new dyns_Named.of$dyns_Square(_19.value)); - const shape: rt.Arc = rt.arcClone(named); - const other: rt.Weak = new rt.Weak(shape); + const named: rt.Arc = new rt.ArcDyn(_19, new Named.of$dyns_Square(_19.value)); + const shape: rt.Arc = rt.arcClone(named); + const other: rt.Weak = new rt.Weak(shape); const _34: string = named.value.label$Named(); const _38: rt.u32 = shape.value.area$Shape(); const _42: rt.usize = sq.strong; @@ -1000,55 +1000,55 @@ export function pointers(dataData: Uint8Array, dataStart: number, dataLen: numbe const _48: rt.usize = rt.weakWeakCount(weak2); const _51: boolean = rt.arcPtrEq(weak2.arc, other.arc); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, _34), (f: rt.Formatter) => rt.u32Display(_38, f), (f: rt.Formatter) => rt.usizeDisplay(_42, f), (f: rt.Formatter) => rt.usizeDisplay(_45, f), (f: rt.Formatter) => rt.usizeDisplay(_48, f), (f: rt.Formatter) => rt.fmtBool(_51, f)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " "])); - const again: rt.Weak = rt.weakClone(weak2); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " "])); + const again: rt.Weak = rt.weakClone(weak2); sq[Symbol.dispose](); named[Symbol.dispose](); - const _75: rt.u32 | undefined = option_map$1i542n2(rt.weakUpgrade(again), (s: rt.Arc): rt.u32 => { + const _75: rt.u32 | undefined = option_map$1i542n2(rt.weakUpgrade(again), (s: rt.Arc): rt.u32 => { const _0: rt.u32 = s.value.area$Shape(); s[Symbol.dispose](); return _0; }); const _79: rt.usize = shape.strong; const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_75, f, rt.u32Debug), (f: rt.Formatter) => rt.usizeDisplay(_79, f)]; - fmt_put(out, rt.fmtFormat([args4[0], " ", args4[1], " "])); + put(out, rt.fmtFormat([args4[0], " ", args4[1], " "])); shape[Symbol.dispose](); - const _97: rt.Arc | undefined = rt.weakUpgrade(weak2); + const _97: rt.Arc | undefined = rt.weakUpgrade(weak2); const _95: boolean = _97 === undefined; - const _102: rt.Arc | undefined = rt.weakUpgrade(again); + const _102: rt.Arc | undefined = rt.weakUpgrade(again); const _100: boolean = _102 === undefined; const _105: rt.usize = weak2.arc.strong; const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(_95, f), (f: rt.Formatter) => rt.fmtBool(_100, f), (f: rt.Formatter) => rt.usizeDisplay(_105, f)]; const _91: string = rt.fmtFormat([args6[0], " ", args6[1], " ", args6[2], " "]); rt.drop(_102); rt.drop(_97); - fmt_put(out, _91); - const noisy: rt.Arc = new rt.Arc(new dyns_Noisy.Noisy(dataData[dataStart + 1], rt.arcClone(log))); - const weak4: rt.Weak = rt.weakDyn(new rt.Weak(noisy), (arc2: rt.Arc): rt.Arc => { - return new rt.ArcDyn(arc2, new dyns_Shape.of$dyns_Noisy(arc2.value)); + put(out, _91); + const noisy: rt.Arc = new rt.Arc(new Noisy.Noisy(dataData[dataStart + 1], rt.arcClone(log))); + const weak4: rt.Weak = rt.weakDyn(new rt.Weak(noisy), (arc2: rt.Arc): rt.Arc => { + return new rt.ArcDyn(arc2, new Shape.of$dyns_Noisy(arc2.value)); }); - const part = option_map$1i542n2(rt.weakUpgrade(weak4), (s2: rt.Arc): rt.u32 => { + const part = option_map$1i542n2(rt.weakUpgrade(weak4), (s2: rt.Arc): rt.u32 => { const _02: rt.u32 = s2.value.area$Shape(); s2[Symbol.dispose](); return _02; }); const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part, f, rt.u32Debug)]; - fmt_put(out, rt.fmtFormat([args8[0], " "])); + put(out, rt.fmtFormat([args8[0], " "])); noisy[Symbol.dispose](); - const _147: rt.Arc | undefined = rt.weakUpgrade(weak4); + const _147: rt.Arc | undefined = rt.weakUpgrade(weak4); const _145: boolean = _147 === undefined; const _150: rt.RefCell = rt.refCellBorrow(log.value); const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(_145, f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(_150.value), f, rt.u8Debug)]; const _141: string = rt.fmtFormat([args10[0], " ", args10[1], " "]); rt.refRelease(_150); rt.drop(_147); - fmt_put(out, _141); + put(out, _141); const looped: rt.Arc = rt.arcNewCyclic((me: rt.Weak): Looped.Looped => { - return new Looped.Looped(dataData[dataStart], rt.weakDyn(rt.weakClone(me), (arc3: rt.Arc): rt.Arc => { - return new rt.ArcDyn(arc3, new dyns_Shape.of$dyns_Looped(arc3.value)); + return new Looped.Looped(dataData[dataStart], rt.weakDyn(rt.weakClone(me), (arc3: rt.Arc): rt.Arc => { + return new rt.ArcDyn(arc3, new Shape.of$dyns_Looped(arc3.value)); })); }); - const _168: rt.u32 | undefined = option_map$1i542n2(rt.weakUpgrade(looped.value.me), (s3: rt.Arc): rt.u32 => { + const _168: rt.u32 | undefined = option_map$1i542n2(rt.weakUpgrade(looped.value.me), (s3: rt.Arc): rt.u32 => { const _04: rt.u32 = s3.value.area$Shape(); s3[Symbol.dispose](); return _04; @@ -1056,61 +1056,61 @@ export function pointers(dataData: Uint8Array, dataStart: number, dataLen: numbe const _174: rt.usize = looped.strong; const _177: rt.usize = looped.weak; const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_168, f, rt.u32Debug), (f: rt.Formatter) => rt.usizeDisplay(_174, f), (f: rt.Formatter) => rt.usizeDisplay(_177, f)]; - fmt_put(out, rt.fmtFormat([args12[0], " ", args12[1], " ", args12[2], " "])); - const pinned: dyns_Shape.Shape = new dyns_Shape.of$dyns_Noisy(new dyns_Noisy.Noisy(rt.u8WrappingAdd(dataData[dataStart], 1), rt.arcClone(log))); + put(out, rt.fmtFormat([args12[0], " ", args12[1], " ", args12[2], " "])); + const pinned: Shape.Shape = new Shape.of$dyns_Noisy(new Noisy.Noisy(rt.u8WrappingAdd(dataData[dataStart], 1), rt.arcClone(log))); let n: rt.u32 = dataData[dataStart + 1] as rt.u32; - const borrowed2: dyns_Shape.Shape = new dyns_Shape.ofPlace$u32(rt.place(() => n, (value) => n = value)); + const borrowed2: Shape.Shape = new Shape.ofPlace$u32(rt.place(() => n, (value) => n = value)); const _205: rt.u32 = pinned.area$Shape(); const _209: rt.u8 = pinned.sides$Shape(); const _213: rt.u32 = borrowed2.area$Shape(); const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_205, f), (f: rt.Formatter) => rt.u8Display(_209, f), (f: rt.Formatter) => rt.u32Display(_213, f)]; - fmt_put(out, rt.fmtFormat([args14[0], " ", args14[1], " ", args14[2], " "])); + put(out, rt.fmtFormat([args14[0], " ", args14[1], " ", args14[2], " "])); rt.drop(pinned); const _230: rt.RefCell = rt.refCellBorrow(log.value); const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteVecView(_230.value), f, rt.u8Debug)]; const _226: string = rt.fmtFormat([args16[0], " "]); rt.refRelease(_230); - fmt_put(out, _226); - const boxes: dyns_Shape.Shape[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(new rt.ByteSlice(dataData, dataStart + 2, dataLen - 2))), (_2: rt.u8): dyns_Shape.Shape => { + put(out, _226); + const boxes: Shape.Shape[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(new rt.ByteSlice(dataData, dataStart + 2, dataLen - 2))), (_2: rt.u8): Shape.Shape => { const x2: rt.u8 = _2; const _43: rt.u8 = rt.u8Rem(x2, 3); if (_43 === 0) { - return new dyns_Shape.of$dyns_Noisy(new dyns_Noisy.Noisy(x2, rt.arcClone(log))); + return new Shape.of$dyns_Noisy(new Noisy.Noisy(x2, rt.arcClone(log))); } if (_43 === 1) { - return new dyns_Shape.of$u32(x2 as rt.u32); + return new Shape.of$u32(x2 as rt.u32); } - return new dyns_Shape.of$dyns_Tri({ tag: "Tall", _0: x2 } as Tri.Tri); + return new Shape.of$dyns_Tri({ tag: "Tall", _0: x2 } as Tri.Tri); }), undefined, 8, true); - const rcs: rt.Arc[] = []; - const arcs: rt.Arc[] = []; - const iter: rt.Iter<[rt.usize, dyns_Shape.Shape]> = rt.iterEnumerate(rt.iterSlice(boxes, rt.drop)); + const rcs: rt.Arc[] = []; + const arcs: rt.Arc[] = []; + const iter: rt.Iter<[rt.usize, Shape.Shape]> = rt.iterEnumerate(rt.iterSlice(boxes, rt.drop)); while (true) { - const _249: [rt.usize, dyns_Shape.Shape] | rt.Done = iter.next(); + const _249: [rt.usize, Shape.Shape] | rt.Done = iter.next(); if (_249 === rt.DONE) { break; } const i: rt.usize = _249[0]; - const boxed: dyns_Shape.Shape = _249[1]; + const boxed: Shape.Shape = _249[1]; if (rt.usizeRem(i, 2) === 0) { - const _257: rt.Arc = new rt.Arc(boxed); + const _257: rt.Arc = new rt.Arc(boxed); rcs.push(_257); } else { - const _259: rt.Arc = new rt.Arc(boxed); + const _259: rt.Arc = new rt.Arc(boxed); arcs.push(_259); } } rt.drop(iter); - const kept: rt.Arc[] = rt.iterToArray(rt.iterMap(rt.iterStepBy(rt.iterSlice(rcs), 2), (a0: rt.Arc): rt.Arc => { + const kept: rt.Arc[] = rt.iterToArray(rt.iterMap(rt.iterStepBy(rt.iterSlice(rcs), 2), (a0: rt.Arc): rt.Arc => { return rt.arcClone(a0); }), undefined, 8, true); - const part2 = rt.iterToArray(rt.iterChain(rt.iterMap(rt.iterSlice(rcs), (s4: rt.Arc): rt.u32 => { + const part2 = rt.iterToArray(rt.iterChain(rt.iterMap(rt.iterSlice(rcs), (s4: rt.Arc): rt.u32 => { return s4.value.area$Shape(); - }), rt.iterMap(rt.iterSlice(arcs), (s5: rt.Arc): rt.u32 => { + }), rt.iterMap(rt.iterSlice(arcs), (s5: rt.Arc): rt.u32 => { return s5.value.area$Shape(); })), undefined, 4, true); const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(part2, f, rt.u32Debug)]; - fmt_put(out, rt.fmtFormat([args18[0], " "])); + put(out, rt.fmtFormat([args18[0], " "])); const _291: rt.RefCell = rt.refCellBorrowMut(log.value); rt.byteVecClear(_291.value); rt.refMutRelease(_291); @@ -1119,19 +1119,19 @@ export function pointers(dataData: Uint8Array, dataStart: number, dataLen: numbe const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteVecView(_304.value), f, rt.u8Debug)]; const _300: string = rt.fmtFormat([args20[0], " "]); rt.refRelease(_304); - fmt_put(out, _300); + put(out, _300); rt.dropAll(rcs); const _321: rt.RefCell = rt.refCellBorrow(log.value); const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteVecView(_321.value), f, rt.u8Debug)]; const _317: string = rt.fmtFormat([args22[0], " "]); rt.refRelease(_321); - fmt_put(out, _317); + put(out, _317); rt.dropAll(kept); const _337: rt.RefCell = rt.refCellBorrow(log.value); const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteVecView(_337.value), f, rt.u8Debug)]; const _333: string = rt.fmtFormat([args24[0], " "]); rt.refRelease(_337); - fmt_put(out, _333); + put(out, _333); const _345: rt.Arc = new rt.Arc({ side: dataData[dataStart + 1] as rt.u16 }); const any: rt.Arc = new rt.ArcDyn(_345, new Any.of$dyns_Square(_345.value)); const _351: rt.Result, rt.Arc> = rt.arcDowncast(rt.arcClone(any), Any.of$dyns_Tri, (object) => object.v); @@ -1145,26 +1145,26 @@ export function pointers(dataData: Uint8Array, dataStart: number, dataLen: numbe const _372: rt.Fmt = (f: rt.Formatter) => rt.fmtBool(wrong, f); const arg = _365.side; const args26: rt.Fmt[] = [_372, (f: rt.Formatter) => rt.u16Display(arg, f), (f: rt.Formatter) => rt.usizeDisplay(_368, f)]; - fmt_put(out, rt.fmtFormat([args26[0], " ", args26[1], " ", args26[2], " "])); + put(out, rt.fmtFormat([args26[0], " ", args26[1], " ", args26[2], " "])); sq2[Symbol.dispose](); } else { - fmt_put(out, "none "); + put(out, "none "); } if (!_355.ok) { drop$Result_Rc_dyns_Square_Rc_dyn_Any(_355); } - const any2: rt.Arc = new rt.Arc(new Any.of$dyns_Noisy(new dyns_Noisy.Noisy(rt.u8WrappingAdd(dataData[dataStart + 1], 1), rt.arcClone(log)))); + const any2: rt.Arc = new rt.Arc(new Any.of$dyns_Noisy(new Noisy.Noisy(rt.u8WrappingAdd(dataData[dataStart + 1], 1), rt.arcClone(log)))); const held: rt.Arc = rt.arcClone(any2); _595 = true; b5: { - const _388: [rt.Result, rt.Arc>, rt.Result, rt.Arc>] = [rt.arcDowncast(rt.arcClone(any2), Any.of$dyns_Noisy, (object) => object.v), rt.arcDowncast(rt.arcClone(held), Any.of$dyns_Noisy, (object) => object.v)]; + const _388: [rt.Result, rt.Arc>, rt.Result, rt.Arc>] = [rt.arcDowncast(rt.arcClone(any2), Any.of$dyns_Noisy, (object) => object.v), rt.arcDowncast(rt.arcClone(held), Any.of$dyns_Noisy, (object) => object.v)]; if (_388[0].ok) { if (_388[1].ok) { - const x: rt.Arc = (_388[0] as { ok: true; value: rt.Arc }).value; - const y: rt.Arc = (_388[1] as { ok: true; value: rt.Arc }).value; - const _403: rt.Arc = rt.arcClone(x); + const x: rt.Arc = (_388[0] as { ok: true; value: rt.Arc }).value; + const y: rt.Arc = (_388[1] as { ok: true; value: rt.Arc }).value; + const _403: rt.Arc = rt.arcClone(x); const _402: rt.Arc = new rt.ArcDyn(_403, new Any.of$dyns_Noisy(_403.value)); - const _406: rt.Arc = rt.arcClone(y); + const _406: rt.Arc = rt.arcClone(y); const _401: [rt.Arc, rt.Arc] = [_402, new rt.ArcDyn(_406, new Any.of$dyns_Noisy(_406.value))]; const ex: rt.Arc = _402; const ey: rt.Arc = _401[1]; @@ -1173,7 +1173,7 @@ export function pointers(dataData: Uint8Array, dataStart: number, dataLen: numbe const _424: boolean = rt.arcPtrEq(ex, held); const _428: rt.usize = x.strong; const args28: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(_416, f), (f: rt.Formatter) => rt.fmtBool(_420, f), (f: rt.Formatter) => rt.fmtBool(_424, f), (f: rt.Formatter) => rt.usizeDisplay(_428, f)]; - fmt_put(out, rt.fmtFormat([args28[0], " ", args28[1], " ", args28[2], " ", args28[3], " "])); + put(out, rt.fmtFormat([args28[0], " ", args28[1], " ", args28[2], " ", args28[3], " "])); ey[Symbol.dispose](); ex[Symbol.dispose](); y[Symbol.dispose](); @@ -1182,12 +1182,12 @@ export function pointers(dataData: Uint8Array, dataStart: number, dataLen: numbe } } if (_388[0].ok) { - (_388[0] as { ok: true; value: rt.Arc }).value[Symbol.dispose](); + (_388[0] as { ok: true; value: rt.Arc }).value[Symbol.dispose](); } else { drop$Result_Rc_dyns_Noisy_Rc_dyn_Any(_388[0]); } if (_388[1].ok) { - (_388[1] as { ok: true; value: rt.Arc }).value[Symbol.dispose](); + (_388[1] as { ok: true; value: rt.Arc }).value[Symbol.dispose](); } else { drop$Result_Rc_dyns_Noisy_Rc_dyn_Any(_388[1]); } @@ -1195,14 +1195,14 @@ export function pointers(dataData: Uint8Array, dataStart: number, dataLen: numbe const _440: rt.RefCell = rt.refCellBorrowMut(log.value); rt.byteVecClear(_440.value); rt.refMutRelease(_440); - const _444: rt.Result, rt.Arc> = rt.arcDowncast(any2, Any.of$dyns_Noisy, (object) => object.v); + const _444: rt.Result, rt.Arc> = rt.arcDowncast(any2, Any.of$dyns_Noisy, (object) => object.v); if (_444.ok) { - const n2: rt.Arc = _444.value; - const _455: dyns_Noisy.Noisy = n2.value; + const n2: rt.Arc = _444.value; + const _455: Noisy.Noisy = n2.value; const _458: rt.usize = n2.strong; const arg2 = _455._0; const args30: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(arg2, f), (f: rt.Formatter) => rt.usizeDisplay(_458, f)]; - fmt_put(out, rt.fmtFormat([args30[0], " ", args30[1], " "])); + put(out, rt.fmtFormat([args30[0], " ", args30[1], " "])); _595 = false; held[Symbol.dispose](); const _475: rt.usize = n2.strong; @@ -1210,10 +1210,10 @@ export function pointers(dataData: Uint8Array, dataStart: number, dataLen: numbe const args32: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_475, f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(_478.value), f, rt.u8Debug)]; const _471: string = rt.fmtFormat([args32[0], " ", args32[1], " "]); rt.refRelease(_478); - fmt_put(out, _471); + put(out, _471); n2[Symbol.dispose](); } else { - fmt_put(out, "none "); + put(out, "none "); } if (!_444.ok) { drop$Result_Rc_dyns_Noisy_Rc_dyn_Any(_444); @@ -1222,14 +1222,14 @@ export function pointers(dataData: Uint8Array, dataStart: number, dataLen: numbe const args34: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteVecView(_495.value), f, rt.u8Debug)]; const _491: string = rt.fmtFormat([args34[0], " "]); rt.refRelease(_495); - fmt_put(out, _491); + put(out, _491); const part3 = option_map$0j05j69(ok$00p9ap8(rt.arcDowncast(new rt.Arc(new Any.of$u32(dataData[dataStart] as rt.u32)), Any.of$u32, (object) => object.v)), (n3: rt.Arc): rt.u32 => { const _08: rt.u32 = n3.value; n3[Symbol.dispose](); return _08; }); const args36: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part3, f, rt.u32Debug)]; - fmt_put(out, rt.fmtFormat([args36[0], " "])); + put(out, rt.fmtFormat([args36[0], " "])); const _523: rt.Arc<(a0: rt.u8) => rt.u8> = new rt.Arc((x3: rt.u8): rt.u8 => { return rt.u8WrappingAdd(x3, dataData[dataStart]); }); @@ -1240,7 +1240,7 @@ export function pointers(dataData: Uint8Array, dataStart: number, dataLen: numbe const _537: rt.u8 = f.value(dataData[dataStart + 1]); const _543: rt.u8 = g.value(dataData[dataStart]); const args38: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(_537, f), (f: rt.Formatter) => rt.u8Display(_543, f)]; - fmt_put(out, rt.fmtFormat([args38[0], " ", args38[1]])); + put(out, rt.fmtFormat([args38[0], " ", args38[1]])); g[Symbol.dispose](); f[Symbol.dispose](); if (_595) { diff --git a/ts/fixtures/lang/dyns/expected/harness.ts b/ts/fixtures/lang/dyns/expected/harness.ts new file mode 100644 index 000000000..3b7bbcfb0 --- /dev/null +++ b/ts/fixtures/lang/dyns/expected/harness.ts @@ -0,0 +1,46 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/dyns/expected/lib.ts b/ts/fixtures/lang/dyns/expected/lib.ts new file mode 100644 index 000000000..252aa0520 --- /dev/null +++ b/ts/fixtures/lang/dyns/expected/lib.ts @@ -0,0 +1,68 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import type * as Any from "./core/any.Any.ts"; +import { dyns, shared, anys, fns, iters, pointers } from "./dyns.ts"; +import type * as Noisy from "./dyns.Noisy.ts"; +import type * as Square from "./dyns.Square.ts"; +import type * as Tri from "./dyns.Tri.ts"; + +export function drop$Result_Rc_dyns_Noisy_Rc_dyn_Any(_1: rt.Result, rt.Arc>): void { + if (_1.ok) { + _1.value[Symbol.dispose](); + } else { + _1.error[Symbol.dispose](); + } +} + +export function drop$Result_Rc_dyns_Square_Rc_dyn_Any(_1: rt.Result, rt.Arc>): void { + if (_1.ok) { + _1.value[Symbol.dispose](); + } else { + _1.error[Symbol.dispose](); + } +} + +export function drop$Result_Rc_dyns_Tri_Rc_dyn_Any(_1: rt.Result, rt.Arc>): void { + if (_1.ok) { + _1.value[Symbol.dispose](); + } else { + _1.error[Symbol.dispose](); + } +} + +export function drop$Result_sync_Arc_u32_sync_Arc_dyn_Any_marker_Sync_marker_Send(_1: rt.Result, rt.Arc>): void { + if (_1.ok) { + _1.value[Symbol.dispose](); + } else { + _1.error[Symbol.dispose](); + } +} + +export function drop$Result_tuple2_usize_u8_sync_Arc_dyn_Any_marker_Sync_marker_Send(_1: rt.Result<[rt.usize, rt.u8], rt.Arc>): void { + if (!_1.ok) { + _1.error[Symbol.dispose](); + } +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["dyns::dyns", (_22: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + dyns(data.data, data.start, data.length, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["dyns::shared", (_23: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + shared(data2.data, data2.start, data2.length, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["dyns::anys", (_24: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + anys(data3.data, data3.start, data3.length, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["dyns::fns", (_25: rt.u8, data4: rt.ByteSlice, out4: rt.ByteVec): undefined => { + fns(data4, out4); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["dyns::pointers", (_26: rt.u8, data5: rt.ByteSlice, out5: rt.ByteVec): undefined => { + pointers(data5.data, data5.start, data5.length, out5); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["dyns::iters", (_27: rt.u8, data6: rt.ByteSlice, out6: rt.ByteVec): undefined => { + iters(data6, out6); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/dyns.rs b/ts/fixtures/lang/dyns/src/dyns.rs similarity index 99% rename from ts/fixtures/lang/src/dyns.rs rename to ts/fixtures/lang/dyns/src/dyns.rs index 56149fd9f..dcb1f8ade 100644 --- a/ts/fixtures/lang/src/dyns.rs +++ b/ts/fixtures/lang/dyns/src/dyns.rs @@ -20,7 +20,7 @@ use std::rc::{self, Rc}; use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::{Arc, Weak}; -use crate::fmt::put; +use crate::harness::put; pub(crate) trait Shape { fn area(&self) -> u32; diff --git a/ts/fixtures/lang/dyns/src/lib.rs b/ts/fixtures/lang/dyns/src/lib.rs new file mode 100644 index 000000000..77c77e7f1 --- /dev/null +++ b/ts/fixtures/lang/dyns/src/lib.rs @@ -0,0 +1,26 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod dyns; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("dyns::dyns", |_, data, out| dyns::dyns(data, out)), + ("dyns::shared", |_, data, out| dyns::shared(data, out)), + ("dyns::anys", |_, data, out| dyns::anys(data, out)), + ("dyns::fns", |_, data, out| dyns::fns(data, out)), + ("dyns::pointers", |_, data, out| dyns::pointers(data, out)), + ("dyns::iters", |_, data, out| dyns::iters(data, out)), + ] +} diff --git a/ts/fixtures/lang/dyns/ts.toml b/ts/fixtures/lang/dyns/ts.toml new file mode 100644 index 000000000..c8858e909 --- /dev/null +++ b/ts/fixtures/lang/dyns/ts.toml @@ -0,0 +1,2 @@ +package = "lang-dyns-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/edits/Cargo.toml b/ts/fixtures/lang/edits/Cargo.toml new file mode 100644 index 000000000..2b6a2dff2 --- /dev/null +++ b/ts/fixtures/lang/edits/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-edits-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/edits/expected/core/option.ts b/ts/fixtures/lang/edits/expected/core/option.ts new file mode 100644 index 000000000..15367f327 --- /dev/null +++ b/ts/fixtures/lang/edits/expected/core/option.ts @@ -0,0 +1,72 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import * as Named from "../edits.Named.ts"; + +export function unwrapOr$039uout(self: Named.Named[] | undefined, default_: Named.Named[]): Named.Named[] { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$1j4op5y(self: rt.u16 | undefined, default_: rt.u16): rt.u16 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$0xa0bn7(self: Named.Named | undefined, f: (a0: Named.Named) => rt.u16): rt.u16 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$1u8sh4f(self: Named.Named | undefined, _: (a0: Named.Named) => Named.Named[]): Named.Named[] | undefined { + if (self === undefined) { + return undefined; + } + return [self]; +} + +export function mapOr$14njs1h(self: Named.Named | undefined, default_: rt.u16, f: (a0: Named.Named) => rt.u16): rt.u16 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1llunel(self: rt.u16 | undefined, default_: rt.u16, f: (a0: rt.u16) => rt.u16): rt.u16 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function filter$184yuq2(self: Named.Named | undefined, predicate: (a0: Named.Named) => boolean): Named.Named | undefined { + if (self !== undefined) { + const x: Named.Named = self; + if (predicate(x)) { + return x; + } + } + return undefined; +} + +export function clone$0vcwlo5(self: Named.Named | undefined): Named.Named | undefined { + if (self === undefined) { + return undefined; + } + return Named.clone$Clone(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/expected/edits.Lean.ts b/ts/fixtures/lang/edits/expected/edits.Lean.ts similarity index 100% rename from ts/fixtures/lang/expected/edits.Lean.ts rename to ts/fixtures/lang/edits/expected/edits.Lean.ts diff --git a/ts/fixtures/lang/expected/edits.Named.ts b/ts/fixtures/lang/edits/expected/edits.Named.ts similarity index 100% rename from ts/fixtures/lang/expected/edits.Named.ts rename to ts/fixtures/lang/edits/expected/edits.Named.ts diff --git a/ts/fixtures/lang/expected/edits.Stamp.ts b/ts/fixtures/lang/edits/expected/edits.Stamp.ts similarity index 100% rename from ts/fixtures/lang/expected/edits.Stamp.ts rename to ts/fixtures/lang/edits/expected/edits.Stamp.ts diff --git a/ts/fixtures/lang/expected/edits.Tally.ts b/ts/fixtures/lang/edits/expected/edits.Tally.ts similarity index 100% rename from ts/fixtures/lang/expected/edits.Tally.ts rename to ts/fixtures/lang/edits/expected/edits.Tally.ts diff --git a/ts/fixtures/lang/expected/edits.ts b/ts/fixtures/lang/edits/expected/edits.ts similarity index 79% rename from ts/fixtures/lang/expected/edits.ts rename to ts/fixtures/lang/edits/expected/edits.ts index 5fb68a94b..ec9864035 100644 --- a/ts/fixtures/lang/expected/edits.ts +++ b/ts/fixtures/lang/edits/expected/edits.ts @@ -1,22 +1,20 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { copy$array_char } from "./lib.ts"; -import { unwrapOr$039uout as option_unwrapOr$039uout, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOr$1j4op5y as option_unwrapOr$1j4op5y, map$0xa0bn7 as option_map$0xa0bn7, map$1u8sh4f as option_map$1u8sh4f, mapOr$14njs1h as option_mapOr$14njs1h, mapOr$1llunel as option_mapOr$1llunel, filter$184yuq2, clone$0vcwlo5 as option_clone$0vcwlo5 } from "./core/option.ts"; +import { unwrapOr$039uout as option_unwrapOr$039uout, unwrapOr$1j4op5y as option_unwrapOr$1j4op5y, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$0xa0bn7 as option_map$0xa0bn7, map$1u8sh4f as option_map$1u8sh4f, mapOr$14njs1h as option_mapOr$14njs1h, mapOr$1llunel as option_mapOr$1llunel, filter$184yuq2, clone$0vcwlo5 as option_clone$0vcwlo5 } from "./core/option.ts"; import * as Lean from "./edits.Lean.ts"; -import * as edits_Named from "./edits.Named.ts"; +import * as Named from "./edits.Named.ts"; import * as Stamp from "./edits.Stamp.ts"; -import * as edits_Tally from "./edits.Tally.ts"; -import { put as fmt_put } from "./fmt.ts"; -import { text as strs_text } from "./strs.ts"; +import * as Tally from "./edits.Tally.ts"; +import { put, text } from "./harness.ts"; /** Into an `Option`, as a parameter that takes either. */ -export function optional$Option_edits_Named(n: edits_Named.Named | undefined): edits_Named.Named | undefined { +export function optional$Option_edits_Named(n: Named.Named | undefined): Named.Named | undefined { return n; } /** Into an `Option`, as a parameter that takes either. */ -export function optional$edits_Named(n: edits_Named.Named): edits_Named.Named | undefined { +export function optional$edits_Named(n: Named.Named): Named.Named | undefined { return n; } @@ -28,14 +26,14 @@ export function putU16s(out: rt.ByteVec, v: rt.u16[]): void { } export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { - const _104: (a0: rt.u16) => edits_Named.Named = (w: rt.u16): edits_Named.Named => { - return { id: w, name: strs_text(rt.byteSliceFrom(Uint8Array.of(rt.u8Div(w & 0xff, 16)))) }; + const _104: (a0: rt.u16) => Named.Named = (w: rt.u16): Named.Named => { + return { id: w, name: text(rt.byteSliceFrom(Uint8Array.of(rt.u8Div(w & 0xff, 16)))) }; }; - const _604: (a0: rt.u16) => edits_Named.Named = (w2: rt.u16): edits_Named.Named => { - return { id: w2, name: strs_text(rt.byteSliceFrom(Uint8Array.of(w2 & 0xff))) }; + const _604: (a0: rt.u16) => Named.Named = (w2: rt.u16): Named.Named => { + return { id: w2, name: text(rt.byteSliceFrom(Uint8Array.of(w2 & 0xff))) }; }; - const _605: (a0: edits_Named.Named[]) => rt.u16[] = (v8: edits_Named.Named[]): rt.u16[] => { - return rt.iterToArray(rt.iterMap(rt.iterSlice(v8), (n: edits_Named.Named): rt.u16 => { + const _605: (a0: Named.Named[]) => rt.u16[] = (v8: Named.Named[]): rt.u16[] => { + return rt.iterToArray(rt.iterMap(rt.iterSlice(v8), (n: Named.Named): rt.u16 => { return n.id; }), undefined, 2, true); }; @@ -67,7 +65,7 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { putU16s(out, [_33[0], _33[1]]); } const names: string[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_233: rt.u8): string => { - return strs_text(rt.byteSliceFrom(Uint8Array.of(_233))); + return text(rt.byteSliceFrom(Uint8Array.of(_233))); }), undefined, 12, true); rt.vecRetain(names, (s3: string): boolean => { return rt.stringLen(s3) > 1; @@ -92,13 +90,13 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { return rt.usizeRem(rt.stringLen(s4.v), 3) !== 0; }); if (_66 !== undefined) { - fmt_put(out, _66); + put(out, _66); } else { break; } } for (const _76 of names) { - fmt_put(out, _76); + put(out, _76); } const part8 = rt.usizeSaturatingSub(data.length, 1); const stop: rt.u16 = rt.u16Mul(at(part8) as rt.u16, 3); @@ -118,30 +116,30 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { }), undefined, 2, true); rt.vecDedupBy(v3, rt.same); putU16s(out, v3); - const keyed: edits_Named.Named[] = rt.iterToArray(rt.iterMap(rt.iterSlice(words), (_224: rt.u16): edits_Named.Named => { + const keyed: Named.Named[] = rt.iterToArray(rt.iterMap(rt.iterSlice(words), (_224: rt.u16): Named.Named => { return _104(_224); }), undefined, 16, true); - rt.vecDedupByKey(keyed, (n3: edits_Named.Named): rt.u16 => { + rt.vecDedupByKey(keyed, (n3: Named.Named): rt.u16 => { return rt.u16Div(n3.id, 24); }, rt.same); for (const _117 of keyed) { putU16s(out, [_117.id]); } - const tested: edits_Named.Named[] = rt.iterToArray(rt.iterMap(rt.iterSlice(words), (_225: rt.u16): edits_Named.Named => { + const tested: Named.Named[] = rt.iterToArray(rt.iterMap(rt.iterSlice(words), (_225: rt.u16): Named.Named => { return _104(_225); }), undefined, 16, true); const seen2: rt.u16[] = []; - rt.vecDedupBy(tested, (a3: edits_Named.Named, b10: edits_Named.Named): boolean => { + rt.vecDedupBy(tested, (a3: Named.Named, b10: Named.Named): boolean => { seen2.push(a3.id); seen2.push(b10.id); return a3.name === b10.name; }); putU16s(out, seen2); for (const _144 of tested) { - fmt_put(out, _144.name); + put(out, _144.name); } const names2: string[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_226: rt.u8): string => { - return strs_text(rt.byteSliceFrom(Uint8Array.of(rt.u8Rem(_226, 3)))); + return text(rt.byteSliceFrom(Uint8Array.of(rt.u8Rem(_226, 3)))); }), undefined, 12, true); rt.vecDedupBy(names2, rt.same); rt.byteVecPush(out, names2.length & 0xff); @@ -192,11 +190,11 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } const names3: string[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_221: rt.u8): string => { const b8: rt.u8 = _221; - return strs_text(rt.byteSliceFrom(Uint8Array.of(b8, rt.u8Div(b8, 16)))); + return text(rt.byteSliceFrom(Uint8Array.of(b8, rt.u8Div(b8, 16)))); }), undefined, 12, true); rt.sliceSort(names3, rt.cmpLt(rt.cmpStr), 12, true); for (const _263 of names3) { - fmt_put(out, _263); + put(out, _263); } } else if (_8 === 3) { const v6: rt.u16[] = rt.vecExact(words.slice(), 2); @@ -217,12 +215,12 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } v6.reverse(); putU16s(out, v6); - const named: edits_Named.Named[] = rt.iterToArray(rt.iterMap(rt.iterSlice(words), (_212: rt.u16): edits_Named.Named => { + const named: Named.Named[] = rt.iterToArray(rt.iterMap(rt.iterSlice(words), (_212: rt.u16): Named.Named => { const w6: rt.u16 = _212; - return { id: w6, name: strs_text(rt.byteSliceFrom(Uint8Array.of(w6 & 0xff))) }; + return { id: w6, name: text(rt.byteSliceFrom(Uint8Array.of(w6 & 0xff))) }; }), undefined, 16, true); - const probe: edits_Named.Named = { id: rt.u16Mul(at(1) as rt.u16, 3), name: strs_text(rt.byteSliceFrom(Uint8Array.of(rt.u8WrappingMul(at(1), 3)))) }; - rt.byteVecPush(out, rt.sliceContains(named, probe, edits_Named.eq$cmp_PartialEq) ? 1 : 0); + const probe: Named.Named = { id: rt.u16Mul(at(1) as rt.u16, 3), name: text(rt.byteSliceFrom(Uint8Array.of(rt.u8WrappingMul(at(1), 3)))) }; + rt.byteVecPush(out, rt.sliceContains(named, probe, Named.eq$cmp_PartialEq) ? 1 : 0); rt.byteVecPush(out, rt.sliceContains(words, rt.u16Mul(at(2) as rt.u16, 3), rt.same) ? 1 : 0); const _361: rt.u8 = at(3); rt.byteVecPush(out, rt.byteSliceView(data).includes(_361) ? 1 : 0); @@ -235,22 +233,22 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.sliceSwap(moved, i, j); putU16s(out, moved); } else if (_8 === 4) { - const named2: edits_Named.Named[] = rt.iterToArray(rt.iterMap(rt.iterSlice(words), (_28: rt.u16): edits_Named.Named => { + const named2: Named.Named[] = rt.iterToArray(rt.iterMap(rt.iterSlice(words), (_28: rt.u16): Named.Named => { const w4: rt.u16 = _28; - return { id: w4, name: strs_text(rt.byteSliceFrom(Uint8Array.of(w4 & 0xff))) }; + return { id: w4, name: text(rt.byteSliceFrom(Uint8Array.of(w4 & 0xff))) }; }), undefined, 16, true); - const cloned: edits_Named.Named[] = rt.vecExact(named2.map(edits_Named.clone$Clone), 16); - rt.byteVecPush(out, rt.eqSlice(edits_Named.eq$cmp_PartialEq)(cloned, named2) ? 1 : 0); - const changed: edits_Named.Named[] = rt.vecExact(named2.map(edits_Named.clone$Clone), 16); - const _411: edits_Named.Named | undefined = rt.sliceFirst(changed); + const cloned: Named.Named[] = rt.vecExact(named2.map(Named.clone$Clone), 16); + rt.byteVecPush(out, rt.eqSlice(Named.eq$cmp_PartialEq)(cloned, named2) ? 1 : 0); + const changed: Named.Named[] = rt.vecExact(named2.map(Named.clone$Clone), 16); + const _411: Named.Named | undefined = rt.sliceFirst(changed); if (_411 !== undefined) { _411.name = _411.name + "!"; } - rt.byteVecPush(out, rt.eqSlice(edits_Named.eq$cmp_PartialEq)(changed, named2) ? 1 : 0); - rt.byteVecPush(out, !rt.eqSlice(edits_Named.eq$cmp_PartialEq)(changed, named2) ? 1 : 0); - rt.byteVecPush(out, rt.cmpSlice(edits_Named.partialCmp$cmp_PartialOrd)(changed, named2) === -1 ? 1 : 0); - const _435: edits_Named.Named[] = rt.sliceRange(named2, 0, rt.usizeDiv(named2.length, 2)); - rt.vecExtendFromSlice(changed, _435, 16, edits_Named.clone$Clone); + rt.byteVecPush(out, rt.eqSlice(Named.eq$cmp_PartialEq)(changed, named2) ? 1 : 0); + rt.byteVecPush(out, !rt.eqSlice(Named.eq$cmp_PartialEq)(changed, named2) ? 1 : 0); + rt.byteVecPush(out, rt.cmpSlice(Named.partialCmp$cmp_PartialOrd)(changed, named2) === -1 ? 1 : 0); + const _435: Named.Named[] = rt.sliceRange(named2, 0, rt.usizeDiv(named2.length, 2)); + rt.vecExtendFromSlice(changed, _435, 16, Named.clone$Clone); rt.byteVecPush(out, changed.length & 0xff); const nested: rt.u16[][] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_29: rt.u8): rt.u16[] => { const b5: rt.u8 = _29; @@ -262,9 +260,9 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { return rt.vecExact(a027.slice(), 2); }), 12); rt.byteVecPush(out, rt.eqSlice(rt.eqSlice(rt.same))(_453, nested) ? 1 : 0); - const pair: [string, rt.u8] = [strs_text(data), at(0)]; + const pair: [string, rt.u8] = [text(data), at(0)]; const copy: [string, rt.u8] = rt.tupleClone(pair, [undefined, undefined]); - fmt_put(out, copy[0]); + put(out, copy[0]); const _470: [rt.u8, string] = [copy[1], copy[0]]; const _474: [rt.u8, string] = [at(1), pair[0]]; rt.byteVecPush(out, rt.cmpTuple<[rt.u8, string], rt.Ordering | undefined>([rt.cmp, rt.cmpStr])(_470, _474) === 1 ? 1 : 0); @@ -275,13 +273,13 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.vecExtendFromSlice(grown, words, 2); putU16s(out, grown); } else if (_8 === 5) { - let tally: edits_Tally.Tally = { n: at(0), names: [strs_text(data)] }; - const default_ = edits_Tally.default$Default(); + let tally: Tally.Tally = { n: at(0), names: [text(data)] }; + const default_ = Tally.default$Default(); const taken3 = tally; tally = default_; rt.byteVecPush(out, taken3.n); rt.byteVecPush(out, tally.n); - fmt_put(out, tally.names[rt.idx(tally.names, 0)]); + put(out, tally.names[rt.idx(tally.names, 0)]); let queue: rt.VecDeque = rt.dequeFromVec(rt.iterToArray(rt.iterSlice(words), undefined, 2, true), 2) as rt.VecDeque; const default_2 = rt.dequeNew(2) as rt.VecDeque; const taken4 = queue; @@ -310,49 +308,49 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, rt.ordMin(p, q, rt.cmpLt(Lean.partialCmp$cmp_PartialOrd))._0); rt.byteVecPush(out, rt.ordClamp(p, q, r, rt.cmpLe(Lean.partialCmp$cmp_PartialOrd), rt.cmpLt(Lean.partialCmp$cmp_PartialOrd), rt.cmpGt(Lean.partialCmp$cmp_PartialOrd))._0); } else if (_8 === 6) { - const v7: edits_Named.Named[] = rt.iterToArray(rt.iterMap(rt.iterSlice(words), (_23: rt.u16): edits_Named.Named => { + const v7: Named.Named[] = rt.iterToArray(rt.iterMap(rt.iterSlice(words), (_23: rt.u16): Named.Named => { return _604(_23); }), undefined, 16, true); const _615: rt.usize = rt.usizeRem(at(0) as rt.usize, 8); - const _621: edits_Named.Named = _604(511); + const _621: Named.Named = _604(511); rt.vecInsert(v7, _615, _621); putU16s(out, _605(v7)); const _634: rt.usize = rt.usizeRem(at(1) as rt.usize, 8); - const removed: edits_Named.Named = rt.vecRemove(v7, _634); + const removed: Named.Named = rt.vecRemove(v7, _634); putU16s(out, [removed.id]); - const kept: edits_Named.Named[] = rt.vecExact(v7.map(edits_Named.clone$Clone), 16); + const kept: Named.Named[] = rt.vecExact(v7.map(Named.clone$Clone), 16); const _649: rt.usize = rt.usizeRem(at(2) as rt.usize, 4); rt.vecTruncate(v7, _649); putU16s(out, _605(v7)); rt.vecTruncate(v7, 0); rt.byteVecPush(out, v7.length === 0 ? 1 : 0); - const boxed: edits_Named.Named = removed; - const copy2: edits_Named.Named = edits_Named.clone$Clone(boxed); + const boxed: Named.Named = removed; + const copy2: Named.Named = Named.clone$Clone(boxed); copy2.name = copy2.name + "!"; - fmt_put(out, boxed.name); - fmt_put(out, copy2.name); - const held: edits_Named.Named | undefined = filter$184yuq2(boxed, (_27: edits_Named.Named): boolean => { + put(out, boxed.name); + put(out, copy2.name); + const held: Named.Named | undefined = filter$184yuq2(boxed, (_27: Named.Named): boolean => { return rt.u8Rem(at(3), 2) === 0; }); - rt.byteVecPush(out, option_map$0xa0bn7(option_clone$0vcwlo5(held), (b3: edits_Named.Named): rt.u16 => { + rt.byteVecPush(out, option_map$0xa0bn7(option_clone$0vcwlo5(held), (b3: Named.Named): rt.u16 => { return b3.id; - }) === option_map$0xa0bn7(held, (b4: edits_Named.Named): rt.u16 => { + }) === option_map$0xa0bn7(held, (b4: Named.Named): rt.u16 => { return b4.id; }) ? 1 : 0); - const some: edits_Named.Named[] | undefined = rt.vecExact(kept.map(edits_Named.clone$Clone), 16); - const _701: edits_Named.Named[] | undefined = rt.vecExact(kept.map(edits_Named.clone$Clone), 16); - rt.byteVecPush(out, rt.eqOption(rt.eqSlice(edits_Named.eq$cmp_PartialEq))(some, _701) ? 1 : 0); - rt.byteVecPush(out, rt.eqOption(rt.eqSlice(edits_Named.eq$cmp_PartialEq))(some, undefined) ? 1 : 0); - const _715: edits_Named.Named[] = []; - rt.byteVecPush(out, !rt.eqOption(rt.eqSlice(edits_Named.eq$cmp_PartialEq))(some, _715) ? 1 : 0); - const _720: edits_Named.Named | undefined = optional$edits_Named(_604(5)); - const _725: edits_Named.Named | undefined = optional$Option_edits_Named(undefined); - rt.byteVecPush(out, rt.eqOption(edits_Named.eq$cmp_PartialEq)(_720, _725) ? 1 : 0); + const some: Named.Named[] | undefined = rt.vecExact(kept.map(Named.clone$Clone), 16); + const _701: Named.Named[] | undefined = rt.vecExact(kept.map(Named.clone$Clone), 16); + rt.byteVecPush(out, rt.eqOption(rt.eqSlice(Named.eq$cmp_PartialEq))(some, _701) ? 1 : 0); + rt.byteVecPush(out, rt.eqOption(rt.eqSlice(Named.eq$cmp_PartialEq))(some, undefined) ? 1 : 0); + const _715: Named.Named[] = []; + rt.byteVecPush(out, !rt.eqOption(rt.eqSlice(Named.eq$cmp_PartialEq))(some, _715) ? 1 : 0); + const _720: Named.Named | undefined = optional$edits_Named(_604(5)); + const _725: Named.Named | undefined = optional$Option_edits_Named(undefined); + rt.byteVecPush(out, rt.eqOption(Named.eq$cmp_PartialEq)(_720, _725) ? 1 : 0); const part3 = at(4) as rt.u16; - rt.byteVecPush(out, option_mapOr$14njs1h(optional$edits_Named(_604(part3)), 65535, (n2: edits_Named.Named): rt.u16 => { + rt.byteVecPush(out, option_mapOr$14njs1h(optional$edits_Named(_604(part3)), 65535, (n2: Named.Named): rt.u16 => { return n2.id; }) & 0xff); - const part4 = option_unwrapOr$039uout(option_map$1u8sh4f(rt.sliceFirst(kept), (a09: edits_Named.Named): edits_Named.Named[] => { + const part4 = option_unwrapOr$039uout(option_map$1u8sh4f(rt.sliceFirst(kept), (a09: Named.Named): Named.Named[] => { return [a09]; }), kept); putU16s(out, _605(part4)); @@ -363,18 +361,18 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _764.data[_764.start]); const part6 = rt.fromUtf8ErrorClone(rt.resultUnwrapErr(rt.stringFromUtf8(rt.byteVecFrom(Uint8Array.of(97, 255, at(6)))), rt.fmtStr)); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtFromUtf8ErrorDebug(part6, f)]; - fmt_put(out, rt.fmtFormat([args2[0]])); + put(out, rt.fmtFormat([args2[0]])); rt.byteVecPush(out, 16 & 0xff); rt.byteVecPush(out, 16 & 0xff); rt.byteVecPush(out, 4 & 0xff); rt.byteVecPush(out, 6 & 0xff); rt.byteVecPush(out, rt.u8Mul(4 & 0xff, 1 & 0xff)); } else { - const s2: string = strs_text(data); + const s2: string = text(data); const sep: rt.char[] = [47, 97]; rt.byteVecPush(out, rt.strContains(s2, rt.patternChars(sep)) ? 1 : 0); rt.byteVecPush(out, rt.strContains(s2, rt.patternChars(rt.sliceRange(sep, 0))) ? 1 : 0); - rt.byteVecPush(out, rt.iterCount(rt.strSplit(s2, rt.patternChars(copy$array_char(sep)))) & 0xff); + rt.byteVecPush(out, rt.iterCount(rt.strSplit(s2, rt.patternChars(sep))) & 0xff); rt.byteVecPush(out, rt.strEndsWith(s2, "/") ? 1 : 0); rt.byteVecPush(out, rt.strEndsWith(s2, "😀") ? 1 : 0); rt.byteVecPush(out, rt.strEndsWith(s2, (c: rt.char): boolean => { @@ -384,15 +382,15 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (_848 === undefined) { rt.byteVecPush(out, 253); } else { - fmt_put(out, _848[0]); - fmt_put(out, _848[1]); + put(out, _848[0]); + put(out, _848[1]); } const _857: [string, string] | undefined = rt.strSplitOnce(s2, "a0"); if (_857 === undefined) { rt.byteVecPush(out, 253); } else { - fmt_put(out, _857[0]); - fmt_put(out, _857[1]); + put(out, _857[0]); + put(out, _857[1]); } const iter11: rt.RangeInclusive = new rt.RangeInclusive(0, rt.usizeAdd(rt.stringLen(s2), 1), rt.usizeStep); while (true) { diff --git a/ts/fixtures/lang/edits/expected/harness.ts b/ts/fixtures/lang/edits/expected/harness.ts new file mode 100644 index 000000000..7c19e53ff --- /dev/null +++ b/ts/fixtures/lang/edits/expected/harness.ts @@ -0,0 +1,64 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +/** A char of the alphabet for each byte, by its low bits. */ +export function text(data: rt.ByteSlice): string { + let s: string = ""; + const iterS: Uint8Array = rt.byteSliceView(data); + let iterI: number = 0; + while (true) { + const _5: rt.u8 | rt.Done = iterI < iterS.length ? iterS[iterI++] : rt.DONE; + if (_5 === rt.DONE) { + return s; + } + const _13: rt.usize = rt.u8Rem(_5, 16) as rt.usize; + if (!(_13 < 16)) { + rt.panic("index out of bounds: the len is " + 16 + " but the index is " + _13); + } + s = s + String.fromCodePoint([47, 92, 97, 48, 57, 127, 128, 233, 2047, 2048, 55295, 57344, 65535, 65536, 128512, 1114111][_13]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/edits/expected/lib.ts b/ts/fixtures/lang/edits/expected/lib.ts new file mode 100644 index 000000000..d5243a15e --- /dev/null +++ b/ts/fixtures/lang/edits/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { edits, bytes } from "./edits.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["edits::edits", edits as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["edits::bytes", bytes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/edits.rs b/ts/fixtures/lang/edits/src/edits.rs similarity index 99% rename from ts/fixtures/lang/src/edits.rs rename to ts/fixtures/lang/edits/src/edits.rs index b23a8cf17..63ae38cfc 100644 --- a/ts/fixtures/lang/src/edits.rs +++ b/ts/fixtures/lang/edits/src/edits.rs @@ -6,8 +6,7 @@ use std::cmp::Ordering; use std::collections::{BTreeSet, VecDeque}; -use crate::fmt::put; -use crate::strs::text; +use crate::harness::{put, text}; /// The crate's own order, whose `min`, `max`, and `clamp` are `Ord`'s defaults. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)] diff --git a/ts/fixtures/lang/edits/src/lib.rs b/ts/fixtures/lang/edits/src/lib.rs new file mode 100644 index 000000000..dcb369dcf --- /dev/null +++ b/ts/fixtures/lang/edits/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod edits; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("edits::edits", edits::edits), ("edits::bytes", edits::bytes)] +} diff --git a/ts/fixtures/lang/edits/ts.toml b/ts/fixtures/lang/edits/ts.toml new file mode 100644 index 000000000..6e09bf9cd --- /dev/null +++ b/ts/fixtures/lang/edits/ts.toml @@ -0,0 +1,2 @@ +package = "lang-edits-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/elements/Cargo.toml b/ts/fixtures/lang/elements/Cargo.toml new file mode 100644 index 000000000..5b0671ef9 --- /dev/null +++ b/ts/fixtures/lang/elements/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-elements-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/elements/expected/core/bool.ts b/ts/fixtures/lang/elements/expected/core/bool.ts new file mode 100644 index 000000000..92f51ca46 --- /dev/null +++ b/ts/fixtures/lang/elements/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$03chm1q(self: boolean, t: [rt.u8, rt.u8]): [rt.u8, rt.u8] | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/elements/expected/core/option.ts b/ts/fixtures/lang/elements/expected/core/option.ts new file mode 100644 index 000000000..2a5f005a2 --- /dev/null +++ b/ts/fixtures/lang/elements/expected/core/option.ts @@ -0,0 +1,33 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$1fmzefe(self: rt.u8 | undefined, f: (a0: rt.u8) => [rt.u8, rt.u8]): [rt.u8, rt.u8] | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function mapOr$0grxkdu(self: rt.u32[] | undefined, default_: rt.u32, f: (a0: rt.u32[]) => rt.u32): rt.u32 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1nlkf9b(self: [rt.u8, rt.u8] | undefined, default_: Uint8Array, f: (a0: [rt.u8, rt.u8]) => Uint8Array): Uint8Array { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/expected/elements.Inline.ts b/ts/fixtures/lang/elements/expected/elements.Inline.ts similarity index 100% rename from ts/fixtures/lang/expected/elements.Inline.ts rename to ts/fixtures/lang/elements/expected/elements.Inline.ts diff --git a/ts/fixtures/lang/expected/elements.Storage.ts b/ts/fixtures/lang/elements/expected/elements.Storage.ts similarity index 100% rename from ts/fixtures/lang/expected/elements.Storage.ts rename to ts/fixtures/lang/elements/expected/elements.Storage.ts diff --git a/ts/fixtures/lang/expected/elements.ts b/ts/fixtures/lang/elements/expected/elements.ts similarity index 98% rename from ts/fixtures/lang/expected/elements.ts rename to ts/fixtures/lang/elements/expected/elements.ts index 096e285b1..1f2e8767b 100644 --- a/ts/fixtures/lang/expected/elements.ts +++ b/ts/fixtures/lang/elements/expected/elements.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { copy$Option_tuple2_u8_u8, copy$array_Option_tuple2_u8_u8, copy$mem_MaybeUninit_Result_tuple2_u32_u32_u8, drop$elements_Inline_Option_tuple2_u8_u8, drop$elements_Inline_sync_Arc_u8 } from "./lib.ts"; +import { copy$Option_tuple2_u8_u8, copy$array_Option_tuple2_u8_u8, drop$elements_Inline_Option_tuple2_u8_u8, drop$elements_Inline_sync_Arc_u8 } from "./lib.ts"; import { thenSome$03chm1q } from "./core/bool.ts"; import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$1fmzefe as option_map$1fmzefe, mapOr$0grxkdu as option_mapOr$0grxkdu, mapOr$1nlkf9b as option_mapOr$1nlkf9b } from "./core/option.ts"; import { offsetFrom } from "./elements/mine/ptr.ts"; @@ -266,11 +266,11 @@ export function edges(data: rt.ByteSlice, out: rt.ByteVec): void { const item = (undefined as unknown) as rt.Result<[rt.u32, rt.u32], rt.u8>; const item2 = (undefined as unknown) as rt.Result<[rt.u32, rt.u32], rt.u8>; const dst: rt.Result<[rt.u32, rt.u32], rt.u8>[] = Array.from({ length: 2 }, (): rt.Result<[rt.u32, rt.u32], rt.u8> => { - return copy$mem_MaybeUninit_Result_tuple2_u32_u32_u8(item2); + return item2; }); rt.ptrCopy(rt.sliceAsPtr(Array.from({ length: 2 }, (): rt.Result<[rt.u32, rt.u32], rt.u8> => { - return copy$mem_MaybeUninit_Result_tuple2_u32_u32_u8(item); - })), rt.sliceAsPtr(dst), 2, copy$mem_MaybeUninit_Result_tuple2_u32_u32_u8); + return item; + })), rt.sliceAsPtr(dst), 2); if (!((n & 1) === 0)) { _200 = rt.Err(n); } else { diff --git a/ts/fixtures/lang/expected/elements/mine/ptr.ts b/ts/fixtures/lang/elements/expected/elements/mine/ptr.ts similarity index 100% rename from ts/fixtures/lang/expected/elements/mine/ptr.ts rename to ts/fixtures/lang/elements/expected/elements/mine/ptr.ts diff --git a/ts/fixtures/lang/expected/elements/mine/raw.ts b/ts/fixtures/lang/elements/expected/elements/mine/raw.ts similarity index 100% rename from ts/fixtures/lang/expected/elements/mine/raw.ts rename to ts/fixtures/lang/elements/expected/elements/mine/raw.ts diff --git a/ts/fixtures/lang/elements/expected/harness.ts b/ts/fixtures/lang/elements/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/elements/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/elements/expected/lib.ts b/ts/fixtures/lang/elements/expected/lib.ts new file mode 100644 index 000000000..c74abd8d2 --- /dev/null +++ b/ts/fixtures/lang/elements/expected/lib.ts @@ -0,0 +1,63 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { vecs, arrays, segments, inline, edges, rawSlices, emptyParts } from "./elements.ts"; +import * as Inline from "./elements.Inline.ts"; + +export function copy$Option_tuple2_u8_u8(v: [rt.u8, rt.u8] | undefined): [rt.u8, rt.u8] | undefined { + return v === undefined ? v : copy$tuple2_u8_u8(v); +} + +export function copy$array_Option_tuple2_u8_u8(v: Array<[rt.u8, rt.u8] | undefined>): Array<[rt.u8, rt.u8] | undefined> { + return v.map(copy$Option_tuple2_u8_u8); +} + +export function copy$mem_MaybeUninit_Option_tuple2_u8_u8(v: [rt.u8, rt.u8] | undefined): [rt.u8, rt.u8] | undefined { + if (v === undefined) { + return v; + } + return v === undefined ? v : copy$tuple2_u8_u8(v); +} + +export function copy$mem_MaybeUninit_array_Option_tuple2_u8_u8(v: Array<[rt.u8, rt.u8] | undefined>): Array<[rt.u8, rt.u8] | undefined> { + if (v === undefined) { + return v; + } + return v.map(copy$mem_MaybeUninit_Option_tuple2_u8_u8); +} + +export function copy$tuple2_u8_u8(v: [rt.u8, rt.u8]): [rt.u8, rt.u8] { + return [v[0], v[1]]; +} + +export function drop$elements_Inline_Option_tuple2_u8_u8(_1: Inline.Inline<[rt.u8, rt.u8] | undefined>): void { + Inline.drop$ops_Drop_Option_tuple2_u8_u8(_1); +} + +export function drop$elements_Inline_sync_Arc_u8(_1: Inline.Inline>): void { + Inline.drop$ops_Drop_sync_Arc_u8(_1); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["elements::vecs", (_24: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + vecs(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["elements::arrays", (_25: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + arrays(data2, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["elements::segments", (_26: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + segments(data3, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["elements::inline", (_27: rt.u8, data4: rt.ByteSlice, out4: rt.ByteVec): undefined => { + inline(data4, out4); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["elements::edges", (_28: rt.u8, data5: rt.ByteSlice, out5: rt.ByteVec): undefined => { + edges(data5, out5); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["elements::raw_slices", (_29: rt.u8, data6: rt.ByteSlice, out6: rt.ByteVec): undefined => { + rawSlices(data6, out6); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["elements::empty_parts", (_210: rt.u8, data7: rt.ByteSlice, out7: rt.ByteVec): undefined => { + emptyParts(data7, out7); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/elements.rs b/ts/fixtures/lang/elements/src/elements.rs similarity index 100% rename from ts/fixtures/lang/src/elements.rs rename to ts/fixtures/lang/elements/src/elements.rs diff --git a/ts/fixtures/lang/elements/src/lib.rs b/ts/fixtures/lang/elements/src/lib.rs new file mode 100644 index 000000000..83d144b42 --- /dev/null +++ b/ts/fixtures/lang/elements/src/lib.rs @@ -0,0 +1,27 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod elements; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("elements::vecs", |_, data, out| elements::vecs(data, out)), + ("elements::arrays", |_, data, out| elements::arrays(data, out)), + ("elements::segments", |_, data, out| elements::segments(data, out)), + ("elements::inline", |_, data, out| elements::inline(data, out)), + ("elements::edges", |_, data, out| elements::edges(data, out)), + ("elements::raw_slices", |_, data, out| elements::raw_slices(data, out)), + ("elements::empty_parts", |_, data, out| elements::empty_parts(data, out)), + ] +} diff --git a/ts/fixtures/lang/elements/ts.toml b/ts/fixtures/lang/elements/ts.toml new file mode 100644 index 000000000..753e58159 --- /dev/null +++ b/ts/fixtures/lang/elements/ts.toml @@ -0,0 +1,2 @@ +package = "lang-elements-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/ends/Cargo.toml b/ts/fixtures/lang/ends/Cargo.toml new file mode 100644 index 000000000..aeaa8fddf --- /dev/null +++ b/ts/fixtures/lang/ends/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-ends-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/ends/caller.ts b/ts/fixtures/lang/ends/caller.ts new file mode 100644 index 000000000..86a4808a1 --- /dev/null +++ b/ts/fixtures/lang/ends/caller.ts @@ -0,0 +1,18 @@ +// The inputs `ends`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `ends::ends`: each kind of iterator through every consumer and either end's bits, of + * runs empty, short, and long, whose hints are exact, loose, and lying, after none and a + * few steps through each of its methods. + */ +const endsCases = [0x00, 0x03, 0x0f, 0x15, 0x27, 0x36, 0x2f].flatMap((shape) => + [[], [0x01, 0x00], [0x0a, 0x0d, 0x03], [0x05, 0x06, 0x04, 0x0f]].flatMap((steps) => + Array.from({ length: 4 * 256 }, (_, i) => Uint8Array.of(...op("ends::ends"), i % 4, shape, i >> 2, ...steps)), + ), +); + +export const cases: Uint8Array[] = [...endsCases]; diff --git a/ts/fixtures/lang/ends/expected/core/bool.ts b/ts/fixtures/lang/ends/expected/core/bool.ts new file mode 100644 index 000000000..17d957542 --- /dev/null +++ b/ts/fixtures/lang/ends/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0d5am30(self: boolean, t: rt.u8): rt.u8 | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/ends/expected/core/option.ts b/ts/fixtures/lang/ends/expected/core/option.ts new file mode 100644 index 000000000..17e6e9c22 --- /dev/null +++ b/ts/fixtures/lang/ends/expected/core/option.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$1sj2ls1(self: [rt.usize, rt.u8] | undefined, f: (a0: [rt.usize, rt.u8]) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0vbopjd(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.usize): rt.usize | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$05nbzug(self: rt.usize | undefined, f: (a0: rt.usize) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function mapOr$02k4ito(self: rt.usize | undefined, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/expected/ends.Counted.ts b/ts/fixtures/lang/ends/expected/ends.Counted.ts similarity index 52% rename from ts/fixtures/lang/expected/ends.Counted.ts rename to ts/fixtures/lang/ends/expected/ends.Counted.ts index fdfea08ce..5954bf447 100644 --- a/ts/fixtures/lang/expected/ends.Counted.ts +++ b/ts/fixtures/lang/ends/expected/ends.Counted.ts @@ -1,28 +1,28 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import * as ends_Run from "./ends.Run.ts"; +import * as Run from "./ends.Run.ts"; /** A `Run` whose `len` is its own, which reads the run's, as hashlink's `Values` does. */ export interface Counted { - _0: ends_Run.Run; + _0: Run.Run; } export function next$iter_Iterator(self: Counted): rt.u8 | rt.Done { - return ends_Run.next$iter_Iterator(self._0); + return Run.next$iter_Iterator(self._0); } export function sizeHint$iter_Iterator(self: Counted): [rt.usize, rt.usize | undefined] { - return ends_Run.sizeHint$iter_Iterator(self._0); + return Run.sizeHint$iter_Iterator(self._0); } export function nextBack$iter_DoubleEndedIterator(self: Counted): rt.u8 | undefined { - return ends_Run.nextBack$iter_DoubleEndedIterator(self._0); + return Run.nextBack$iter_DoubleEndedIterator(self._0); } export function len$iter_ExactSizeIterator(self: Counted): rt.usize { - ends_Run.logged(self._0, 108); - return rt.iterFrom(self._0, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))).len(); + Run.logged(self._0, 108); + return rt.iterFrom(self._0, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))).len(); } //# sourceMappingURL=ends.Counted.ts.map diff --git a/ts/fixtures/lang/expected/ends.Flicker.ts b/ts/fixtures/lang/ends/expected/ends.Flicker.ts similarity index 100% rename from ts/fixtures/lang/expected/ends.Flicker.ts rename to ts/fixtures/lang/ends/expected/ends.Flicker.ts diff --git a/ts/fixtures/lang/expected/ends.Lapse.ts b/ts/fixtures/lang/ends/expected/ends.Lapse.ts similarity index 100% rename from ts/fixtures/lang/expected/ends.Lapse.ts rename to ts/fixtures/lang/ends/expected/ends.Lapse.ts diff --git a/ts/fixtures/lang/expected/ends.Run.ts b/ts/fixtures/lang/ends/expected/ends.Run.ts similarity index 100% rename from ts/fixtures/lang/expected/ends.Run.ts rename to ts/fixtures/lang/ends/expected/ends.Run.ts diff --git a/ts/fixtures/lang/ends/expected/ends.ts b/ts/fixtures/lang/ends/expected/ends.ts new file mode 100644 index 000000000..2d59f38ee --- /dev/null +++ b/ts/fixtures/lang/ends/expected/ends.ts @@ -0,0 +1,324 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$1sj2ls1 as option_map$1sj2ls1, map$05nbzug as option_map$05nbzug, mapOr$02k4ito as option_mapOr$02k4ito } from "./core/option.ts"; +import * as Counted from "./ends.Counted.ts"; +import * as Flicker from "./ends.Flicker.ts"; +import * as Lapse from "./ends.Lapse.ts"; +import * as Run from "./ends.Run.ts"; + +/** An item, or 0xff for `None`. */ +export function put(out: rt.ByteVec, item: rt.u8 | undefined): void { + rt.byteVecPush(out, option_unwrapOr$0r2bmpr(item, 255)); +} + +/** A hint, the upper bound 0xff for `None`. */ +export function putHint(out: rt.ByteVec, _2: [rt.usize, rt.usize | undefined]): void { + const lower: rt.usize = _2[0]; + const upper: rt.usize | undefined = _2[1]; + rt.byteVecPush(out, lower & 0xff); + rt.byteVecPush(out, option_mapOr$02k4ito(upper, 255, (upper2: rt.usize): rt.u8 => { + return upper2 & 0xff; + })); +} + +/** + * A `Vec` collected or extended by `items`, by its length and capacity: what std reserved + * by their hints. + */ +export function putVec(out: rt.ByteVec, v: rt.ByteVec): void { + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(v.length & 0xff, v.data.length & 0xff)), undefined, true); + rt.iterExtendBytes(out, rt.byteVecIntoIter(v), undefined, true); +} + +/** + * The run `data`'s first byte picks steps through with each of its other bytes, read + * directly, through `&mut`, or by std's adaptors, and consumed by the third byte's pick, + * with what each read and each call of its methods logged. + */ +export function ends(kind: rt.u8, dataData: Uint8Array, dataStart: number, dataLen: number, out: rt.ByteVec): void { + let over!: rt.u8 | undefined; + let item!: rt.u8 | undefined; + if (dataLen >= 2) { + const log: rt.RefCell = new rt.RefCell(new rt.ByteVec()); + const over2: rt.u8 = rt.u8Shr(dataData[dataStart], 4) & 3; + if (over2 === 0) { + over = undefined; + } else { + over = rt.u8Sub(over2, 1); + } + const run: Run.Run = { front: 0, back: rt.u8Rem(dataData[dataStart], 16), over, log }; + const iter: rt.Iter = rt.iterTake(rt.iterSlice(rt.byteSliceView(new rt.ByteSlice(dataData, dataStart + 2, dataLen - 2))), 8); + while (true) { + const _25: rt.u8 | rt.Done = iter.next(); + if (_25 === rt.DONE) { + break; + } + const step: rt.u8 = _25; + const _29: rt.u8 = rt.u8Rem(step, 8); + if (_29 === 0) { + put(out, rt.iterToOption(Run.next$iter_Iterator(run))); + } else if (_29 === 1) { + put(out, Run.nextBack$iter_DoubleEndedIterator(run)); + } else if (_29 === 2) { + const _37: rt.usize = rt.usizeRem(step >> 3 as rt.usize, 4); + put(out, rt.iterNthBack(rt.iterFrom(run, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))), _37)); + } else if (_29 === 3) { + rt.byteVecPush(out, rt.iterFrom(run, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))).len() & 0xff); + } else if (_29 === 4) { + putHint(out, Run.sizeHint$iter_Iterator(run)); + } else if (_29 === 5) { + if (!((step & 8) === 0)) { + put(out, Run.nextBack$iter_DoubleEndedIterator(run)); + } else { + put(out, rt.iterToOption(rt.iterRev(rt.iterFrom(run, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it)))).next())); + } + } else if (_29 === 6) { + rt.byteVecPush(out, rt.iterFrom(run, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))).len() & 0xff); + } else { + const _62: rt.usize = rt.usizeRem(step >> 3 as rt.usize, 4); + put(out, rt.iterNth(rt.iterFrom(run, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))), _62)); + } + } + const k: rt.usize = rt.u8Shr(dataData[dataStart + 1], 4) as rt.usize; + b4: { + const _71: rt.u8 = rt.u8Rem(kind, 4); + if (_71 === 0) { + consumed$ends_Run(run, rt.u8Rem(dataData[dataStart + 1], 16), k, out); + } else if (_71 === 1) { + consumed$ends_Counted({ _0: run }, rt.u8Rem(dataData[dataStart + 1], 16), k, out); + } else if (_71 === 2) { + fuses(dataData[dataStart + 1], out); + } else { + let bits: rt.u8 = dataData[dataStart + 1]; + while (true) { + if ((bits & 1) === 0) { + item = rt.iterToOption(Run.next$iter_Iterator(run)); + } else { + item = Run.nextBack$iter_DoubleEndedIterator(run); + } + bits = rt.intRotateRight(bits, 1, 8, false); + put(out, item); + if (item === undefined) { + put(out, Run.nextBack$iter_DoubleEndedIterator(run)); + break b4; + } + } + } + } + rt.byteVecPush(out, 254); + rt.iterExtendBytes(out, rt.byteVecIntoIter(log.value), undefined, true); + } +} + +/** `it`, consumed by std's adaptor or consumer `pick`, with `k` its count where it takes one. */ +export function consumed$ends_Counted(it: Counted.Counted, pick: rt.u8, k: rt.usize, out: rt.ByteVec): void { + let _32!: rt.u8 | undefined; + if (pick === 0) { + putVec(out, rt.iterToByteVec(rt.iterRev(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it))), "next")); + } else if (pick === 1) { + putVec(out, rt.iterToByteVec(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it)), "next")); + } else if (pick === 2) { + rt.byteVecPush(out, rt.iterRev(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it))).len() & 0xff); + } else if (pick === 3) { + rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterRev(rt.iterEnumerate(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it)))), (_211: [rt.usize, rt.u8]): Uint8Array => { + return Uint8Array.of(_211[0] & 0xff, _211[1]); + }, (value: Uint8Array) => rt.iterSlice(value), false, 2), "next"); + } else if (pick === 4) { + rt.iterExtendBytes(out, rt.iterRev(rt.iterSkip(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it)), k)), "next"); + } else if (pick === 5) { + rt.iterExtendBytes(out, rt.iterRev(rt.iterTake(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it)), k)), "next"); + } else if (pick === 6) { + const _27: Counted.Counted = it; + const _28: rt.usize = rt.max(k, 1); + rt.iterExtendBytes(out, rt.iterRev(rt.iterStepBy(rt.iterFrom(_27, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it)), _28)), "next"); + } else if (pick === 7) { + put(out, option_map$05nbzug(rt.iterRposition(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it)), (b8: rt.u8): boolean => { + return rt.u8Rem(b8, 3) === 0; + }), (i3: rt.usize): rt.u8 => { + return i3 & 0xff; + })); + } else if (pick === 8) { + const _33: rt.usize = rt.usizeRem(k, 4); + if (_33 === 0) { + const _37: Counted.Counted = it; + const _38: rt.usize = rt.usizeDiv(k, 4); + _32 = rt.iterRfind(rt.iterSkip(rt.iterFrom(_37, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it)), _38), (b7: rt.u8): boolean => { + return rt.u8Rem(b7, 3) === 0; + }); + } else if (_33 === 1) { + const _42: Counted.Counted = it; + const _43: rt.usize = rt.usizeDiv(k, 4); + _32 = rt.iterRfind(rt.iterTake(rt.iterFrom(_42, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it)), _43), (b6: rt.u8): boolean => { + return rt.u8Rem(b6, 3) === 0; + }); + } else if (_33 === 2) { + _32 = option_map$1sj2ls1(rt.iterRfind(rt.iterEnumerate(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it))), (_2: [rt.usize, rt.u8]): boolean => { + return rt.u8Rem(rt.u8Add(_2[0] & 0xff, _2[1]), 3) === 0; + }), (_210: [rt.usize, rt.u8]): rt.u8 => { + return (_210[0] & 0xff) ^ _210[1]; + }); + } else { + const _51: Counted.Counted = it; + const _52: rt.usize = rt.usizeAdd(rt.usizeDiv(k, 4), 1); + _32 = rt.iterRfind(rt.iterStepBy(rt.iterFrom(_51, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it)), _52), (b3: rt.u8): boolean => { + return rt.u8Rem(b3, 3) === 0; + }); + } + put(out, _32); + } else if (pick === 9) { + put(out, rt.iterLast(rt.iterRev(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it))))); + } else if (pick === 10) { + rt.iterExtendBytes(out, rt.iterTake(rt.iterRev(rt.iterMap(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it)), (b2: rt.u8): rt.u8 => { + return b2 ^ 85; + })), k), "next"); + } else if (pick === 11) { + const v: rt.ByteVec = rt.byteVecFrom(Uint8Array.of(170)); + const _67: rt.Iter = rt.iterTake(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it)), k); + rt.iterExtendBytes(v, _67, "next"); + putVec(out, v); + rt.byteVecPush(out, Counted.len$iter_ExactSizeIterator(it) & 0xff); + } else if (pick === 12) { + const zip: rt.Iter<[rt.u8, rt.u8]> = rt.iterZip(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it)), new rt.Range(0, 5)); + while (true) { + const _79: [rt.u8, rt.u8] | undefined = rt.iterToOption(zip.nextBack()); + if (_79 !== undefined) { + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_79[0], _79[1])), undefined, true); + } else { + break; + } + } + } else if (pick === 13) { + const fused: rt.Iter = rt.iterFuse(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it))); + put(out, rt.iterToOption(fused.nextBack())); + rt.byteVecPush(out, fused.len() & 0xff); + rt.iterExtendBytes(out, fused, "next"); + } else if (pick === 14) { + put(out, rt.iterNth(rt.iterRev(rt.iterChain(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it)), rt.iterSlice(Uint8Array.of(7, 8)))), k)); + } else { + const peek: rt.Peekable = rt.iterPeekable(rt.iterFrom(it, (it: Counted.Counted) => Counted.next$iter_Iterator(it), undefined, (it: Counted.Counted) => Counted.sizeHint$iter_Iterator(it), (it: Counted.Counted) => rt.iterFromOption(Counted.nextBack$iter_DoubleEndedIterator(it)), (it: Counted.Counted) => Counted.len$iter_ExactSizeIterator(it))); + put(out, rt.peekablePeek(peek)); + rt.byteVecPush(out, peek.len() & 0xff); + rt.iterExtendBytes(out, rt.iterRev(peek), "next"); + } +} + +/** `it`, consumed by std's adaptor or consumer `pick`, with `k` its count where it takes one. */ +export function consumed$ends_Run(it: Run.Run, pick: rt.u8, k: rt.usize, out: rt.ByteVec): void { + let _32!: rt.u8 | undefined; + if (pick === 0) { + putVec(out, rt.iterToByteVec(rt.iterRev(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it)))), "next")); + } else if (pick === 1) { + putVec(out, rt.iterToByteVec(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))), "next")); + } else if (pick === 2) { + rt.byteVecPush(out, rt.iterRev(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it)))).len() & 0xff); + } else if (pick === 3) { + rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterRev(rt.iterEnumerate(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))))), (_211: [rt.usize, rt.u8]): Uint8Array => { + return Uint8Array.of(_211[0] & 0xff, _211[1]); + }, (value: Uint8Array) => rt.iterSlice(value), false, 2), "next"); + } else if (pick === 4) { + rt.iterExtendBytes(out, rt.iterRev(rt.iterSkip(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))), k)), "next"); + } else if (pick === 5) { + rt.iterExtendBytes(out, rt.iterRev(rt.iterTake(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))), k)), "next"); + } else if (pick === 6) { + const _27: Run.Run = it; + const _28: rt.usize = rt.max(k, 1); + rt.iterExtendBytes(out, rt.iterRev(rt.iterStepBy(rt.iterFrom(_27, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))), _28)), "next"); + } else if (pick === 7) { + put(out, option_map$05nbzug(rt.iterRposition(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))), (b8: rt.u8): boolean => { + return rt.u8Rem(b8, 3) === 0; + }), (i3: rt.usize): rt.u8 => { + return i3 & 0xff; + })); + } else if (pick === 8) { + const _33: rt.usize = rt.usizeRem(k, 4); + if (_33 === 0) { + const _37: Run.Run = it; + const _38: rt.usize = rt.usizeDiv(k, 4); + _32 = rt.iterRfind(rt.iterSkip(rt.iterFrom(_37, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))), _38), (b7: rt.u8): boolean => { + return rt.u8Rem(b7, 3) === 0; + }); + } else if (_33 === 1) { + const _42: Run.Run = it; + const _43: rt.usize = rt.usizeDiv(k, 4); + _32 = rt.iterRfind(rt.iterTake(rt.iterFrom(_42, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))), _43), (b6: rt.u8): boolean => { + return rt.u8Rem(b6, 3) === 0; + }); + } else if (_33 === 2) { + _32 = option_map$1sj2ls1(rt.iterRfind(rt.iterEnumerate(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it)))), (_2: [rt.usize, rt.u8]): boolean => { + return rt.u8Rem(rt.u8Add(_2[0] & 0xff, _2[1]), 3) === 0; + }), (_210: [rt.usize, rt.u8]): rt.u8 => { + return (_210[0] & 0xff) ^ _210[1]; + }); + } else { + const _51: Run.Run = it; + const _52: rt.usize = rt.usizeAdd(rt.usizeDiv(k, 4), 1); + _32 = rt.iterRfind(rt.iterStepBy(rt.iterFrom(_51, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))), _52), (b3: rt.u8): boolean => { + return rt.u8Rem(b3, 3) === 0; + }); + } + put(out, _32); + } else if (pick === 9) { + put(out, rt.iterLast(rt.iterRev(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it)))))); + } else if (pick === 10) { + rt.iterExtendBytes(out, rt.iterTake(rt.iterRev(rt.iterMap(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))), (b2: rt.u8): rt.u8 => { + return b2 ^ 85; + })), k), "next"); + } else if (pick === 11) { + const v: rt.ByteVec = rt.byteVecFrom(Uint8Array.of(170)); + const _67: rt.Iter = rt.iterTake(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))), k); + rt.iterExtendBytes(v, _67, "next"); + putVec(out, v); + rt.byteVecPush(out, rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))).len() & 0xff); + } else if (pick === 12) { + const zip: rt.Iter<[rt.u8, rt.u8]> = rt.iterZip(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))), new rt.Range(0, 5)); + while (true) { + const _79: [rt.u8, rt.u8] | undefined = rt.iterToOption(zip.nextBack()); + if (_79 !== undefined) { + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_79[0], _79[1])), undefined, true); + } else { + break; + } + } + } else if (pick === 13) { + const fused: rt.Iter = rt.iterFuse(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it)))); + put(out, rt.iterToOption(fused.nextBack())); + rt.byteVecPush(out, fused.len() & 0xff); + rt.iterExtendBytes(out, fused, "next"); + } else if (pick === 14) { + put(out, rt.iterNth(rt.iterRev(rt.iterChain(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it))), rt.iterSlice(Uint8Array.of(7, 8)))), k)); + } else { + const peek: rt.Peekable = rt.iterPeekable(rt.iterFrom(it, (it: Run.Run) => Run.next$iter_Iterator(it), undefined, (it: Run.Run) => Run.sizeHint$iter_Iterator(it), (it: Run.Run) => rt.iterFromOption(Run.nextBack$iter_DoubleEndedIterator(it)))); + put(out, rt.peekablePeek(peek)); + rt.byteVecPush(out, peek.len() & 0xff); + rt.iterExtendBytes(out, rt.iterRev(peek), "next"); + } +} + +/** + * `fuse` of a `Flicker`, which reads on past its first `None`, or of a `Lapse`, which + * doesn't, read by the bits of `bits` from either end. + */ +export function fuses(bits: rt.u8, out: rt.ByteVec): void { + let _12!: rt.i32; + const start: rt.u8 = bits >> 4; + const fused: rt.Iter = rt.iterFuse(rt.iterFrom({ _0: start }, (it: Flicker.Flicker) => Flicker.next$iter_Iterator(it), undefined, undefined, (it: Flicker.Flicker) => rt.iterFromOption(Flicker.nextBack$iter_DoubleEndedIterator(it))), true); + let iterStart: rt.i32 = 0; + const iterEnd: rt.i32 = 6; + while ((_12 = iterStart++) < iterEnd) { + if ((rt.u8Shr(bits, rt.i32Rem(_12, 4)) & 1) === 0) { + put(out, rt.iterToOption(fused.next())); + } else { + put(out, rt.iterToOption(fused.nextBack())); + } + } + const lapsed: rt.Iter = rt.iterFuse(rt.iterFrom({ _0: { _0: start } }, (it: Lapse.Lapse) => Lapse.next$iter_Iterator(it))); + let iterStart2: rt.i32 = 0; + const iterEnd2: rt.i32 = 4; + while (iterStart2++ < iterEnd2) { + put(out, rt.iterToOption(lapsed.next())); + } + rt.iterExtendBytes(out, rt.byteVecIntoIter(rt.iterToByteVec(rt.iterTake(rt.iterFlatten(rt.iterSlice([{ _0: start }, { _0: rt.u8WrappingAdd(start, 1) }]), (value: Flicker.Flicker) => rt.iterFrom(value, (it: Flicker.Flicker) => Flicker.next$iter_Iterator(it), undefined, undefined, (it: Flicker.Flicker) => rt.iterFromOption(Flicker.nextBack$iter_DoubleEndedIterator(it))), true), 5), "next")), undefined, true); +} + +//# sourceMappingURL=ends.ts.map diff --git a/ts/fixtures/lang/ends/expected/harness.ts b/ts/fixtures/lang/ends/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/ends/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/ends/expected/lib.ts b/ts/fixtures/lang/ends/expected/lib.ts new file mode 100644 index 000000000..a013b65c0 --- /dev/null +++ b/ts/fixtures/lang/ends/expected/lib.ts @@ -0,0 +1,16 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { ends } from "./ends.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["ends::ends", (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec): undefined => { + ends(a0, a1.data, a1.start, a1.length, a2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/ends.rs b/ts/fixtures/lang/ends/src/ends.rs similarity index 100% rename from ts/fixtures/lang/src/ends.rs rename to ts/fixtures/lang/ends/src/ends.rs diff --git a/ts/fixtures/lang/ends/src/lib.rs b/ts/fixtures/lang/ends/src/lib.rs new file mode 100644 index 000000000..57af8aea8 --- /dev/null +++ b/ts/fixtures/lang/ends/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod ends; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("ends::ends", ends::ends)] +} diff --git a/ts/fixtures/lang/ends/ts.toml b/ts/fixtures/lang/ends/ts.toml new file mode 100644 index 000000000..085122c40 --- /dev/null +++ b/ts/fixtures/lang/ends/ts.toml @@ -0,0 +1,2 @@ +package = "lang-ends-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/errors/Cargo.toml b/ts/fixtures/lang/errors/Cargo.toml new file mode 100644 index 000000000..3f6cba9f5 --- /dev/null +++ b/ts/fixtures/lang/errors/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-errors-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/expected/alloc/string.ts b/ts/fixtures/lang/errors/expected/alloc/string.ts similarity index 100% rename from ts/fixtures/lang/expected/alloc/string.ts rename to ts/fixtures/lang/errors/expected/alloc/string.ts diff --git a/ts/fixtures/lang/errors/expected/core/bool.ts b/ts/fixtures/lang/errors/expected/core/bool.ts new file mode 100644 index 000000000..5c7547377 --- /dev/null +++ b/ts/fixtures/lang/errors/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function then$0afp4no(self: boolean, f: () => rt.Result): rt.Result | undefined { + if (!self) { + return undefined; + } + return f(); +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/expected/core/char/convert.ts b/ts/fixtures/lang/errors/expected/core/char/convert.ts similarity index 100% rename from ts/fixtures/lang/expected/core/char/convert.ts rename to ts/fixtures/lang/errors/expected/core/char/convert.ts diff --git a/ts/fixtures/lang/expected/core/char/methods.ts b/ts/fixtures/lang/errors/expected/core/char/methods.ts similarity index 100% rename from ts/fixtures/lang/expected/core/char/methods.ts rename to ts/fixtures/lang/errors/expected/core/char/methods.ts diff --git a/ts/fixtures/lang/expected/core/error.Error.ts b/ts/fixtures/lang/errors/expected/core/error.Error.ts similarity index 100% rename from ts/fixtures/lang/expected/core/error.Error.ts rename to ts/fixtures/lang/errors/expected/core/error.Error.ts diff --git a/ts/fixtures/lang/expected/core/fmt.ts b/ts/fixtures/lang/errors/expected/core/fmt.ts similarity index 100% rename from ts/fixtures/lang/expected/core/fmt.ts rename to ts/fixtures/lang/errors/expected/core/fmt.ts diff --git a/ts/fixtures/lang/errors/expected/core/num.ts b/ts/fixtures/lang/errors/expected/core/num.ts new file mode 100644 index 000000000..29c91af3f --- /dev/null +++ b/ts/fixtures/lang/errors/expected/core/num.ts @@ -0,0 +1,839 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import { toDigit$01k9ewn } from "../core/char/methods.ts"; + +export function canNotOverflow$0q497dn(radix: rt.u32, isSignedTy: boolean, _digitsData: Uint8Array, _digitsStart: number, digitsLen: number): boolean { + if (!(radix <= 16)) { + return false; + } + return digitsLen <= rt.usizeSub(rt.usizeMul(16, 2), isSignedTy ? 1 : 0); +} + +export function canNotOverflow$0aqh4yo(radix: rt.u32, isSignedTy: boolean, _digitsData: Uint8Array, _digitsStart: number, digitsLen: number): boolean { + if (!(radix <= 16)) { + return false; + } + return digitsLen <= rt.usizeSub(rt.usizeMul(1, 2), isSignedTy ? 1 : 0); +} + +export function canNotOverflow$0uown4l(radix: rt.u32, isSignedTy: boolean, _digitsData: Uint8Array, _digitsStart: number, digitsLen: number): boolean { + if (!(radix <= 16)) { + return false; + } + return digitsLen <= rt.usizeSub(rt.usizeMul(4, 2), isSignedTy ? 1 : 0); +} + +export function canNotOverflow$03q1vv8(radix: rt.u32, isSignedTy: boolean, _digitsData: Uint8Array, _digitsStart: number, digitsLen: number): boolean { + if (!(radix <= 16)) { + return false; + } + return digitsLen <= rt.usizeSub(rt.usizeMul(8, 2), isSignedTy ? 1 : 0); +} + +export function fromAsciiBytesRadixPanic(radix: rt.u32): never { + doPanic$0sx2e1f(radix); +} + +export function doPanic$0sx2e1f(radix: rt.u32): never { + runtime$0bn0geu(radix); +} + +export function runtime$0bn0geu(radix: rt.u32): never { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(radix, f)]; + rt.panicFmt(["from_ascii_bytes_radix: radix must lie in the range `[2, 36]` - found ", args2[0]]); +} + +export function fromAsciiBytesRadixImpl$0xhcrxt(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = rt.i128Gt(0, { hi: -0x80000000, w2: 0, w1: 0, lo: 0 } as rt.i128); + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.i128 = 0; + b5: { + if (!canNotOverflow$0q497dn(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.i128 | undefined = rt.i128CheckedMul(result, radix as rt.i128); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.i128 = _92 as rt.i128; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.i128 | undefined = rt.i128CheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.i128 | undefined = rt.i128CheckedMul(result, radix as rt.i128); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.i128 = _67 as rt.i128; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.i128 | undefined = rt.i128CheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.i128WrappingMul(result, radix as rt.i128); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.i128WrappingSub(result, _49 as rt.i128); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.i128WrappingMul(result, radix as rt.i128); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.i128WrappingAdd(result, _32 as rt.i128); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromAsciiBytesRadixImpl$18og5o1(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = 0 > -128; + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.i8 = 0; + b5: { + if (!canNotOverflow$0aqh4yo(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.i8 | undefined = rt.i8CheckedMul(result, (radix << 24) >> 24); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.i8 = (_92 << 24) >> 24; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.i8 | undefined = rt.i8CheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.i8 | undefined = rt.i8CheckedMul(result, (radix << 24) >> 24); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.i8 = (_67 << 24) >> 24; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.i8 | undefined = rt.i8CheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.i8WrappingMul(result, (radix << 24) >> 24); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.i8WrappingSub(result, (_49 << 24) >> 24); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.i8WrappingMul(result, (radix << 24) >> 24); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.i8WrappingAdd(result, (_32 << 24) >> 24); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromStr$0zyj6he(src: string): rt.Result { + return fromStrRadix$0366bau(src, 10); +} + +export function fromStr$0ovlgjd(src: string): rt.Result { + return fromStrRadix$0s9rspw(src, 10); +} + +export function fromStrRadix$0366bau(src: string, radix: rt.u32): rt.Result { + return fromAsciiBytesRadixImpl$0xhcrxt(rt.stringAsBytes(src), radix); +} + +export function fromStrRadix$0s9rspw(src: string, radix: rt.u32): rt.Result { + return fromAsciiBytesRadixImpl$18og5o1(rt.stringAsBytes(src), radix); +} + +export function fromAsciiBytesRadixImpl$0ax4wbr(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = 0 > 0; + if (src.length === 1) { + const value5 = src.data[src.start]; + if (value5 === 43 || value5 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value6 = src.data[src.start]; + if (value6 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value6 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.u32 = 0; + b5: { + if (!canNotOverflow$0uown4l(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.u32 | undefined = rt.u32CheckedMul(result, radix); + const _84: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_84 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.u32 = _84; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _95: rt.u32 | undefined = rt.u32CheckedSub(result, x4); + if (_95 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _95; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.u32 | undefined = rt.u32CheckedMul(result, radix); + const _61: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_61 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.u32 = _61; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _72: rt.u32 | undefined = rt.u32CheckedAdd(result, x3); + if (_72 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _72; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.u32WrappingMul(result, radix); + const _46: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_46 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u32WrappingSub(result, _46); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.u32WrappingMul(result, radix); + const _31: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_31 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u32WrappingAdd(result, _31); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromAsciiBytesRadixImpl$02xpj41(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = rt.u64Gt(0, 0); + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.u64 = 0; + b5: { + if (!canNotOverflow$03q1vv8(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.u64 | undefined = rt.u64CheckedMul(result, radix as rt.u64); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.u64 = _92 as rt.u64; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.u64 | undefined = rt.u64CheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.u64 | undefined = rt.u64CheckedMul(result, radix as rt.u64); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.u64 = _67 as rt.u64; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.u64 | undefined = rt.u64CheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.u64WrappingMul(result, radix as rt.u64); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u64WrappingSub(result, _49 as rt.u64); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.u64WrappingMul(result, radix as rt.u64); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u64WrappingAdd(result, _32 as rt.u64); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromAsciiBytesRadixImpl$1n9fygl(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = 0 > 0; + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.u8 = 0; + b5: { + if (!canNotOverflow$0aqh4yo(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.u8 | undefined = rt.u8CheckedMul(result, radix & 0xff); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.u8 = _92 & 0xff; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.u8 | undefined = rt.u8CheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.u8 | undefined = rt.u8CheckedMul(result, radix & 0xff); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.u8 = _67 & 0xff; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.u8 | undefined = rt.u8CheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.u8WrappingMul(result, radix & 0xff); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u8WrappingSub(result, _49 & 0xff); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.u8WrappingMul(result, radix & 0xff); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u8WrappingAdd(result, _32 & 0xff); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromStr$1ypcnp8(src: string): rt.Result { + return fromStrRadix$1gp4jqq(src, 10); +} + +export function fromStr$1hq0zfa(src: string): rt.Result { + return fromStrRadix$0nj08um(src, 10); +} + +export function fromStrRadix$1gp4jqq(src: string, radix: rt.u32): rt.Result { + return fromAsciiBytesRadixImpl$02xpj41(rt.stringAsBytes(src), radix); +} + +export function fromStrRadix$0nj08um(src: string, radix: rt.u32): rt.Result { + return fromAsciiBytesRadixImpl$1n9fygl(rt.stringAsBytes(src), radix); +} + +//# sourceMappingURL=num.ts.map diff --git a/ts/fixtures/lang/expected/core/num/error.ts b/ts/fixtures/lang/errors/expected/core/num/error.ts similarity index 100% rename from ts/fixtures/lang/expected/core/num/error.ts rename to ts/fixtures/lang/errors/expected/core/num/error.ts diff --git a/ts/fixtures/lang/expected/core/num/float_parse.ts b/ts/fixtures/lang/errors/expected/core/num/float_parse.ts similarity index 100% rename from ts/fixtures/lang/expected/core/num/float_parse.ts rename to ts/fixtures/lang/errors/expected/core/num/float_parse.ts diff --git a/ts/fixtures/lang/errors/expected/core/num/nonzero.ts b/ts/fixtures/lang/errors/expected/core/num/nonzero.ts new file mode 100644 index 000000000..18d557d6e --- /dev/null +++ b/ts/fixtures/lang/errors/expected/core/num/nonzero.ts @@ -0,0 +1,26 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../../rt.ts"; +import { fromAsciiBytesRadixImpl$0ax4wbr as num_fromAsciiBytesRadixImpl$0ax4wbr } from "../../core/num.ts"; + +export function fromAsciiBytesRadixImpl$0v1vsb2(src: rt.ByteSlice, radix: rt.u32): rt.Result { + const _3: rt.Result = num_fromAsciiBytesRadixImpl$0ax4wbr(src, radix); + if (_3.ok) { + const _7: rt.u32 | undefined = rt.nonZero(_3.value); + if (_7 !== undefined) { + return rt.Ok(_7); + } + return rt.Err({ kind: "Zero" as rt.IntErrorKind }); + } + return _3; +} + +export function fromStr$0gvyqp3(src: string): rt.Result { + return fromStrRadix$18imw6k(src, 10); +} + +export function fromStrRadix$18imw6k(src: string, radix: rt.u32): rt.Result { + return fromAsciiBytesRadixImpl$0v1vsb2(rt.stringAsBytes(src), radix); +} + +//# sourceMappingURL=nonzero.ts.map diff --git a/ts/fixtures/lang/errors/expected/core/result.ts b/ts/fixtures/lang/errors/expected/core/result.ts new file mode 100644 index 000000000..b4a2e6f66 --- /dev/null +++ b/ts/fixtures/lang/errors/expected/core/result.ts @@ -0,0 +1,232 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import { eq$09knsz6 as string_eq$09knsz6 } from "../alloc/string.ts"; +import { eq$09vw48j as convert_eq$09vw48j } from "../core/char/convert.ts"; +import { eq$08q6k9m as fmt_eq$08q6k9m } from "../core/fmt.ts"; +import { eq$1nf2rde as num_error_eq$1nf2rde, eq$18sin5z as num_error_eq$18sin5z } from "../core/num/error.ts"; +import { eq$1horntk as float_parse_eq$1horntk } from "../core/num/float_parse.ts"; +import { eq$1v93ipo as str_error_eq$1v93ipo, eq$1f3e51k as str_error_eq$1f3e51k } from "../core/str/error.ts"; +import { eq$0dhyfbb as time_eq$0dhyfbb } from "../core/time.ts"; +import type * as Failure from "../errors.Failure.ts"; + +export function eq$04qb8k3(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.u8 | undefined }).value; + } + return num_error_eq$18sin5z(self.error, (other as { ok: false; error: rt.ParseIntError }).error); +} + +export function eq$10fppe8(self: rt.Result, rt.ParseBoolError>, other: rt.Result, rt.ParseBoolError>): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return eq$04iua4k(self.value, (other as { ok: true; value: rt.Result }).value); + } + return str_error_eq$1f3e51k(self.error, (other as { ok: false; error: rt.ParseBoolError }).error); +} + +export function eq$0ecfqx9(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: string }).value; + } + return string_eq$09knsz6(self.error, (other as { ok: false; error: rt.FromUtf8Error }).error); +} + +export function eq$0nlhjpf(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: boolean }).value; + } + return str_error_eq$1f3e51k(self.error, (other as { ok: false; error: rt.ParseBoolError }).error); +} + +export function eq$04iua4k(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.char }).value; + } + return convert_eq$09vw48j(self.error, (other as { ok: false; error: rt.ParseCharError }).error); +} + +export function eq$1dhtbkj(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.f64 }).value; + } + return float_parse_eq$1horntk(self.error, (other as { ok: false; error: rt.ParseFloatError }).error); +} + +export function eq$0pe0qmq(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return rt.i128Eq(self.value, (other as { ok: true; value: rt.i128 }).value); + } + return num_error_eq$18sin5z(self.error, (other as { ok: false; error: rt.ParseIntError }).error); +} + +export function eq$1mpp8xa(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.i8 }).value; + } + return num_error_eq$18sin5z(self.error, (other as { ok: false; error: rt.ParseIntError }).error); +} + +export function eq$0grmb7g(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.i8 }).value; + } + return num_error_eq$1nf2rde(self.error, (other as { ok: false; error: rt.TryFromIntError }).error); +} + +export function eq$19kc15f(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.u32 }).value; + } + return num_error_eq$18sin5z(self.error, (other as { ok: false; error: rt.ParseIntError }).error); +} + +export function eq$0rj0czq(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: string }).value; + } + return str_error_eq$1v93ipo(self.error, (other as { ok: false; error: rt.Utf8Error }).error); +} + +export function eq$1hq3neq(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return rt.durationEq(self.value, (other as { ok: true; value: rt.Duration }).value); + } + return time_eq$0dhyfbb(self.error, (other as { ok: false; error: rt.TryFromFloatSecsError }).error); +} + +export function eq$08241oi(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.u16 }).value; + } + return true; +} + +export function eq$0bl30vt(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return rt.u64Eq(self.value, (other as { ok: true; value: rt.u64 }).value); + } + return num_error_eq$18sin5z(self.error, (other as { ok: false; error: rt.ParseIntError }).error); +} + +export function eq$1fkhuzl(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.u8 }).value; + } + return self.error === (other as { ok: false; error: rt.IntErrorKind }).error; +} + +export function eq$0p1bb4y(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.u8 }).value; + } + return num_error_eq$18sin5z(self.error, (other as { ok: false; error: rt.ParseIntError }).error); +} + +export function eq$03gbayb(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return true; + } + return fmt_eq$08q6k9m(self.error, (other as { ok: false; error: rt.FmtError }).error); +} + +export function err$1ujom0k(self: rt.Result): rt.ParseBoolError | undefined { + if (self.ok) { + return undefined; + } + return self.error; +} + +export function err$02r96h1(self: rt.Result): rt.ParseCharError | undefined { + if (self.ok) { + return undefined; + } + return self.error; +} + +export function err$0jf6smd(self: rt.Result): rt.ParseIntError | undefined { + if (self.ok) { + return undefined; + } + return self.error; +} + +export function map$0fm1w6u(self: rt.Result, op: (a0: boolean) => rt.Result): rt.Result, rt.ParseBoolError> { + if (self.ok) { + return rt.Ok(op(self.value)); + } + return self as rt.Result, rt.ParseBoolError>; +} + +export function map$0r57egs(self: rt.Result, op: (a0: rt.u8) => rt.u8 | undefined): rt.Result { + if (self.ok) { + return rt.Ok(op(self.value)); + } + return self as rt.Result; +} + +export function mapErr$1ff8zoy(self: rt.Result, _: (a0: rt.ParseIntError) => Failure.Failure): rt.Result { + if (self.ok) { + return self as rt.Result; + } + return rt.Err({ tag: "Parse", _0: self.error } as Failure.Failure); +} + +export function mapErr$0u5yxjj(self: rt.Result, op: (a0: rt.ParseIntError) => rt.IntErrorKind): rt.Result { + if (self.ok) { + return self as rt.Result; + } + return rt.Err(op(self.error)); +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/errors/expected/core/str.ts b/ts/fixtures/lang/errors/expected/core/str.ts new file mode 100644 index 000000000..36543d824 --- /dev/null +++ b/ts/fixtures/lang/errors/expected/core/str.ts @@ -0,0 +1,32 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import { fromStr$0zyj6he as num_fromStr$0zyj6he, fromStr$0ovlgjd as num_fromStr$0ovlgjd, fromStr$1ypcnp8 as num_fromStr$1ypcnp8, fromStr$1hq0zfa as num_fromStr$1hq0zfa } from "../core/num.ts"; +import { fromStr$0gvyqp3 as nonzero_fromStr$0gvyqp3 } from "../core/num/nonzero.ts"; +import { fromStr$05d44vn as traits_fromStr$05d44vn } from "../core/str/traits.ts"; + +export function parse$0vh4cry(self: string): rt.Result { + return traits_fromStr$05d44vn(self); +} + +export function parse$082ztwj(self: string): rt.Result { + return num_fromStr$0zyj6he(self); +} + +export function parse$1ci7nyc(self: string): rt.Result { + return num_fromStr$0ovlgjd(self); +} + +export function parse$1s5pqso(self: string): rt.Result { + return nonzero_fromStr$0gvyqp3(self); +} + +export function parse$0o4ono0(self: string): rt.Result { + return num_fromStr$1ypcnp8(self); +} + +export function parse$0at0fdl(self: string): rt.Result { + return num_fromStr$1hq0zfa(self); +} + +//# sourceMappingURL=str.ts.map diff --git a/ts/fixtures/lang/expected/core/str/error.ts b/ts/fixtures/lang/errors/expected/core/str/error.ts similarity index 100% rename from ts/fixtures/lang/expected/core/str/error.ts rename to ts/fixtures/lang/errors/expected/core/str/error.ts diff --git a/ts/fixtures/lang/expected/core/str/traits.ts b/ts/fixtures/lang/errors/expected/core/str/traits.ts similarity index 100% rename from ts/fixtures/lang/expected/core/str/traits.ts rename to ts/fixtures/lang/errors/expected/core/str/traits.ts diff --git a/ts/fixtures/lang/expected/core/time.ts b/ts/fixtures/lang/errors/expected/core/time.ts similarity index 100% rename from ts/fixtures/lang/expected/core/time.ts rename to ts/fixtures/lang/errors/expected/core/time.ts diff --git a/ts/fixtures/lang/expected/errors.Coded.ts b/ts/fixtures/lang/errors/expected/errors.Coded.ts similarity index 71% rename from ts/fixtures/lang/expected/errors.Coded.ts rename to ts/fixtures/lang/errors/expected/errors.Coded.ts index 4eced1b6a..2cf004028 100644 --- a/ts/fixtures/lang/expected/errors.Coded.ts +++ b/ts/fixtures/lang/errors/expected/errors.Coded.ts @@ -2,12 +2,12 @@ import * as rt from "./rt.ts"; import { drop$errors_Failure } from "./lib.ts"; -import type * as error_Error from "./core/error.Error.ts"; +import type * as Error from "./core/error.Error.ts"; import * as Failure from "./errors.Failure.ts"; /** The crate's own trait over `Error`, as moq's transports' errors are. */ export type Coded = - | { code$Coded: () => rt.u8; source$Error: () => error_Error.Error | undefined; fmt$Display: (a0: rt.Formatter) => rt.Result; fmt$Debug: (a0: rt.Formatter) => rt.Result }; + | { code$Coded: () => rt.u8; source$Error: () => Error.Error | undefined; fmt$Display: (a0: rt.Formatter) => rt.Result; fmt$Debug: (a0: rt.Formatter) => rt.Result }; export class of$errors_Failure { v: Failure.Failure; @@ -32,7 +32,7 @@ export class of$errors_Failure { return Failure.fmt$fmt_Display(this.v, a); } - source$Error(): error_Error.Error | undefined { + source$Error(): Error.Error | undefined { return Failure.source$Error(this.v); } } diff --git a/ts/fixtures/lang/expected/errors.Failure.ts b/ts/fixtures/lang/errors/expected/errors.Failure.ts similarity index 88% rename from ts/fixtures/lang/expected/errors.Failure.ts rename to ts/fixtures/lang/errors/expected/errors.Failure.ts index 6b95b8923..bbd88c74b 100644 --- a/ts/fixtures/lang/expected/errors.Failure.ts +++ b/ts/fixtures/lang/errors/expected/errors.Failure.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import * as error_Error from "./core/error.Error.ts"; +import * as Error from "./core/error.Error.ts"; import * as Leaf from "./errors.Leaf.ts"; export function fmt$fmt_Debug(self: Failure, f: rt.Formatter): rt.Result { @@ -38,14 +38,14 @@ export function fmt$fmt_Display(self: Failure, f: rt.Formatter): rt.Result { const _3: string = "Leaf"; @@ -31,7 +31,7 @@ export function fmt$fmt_Display(self: Leaf, f: rt.Formatter): rt.Result { @@ -27,7 +27,7 @@ export function fmt$fmt_Display(self: Transported, f: rt.Formatter): rt.Result | undefined>, out: rt.ByteVec): void { @@ -549,13 +549,13 @@ export function DROPPED$init(): rt.Cell { } /** Each error in the chain, by `Display` and `Debug`. */ -export function chain(e: error_Error.Error): string { +export function chain(e: Error.Error): string { const args2: rt.Fmt[] = [(f: rt.Formatter) => e.fmt$Display(f), (f: rt.Formatter) => e.fmt$Debug(f)]; let s: string = rt.fmtFormat([args2[0], " ", args2[1]]); - let cur: error_Error.Error | undefined = e.source$Error(); + let cur: Error.Error | undefined = e.source$Error(); while (true) { if (cur !== undefined) { - const c: error_Error.Error = cur; + const c: Error.Error = cur; const args4: rt.Fmt[] = [(f: rt.Formatter) => c.fmt$Display(f), (f: rt.Formatter) => c.fmt$Debug(f)]; const _17: string = rt.fmtFormat([" <- ", args4[0], " ", args4[1]]); s = s + _17; @@ -582,7 +582,7 @@ export function failure(kind: rt.u8, n: rt.u8): Failure.Failure { } /** `?` boxes a `Failure` as a `dyn Error`, as does `into`. */ -export function checked(kind: rt.u8, n: rt.u8): rt.Result { +export function checked(kind: rt.u8, n: rt.u8): rt.Result { if (!(rt.u8Rem(n, 4) === 0)) { const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(n, f)]; const _8: rt.Result = result_mapErr$1ff8zoy(num_fromStr$1hq0zfa(rt.fmtFormat([args2[0], args2[0]])), (a0: rt.ParseIntError): Failure.Failure => { @@ -591,9 +591,9 @@ export function checked(kind: rt.u8, n: rt.u8): rt.Result rt.fmtPad(f, _21), (f: rt.Formatter) => rt.fmtPad(f, _26)]; const _17: string = rt.fmtFormat([args2[0], " | ", args2[1], " | "]); _29[Symbol.dispose](); drop$errors_Failure(_24); - fmt_put(out, _17); - const part = chain(new error_Error.of$num_ParseIntError(rt.resultUnwrapErr(num_fromStr$1hq0zfa("x"), rt.u8Debug))); + put(out, _17); + const part = chain(new Error.of$num_ParseIntError(rt.resultUnwrapErr(num_fromStr$1hq0zfa("x"), rt.u8Debug))); const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, part)]; - fmt_put(out, rt.fmtFormat([args4[0], " | "])); + put(out, rt.fmtFormat([args4[0], " | "])); const held: Failure.Failure = failure(a, b); - const _64: string = chain(new error_Error.of$boxed_Box_errors_Failure(held)); - const _68: string = chain(new error_Error.of$ref_errors_Failure(held)); + const _64: string = chain(new Error.of$boxed_Box_errors_Failure(held)); + const _68: string = chain(new Error.of$ref_errors_Failure(held)); const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, _64), (f: rt.Formatter) => rt.fmtPad(f, _68)]; - fmt_put(out, rt.fmtFormat([args6[0], " | ", args6[1], " | "])); + put(out, rt.fmtFormat([args6[0], " | ", args6[1], " | "])); const coded: Coded.Coded = new Coded.of$errors_Failure(failure(b, a)); - const up: error_Error.Error = coded; + const up: Error.Error = coded; const _89: rt.u8 = coded.code$Coded(); const _92: string = chain(up); const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(_89, f), (f: rt.Formatter) => rt.fmtPad(f, _92)]; - fmt_put(out, rt.fmtFormat([args8[0], " ", args8[1], " | "])); + put(out, rt.fmtFormat([args8[0], " ", args8[1], " | "])); const boxed: Transported.Transported = new Transported.Transported(coded); - const _107: string = chain(new error_Error.of$errors_Transported(boxed)); + const _107: string = chain(new Error.of$errors_Transported(boxed)); const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, _107), (f: rt.Formatter) => Transported.fmt$fmt_Debug(boxed, f)]; - fmt_put(out, rt.fmtFormat([args10[0], " ", rt.fmtSpec({ alternate: true }, args10[1]), " | "])); - local_set$0st49po(DROPPED, 0); - const results: rt.Result[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(new rt.ByteSlice(dataData, dataStart + 2, dataLen - 2))), (_2: rt.u8): rt.Result => { + put(out, rt.fmtFormat([args10[0], " ", rt.fmtSpec({ alternate: true }, args10[1]), " | "])); + set$0st49po(DROPPED, 0); + const results: rt.Result[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(new rt.ByteSlice(dataData, dataStart + 2, dataLen - 2))), (_2: rt.u8): rt.Result => { const n: rt.u8 = _2; return checked(rt.u8WrappingAdd(a, n), n); }), undefined, 8, true); @@ -637,31 +637,31 @@ export function objects(dataData: Uint8Array, dataStart: number, dataLen: number if (_127.ok) { const arg = _127.value; const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(arg, f)]; - fmt_put(out, rt.fmtFormat([args12[0], " "])); + put(out, rt.fmtFormat([args12[0], " "])); } else { const part2 = chain(_127.error); const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, part2)]; - fmt_put(out, rt.fmtFormat([args14[0], " "])); + put(out, rt.fmtFormat([args14[0], " "])); } } rt.dropAll(results, drop$Result_u8_boxed_Box_dyn_Error_marker_Sync_marker_Send); - const part3 = local_get$1ei2eoj(DROPPED); + const part3 = get$1ei2eoj(DROPPED); const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part3, f)]; - fmt_put(out, rt.fmtFormat(["| ", args16[0], " "])); - local_set$0st49po(DROPPED, 0); + put(out, rt.fmtFormat(["| ", args16[0], " "])); + set$0st49po(DROPPED, 0); const leaf: Leaf.Leaf = new Leaf.Leaf(b); - const borrowed: error_Error.Error = new error_Error.of$ref_errors_Leaf(leaf); + const borrowed: Error.Error = new Error.of$ref_errors_Leaf(leaf); const part4 = chain(borrowed); const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, part4)]; - fmt_put(out, rt.fmtFormat([args18[0], " "])); + put(out, rt.fmtFormat([args18[0], " "])); rt.drop(borrowed); - const part5 = local_get$1ei2eoj(DROPPED); + const part5 = get$1ei2eoj(DROPPED); const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part5, f)]; - fmt_put(out, rt.fmtFormat([args20[0], " "])); + put(out, rt.fmtFormat([args20[0], " "])); leaf[Symbol.dispose](); - const part6 = local_get$1ei2eoj(DROPPED); + const part6 = get$1ei2eoj(DROPPED); const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part6, f)]; - fmt_put(out, rt.fmtFormat([args22[0]])); + put(out, rt.fmtFormat([args22[0]])); boxed[Symbol.dispose](); drop$errors_Failure(held); } diff --git a/ts/fixtures/lang/errors/expected/harness.ts b/ts/fixtures/lang/errors/expected/harness.ts new file mode 100644 index 000000000..3b7bbcfb0 --- /dev/null +++ b/ts/fixtures/lang/errors/expected/harness.ts @@ -0,0 +1,46 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/errors/expected/lib.ts b/ts/fixtures/lang/errors/expected/lib.ts new file mode 100644 index 000000000..227f1438b --- /dev/null +++ b/ts/fixtures/lang/errors/expected/lib.ts @@ -0,0 +1,30 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import type * as Error from "./core/error.Error.ts"; +import { eqs, objects } from "./errors.ts"; +import type * as Failure from "./errors.Failure.ts"; + +export function drop$Result_u8_boxed_Box_dyn_Error_marker_Sync_marker_Send(_1: rt.Result): void { + if (!_1.ok) { + rt.drop(_1.error); + } +} + +export function drop$errors_Failure(_1: Failure.Failure): void { + if (_1.tag === "Wrapped") { + _1._0[Symbol.dispose](); + } +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["errors::eqs", eqs as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["errors::objects", (_22: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + objects(data.data, data.start, data.length, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/errors/expected/std/thread/local.ts b/ts/fixtures/lang/errors/expected/std/thread/local.ts new file mode 100644 index 000000000..68c0c768b --- /dev/null +++ b/ts/fixtures/lang/errors/expected/std/thread/local.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../../rt.ts"; + +export function set$0st49po(self: rt.LocalKey>, value: rt.u32): void { + rt.localKeyInitializeWith(self, new rt.Cell(value), (value2: rt.Cell | undefined, cell: rt.Cell): undefined => { + if (value2 !== undefined) { + rt.cellSet(cell, value2.v); + } + }); +} + +export function get$1ei2eoj(self: rt.LocalKey>): rt.u32 { + return ((a0: rt.Cell): rt.u32 => { + return a0.v; + })(self.get()); +} + +//# sourceMappingURL=local.ts.map diff --git a/ts/fixtures/lang/src/errors.rs b/ts/fixtures/lang/errors/src/errors.rs similarity index 99% rename from ts/fixtures/lang/src/errors.rs rename to ts/fixtures/lang/errors/src/errors.rs index e3cc7253a..8be666d9a 100644 --- a/ts/fixtures/lang/src/errors.rs +++ b/ts/fixtures/lang/errors/src/errors.rs @@ -12,7 +12,7 @@ use std::num::{IntErrorKind, NonZero, ParseIntError, TryFromIntError}; use std::str::FromStr; use std::time::Duration; -use crate::fmt::put; +use crate::harness::put; /// Strings that parse into one of the types, or fail each way it can: empty, an invalid /// digit, past either end, zero, more than one char, a sign alone, and NaN. diff --git a/ts/fixtures/lang/errors/src/lib.rs b/ts/fixtures/lang/errors/src/lib.rs new file mode 100644 index 000000000..f96979a67 --- /dev/null +++ b/ts/fixtures/lang/errors/src/lib.rs @@ -0,0 +1,22 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod errors; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("errors::eqs", errors::eqs), + ("errors::objects", |_, data, out| errors::objects(data, out)), + ] +} diff --git a/ts/fixtures/lang/errors/ts.toml b/ts/fixtures/lang/errors/ts.toml new file mode 100644 index 000000000..a133b2be6 --- /dev/null +++ b/ts/fixtures/lang/errors/ts.toml @@ -0,0 +1,2 @@ +package = "lang-errors-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/expected/core/bool.ts b/ts/fixtures/lang/expected/core/bool.ts deleted file mode 100644 index 579a88bd3..000000000 --- a/ts/fixtures/lang/expected/core/bool.ts +++ /dev/null @@ -1,311 +0,0 @@ -// Generated by rust2-ts. Do not edit. - -import * as rt from "../rt.ts"; -import type * as borrows_Tagged from "../borrows.Tagged.ts"; -import * as defaults_Made from "../defaults.Made.ts"; -import type * as Hop from "../keys.Hop.ts"; -import type * as Way from "../keys.Way.ts"; -import type * as Void from "../shapes.Void.ts"; - -export function thenSome$0ztng9q(self: boolean, t: rt.Result): rt.Result | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$0rsp0eu(self: boolean, t: Uint8Array): Uint8Array | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$0kwiij6(self: boolean, t: rt.i16): rt.i16 | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$0n2gkz4(self: boolean, t: rt.i32): rt.i32 | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$0tjggir(self: boolean, t: rt.i64): rt.i64 | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$1s4itlz(self: boolean, t: rt.i8): rt.i8 | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$0jkru5t(self: boolean, t: rt.isize): rt.isize | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$1d6toqn(self: boolean, t: undefined): undefined | rt.None { - if (!self) { - return rt.None; - } - return t; -} - -export function thenSome$0zrlsto(self: boolean, t: rt.ByteSlice): rt.ByteSlice | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$0xksuo2(self: boolean, t: rt.Place): rt.Place | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$0sf2w1i(self: boolean, t: rt.Place): rt.Place | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$0d5am30(self: boolean, t: rt.u8): rt.u8 | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$1jqdi5p(self: boolean, t: rt.Duration): rt.Duration | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$0j2n934(self: boolean, t: [rt.u8, rt.u16]): [rt.u8, rt.u16] | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$03chm1q(self: boolean, t: [rt.u8, rt.u8]): [rt.u8, rt.u8] | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$0b23a33(self: boolean, t: rt.u16): rt.u16 | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$1af3oea(self: boolean, t: rt.u32): rt.u32 | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$1ugl8af(self: boolean, t: rt.u64): rt.u64 | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function thenSome$1j8foe9(self: boolean, _: undefined): undefined | rt.None { - if (!self) { - return rt.None; - } - return undefined; -} - -export function thenSome$07z8k4h(self: boolean, t: rt.usize): rt.usize | undefined { - if (!self) { - return undefined; - } - return t; -} - -export function then$16ew6vr(self: boolean, f: () => rt.u8 | undefined): rt.u8 | undefined | rt.None { - if (!self) { - return rt.None; - } - return f(); -} - -export function then$0afp4no(self: boolean, f: () => rt.Result): rt.Result | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$0h950d8(self: boolean, _: () => rt.u16[]): rt.u16[] | undefined { - if (!self) { - return undefined; - } - return []; -} - -export function then$1i9qaz4(self: boolean, _: () => rt.ByteVec): rt.ByteVec | undefined { - if (!self) { - return undefined; - } - return new rt.ByteVec(); -} - -export function then$0ozmvid(self: boolean, f: () => rt.ByteVec): rt.ByteVec | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$0l8o6jo(self: boolean, f: () => rt.u32[]): rt.u32[] | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$11x7xqs(self: boolean, f: () => Uint8Array): Uint8Array | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$0b2eeh4(self: boolean, f: () => Array): Array | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$1ghn4qd(self: boolean, f: () => boolean[]): boolean[] | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$1dhbcvy(self: boolean, f: () => rt.char[]): rt.char[] | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$1nf265w(self: boolean, f: () => rt.i32[]): rt.i32[] | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$1c9ust9(self: boolean, f: () => Hop.Hop[]): Hop.Hop[] | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$0l07w38(self: boolean, f: () => rt.u16[]): rt.u16[] | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$0uovwq9(self: boolean, f: () => rt.u64[]): rt.u64[] | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$1j955kq(self: boolean, _: () => defaults_Made.Made): defaults_Made.Made | undefined { - if (!self) { - return undefined; - } - return defaults_Made.default$Default(); -} - -export function then$0ea5h05(self: boolean, f: () => rt.u32): rt.u32 | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$1jgls7y(self: boolean, f: () => rt.RefCell): rt.RefCell | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$0wlzj76(self: boolean, f: () => rt.Ordering): rt.Ordering | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$18np55d(self: boolean, f: () => Way.Way | undefined): Way.Way | undefined | rt.None { - if (!self) { - return rt.None; - } - return f(); -} - -export function then$0w2ymju(self: boolean, f: () => rt.ByteSlice): rt.ByteSlice | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$0havnzo(self: boolean, f: () => string): string | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$1t2ieki(self: boolean, f: () => [rt.u64 | undefined, defaults_Made.Made]): [rt.u64 | undefined, defaults_Made.Made] | undefined { - if (!self) { - return undefined; - } - return f(); -} - -export function then$1btzga3(self: boolean, f: () => rt.u8): rt.u8 | undefined { - if (!self) { - return undefined; - } - return f(); -} - -//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/expected/core/option.ts b/ts/fixtures/lang/expected/core/option.ts deleted file mode 100644 index 755b61c8c..000000000 --- a/ts/fixtures/lang/expected/core/option.ts +++ /dev/null @@ -1,2044 +0,0 @@ -// Generated by rust2-ts. Do not edit. - -import * as rt from "../rt.ts"; -import { opaque as args_opaque, len as args_len } from "../args.ts"; -import type * as borrows_Noisy from "../borrows.Noisy.ts"; -import type * as borrows_Tagged from "../borrows.Tagged.ts"; -import type * as bounds_Item from "../bounds.Item.ts"; -import * as clones_Logged from "../clones.Logged.ts"; -import type * as ByRef from "../collections.ByRef.ts"; -import type * as ByVal from "../collections.ByVal.ts"; -import type * as Mixed from "../collections.Mixed.ts"; -import type * as collections_Nibble from "../collections.Nibble.ts"; -import type * as collections_Picky from "../collections.Picky.ts"; -import type * as Rank from "../collections.Rank.ts"; -import type * as collections_Tally from "../collections.Tally.ts"; -import type * as ArcNode from "../counts.ArcNode.ts"; -import type * as ArcShared from "../counts.ArcShared.ts"; -import type * as counts_Counted from "../counts.Counted.ts"; -import type * as Id from "../counts.Id.ts"; -import type * as counts_Noisy from "../counts.Noisy.ts"; -import type * as RcNode from "../counts.RcNode.ts"; -import type * as RcShared from "../counts.RcShared.ts"; -import type * as counts_Twin from "../counts.Twin.ts"; -import type * as cycles_Logged from "../cycles.Logged.ts"; -import * as defaults_Made from "../defaults.Made.ts"; -import type * as dyns_Shape from "../dyns.Shape.ts"; -import type * as dyns_Tagged from "../dyns.Tagged.ts"; -import * as edits_Named from "../edits.Named.ts"; -import type * as Ticked from "../generics.Ticked.ts"; -import type * as heap_Fault from "../heap.Fault.ts"; -import type * as hints_Unit from "../hints.Unit.ts"; -import type * as Badge from "../iters.Badge.ts"; -import type * as Quarter from "../iters.Quarter.ts"; -import type * as Tilt from "../iters.Tilt.ts"; -import { side, order as keys_order } from "../keys.ts"; -import type * as Hop from "../keys.Hop.ts"; -import type * as Side from "../keys.Side.ts"; -import type * as Way from "../keys.Way.ts"; -import type * as locals_Noisy from "../locals.Noisy.ts"; -import type * as orders_Item from "../orders.Item.ts"; -import type * as Loaded from "../pointers.Loaded.ts"; -import type * as pointers_Pair from "../pointers.Pair.ts"; -import type * as returns_Error from "../returns.Error.ts"; -import { sum as separated_sum, sumWords, sumPairs, sumTexts, sumTwos } from "../separated.ts"; -import type * as separated_Pair from "../separated.Pair.ts"; -import { from$convert_From_shapes_Dir_u8 } from "../shapes.ts"; -import type * as shapes_Dir from "../shapes.Dir.ts"; -import type * as Meters from "../shapes.Meters.ts"; -import type * as Point from "../shapes.Point.ts"; -import type * as shapes_Shape from "../shapes.Shape.ts"; -import { digest as slices_digest, digestWords } from "../slices.ts"; -import type * as slices_Item from "../slices.Item.ts"; -import * as slices_Noisy from "../slices.Noisy.ts"; -import type * as slices_Pair from "../slices.Pair.ts"; -import type * as Loud from "../zeros.Loud.ts"; -import * as zeros_Tagged from "../zeros.Tagged.ts"; - -export function isSomeAnd$08u1px1(self: rt.Ordering | undefined, f: (a0: rt.Ordering) => boolean): boolean { - if (self === undefined) { - return false; - } - return f(self); -} - -export function isSomeAnd$09tpccf(self: rt.u8 | undefined, f: (a0: rt.u8) => boolean): boolean { - if (self === undefined) { - return false; - } - return f(self); -} - -export function isNoneOr$1s1o3ss(self: rt.u8 | undefined, f: (a0: rt.u8) => boolean): boolean { - if (self === undefined) { - return true; - } - return f(self); -} - -export function unwrapOr$1kxjsqb(self: rt.u8 | undefined | rt.None, default_: rt.u8 | undefined): rt.u8 | undefined { - if (self === rt.None) { - return default_; - } - return self; -} - -export function unwrapOr$17ntxfo(self: rt.Result | undefined, default_: rt.Result): rt.Result { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$1la41a6(self: Uint8Array | undefined, default_: Uint8Array): Uint8Array { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$1iemzn8(self: string | undefined, default_: string): string { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$0k15iai(self: rt.char | undefined, default_: rt.char): rt.char { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$0l1fs14(self: rt.Ordering | undefined, default_: rt.Ordering): rt.Ordering { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$0ujf6zi(self: counts_Twin.Twin | undefined, default_: counts_Twin.Twin): counts_Twin.Twin { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$19h8ynp(self: rt.f32 | undefined, default_: rt.f32): rt.f32 { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$1ayoj7n(self: rt.f64 | undefined, default_: rt.f64): rt.f64 { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$00uis1j(self: rt.i64 | undefined, default_: rt.i64): rt.i64 { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$1tvry1i(self: rt.u64 | undefined, default_: rt.u64): rt.u64 { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$0mkoact(self: Loaded.Loaded | undefined, default_: Loaded.Loaded): Loaded.Loaded { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$1rbuegs(self: rt.ByteSlice | undefined, default_: rt.ByteSlice): rt.ByteSlice { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$039uout(self: edits_Named.Named[] | undefined, default_: edits_Named.Named[]): edits_Named.Named[] { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$0x6fy3l(self: [rt.u8, rt.u8] | undefined, default_: [rt.u8, rt.u8]): [rt.u8, rt.u8] { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$14m5xjm(self: [rt.usize, rt.u8] | undefined, default_: [rt.usize, rt.u8]): [rt.usize, rt.u8] { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$1j4op5y(self: rt.u16 | undefined, default_: rt.u16): rt.u16 { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$11c0we2(self: rt.u32 | undefined, default_: rt.u32): rt.u32 { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOr$0l7j3f6(self: rt.usize | undefined, default_: rt.usize): rt.usize { - if (self === undefined) { - return default_; - } - return self; -} - -export function unwrapOrElse$1badkpb(self: string | undefined, f: () => string): string { - if (self === undefined) { - return f(); - } - return self; -} - -export function unwrapOrElse$13moxzl(self: rt.u8 | undefined, f: () => rt.u8): rt.u8 { - if (self === undefined) { - return f(); - } - return self; -} - -export function unwrapOrDefault$165pyh5(self: string | undefined): string { - if (self === undefined) { - return ""; - } - return self; -} - -export function unwrapOrDefault$0wx44sw(self: rt.ByteVec | undefined): rt.ByteVec { - if (self === undefined) { - return new rt.ByteVec(); - } - return self; -} - -export function unwrapOrDefault$0301ewp(self: rt.ByteSlice | undefined): rt.ByteSlice { - if (self === undefined) { - return rt.byteSliceFrom(new Uint8Array(0)); - } - return self; -} - -export function unwrapOrDefault$0k1p6nh(self: [rt.u64 | undefined, defaults_Made.Made] | undefined): [rt.u64 | undefined, defaults_Made.Made] { - if (self === undefined) { - return [undefined, defaults_Made.default$Default()]; - } - return self; -} - -export function unwrapOrDefault$001fvl5(self: rt.u16 | undefined): rt.u16 { - if (self === undefined) { - return 0; - } - return self; -} - -export function unwrapOrDefault$1q0ps0j(self: rt.u8 | undefined): rt.u8 { - if (self === undefined) { - return 0; - } - return self; -} - -export function unwrapOrDefault$1b97y1a(self: zeros_Tagged.Tagged | undefined): zeros_Tagged.Tagged { - if (self === undefined) { - return zeros_Tagged.default$Default_String(); - } - return self; -} - -export function map$0pkankm(self: rt.u8 | undefined | rt.None, f: (a0: rt.u8 | undefined) => rt.u8 | undefined): rt.u8 | undefined | rt.None { - if (self === rt.None) { - return rt.None; - } - return f(self); -} - -export function map$1j8xzu6(self: rt.u8 | undefined | rt.None, f: (a0: rt.u8 | undefined) => undefined): undefined | rt.None { - if (self === rt.None) { - return rt.None; - } - f(self); - return undefined; -} - -export function map$1i542n2(self: rt.Arc | undefined, f: (a0: rt.Arc) => rt.u32): rt.u32 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0oedb57(self: rt.Arc> | undefined, f: (a0: rt.Arc>) => [rt.usize, rt.usize | undefined]): [rt.usize, rt.usize | undefined] | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1mp7tga(self: rt.i64[] | undefined, f: (a0: rt.i64[]) => rt.usize): rt.usize | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1c7fhtg(self: rt.ByteVec | undefined, f: (a0: rt.ByteVec) => rt.usize): rt.usize | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0po44cb(self: undefined[] | undefined, f: (a0: undefined[]) => Uint8Array): Uint8Array | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0p6o7wa(self: Uint8Array | undefined, f: (a0: Uint8Array) => Uint8Array): Uint8Array | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1iekgsb(self: bounds_Item.Item | undefined, f: (a0: bounds_Item.Item) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0xa0bn7(self: edits_Named.Named | undefined, f: (a0: edits_Named.Named) => rt.u16): rt.u16 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1u07cey(self: cycles_Logged.Logged | undefined, f: (a0: cycles_Logged.Logged) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$08a6hpg(self: dyns_Tagged.Tagged | undefined, f: (a0: dyns_Tagged.Tagged) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$146awhd(self: Hop.Hop | undefined, f: (a0: Hop.Hop) => [rt.u64, rt.u64]): [rt.u64, rt.u64] | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$120lney(self: Hop.Hop | undefined, f: (a0: Hop.Hop) => rt.u64): rt.u64 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0lcwx9x(self: Way.Way | undefined, f: (a0: Way.Way) => boolean): boolean | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1diqi3e(self: rt.Place | undefined, f: (a0: rt.Place) => undefined): undefined | rt.None { - if (self === undefined) { - return rt.None; - } - f(self); - return undefined; -} - -export function map$1jcn6wm(self: rt.ByteSlice | undefined, f: (a0: rt.ByteSlice) => Uint8Array): Uint8Array | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1qfllpb(self: rt.Iter | undefined, f: (a0: rt.Iter) => rt.u8 | undefined): rt.u8 | undefined | rt.None { - if (self === undefined) { - return rt.None; - } - return f(self); -} - -export function map$1k7m6zz(self: [rt.u8, rt.u8] | undefined, f: (a0: [rt.u8, rt.u8]) => [rt.u8, rt.u8]): [rt.u8, rt.u8] | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$18pd8cy(self: rt.i128 | undefined, _: (a0: rt.i128) => rt.i128): rt.i128 | undefined { - if (self === undefined) { - return undefined; - } - return self; -} - -export function map$0b7sac9(self: rt.i16 | undefined, _: (a0: rt.i16) => rt.i16): rt.i16 | undefined { - if (self === undefined) { - return undefined; - } - return self; -} - -export function map$0x0f126(self: rt.i32 | undefined, _: (a0: rt.i32) => rt.i32): rt.i32 | undefined { - if (self === undefined) { - return undefined; - } - return self; -} - -export function map$02fxff7(self: rt.i64 | undefined, _: (a0: rt.i64) => rt.i64): rt.i64 | undefined { - if (self === undefined) { - return undefined; - } - return self; -} - -export function map$1u19ipa(self: rt.i8 | undefined, _: (a0: rt.i8) => rt.i8): rt.i8 | undefined { - if (self === undefined) { - return undefined; - } - return self; -} - -export function map$1rlqf9d(self: rt.isize | undefined, _: (a0: rt.isize) => rt.isize): rt.isize | undefined { - if (self === undefined) { - return undefined; - } - return self; -} - -export function map$1fszu7p(self: rt.u128 | undefined, _: (a0: rt.u128) => rt.u128): rt.u128 | undefined { - if (self === undefined) { - return undefined; - } - return self; -} - -export function map$12xrbxt(self: rt.u16 | undefined, _: (a0: rt.u16) => rt.u16): rt.u16 | undefined { - if (self === undefined) { - return undefined; - } - return self; -} - -export function map$0xz4pvf(self: rt.u32 | undefined, _: (a0: rt.u32) => rt.u32): rt.u32 | undefined { - if (self === undefined) { - return undefined; - } - return self; -} - -export function map$1rxjg4m(self: rt.u64 | undefined, _: (a0: rt.u64) => rt.u64): rt.u64 | undefined { - if (self === undefined) { - return undefined; - } - return self; -} - -export function map$03bv7br(self: rt.u8 | undefined, _: (a0: rt.u8) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return self; -} - -export function map$08v2q5m(self: rt.usize | undefined, _: (a0: rt.usize) => rt.usize): rt.usize | undefined { - if (self === undefined) { - return undefined; - } - return self; -} - -export function map$1srhyy0(self: rt.Arc | undefined, _: (a0: rt.Arc) => rt.Arc): rt.Arc | undefined { - if (self === undefined) { - return undefined; - } - return rt.arcClone(self); -} - -export function map$13pnxtn(self: rt.Arc | undefined, _: (a0: rt.Arc) => counts_Noisy.Noisy): counts_Noisy.Noisy | undefined { - if (self === undefined) { - return undefined; - } - return self.value; -} - -export function map$0ufgkyq(self: rt.Arc | undefined, _: (a0: rt.Arc) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return self.value; -} - -export function map$0isl2bb(self: rt.Result | undefined, f: (a0: rt.Result) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1uo1d4o(self: string | undefined, _: (a0: string) => string): string | undefined { - if (self === undefined) { - return undefined; - } - return self; -} - -export function map$1httady(self: string[] | undefined, f: (a0: string[]) => string): string | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1wqzuhy(self: rt.u16[] | undefined, f: (a0: rt.u16[]) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0c2keyb(self: rt.ByteSlice | undefined, f: (a0: rt.ByteSlice) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$11y9s7r(self: slices_Pair.Pair[] | undefined, f: (a0: slices_Pair.Pair[]) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1k1fy8u(self: rt.u32 | undefined | rt.None, _: (a0: rt.u32 | undefined) => rt.u32 | undefined): rt.u32 | undefined | rt.None { - if (self === rt.None) { - return rt.None; - } - return self; -} - -export function map$0ltgf8p(self: ByRef.ByRef | undefined, f: (a0: ByRef.ByRef) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1ajptuf(self: ByVal.ByVal | undefined, f: (a0: ByVal.ByVal) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0i8kclf(self: Mixed.Mixed | undefined, f: (a0: Mixed.Mixed) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$09ua5et(self: collections_Nibble.Nibble | undefined, f: (a0: collections_Nibble.Nibble) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1u8sh4f(self: edits_Named.Named | undefined, _: (a0: edits_Named.Named) => edits_Named.Named[]): edits_Named.Named[] | undefined { - if (self === undefined) { - return undefined; - } - return [self]; -} - -export function map$1cfrse5(self: Loaded.Loaded | undefined, f: (a0: Loaded.Loaded) => Loaded.Loaded): Loaded.Loaded | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1r7pvtd(self: string[] | undefined, _: (a0: string[]) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return sumTexts(self); -} - -export function map$14orwce(self: Uint8Array[] | undefined, _: (a0: Uint8Array[]) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return sumTwos(self); -} - -export function map$02o7iu2(self: separated_Pair.Pair[] | undefined, _: (a0: separated_Pair.Pair[]) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return sumPairs(self); -} - -export function map$0vryjg8(self: rt.u16[] | undefined, _: (a0: rt.u16[]) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return sumWords(self); -} - -export function map$0qyyft9(self: rt.u16[] | undefined, _: (a0: rt.u16[]) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return digestWords(self); -} - -export function map$0waqle9(self: rt.ByteSlice | undefined, _: (a0: rt.ByteSlice) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return args_opaque(self); -} - -export function map$1uuzv15(self: rt.ByteSlice | undefined, _: (a0: rt.ByteSlice) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return separated_sum(self); -} - -export function map$1xk4yz1(self: rt.ByteSlice | undefined, _: (a0: rt.ByteSlice) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return slices_digest(self); -} - -export function map$0rbsrz6(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8 | undefined): rt.u8 | undefined | rt.None { - if (self === undefined) { - return rt.None; - } - return f(self); -} - -export function map$12l9avg(self: rt.u8 | undefined, f: (a0: rt.u8) => Ticked.Ticked[]): Ticked.Ticked[] | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1fmzefe(self: rt.u8 | undefined, f: (a0: rt.u8) => [rt.u8, rt.u8]): [rt.u8, rt.u8] | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1qp1ym6(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u32): rt.u32 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0p22lts(self: rt.u8 | undefined, f: (a0: rt.u8) => undefined): undefined | rt.None { - if (self === undefined) { - return rt.None; - } - f(self); - return undefined; -} - -export function map$1ibcmaa(self: rt.u8 | undefined, f: (a0: rt.u8) => Loud.Loud): Loud.Loud | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$05nbzug(self: rt.usize | undefined, f: (a0: rt.usize) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0600mq0(self: shapes_Dir.Dir | undefined, f: (a0: shapes_Dir.Dir) => shapes_Shape.Shape): shapes_Shape.Shape | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$18z3v8h(self: shapes_Dir.Dir | undefined, _: (a0: shapes_Dir.Dir) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return from$convert_From_shapes_Dir_u8(self); -} - -export function map$003seos(self: slices_Item.Item | undefined, f: (a0: slices_Item.Item) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$155qrdr(self: rt.Arc | undefined, f: (a0: rt.Arc) => rt.u64): rt.u64 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0j05j69(self: rt.Arc | undefined, f: (a0: rt.Arc) => rt.u32): rt.u32 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0jcaaxx(self: [rt.u8 | undefined, rt.u8] | undefined, f: (a0: [rt.u8 | undefined, rt.u8]) => Uint8Array): Uint8Array | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1yogfym(self: [rt.u8, rt.ByteSlice] | undefined, f: (a0: [rt.u8, rt.ByteSlice]) => rt.ByteSlice): rt.ByteSlice | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1hdkvwd(self: [rt.u8, rt.u8] | undefined, f: (a0: [rt.u8, rt.u8]) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0gl6wke(self: [rt.usize, string] | undefined, f: (a0: [rt.usize, string]) => string): string | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1sj2ls1(self: [rt.usize, rt.u8] | undefined, f: (a0: [rt.usize, rt.u8]) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0a57co2(self: rt.u32 | undefined, f: (a0: rt.u32) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0oc32h1(self: rt.u8 | undefined, f: (a0: rt.u8) => string): string | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0ejznqm(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.ByteVec): rt.ByteVec | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0jg2jop(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u32[]): rt.u32[] | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1iwwjee(self: rt.u8 | undefined, f: (a0: rt.u8) => Uint8Array): Uint8Array | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0y3liwu(self: rt.u8 | undefined, f: (a0: rt.u8) => clones_Logged.Logged): clones_Logged.Logged | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0gn4nwv(self: rt.u8 | undefined, _: (a0: rt.u8) => Side.Side): Side.Side | undefined { - if (self === undefined) { - return undefined; - } - return side(self); -} - -export function map$0of9gds(self: rt.u8 | undefined, f: (a0: rt.u8) => Badge.Badge): Badge.Badge | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1pb5zw8(self: rt.u8 | undefined, f: (a0: rt.u8) => [rt.u16, rt.u8]): [rt.u16, rt.u8] | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$1c7zybz(self: rt.u8 | undefined, _: (a0: rt.u8) => rt.u32): rt.u32 | undefined { - if (self === undefined) { - return undefined; - } - return self as rt.u32; -} - -export function map$0cs071d(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0vbopjd(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.usize): rt.usize | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function map$0at3a41(self: undefined | rt.None, f: (a0: undefined) => rt.u8 | undefined): rt.u8 | undefined | rt.None { - if (self === rt.None) { - return rt.None; - } - return f(undefined); -} - -export function inspect$0di0vx1(self: rt.u8 | undefined, f: (a0: rt.u8) => undefined): rt.u8 | undefined { - if (self !== undefined) { - f(self); - } - return self; -} - -export function mapOr$1xztl8h(self: rt.u8 | undefined | rt.None, default_: rt.u8, f: (a0: rt.u8 | undefined) => rt.u8): rt.u8 { - if (self === rt.None) { - return default_; - } - return f(self); -} - -export function mapOr$036yrbw(self: rt.Arc | undefined, default_: rt.u8, f: (a0: rt.Arc) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1ndy2gq(self: rt.Arc | undefined, default_: rt.u8, f: (a0: rt.Arc) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1qmxzyf(self: rt.Arc | undefined, default_: rt.u8, f: (a0: rt.Arc) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1q3ff8g(self: rt.Arc | undefined, default_: rt.u8, f: (a0: rt.Arc) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0lcrgk1(self: string | undefined, default_: rt.u8, f: (a0: string) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0ow0wo0(self: rt.u32[][] | undefined, default_: rt.usize, f: (a0: rt.u32[][]) => rt.usize): rt.usize { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0r2th8w(self: hints_Unit.Unit[] | undefined, default_: rt.usize, f: (a0: hints_Unit.Unit[]) => rt.usize): rt.usize { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0pdoq6p(self: [rt.u64, rt.u8][] | undefined, default_: rt.usize, f: (a0: [rt.u64, rt.u8][]) => rt.usize): rt.usize { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0amk6zv(self: [rt.u8, rt.u8, rt.u8][] | undefined, default_: rt.usize, f: (a0: [rt.u8, rt.u8, rt.u8][]) => rt.usize): rt.usize { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1kiffmd(self: rt.u16[] | undefined, default_: rt.u8, f: (a0: rt.u16[]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1umcrqz(self: rt.u32[] | undefined, default_: rt.usize, f: (a0: rt.u32[]) => rt.usize): rt.usize { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1a3irjf(self: rt.ByteVec | undefined, default_: rt.u8, f: (a0: rt.ByteVec) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$08xwngs(self: rt.ByteVec | undefined, default_: rt.usize, f: (a0: rt.ByteVec) => rt.usize): rt.usize { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1h1mlmc(self: rt.u32[] | undefined, default_: rt.u8, f: (a0: rt.u32[]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1bumeih(self: Array | undefined, default_: rt.u8, f: (a0: Array) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0qqhf4e(self: boolean[] | undefined, default_: rt.u8, f: (a0: boolean[]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$141aobk(self: rt.char[] | undefined, default_: rt.u8, f: (a0: rt.char[]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$17y4wkx(self: rt.i32[] | undefined, default_: rt.u8, f: (a0: rt.i32[]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0rtxftk(self: Hop.Hop[] | undefined, default_: rt.u8, f: (a0: Hop.Hop[]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0nlcxqx(self: rt.u64[] | undefined, default_: rt.u8, f: (a0: rt.u64[]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0sl5app(self: Uint8Array | undefined, default_: rt.u8, f: (a0: Uint8Array) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0atjiti(self: rt.char | undefined, default_: rt.u32, _: (a0: rt.char) => rt.u32): rt.u32 { - if (self === undefined) { - return default_; - } - return self as rt.u32; -} - -export function mapOr$0okqj9y(self: rt.char | undefined, default_: rt.u8, f: (a0: rt.char) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1e4a1e0(self: rt.Ordering | undefined, default_: rt.u8, f: (a0: rt.Ordering) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1dgdmlk(self: rt.Ordering | undefined, default_: rt.u8, _: (a0: rt.Ordering) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return keys_order(self); -} - -export function mapOr$0q0ymkh(self: collections_Nibble.Nibble | undefined, default_: rt.u8, f: (a0: collections_Nibble.Nibble) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1ht002r(self: collections_Tally.Tally | undefined, default_: rt.u8, f: (a0: collections_Tally.Tally) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1ailw2a(self: counts_Counted.Counted | undefined, default_: rt.u8, f: (a0: counts_Counted.Counted) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0djjvgl(self: cycles_Logged.Logged | undefined, default_: rt.u8, f: (a0: cycles_Logged.Logged) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$14njs1h(self: edits_Named.Named | undefined, default_: rt.u16, f: (a0: edits_Named.Named) => rt.u16): rt.u16 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1lznlgz(self: Quarter.Quarter | undefined, default_: rt.u8, f: (a0: Quarter.Quarter) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0tmtgfi(self: Tilt.Tilt | undefined, default_: rt.u8, f: (a0: Tilt.Tilt) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$04khdaj(self: Hop.Hop | undefined, default_: rt.u64, f: (a0: Hop.Hop) => rt.u64): rt.u64 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0cqaybi(self: locals_Noisy.Noisy | undefined, default_: rt.u8, f: (a0: locals_Noisy.Noisy) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1w5qtj7(self: undefined | rt.None, default_: rt.u8, f: (a0: undefined) => rt.u8): rt.u8 { - if (self === rt.None) { - return default_; - } - return f(self); -} - -export function mapOr$0grxkdu(self: rt.u32[] | undefined, default_: rt.u32, f: (a0: rt.u32[]) => rt.u32): rt.u32 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1giiemz(self: rt.Place | undefined, default_: rt.u32, f: (a0: rt.Place) => rt.u32): rt.u32 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0ev76sb(self: rt.Place | undefined, default_: rt.u8, f: (a0: rt.Place) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$14aggam(self: orders_Item.Item | undefined, default_: rt.u8, f: (a0: orders_Item.Item) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$08xz81a(self: pointers_Pair.Pair | undefined, default_: rt.u8, f: (a0: pointers_Pair.Pair) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1unqgn7(self: rt.Arc[] | undefined, default_: rt.u8, f: (a0: rt.Arc[]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0z7fb2w(self: rt.ByteSlice | undefined, default_: Uint8Array, f: (a0: rt.ByteSlice) => Uint8Array): Uint8Array { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1w1gbwl(self: rt.ByteSlice | undefined, default_: rt.u8, f: (a0: rt.ByteSlice) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0qqbaqw(self: borrows_Noisy.Noisy | undefined, default_: rt.u8, f: (a0: borrows_Noisy.Noisy) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1dvn0au(self: borrows_Tagged.Tagged | undefined, default_: rt.u8, f: (a0: borrows_Tagged.Tagged) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1yabfom(self: clones_Logged.Logged | undefined, default_: rt.u8, _: (a0: clones_Logged.Logged) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return clones_Logged.id(self); -} - -export function mapOr$0bnr5nu(self: collections_Picky.Picky | undefined, default_: rt.u16, f: (a0: collections_Picky.Picky) => rt.u16): rt.u16 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1hh0iyl(self: ArcShared.ArcShared | undefined, default_: rt.u8, f: (a0: ArcShared.ArcShared) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1iuqai4(self: counts_Noisy.Noisy | undefined, default_: rt.u8, f: (a0: counts_Noisy.Noisy) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1kfudqo(self: RcShared.RcShared | undefined, default_: rt.u8, f: (a0: RcShared.RcShared) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1surhce(self: rt.u8 | undefined, default_: rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0j8cgo8(self: string[] | undefined, default_: rt.u8, _: (a0: string[]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return sumTexts(self); -} - -export function mapOr$0wkl4zm(self: Uint8Array[] | undefined, default_: rt.u8, _: (a0: Uint8Array[]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return sumTwos(self); -} - -export function mapOr$15c63lv(self: separated_Pair.Pair[] | undefined, default_: rt.u8, _: (a0: separated_Pair.Pair[]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return sumPairs(self); -} - -export function mapOr$1qu2moz(self: rt.u16[] | undefined, default_: rt.u8, _: (a0: rt.u16[]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return sumWords(self); -} - -export function mapOr$18m1ie6(self: rt.ByteSlice | undefined, default_: rt.u8, _: (a0: rt.ByteSlice) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return separated_sum(self); -} - -export function mapOr$0dk8jdr(self: rt.ByteSlice | undefined, default_: rt.usize, _: (a0: rt.ByteSlice) => rt.usize): rt.usize { - if (self === undefined) { - return default_; - } - return args_len(self.data, self.start, self.length); -} - -export function mapOr$189goit(self: slices_Noisy.Noisy | undefined, default_: rt.u8, f: (a0: slices_Noisy.Noisy) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1nlkf9b(self: [rt.u8, rt.u8] | undefined, default_: Uint8Array, f: (a0: [rt.u8, rt.u8]) => Uint8Array): Uint8Array { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$099335t(self: rt.u16 | undefined, default_: rt.u8, f: (a0: rt.u16) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0z4mj8g(self: rt.u8 | undefined, default_: rt.u16, f: (a0: rt.u8) => rt.u16): rt.u16 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$15zxk73(self: rt.u8 | undefined, default_: rt.u64, f: (a0: rt.u8) => rt.u64): rt.u64 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1t0muvr(self: rt.u8 | undefined, default_: rt.usize, f: (a0: rt.u8) => rt.usize): rt.usize { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$02k4ito(self: rt.usize | undefined, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1ybqvup(self: Meters.Meters | undefined, default_: rt.u64, f: (a0: Meters.Meters) => rt.u64): rt.u64 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0rtdylj(self: Point.Point | undefined, default_: rt.u8, f: (a0: Point.Point) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0aserv9(self: shapes_Shape.Shape | undefined, default_: rt.u8, f: (a0: shapes_Shape.Shape) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0dgmbpi(self: rt.Arc | undefined, default_: rt.u8, f: (a0: rt.Arc) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1xwgm12(self: [rt.u32[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u32[], rt.u8]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$187k0x1(self: [Array, rt.u8] | undefined, default_: rt.u8, f: (a0: [Array, rt.u8]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$13q9j26(self: [boolean[], rt.u8] | undefined, default_: rt.u8, f: (a0: [boolean[], rt.u8]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1afbbm4(self: [rt.char[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.char[], rt.u8]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$03mkmku(self: [rt.i32[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.i32[], rt.u8]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0spovx0(self: [Hop.Hop[], rt.u8] | undefined, default_: rt.u8, f: (a0: [Hop.Hop[], rt.u8]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0iyypgq(self: [rt.u16[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u16[], rt.u8]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0vfd25u(self: [rt.u64[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u64[], rt.u8]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1to2ul4(self: [Rank.Rank, collections_Tally.Tally] | undefined, default_: rt.u8, f: (a0: [Rank.Rank, collections_Tally.Tally]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1jgrjsu(self: [rt.ByteSlice, rt.ByteSlice] | undefined, default_: rt.ByteSlice, f: (a0: [rt.ByteSlice, rt.ByteSlice]) => rt.ByteSlice): rt.ByteSlice { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1be3nsj(self: [rt.ByteSlice, rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.ByteSlice, rt.u8]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$11e0ggl(self: [rt.ByteSlice, rt.ByteSlice] | undefined, default_: rt.u8, f: (a0: [rt.ByteSlice, rt.ByteSlice]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0a96v80(self: [rt.ByteSlice, [rt.usize, rt.u8]] | undefined, default_: rt.u8, f: (a0: [rt.ByteSlice, [rt.usize, rt.u8]]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1hjjwvv(self: [rt.Mutex, rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.Mutex, rt.u8]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1ttssgs(self: [rt.u8, rt.ByteSlice] | undefined, default_: [rt.u8, rt.ByteSlice], f: (a0: [rt.u8, rt.ByteSlice]) => [rt.u8, rt.ByteSlice]): [rt.u8, rt.ByteSlice] { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0mmpeqx(self: [rt.u8, rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u8, rt.u8]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0ucbp7g(self: [rt.u64, rt.u64] | undefined, default_: rt.u8, f: (a0: [rt.u64, rt.u64]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1vjqo89(self: [rt.u8, rt.ByteSlice] | undefined, default_: rt.u8, f: (a0: [rt.u8, rt.ByteSlice]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1wxcg5q(self: [rt.u8, rt.Arc] | undefined, default_: rt.u8, f: (a0: [rt.u8, rt.Arc]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1h04da8(self: [rt.u8, [rt.u8, rt.usize]] | undefined, default_: rt.u8, f: (a0: [rt.u8, [rt.u8, rt.usize]]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0f73bb7(self: [rt.u8, [rt.usize, rt.ByteSlice]] | undefined, default_: rt.u8, f: (a0: [rt.u8, [rt.usize, rt.ByteSlice]]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0hi5qhf(self: [rt.u8, rt.u16] | undefined, default_: rt.u8, f: (a0: [rt.u8, rt.u16]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$16umieg(self: [rt.usize, string] | undefined, default_: rt.usize, f: (a0: [rt.usize, string]) => rt.usize): rt.usize { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$06gg5x7(self: [rt.usize, rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.usize, rt.u8]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1dmz9kd(self: [rt.usize, [rt.u8, rt.ByteSlice]] | undefined, default_: rt.u8, f: (a0: [rt.usize, [rt.u8, rt.ByteSlice]]) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1llunel(self: rt.u16 | undefined, default_: rt.u16, f: (a0: rt.u16) => rt.u16): rt.u16 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1sxa8ki(self: rt.u32 | undefined, default_: rt.u8, f: (a0: rt.u32) => rt.u8): rt.u8 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$06rr3sb(self: rt.u8 | undefined, default_: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8 | undefined): rt.u8 | undefined { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1m2xzon(self: rt.u8 | undefined, default_: boolean, f: (a0: rt.u8) => boolean): boolean { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$1qo6t0j(self: rt.u8 | undefined, default_: rt.u32, _: (a0: rt.u8) => rt.u32): rt.u32 { - if (self === undefined) { - return default_; - } - return self as rt.u32; -} - -export function mapOr$18ph0j9(self: undefined | rt.None, default_: rt.u8, f: (a0: undefined) => rt.u8): rt.u8 { - if (self === rt.None) { - return default_; - } - return f(undefined); -} - -export function mapOr$147z9gi(self: rt.usize | undefined, default_: string, f: (a0: rt.usize) => string): string { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOr$0jad0p1(self: rt.usize | undefined, default_: rt.u32, f: (a0: rt.usize) => rt.u32): rt.u32 { - if (self === undefined) { - return default_; - } - return f(self); -} - -export function mapOrElse$1g6d36t(self: rt.u8 | undefined, default_: () => rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { - if (self === undefined) { - return default_(); - } - return f(self); -} - -export function okOr$07zal2e(self: rt.u32[] | undefined, err: rt.u8): rt.Result { - if (self === undefined) { - return rt.Err(err); - } - return rt.Ok(self); -} - -export function okOr$1b6nkwr(self: rt.char | undefined, err: rt.u8): rt.Result { - if (self === undefined) { - return rt.Err(err); - } - return rt.Ok(self); -} - -export function okOr$1rxv64q(self: rt.Place | undefined, err: heap_Fault.Fault): rt.Result, heap_Fault.Fault> { - if (self === undefined) { - return rt.Err(err); - } - return rt.Ok(self); -} - -export function okOr$0gtm15y(self: rt.ByteSlice | undefined, err: rt.u8 | undefined): rt.Result { - if (self === undefined) { - return rt.Err(err); - } - return rt.Ok(self); -} - -export function okOr$12p77jh(self: rt.ByteSlice | undefined, err: returns_Error.Error): rt.Result { - if (self === undefined) { - return rt.Err(err); - } - return rt.Ok(self); -} - -export function okOr$0tezn0w(self: rt.ByteSlice | undefined, _: undefined): rt.Result { - if (self === undefined) { - return rt.ERR; - } - return rt.Ok(self); -} - -export function okOr$1w08zpl(self: rt.ByteSlice | undefined, err: rt.usize): rt.Result { - if (self === undefined) { - return rt.Err(err); - } - return rt.Ok(self); -} - -export function okOr$1oufq9m(self: rt.u8 | undefined, err: rt.usize): rt.Result { - if (self === undefined) { - return rt.Err(err); - } - return rt.Ok(self); -} - -export function okOr$0q0ogpn(self: [rt.ByteSlice, rt.ByteSlice] | undefined, err: rt.u8 | undefined): rt.Result<[rt.ByteSlice, rt.ByteSlice], rt.u8 | undefined> { - if (self === undefined) { - return rt.Err(err); - } - return rt.Ok(self); -} - -export function okOr$0m6xlfp(self: rt.u8 | undefined, err: rt.u16): rt.Result { - if (self === undefined) { - return rt.Err(err); - } - return rt.Ok(self); -} - -export function okOr$1vxk0yk(self: rt.u8 | undefined, err: rt.u8): rt.Result { - if (self === undefined) { - return rt.Err(err); - } - return rt.Ok(self); -} - -export function okOr$0g9lvh7(self: rt.u8 | undefined, _: undefined): rt.Result { - if (self === undefined) { - return rt.ERR; - } - return rt.Ok(self); -} - -export function okOr$169x1m6(self: rt.usize | undefined, err: heap_Fault.Fault): rt.Result { - if (self === undefined) { - return rt.Err(err); - } - return rt.Ok(self); -} - -export function okOrElse$0awp3vn(self: rt.ByteVec | undefined, err: () => string): rt.Result { - if (self === undefined) { - return rt.Err(err()); - } - return rt.Ok(self); -} - -export function okOrElse$1v98j0a(self: rt.u8 | undefined, err: () => rt.u16): rt.Result { - if (self === undefined) { - return rt.Err(err()); - } - return rt.Ok(self); -} - -export function asDeref$0hypa7g(self: rt.Arc | undefined): counts_Noisy.Noisy | undefined { - return map$13pnxtn(self, (a0: rt.Arc): counts_Noisy.Noisy => { - return a0.value; - }); -} - -export function asDeref$0s3650c(self: rt.Arc | undefined): rt.u8 | undefined { - return map$0ufgkyq(self, (a0: rt.Arc): rt.u8 => { - return a0.value; - }); -} - -export function asDeref$0w8at8i(self: string | undefined): string | undefined { - return map$1uo1d4o(self, (a0: string): string => { - return a0; - }); -} - -export function asDeref$0w2m0zn(self: rt.u32 | undefined | rt.None): rt.u32 | undefined | rt.None { - return map$1k1fy8u(self, (a0: rt.u32 | undefined): rt.u32 | undefined => { - return a0; - }); -} - -export function asDeref$0avuzwv(self: rt.u32 | undefined): rt.u32 | undefined { - return map$0xz4pvf(self, (a0: rt.u32): rt.u32 => { - return a0; - }); -} - -export function and$06om98g(self: rt.u8 | undefined, optb: rt.u8 | undefined): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return optb; -} - -export function andThen$0qni7te(self: rt.u8 | undefined | rt.None, f: (a0: rt.u8 | undefined) => rt.u8 | undefined | rt.None): rt.u8 | undefined | rt.None { - if (self === rt.None) { - return rt.None; - } - return f(self); -} - -export function andThen$0v0bj8w(self: rt.Iter | undefined, f: (a0: rt.Iter) => dyns_Tagged.Tagged | undefined): dyns_Tagged.Tagged | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function andThen$0ntiuws(self: rt.Iter | undefined, f: (a0: rt.Iter) => rt.u8 | undefined): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function andThen$101gy6h(self: rt.Place | undefined, f: (a0: rt.Place) => rt.Place | undefined): rt.Place | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function andThen$0ocv8av(self: Array | undefined, f: (a0: Array) => rt.u8 | undefined | rt.None): rt.u8 | undefined | rt.None { - if (self === undefined) { - return rt.None; - } - return f(self); -} - -export function andThen$1bd14ex(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8 | undefined | rt.None): rt.u8 | undefined | rt.None { - if (self === undefined) { - return rt.None; - } - return f(self); -} - -export function andThen$17ch833(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8 | undefined): rt.u8 | undefined { - if (self === undefined) { - return undefined; - } - return f(self); -} - -export function filter$19gtvc4(self: rt.u8 | undefined | rt.None, predicate: (a0: rt.u8 | undefined) => boolean): rt.u8 | undefined | rt.None { - if (self !== rt.None) { - const x: rt.u8 | undefined = self; - if (predicate(x)) { - return x; - } - } - return rt.None; -} - -export function filter$1qg98un(self: rt.Arc | undefined, predicate: (a0: rt.Arc) => boolean): rt.Arc | undefined { - if (self !== undefined) { - const x: rt.Arc = self; - if (!predicate(x)) { - x[Symbol.dispose](); - } else { - return x; - } - } - return undefined; -} - -export function filter$1855tjj(self: string | undefined, predicate: (a0: string) => boolean): string | undefined { - if (self !== undefined) { - const x: string = self; - if (predicate(x)) { - return x; - } - } - return undefined; -} - -export function filter$16q8euf(self: rt.Arc[] | undefined, predicate: (a0: rt.Arc[]) => boolean): rt.Arc[] | undefined { - if (self !== undefined) { - const x: rt.Arc[] = self; - if (!predicate(x)) { - rt.dropAll(x); - } else { - return x; - } - } - return undefined; -} - -export function filter$184yuq2(self: edits_Named.Named | undefined, predicate: (a0: edits_Named.Named) => boolean): edits_Named.Named | undefined { - if (self !== undefined) { - const x: edits_Named.Named = self; - if (predicate(x)) { - return x; - } - } - return undefined; -} - -export function filter$1asvriw(self: ArcShared.ArcShared | undefined, predicate: (a0: ArcShared.ArcShared) => boolean): ArcShared.ArcShared | undefined { - if (self !== undefined) { - const x: ArcShared.ArcShared = self; - if (!predicate(x)) { - x[Symbol.dispose](); - } else { - return x; - } - } - return undefined; -} - -export function filter$1gka6nq(self: counts_Noisy.Noisy | undefined, predicate: (a0: counts_Noisy.Noisy) => boolean): counts_Noisy.Noisy | undefined { - if (self !== undefined) { - const x: counts_Noisy.Noisy = self; - if (!predicate(x)) { - x[Symbol.dispose](); - } else { - return x; - } - } - return undefined; -} - -export function filter$14b5774(self: RcShared.RcShared | undefined, predicate: (a0: RcShared.RcShared) => boolean): RcShared.RcShared | undefined { - if (self !== undefined) { - const x: RcShared.RcShared = self; - if (!predicate(x)) { - x[Symbol.dispose](); - } else { - return x; - } - } - return undefined; -} - -export function filter$033ccod(self: [rt.u8, rt.u8] | undefined, predicate: (a0: [rt.u8, rt.u8]) => boolean): [rt.u8, rt.u8] | undefined { - if (self !== undefined) { - const x: [rt.u8, rt.u8] = self; - if (predicate(x)) { - return x; - } - } - return undefined; -} - -export function filter$0v80fk8(self: rt.u8 | undefined, predicate: (a0: rt.u8) => boolean): rt.u8 | undefined { - if (self !== undefined) { - const x: rt.u8 = self; - if (predicate(x)) { - return x; - } - } - return undefined; -} - -export function filter$0tnmmii(self: rt.u32 | undefined, predicate: (a0: rt.u32) => boolean): rt.u32 | undefined { - if (self !== undefined) { - const x: rt.u32 = self; - if (predicate(x)) { - return x; - } - } - return undefined; -} - -export function or$0j02yk0(self: rt.u8 | undefined | rt.None, optb: rt.u8 | undefined | rt.None): rt.u8 | undefined | rt.None { - if (self === rt.None) { - return optb; - } - return self; -} - -export function or$1loyskh(self: rt.u8 | undefined, optb: rt.u8 | undefined): rt.u8 | undefined { - if (self === undefined) { - return optb; - } - return self; -} - -export function orElse$05gzawv(self: string | undefined, f: () => string | undefined): string | undefined { - if (self === undefined) { - return f(); - } - return self; -} - -export function orElse$15bv4ho(self: rt.u8 | undefined, f: () => rt.u8 | undefined): rt.u8 | undefined { - if (self === undefined) { - return f(); - } - return self; -} - -export function xor$0pemq84(self: rt.u8 | undefined | rt.None, optb: rt.u8 | undefined | rt.None): rt.u8 | undefined | rt.None { - let _0!: rt.u8 | undefined | rt.None; - b0: { - if (self === rt.None) { - if (optb !== rt.None) { - _0 = optb; - break b0; - } - } else if (optb === rt.None) { - _0 = self; - break b0; - } - _0 = rt.None; - } - return _0; -} - -export function xor$0kctyix(self: rt.u8 | undefined, optb: rt.u8 | undefined): rt.u8 | undefined { - let _0!: rt.u8 | undefined; - b0: { - if (self === undefined) { - if (optb !== undefined) { - _0 = optb; - break b0; - } - } else if (optb === undefined) { - _0 = self; - break b0; - } - _0 = undefined; - } - return _0; -} - -export function zip$1deudzj(self: rt.u8 | undefined, other: rt.u8 | undefined): [rt.u8, rt.u8] | undefined { - let _0!: [rt.u8, rt.u8] | undefined; - b0: { - if (self !== undefined) { - if (other !== undefined) { - _0 = [self, other] as [rt.u8, rt.u8]; - break b0; - } - } - _0 = undefined; - } - return _0; -} - -export function clone$14nprly(self: string | undefined): string | undefined { - if (self === undefined) { - return undefined; - } - return self; -} - -export function clone$0hmts8n(self: rt.u16[] | undefined): rt.u16[] | undefined { - if (self === undefined) { - return undefined; - } - return rt.vecExact(self.slice(), 2); -} - -export function clone$1grnave(self: rt.ByteVec | undefined): rt.ByteVec | undefined { - if (self === undefined) { - return undefined; - } - return rt.byteVecFrom(rt.byteVecView(self)); -} - -export function clone$0vcwlo5(self: edits_Named.Named | undefined): edits_Named.Named | undefined { - if (self === undefined) { - return undefined; - } - return edits_Named.clone$Clone(self); -} - -export function clone$1omlcob(self: slices_Noisy.Noisy | undefined): slices_Noisy.Noisy | undefined { - if (self === undefined) { - return undefined; - } - return slices_Noisy.clone$Clone(self); -} - -export function flatten$08boupk(self: rt.u32 | undefined | rt.None): rt.u32 | undefined { - if (self === rt.None) { - return undefined; - } - return self; -} - -export function flatten$1nwzx42(self: rt.u8 | undefined | rt.None): rt.u8 | undefined { - if (self === rt.None) { - return undefined; - } - return self; -} - -//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/expected/core/result.ts b/ts/fixtures/lang/expected/core/result.ts deleted file mode 100644 index 6985b2a6a..000000000 --- a/ts/fixtures/lang/expected/core/result.ts +++ /dev/null @@ -1,1044 +0,0 @@ -// Generated by rust2-ts. Do not edit. - -import * as rt from "../rt.ts"; -import { drop$Result_sync_Arc_u32_sync_Arc_dyn_Any_marker_Sync_marker_Send, drop$Result_sync_MutexGuard_locks_Tally_sync_TryLockError_sync_MutexGuard_locks_Tally, drop$Result_sync_RwLockReadGuard_locks_Tally_sync_TryLockError_sync_RwLockReadGuard_locks_Tally, drop$Result_tuple2_usize_u8_sync_Arc_dyn_Any_marker_Sync_marker_Send } from "../lib.ts"; -import { eq$09knsz6 as string_eq$09knsz6 } from "../alloc/string.ts"; -import * as ByRef from "../collections.ByRef.ts"; -import * as ByVal from "../collections.ByVal.ts"; -import type * as Any from "../core/any.Any.ts"; -import { eq$09vw48j as convert_eq$09vw48j } from "../core/char/convert.ts"; -import { eq$08q6k9m as fmt_eq$08q6k9m } from "../core/fmt.ts"; -import { eq$1nf2rde as num_error_eq$1nf2rde, eq$18sin5z as num_error_eq$18sin5z } from "../core/num/error.ts"; -import { eq$1horntk as float_parse_eq$1horntk } from "../core/num/float_parse.ts"; -import { eq$1v93ipo as str_error_eq$1v93ipo, eq$1f3e51k as str_error_eq$1f3e51k } from "../core/str/error.ts"; -import { cmp$175ka5q as poll_cmp$175ka5q } from "../core/task/poll.ts"; -import { eq$0dhyfbb as time_eq$0dhyfbb } from "../core/time.ts"; -import type * as Failure from "../errors.Failure.ts"; -import type * as heap_Fault from "../heap.Fault.ts"; -import type * as locks_Tally from "../locks.Tally.ts"; -import * as Part from "../orders.Part.ts"; -import type * as returns_Error from "../returns.Error.ts"; - -export function eq$04qb8k3(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.u8 | undefined }).value; - } - return num_error_eq$18sin5z(self.error, (other as { ok: false; error: rt.ParseIntError }).error); -} - -export function eq$10fppe8(self: rt.Result, rt.ParseBoolError>, other: rt.Result, rt.ParseBoolError>): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return eq$04iua4k(self.value, (other as { ok: true; value: rt.Result }).value); - } - return str_error_eq$1f3e51k(self.error, (other as { ok: false; error: rt.ParseBoolError }).error); -} - -export function eq$0ecfqx9(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: string }).value; - } - return string_eq$09knsz6(self.error, (other as { ok: false; error: rt.FromUtf8Error }).error); -} - -export function eq$0nlhjpf(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: boolean }).value; - } - return str_error_eq$1f3e51k(self.error, (other as { ok: false; error: rt.ParseBoolError }).error); -} - -export function eq$04iua4k(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.char }).value; - } - return convert_eq$09vw48j(self.error, (other as { ok: false; error: rt.ParseCharError }).error); -} - -export function eq$15zrpyn(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.f64 }).value; - } - return self.error === (other as { ok: false; error: rt.f64 }).error; -} - -export function eq$1dhtbkj(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.f64 }).value; - } - return float_parse_eq$1horntk(self.error, (other as { ok: false; error: rt.ParseFloatError }).error); -} - -export function eq$0pee78b(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return rt.i128Eq(self.value, (other as { ok: true; value: rt.i128 }).value); - } - return true; -} - -export function eq$0pe0qmq(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return rt.i128Eq(self.value, (other as { ok: true; value: rt.i128 }).value); - } - return num_error_eq$18sin5z(self.error, (other as { ok: false; error: rt.ParseIntError }).error); -} - -export function eq$1mi4cle(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.i16 }).value; - } - return true; -} - -export function eq$1ukayff(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.i32 }).value; - } - return true; -} - -export function eq$1hy1is1(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return rt.i64Eq(self.value, (other as { ok: true; value: rt.i64 }).value); - } - return true; -} - -export function eq$1hd8lo9(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.i8 }).value; - } - return true; -} - -export function eq$1mpp8xa(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.i8 }).value; - } - return num_error_eq$18sin5z(self.error, (other as { ok: false; error: rt.ParseIntError }).error); -} - -export function eq$0grmb7g(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.i8 }).value; - } - return num_error_eq$1nf2rde(self.error, (other as { ok: false; error: rt.TryFromIntError }).error); -} - -export function eq$0w2dfat(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.isize }).value; - } - return true; -} - -export function eq$19kc15f(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.u32 }).value; - } - return num_error_eq$18sin5z(self.error, (other as { ok: false; error: rt.ParseIntError }).error); -} - -export function eq$1faqxpo(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return Part.eq$cmp_PartialEq(self.value, (other as { ok: true; value: Part.Part }).value); - } - return Part.eq$cmp_PartialEq(self.error, (other as { ok: false; error: Part.Part }).error); -} - -export function eq$1dt73ez(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return ByRef.eq$cmp_PartialEq_ref(self.value, (other as { ok: true; value: ByRef.ByRef }).value); - } - return self.error === (other as { ok: false; error: rt.u8 }).error; -} - -export function eq$163neqy(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return ByVal.eq$cmp_PartialEq(self.value, (other as { ok: true; value: ByVal.ByVal }).value); - } - return self.error === (other as { ok: false; error: rt.u8 }).error; -} - -export function eq$0rj0czq(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: string }).value; - } - return str_error_eq$1v93ipo(self.error, (other as { ok: false; error: rt.Utf8Error }).error); -} - -export function eq$1hq3neq(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return rt.durationEq(self.value, (other as { ok: true; value: rt.Duration }).value); - } - return time_eq$0dhyfbb(self.error, (other as { ok: false; error: rt.TryFromFloatSecsError }).error); -} - -export function eq$06vyx9e(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return rt.u128Eq(self.value, (other as { ok: true; value: rt.u128 }).value); - } - return true; -} - -export function eq$08241oi(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.u16 }).value; - } - return true; -} - -export function eq$0nbftnc(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.u32 }).value; - } - return true; -} - -export function eq$1gq81ib(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return rt.u64Eq(self.value, (other as { ok: true; value: rt.u64 }).value); - } - return true; -} - -export function eq$0bl30vt(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return rt.u64Eq(self.value, (other as { ok: true; value: rt.u64 }).value); - } - return num_error_eq$18sin5z(self.error, (other as { ok: false; error: rt.ParseIntError }).error); -} - -export function eq$12e5exx(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.u8 }).value; - } - return true; -} - -export function eq$1fkhuzl(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.u8 }).value; - } - return self.error === (other as { ok: false; error: rt.IntErrorKind }).error; -} - -export function eq$0p1bb4y(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.u8 }).value; - } - return num_error_eq$18sin5z(self.error, (other as { ok: false; error: rt.ParseIntError }).error); -} - -export function eq$03gbayb(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return true; - } - return fmt_eq$08q6k9m(self.error, (other as { ok: false; error: rt.FmtError }).error); -} - -export function eq$1xhgva4(self: rt.Result, other: rt.Result): boolean { - if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { - return false; - } - if (self.ok) { - return self.value === (other as { ok: true; value: rt.usize }).value; - } - return true; -} - -export function partialCmp$08on5x6(self: rt.Result, rt.u8>, other: rt.Result, rt.u8>): rt.Ordering | undefined { - if (self.ok) { - if (other.ok) { - return rt.cmpDeque(Part.partialCmp$cmp_PartialOrd)(self.value, other.value); - } - } else if (!other.ok) { - return rt.cmp(self.error, other.error); - } - return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); -} - -export function partialCmp$0v2kxbo(self: rt.Result, other: rt.Result): rt.Ordering | undefined { - if (self.ok) { - if (other.ok) { - return rt.f64PartialCmp(self.value, other.value); - } - } else if (!other.ok) { - return rt.f64PartialCmp(self.error, other.error); - } - return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); -} - -export function partialCmp$0spmpix(self: rt.Result, other: rt.Result): rt.Ordering | undefined { - if (self.ok) { - if (other.ok) { - return Part.partialCmp$cmp_PartialOrd(self.value, other.value); - } - } else if (!other.ok) { - return Part.partialCmp$cmp_PartialOrd(self.error, other.error); - } - return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); -} - -export function partialCmp$0hea5es(self: rt.Result, other: rt.Result): rt.Ordering | undefined { - if (self.ok) { - if (other.ok) { - return rt.cmp(self.value, other.value); - } - } else if (!other.ok) { - return rt.cmp(self.error, other.error); - } - return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); -} - -export function cmp$0nb553d(self: rt.Result, rt.Poll>, other: rt.Result, rt.Poll>): rt.Ordering { - if (self.ok) { - if (other.ok) { - return rt.cmpDeque(rt.cmp)(self.value, other.value); - } - } else if (!other.ok) { - return poll_cmp$175ka5q(self.error, other.error); - } - return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); -} - -export function cmp$0h5rzdg(self: rt.Result, other: rt.Result): rt.Ordering { - if (self.ok) { - if (other.ok) { - return Part.cmp$cmp_Ord(self.value, other.value); - } - } else if (!other.ok) { - return Part.cmp$cmp_Ord(self.error, other.error); - } - return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); -} - -export function cmp$0qsbu3y(self: rt.Result<[Part.Part], rt.u8>, other: rt.Result<[Part.Part], rt.u8>): rt.Ordering { - if (self.ok) { - if (other.ok) { - return rt.cmpTuple<[Part.Part], rt.Ordering>([Part.cmp$cmp_Ord])(self.value, other.value); - } - } else if (!other.ok) { - return rt.cmp(self.error, other.error); - } - return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); -} - -export function cmp$06akmd5(self: rt.Result, other: rt.Result): rt.Ordering { - if (self.ok) { - if (other.ok) { - return rt.cmp(self.value, other.value); - } - } else if (!other.ok) { - return rt.cmp(self.error, other.error); - } - return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); -} - -export function isOkAnd$0jj0nkw(self: rt.Result, f: (a0: rt.u8) => boolean): boolean { - if (self.ok) { - return f(self.value); - } - return false; -} - -export function isErrAnd$0b01a39(self: rt.Result, f: (a0: rt.u16) => boolean): boolean { - if (self.ok) { - return false; - } - return f(self.error); -} - -export function ok$04yj0hm(self: rt.Result): rt.ByteSlice | undefined { - if (self.ok) { - return self.value; - } - return undefined; -} - -export function ok$00p9ap8(self: rt.Result, rt.Arc>): rt.Arc | undefined { - let _0!: rt.Arc | undefined; - if (self.ok) { - _0 = self.value; - } else { - _0 = undefined; - } - if (!self.ok) { - drop$Result_sync_Arc_u32_sync_Arc_dyn_Any_marker_Sync_marker_Send(self); - return _0; - } - return _0; -} - -export function ok$0lceojf(self: rt.Result<[rt.usize, rt.u8], rt.Arc>): [rt.usize, rt.u8] | undefined { - let _0!: [rt.usize, rt.u8] | undefined; - if (self.ok) { - _0 = self.value; - } else { - _0 = undefined; - } - if (!self.ok) { - drop$Result_tuple2_usize_u8_sync_Arc_dyn_Any_marker_Sync_marker_Send(self); - return _0; - } - return _0; -} - -export function ok$1c77lmd(self: rt.Result): rt.u8 | undefined { - if (self.ok) { - return self.value; - } - return undefined; -} - -export function err$1ujom0k(self: rt.Result): rt.ParseBoolError | undefined { - if (self.ok) { - return undefined; - } - return self.error; -} - -export function err$02r96h1(self: rt.Result): rt.ParseCharError | undefined { - if (self.ok) { - return undefined; - } - return self.error; -} - -export function err$0jf6smd(self: rt.Result): rt.ParseIntError | undefined { - if (self.ok) { - return undefined; - } - return self.error; -} - -export function err$1nqzzwu(self: rt.Result): rt.u8 | undefined { - if (self.ok) { - return undefined; - } - return self.error; -} - -export function err$05f656d(self: rt.Result): rt.u16 | undefined { - if (self.ok) { - return undefined; - } - return self.error; -} - -export function err$1nbmqmx(self: rt.Result): rt.u8 | undefined { - if (self.ok) { - return undefined; - } - return self.error; -} - -export function asRef$0iljode(self: rt.Result<[rt.u32, rt.u32], rt.u8>): rt.Result<[rt.u32, rt.u32], rt.u8> { - if (self.ok) { - return rt.Ok(self.value); - } - return rt.Err(self.error); -} - -export function asRef$10maq8w(self: rt.Result): rt.Result { - if (self.ok) { - return rt.Ok(self.value); - } - return rt.Err(self.error); -} - -export function asRef$1glrxiq(self: rt.Result): rt.Result { - if (self.ok) { - return rt.Ok(self.value); - } - return rt.Err(self.error); -} - -export function asRef$0ssaoss(self: rt.Result): rt.Result { - if (self.ok) { - return rt.Ok(self.value); - } - return rt.Err(self.error); -} - -export function map$0d4vpmj(self: rt.Result, op: (a0: rt.i64[]) => rt.usize): rt.Result { - if (self.ok) { - return rt.Ok(op(self.value)); - } - return rt.ERR; -} - -export function map$1qqg34g(self: rt.Result, op: (a0: rt.ByteVec) => rt.ByteVec): rt.Result { - if (self.ok) { - return rt.Ok(op(self.value)); - } - return self; -} - -export function map$1w3j91w(self: rt.Result, op: (a0: rt.ByteVec) => rt.usize): rt.Result { - if (self.ok) { - return rt.Ok(op(self.value)); - } - return rt.ERR; -} - -export function map$0fm1w6u(self: rt.Result, op: (a0: boolean) => rt.Result): rt.Result, rt.ParseBoolError> { - if (self.ok) { - return rt.Ok(op(self.value)); - } - return self as rt.Result, rt.ParseBoolError>; -} - -export function map$0n1xnuw(self: rt.Result, rt.BorrowMutError>, op: (a0: rt.RefCell) => rt.u8): rt.Result { - if (self.ok) { - return rt.Ok(op(self.value)); - } - return self as rt.Result; -} - -export function map$1ma2nl9(self: rt.Result, op: (a0: rt.u8 | undefined) => undefined): rt.Result { - if (self.ok) { - op(self.value); - return rt.OK; - } - return self as rt.Result; -} - -export function map$0l5uclx(self: rt.Result, op: (a0: string) => undefined): rt.Result { - if (self.ok) { - op(self.value); - return rt.OK; - } - return self as rt.Result; -} - -export function map$14n87rz(self: rt.Result, op: (a0: rt.ByteVec) => undefined): rt.Result { - if (self.ok) { - op(self.value); - return rt.OK; - } - return self as rt.Result; -} - -export function map$17yn9bi(self: rt.Result<[rt.u32, rt.u32], rt.u8>, _: (a0: [rt.u32, rt.u32]) => [rt.u32, rt.u32]): rt.Result<[rt.u32, rt.u32], rt.u8> { - if (self.ok) { - return rt.Ok(self.value); - } - return self; -} - -export function map$0m0doqe(self: rt.Result, _: (a0: rt.u32) => rt.u32): rt.Result { - if (self.ok) { - return rt.Ok(self.value); - } - return self; -} - -export function map$0nfi04k(self: rt.Result<[rt.u32, rt.u32], rt.u8>, op: (a0: [rt.u32, rt.u32]) => rt.u32): rt.Result { - if (self.ok) { - return rt.Ok(op(self.value)); - } - return self as rt.Result; -} - -export function map$0h1vl84(self: rt.Result, op: (a0: rt.u64) => undefined): rt.Result { - if (self.ok) { - op(self.value); - return rt.OK; - } - return self as rt.Result; -} - -export function map$03hz3l7(self: rt.Result, op: (a0: rt.u8) => undefined): rt.Result { - if (self.ok) { - op(self.value); - return rt.OK; - } - return self as rt.Result; -} - -export function map$0yqi183(self: rt.Result, op: (a0: undefined) => undefined): rt.Result { - if (self.ok) { - op(self.value); - return rt.OK; - } - return self; -} - -export function map$0zzqmaz(self: rt.Result, rt.Arc>, op: (a0: rt.Arc<[rt.u8, rt.u8]>) => [rt.usize, rt.u8]): rt.Result<[rt.usize, rt.u8], rt.Arc> { - if (self.ok) { - return rt.Ok(op(self.value)); - } - return rt.Err(self.error); -} - -export function map$02txiwz(self: rt.Result, rt.Mutex>, op: (a0: rt.Mutex) => rt.Result, rt.Mutex>): rt.Result, rt.Mutex>, rt.Mutex> { - if (self.ok) { - return rt.Ok(op(self.value)); - } - return self as rt.Result, rt.Mutex>, rt.Mutex>; -} - -export function map$1g6jln5(self: rt.Result, rt.RefCell>, op: (a0: rt.RefCell) => rt.Result, rt.RefCell>): rt.Result, rt.RefCell>, rt.RefCell> { - if (self.ok) { - return rt.Ok(op(self.value)); - } - return self as rt.Result, rt.RefCell>, rt.RefCell>; -} - -export function map$1rffkv6(self: rt.Result, _: (a0: rt.u32) => rt.u64): rt.Result { - if (self.ok) { - return rt.Ok(self.value as rt.u64); - } - return self as rt.Result; -} - -export function map$0r57egs(self: rt.Result, op: (a0: rt.u8) => rt.u8 | undefined): rt.Result { - if (self.ok) { - return rt.Ok(op(self.value)); - } - return self as rt.Result; -} - -export function map$1dbyvzi(self: rt.Result, op: (a0: rt.u8) => rt.u8): rt.Result { - if (self.ok) { - return rt.Ok(op(self.value)); - } - return self; -} - -export function map$132mdj8(self: rt.Result, op: (a0: rt.u8) => rt.u8): rt.Result { - if (self.ok) { - return rt.Ok(op(self.value)); - } - return self; -} - -export function mapOr$0fbyajt(self: rt.Result, default_: rt.usize, _: (a0: rt.ByteSlice) => rt.usize): rt.usize { - if (self.ok) { - return self.value.length; - } - return default_; -} - -export function mapOr$0666x4n(self: rt.Result, rt.TryLockError>>, default_: rt.u8, f: (a0: rt.Mutex) => rt.u8): rt.u8 { - let _0!: rt.u8; - if (self.ok) { - _0 = f(self.value); - } else { - _0 = default_; - } - if (!self.ok) { - drop$Result_sync_MutexGuard_locks_Tally_sync_TryLockError_sync_MutexGuard_locks_Tally(self); - return _0; - } - return _0; -} - -export function mapOr$1qkf3ab(self: rt.Result, rt.TryLockError>>, default_: rt.u8, f: (a0: rt.RefCell) => rt.u8): rt.u8 { - let _0!: rt.u8; - if (self.ok) { - _0 = f(self.value); - } else { - _0 = default_; - } - if (!self.ok) { - drop$Result_sync_RwLockReadGuard_locks_Tally_sync_TryLockError_sync_RwLockReadGuard_locks_Tally(self); - return _0; - } - return _0; -} - -export function mapOr$1mu5bvh(self: rt.Result, default_: rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { - if (self.ok) { - return f(self.value); - } - return default_; -} - -export function mapOr$18ipla0(self: rt.Result, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { - if (self.ok) { - return f(self.value); - } - return default_; -} - -export function mapOrElse$0jxx67n(self: rt.Result, default_: (a0: rt.u16) => rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { - if (self.ok) { - return f(self.value); - } - return default_(self.error); -} - -export function mapErr$0fesv1f(self: rt.Result, op: (a0: rt.LayoutError) => heap_Fault.Fault): rt.Result { - if (self.ok) { - return self as rt.Result; - } - return rt.Err(op(self.error)); -} - -export function mapErr$12w1s5x(self: rt.Result, _: (a0: rt.u8) => rt.u16): rt.Result { - if (self.ok) { - return self as rt.Result; - } - return rt.Err(self.error as rt.u16); -} - -export function mapErr$1lsqfgi(self: rt.Result, op: (a0: rt.u16) => rt.u16): rt.Result { - if (self.ok) { - return self; - } - return rt.Err(op(self.error)); -} - -export function mapErr$1ff8zoy(self: rt.Result, _: (a0: rt.ParseIntError) => Failure.Failure): rt.Result { - if (self.ok) { - return self as rt.Result; - } - return rt.Err({ tag: "Parse", _0: self.error } as Failure.Failure); -} - -export function mapErr$0u5yxjj(self: rt.Result, op: (a0: rt.ParseIntError) => rt.IntErrorKind): rt.Result { - if (self.ok) { - return self as rt.Result; - } - return rt.Err(op(self.error)); -} - -export function mapErr$0dzqwjy(self: rt.Result, op: (a0: string) => rt.u8): rt.Result { - if (self.ok) { - return self as rt.Result; - } - return rt.Err(op(self.error)); -} - -export function mapErr$1whfgss(self: rt.Result, op: (a0: undefined) => undefined): rt.Result { - if (self.ok) { - return self; - } - op(undefined); - return rt.ERR; -} - -export function inspect$16o3gle(self: rt.Result, f: (a0: rt.u8) => undefined): rt.Result { - if (self.ok) { - f(self.value); - } - return self; -} - -export function inspectErr$0g3nypv(self: rt.Result, f: (a0: rt.usize) => undefined): rt.Result { - if (!self.ok) { - f(self.error); - } - return self; -} - -export function inspectErr$06tv5sa(self: rt.Result, f: (a0: rt.u16) => undefined): rt.Result { - if (!self.ok) { - f(self.error); - } - return self; -} - -export function asDeref$1fldd5d(self: rt.Result<[rt.u32, rt.u32], rt.u8>): rt.Result<[rt.u32, rt.u32], rt.u8> { - return map$17yn9bi(asRef$0iljode(self), (a0: [rt.u32, rt.u32]): [rt.u32, rt.u32] => { - return a0; - }); -} - -export function asDeref$04i8i5u(self: rt.Result): rt.Result { - return map$0m0doqe(asRef$10maq8w(self), (a0: rt.u32): rt.u32 => { - return a0; - }); -} - -export function unwrapOrDefault$1exw7nd(self: rt.Result): rt.u8 { - if (self.ok) { - return self.value; - } - return 0; -} - -export function and$0l7ltae(self: rt.Result, res: rt.Result): rt.Result { - if (self.ok) { - return res; - } - return self; -} - -export function andThen$1yropo4(self: rt.Result<[rt.ByteSlice, rt.ByteSlice], returns_Error.Error>, op: (a0: [rt.ByteSlice, rt.ByteSlice]) => rt.Result): rt.Result { - if (self.ok) { - return op(self.value); - } - return self as rt.Result; -} - -export function andThen$0hd6ik8(self: rt.Result, op: (a0: rt.u8) => rt.Result): rt.Result { - if (self.ok) { - return op(self.value); - } - return self; -} - -export function or$1xcfx3w(self: rt.Result, res: rt.Result): rt.Result { - if (self.ok) { - return self; - } - return res; -} - -export function orElse$13ay4um(self: rt.Result, op: (a0: rt.u16) => rt.Result): rt.Result { - if (self.ok) { - return self; - } - return op(self.error); -} - -export function unwrapOr$1pnwyus(self: rt.Result, default_: rt.i16): rt.i16 { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$0xokg9f(self: rt.Result, default_: rt.i32): rt.i32 { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$1imvcmw(self: rt.Result, default_: rt.i64): rt.i64 { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$06fxvgg(self: rt.Result, default_: rt.i8): rt.i8 { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$0gr9tn5(self: rt.Result, default_: rt.isize): rt.isize { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$01jdcm7(self: rt.Result, default_: string): string { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$0nhd29g(self: rt.Result, default_: rt.u16): rt.u16 { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$0hnup9g(self: rt.Result, default_: rt.u16): rt.u16 { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$0u9zzk3(self: rt.Result, default_: rt.u32): rt.u32 { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$0e4foht(self: rt.Result, default_: rt.u32): rt.u32 { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$1dnnsw8(self: rt.Result, default_: rt.u32): rt.u32 { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$09i71ei(self: rt.Result, default_: rt.u64): rt.u64 { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$1k2j44a(self: rt.Result, default_: rt.u64): rt.u64 { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$0k9nfhn(self: rt.Result, default_: rt.u8): rt.u8 { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$0a4h2e7(self: rt.Result, default_: rt.u8): rt.u8 { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$0jmm2jy(self: rt.Result, default_: rt.u8): rt.u8 { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOr$1czbd6g(self: rt.Result, default_: rt.usize): rt.usize { - if (self.ok) { - return self.value; - } - return default_; -} - -export function unwrapOrElse$1reohq9(self: rt.Result, op: (a0: rt.u16) => rt.u8): rt.u8 { - if (self.ok) { - return self.value; - } - return op(self.error); -} - -export function unwrapOrElse$009ibtw(self: rt.Result, op: (a0: rt.u8) => rt.u8): rt.u8 { - if (self.ok) { - return self.value; - } - return op(self.error); -} - -export function copied$0bbq7yi(self: rt.Result): rt.Result { - if (self.ok) { - return rt.Ok(self.value); - } - return self; -} - -export function copied$0ma6p21(self: rt.Result): rt.Result { - if (self.ok) { - return rt.Ok(self.value); - } - return self; -} - -export function clone$04fntvl(self: rt.Result): rt.Result { - if (self.ok) { - return rt.Ok(rt.byteVecFrom(rt.byteVecView(self.value))); - } - return rt.Err(self.error); -} - -//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/expected/ends.ts b/ts/fixtures/lang/expected/ends.ts deleted file mode 100644 index be8e28ffd..000000000 --- a/ts/fixtures/lang/expected/ends.ts +++ /dev/null @@ -1,324 +0,0 @@ -// Generated by rust2-ts. Do not edit. - -import * as rt from "./rt.ts"; -import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$05nbzug as option_map$05nbzug, map$1sj2ls1 as option_map$1sj2ls1, mapOr$02k4ito as option_mapOr$02k4ito } from "./core/option.ts"; -import * as ends_Counted from "./ends.Counted.ts"; -import * as Flicker from "./ends.Flicker.ts"; -import * as Lapse from "./ends.Lapse.ts"; -import * as ends_Run from "./ends.Run.ts"; - -/** An item, or 0xff for `None`. */ -export function put(out: rt.ByteVec, item: rt.u8 | undefined): void { - rt.byteVecPush(out, option_unwrapOr$0r2bmpr(item, 255)); -} - -/** A hint, the upper bound 0xff for `None`. */ -export function putHint(out: rt.ByteVec, _2: [rt.usize, rt.usize | undefined]): void { - const lower: rt.usize = _2[0]; - const upper: rt.usize | undefined = _2[1]; - rt.byteVecPush(out, lower & 0xff); - rt.byteVecPush(out, option_mapOr$02k4ito(upper, 255, (upper2: rt.usize): rt.u8 => { - return upper2 & 0xff; - })); -} - -/** - * A `Vec` collected or extended by `items`, by its length and capacity: what std reserved - * by their hints. - */ -export function putVec(out: rt.ByteVec, v: rt.ByteVec): void { - rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(v.length & 0xff, v.data.length & 0xff)), undefined, true); - rt.iterExtendBytes(out, rt.byteVecIntoIter(v), undefined, true); -} - -/** - * The run `data`'s first byte picks steps through with each of its other bytes, read - * directly, through `&mut`, or by std's adaptors, and consumed by the third byte's pick, - * with what each read and each call of its methods logged. - */ -export function ends(kind: rt.u8, dataData: Uint8Array, dataStart: number, dataLen: number, out: rt.ByteVec): void { - let over!: rt.u8 | undefined; - let item!: rt.u8 | undefined; - if (dataLen >= 2) { - const log: rt.RefCell = new rt.RefCell(new rt.ByteVec()); - const over2: rt.u8 = rt.u8Shr(dataData[dataStart], 4) & 3; - if (over2 === 0) { - over = undefined; - } else { - over = rt.u8Sub(over2, 1); - } - const run: ends_Run.Run = { front: 0, back: rt.u8Rem(dataData[dataStart], 16), over, log }; - const iter: rt.Iter = rt.iterTake(rt.iterSlice(rt.byteSliceView(new rt.ByteSlice(dataData, dataStart + 2, dataLen - 2))), 8); - while (true) { - const _25: rt.u8 | rt.Done = iter.next(); - if (_25 === rt.DONE) { - break; - } - const step: rt.u8 = _25; - const _29: rt.u8 = rt.u8Rem(step, 8); - if (_29 === 0) { - put(out, rt.iterToOption(ends_Run.next$iter_Iterator(run))); - } else if (_29 === 1) { - put(out, ends_Run.nextBack$iter_DoubleEndedIterator(run)); - } else if (_29 === 2) { - const _37: rt.usize = rt.usizeRem(step >> 3 as rt.usize, 4); - put(out, rt.iterNthBack(rt.iterFrom(run, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))), _37)); - } else if (_29 === 3) { - rt.byteVecPush(out, rt.iterFrom(run, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))).len() & 0xff); - } else if (_29 === 4) { - putHint(out, ends_Run.sizeHint$iter_Iterator(run)); - } else if (_29 === 5) { - if (!((step & 8) === 0)) { - put(out, ends_Run.nextBack$iter_DoubleEndedIterator(run)); - } else { - put(out, rt.iterToOption(rt.iterRev(rt.iterFrom(run, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it)))).next())); - } - } else if (_29 === 6) { - rt.byteVecPush(out, rt.iterFrom(run, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))).len() & 0xff); - } else { - const _62: rt.usize = rt.usizeRem(step >> 3 as rt.usize, 4); - put(out, rt.iterNth(rt.iterFrom(run, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))), _62)); - } - } - const k: rt.usize = rt.u8Shr(dataData[dataStart + 1], 4) as rt.usize; - b4: { - const _71: rt.u8 = rt.u8Rem(kind, 4); - if (_71 === 0) { - consumed$ends_Run(run, rt.u8Rem(dataData[dataStart + 1], 16), k, out); - } else if (_71 === 1) { - consumed$ends_Counted({ _0: run }, rt.u8Rem(dataData[dataStart + 1], 16), k, out); - } else if (_71 === 2) { - fuses(dataData[dataStart + 1], out); - } else { - let bits: rt.u8 = dataData[dataStart + 1]; - while (true) { - if ((bits & 1) === 0) { - item = rt.iterToOption(ends_Run.next$iter_Iterator(run)); - } else { - item = ends_Run.nextBack$iter_DoubleEndedIterator(run); - } - bits = rt.intRotateRight(bits, 1, 8, false); - put(out, item); - if (item === undefined) { - put(out, ends_Run.nextBack$iter_DoubleEndedIterator(run)); - break b4; - } - } - } - } - rt.byteVecPush(out, 254); - rt.iterExtendBytes(out, rt.byteVecIntoIter(log.value), undefined, true); - } -} - -/** `it`, consumed by std's adaptor or consumer `pick`, with `k` its count where it takes one. */ -export function consumed$ends_Counted(it: ends_Counted.Counted, pick: rt.u8, k: rt.usize, out: rt.ByteVec): void { - let _32!: rt.u8 | undefined; - if (pick === 0) { - putVec(out, rt.iterToByteVec(rt.iterRev(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it))), "next")); - } else if (pick === 1) { - putVec(out, rt.iterToByteVec(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it)), "next")); - } else if (pick === 2) { - rt.byteVecPush(out, rt.iterRev(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it))).len() & 0xff); - } else if (pick === 3) { - rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterRev(rt.iterEnumerate(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it)))), (_211: [rt.usize, rt.u8]): Uint8Array => { - return Uint8Array.of(_211[0] & 0xff, _211[1]); - }, (value: Uint8Array) => rt.iterSlice(value), false, 2), "next"); - } else if (pick === 4) { - rt.iterExtendBytes(out, rt.iterRev(rt.iterSkip(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it)), k)), "next"); - } else if (pick === 5) { - rt.iterExtendBytes(out, rt.iterRev(rt.iterTake(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it)), k)), "next"); - } else if (pick === 6) { - const _27: ends_Counted.Counted = it; - const _28: rt.usize = rt.max(k, 1); - rt.iterExtendBytes(out, rt.iterRev(rt.iterStepBy(rt.iterFrom(_27, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it)), _28)), "next"); - } else if (pick === 7) { - put(out, option_map$05nbzug(rt.iterRposition(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it)), (b8: rt.u8): boolean => { - return rt.u8Rem(b8, 3) === 0; - }), (i3: rt.usize): rt.u8 => { - return i3 & 0xff; - })); - } else if (pick === 8) { - const _33: rt.usize = rt.usizeRem(k, 4); - if (_33 === 0) { - const _37: ends_Counted.Counted = it; - const _38: rt.usize = rt.usizeDiv(k, 4); - _32 = rt.iterRfind(rt.iterSkip(rt.iterFrom(_37, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it)), _38), (b7: rt.u8): boolean => { - return rt.u8Rem(b7, 3) === 0; - }); - } else if (_33 === 1) { - const _42: ends_Counted.Counted = it; - const _43: rt.usize = rt.usizeDiv(k, 4); - _32 = rt.iterRfind(rt.iterTake(rt.iterFrom(_42, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it)), _43), (b6: rt.u8): boolean => { - return rt.u8Rem(b6, 3) === 0; - }); - } else if (_33 === 2) { - _32 = option_map$1sj2ls1(rt.iterRfind(rt.iterEnumerate(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it))), (_2: [rt.usize, rt.u8]): boolean => { - return rt.u8Rem(rt.u8Add(_2[0] & 0xff, _2[1]), 3) === 0; - }), (_210: [rt.usize, rt.u8]): rt.u8 => { - return (_210[0] & 0xff) ^ _210[1]; - }); - } else { - const _51: ends_Counted.Counted = it; - const _52: rt.usize = rt.usizeAdd(rt.usizeDiv(k, 4), 1); - _32 = rt.iterRfind(rt.iterStepBy(rt.iterFrom(_51, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it)), _52), (b3: rt.u8): boolean => { - return rt.u8Rem(b3, 3) === 0; - }); - } - put(out, _32); - } else if (pick === 9) { - put(out, rt.iterLast(rt.iterRev(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it))))); - } else if (pick === 10) { - rt.iterExtendBytes(out, rt.iterTake(rt.iterRev(rt.iterMap(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it)), (b2: rt.u8): rt.u8 => { - return b2 ^ 85; - })), k), "next"); - } else if (pick === 11) { - const v: rt.ByteVec = rt.byteVecFrom(Uint8Array.of(170)); - const _67: rt.Iter = rt.iterTake(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it)), k); - rt.iterExtendBytes(v, _67, "next"); - putVec(out, v); - rt.byteVecPush(out, ends_Counted.len$iter_ExactSizeIterator(it) & 0xff); - } else if (pick === 12) { - const zip: rt.Iter<[rt.u8, rt.u8]> = rt.iterZip(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it)), new rt.Range(0, 5)); - while (true) { - const _79: [rt.u8, rt.u8] | undefined = rt.iterToOption(zip.nextBack()); - if (_79 !== undefined) { - rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_79[0], _79[1])), undefined, true); - } else { - break; - } - } - } else if (pick === 13) { - const fused: rt.Iter = rt.iterFuse(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it))); - put(out, rt.iterToOption(fused.nextBack())); - rt.byteVecPush(out, fused.len() & 0xff); - rt.iterExtendBytes(out, fused, "next"); - } else if (pick === 14) { - put(out, rt.iterNth(rt.iterRev(rt.iterChain(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it)), rt.iterSlice(Uint8Array.of(7, 8)))), k)); - } else { - const peek: rt.Peekable = rt.iterPeekable(rt.iterFrom(it, (it: ends_Counted.Counted) => ends_Counted.next$iter_Iterator(it), undefined, (it: ends_Counted.Counted) => ends_Counted.sizeHint$iter_Iterator(it), (it: ends_Counted.Counted) => rt.iterFromOption(ends_Counted.nextBack$iter_DoubleEndedIterator(it)), (it: ends_Counted.Counted) => ends_Counted.len$iter_ExactSizeIterator(it))); - put(out, rt.peekablePeek(peek)); - rt.byteVecPush(out, peek.len() & 0xff); - rt.iterExtendBytes(out, rt.iterRev(peek), "next"); - } -} - -/** `it`, consumed by std's adaptor or consumer `pick`, with `k` its count where it takes one. */ -export function consumed$ends_Run(it: ends_Run.Run, pick: rt.u8, k: rt.usize, out: rt.ByteVec): void { - let _32!: rt.u8 | undefined; - if (pick === 0) { - putVec(out, rt.iterToByteVec(rt.iterRev(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it)))), "next")); - } else if (pick === 1) { - putVec(out, rt.iterToByteVec(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))), "next")); - } else if (pick === 2) { - rt.byteVecPush(out, rt.iterRev(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it)))).len() & 0xff); - } else if (pick === 3) { - rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterRev(rt.iterEnumerate(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))))), (_211: [rt.usize, rt.u8]): Uint8Array => { - return Uint8Array.of(_211[0] & 0xff, _211[1]); - }, (value: Uint8Array) => rt.iterSlice(value), false, 2), "next"); - } else if (pick === 4) { - rt.iterExtendBytes(out, rt.iterRev(rt.iterSkip(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))), k)), "next"); - } else if (pick === 5) { - rt.iterExtendBytes(out, rt.iterRev(rt.iterTake(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))), k)), "next"); - } else if (pick === 6) { - const _27: ends_Run.Run = it; - const _28: rt.usize = rt.max(k, 1); - rt.iterExtendBytes(out, rt.iterRev(rt.iterStepBy(rt.iterFrom(_27, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))), _28)), "next"); - } else if (pick === 7) { - put(out, option_map$05nbzug(rt.iterRposition(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))), (b8: rt.u8): boolean => { - return rt.u8Rem(b8, 3) === 0; - }), (i3: rt.usize): rt.u8 => { - return i3 & 0xff; - })); - } else if (pick === 8) { - const _33: rt.usize = rt.usizeRem(k, 4); - if (_33 === 0) { - const _37: ends_Run.Run = it; - const _38: rt.usize = rt.usizeDiv(k, 4); - _32 = rt.iterRfind(rt.iterSkip(rt.iterFrom(_37, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))), _38), (b7: rt.u8): boolean => { - return rt.u8Rem(b7, 3) === 0; - }); - } else if (_33 === 1) { - const _42: ends_Run.Run = it; - const _43: rt.usize = rt.usizeDiv(k, 4); - _32 = rt.iterRfind(rt.iterTake(rt.iterFrom(_42, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))), _43), (b6: rt.u8): boolean => { - return rt.u8Rem(b6, 3) === 0; - }); - } else if (_33 === 2) { - _32 = option_map$1sj2ls1(rt.iterRfind(rt.iterEnumerate(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it)))), (_2: [rt.usize, rt.u8]): boolean => { - return rt.u8Rem(rt.u8Add(_2[0] & 0xff, _2[1]), 3) === 0; - }), (_210: [rt.usize, rt.u8]): rt.u8 => { - return (_210[0] & 0xff) ^ _210[1]; - }); - } else { - const _51: ends_Run.Run = it; - const _52: rt.usize = rt.usizeAdd(rt.usizeDiv(k, 4), 1); - _32 = rt.iterRfind(rt.iterStepBy(rt.iterFrom(_51, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))), _52), (b3: rt.u8): boolean => { - return rt.u8Rem(b3, 3) === 0; - }); - } - put(out, _32); - } else if (pick === 9) { - put(out, rt.iterLast(rt.iterRev(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it)))))); - } else if (pick === 10) { - rt.iterExtendBytes(out, rt.iterTake(rt.iterRev(rt.iterMap(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))), (b2: rt.u8): rt.u8 => { - return b2 ^ 85; - })), k), "next"); - } else if (pick === 11) { - const v: rt.ByteVec = rt.byteVecFrom(Uint8Array.of(170)); - const _67: rt.Iter = rt.iterTake(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))), k); - rt.iterExtendBytes(v, _67, "next"); - putVec(out, v); - rt.byteVecPush(out, rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))).len() & 0xff); - } else if (pick === 12) { - const zip: rt.Iter<[rt.u8, rt.u8]> = rt.iterZip(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))), new rt.Range(0, 5)); - while (true) { - const _79: [rt.u8, rt.u8] | undefined = rt.iterToOption(zip.nextBack()); - if (_79 !== undefined) { - rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_79[0], _79[1])), undefined, true); - } else { - break; - } - } - } else if (pick === 13) { - const fused: rt.Iter = rt.iterFuse(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it)))); - put(out, rt.iterToOption(fused.nextBack())); - rt.byteVecPush(out, fused.len() & 0xff); - rt.iterExtendBytes(out, fused, "next"); - } else if (pick === 14) { - put(out, rt.iterNth(rt.iterRev(rt.iterChain(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it))), rt.iterSlice(Uint8Array.of(7, 8)))), k)); - } else { - const peek: rt.Peekable = rt.iterPeekable(rt.iterFrom(it, (it: ends_Run.Run) => ends_Run.next$iter_Iterator(it), undefined, (it: ends_Run.Run) => ends_Run.sizeHint$iter_Iterator(it), (it: ends_Run.Run) => rt.iterFromOption(ends_Run.nextBack$iter_DoubleEndedIterator(it)))); - put(out, rt.peekablePeek(peek)); - rt.byteVecPush(out, peek.len() & 0xff); - rt.iterExtendBytes(out, rt.iterRev(peek), "next"); - } -} - -/** - * `fuse` of a `Flicker`, which reads on past its first `None`, or of a `Lapse`, which - * doesn't, read by the bits of `bits` from either end. - */ -export function fuses(bits: rt.u8, out: rt.ByteVec): void { - let _12!: rt.i32; - const start: rt.u8 = bits >> 4; - const fused: rt.Iter = rt.iterFuse(rt.iterFrom({ _0: start }, (it: Flicker.Flicker) => Flicker.next$iter_Iterator(it), undefined, undefined, (it: Flicker.Flicker) => rt.iterFromOption(Flicker.nextBack$iter_DoubleEndedIterator(it))), true); - let iterStart: rt.i32 = 0; - const iterEnd: rt.i32 = 6; - while ((_12 = iterStart++) < iterEnd) { - if ((rt.u8Shr(bits, rt.i32Rem(_12, 4)) & 1) === 0) { - put(out, rt.iterToOption(fused.next())); - } else { - put(out, rt.iterToOption(fused.nextBack())); - } - } - const lapsed: rt.Iter = rt.iterFuse(rt.iterFrom({ _0: { _0: start } }, (it: Lapse.Lapse) => Lapse.next$iter_Iterator(it))); - let iterStart2: rt.i32 = 0; - const iterEnd2: rt.i32 = 4; - while (iterStart2++ < iterEnd2) { - put(out, rt.iterToOption(lapsed.next())); - } - rt.iterExtendBytes(out, rt.byteVecIntoIter(rt.iterToByteVec(rt.iterTake(rt.iterFlatten(rt.iterSlice([{ _0: start }, { _0: rt.u8WrappingAdd(start, 1) }]), (value: Flicker.Flicker) => rt.iterFrom(value, (it: Flicker.Flicker) => Flicker.next$iter_Iterator(it), undefined, undefined, (it: Flicker.Flicker) => rt.iterFromOption(Flicker.nextBack$iter_DoubleEndedIterator(it))), true), 5), "next")), undefined, true); -} - -//# sourceMappingURL=ends.ts.map diff --git a/ts/fixtures/lang/expected/fmt.Nested.ts b/ts/fixtures/lang/expected/fmt.Nested.ts deleted file mode 100644 index 7fabf567f..000000000 --- a/ts/fixtures/lang/expected/fmt.Nested.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Generated by rust2-ts. Do not edit. - -import * as rt from "./rt.ts"; -import * as Kind from "./fmt.Kind.ts"; -import * as fmt_Pair from "./fmt.Pair.ts"; -import * as Point from "./shapes.Point.ts"; -import * as shapes_Shape from "./shapes.Shape.ts"; - -export function fmt$fmt_Debug(self: Nested, f: rt.Formatter): rt.Result { - const names: string[] = ["name", "point", "shape", "tags", "pairs", "maybe", "none", "result", "list", "tuple", "single", "empty", "unit", "boxed"]; - const values: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtStr(self.name, f), (f: rt.Formatter) => Point.fmt$fmt_Debug(self.point, f), (f: rt.Formatter) => shapes_Shape.fmt$fmt_Debug(self.shape, f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(self.tags), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(self.pairs, f, (value: fmt_Pair.Pair, f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(value, f)), (f: rt.Formatter) => rt.fmtOption(self.maybe, f, (value: fmt_Pair.Pair, f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(value, f)), (f: rt.Formatter) => rt.fmtOption(self.none, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtResult(self.result, f, rt.u8Debug, rt.fmtStr), (f: rt.Formatter) => rt.fmtList(self.list, f, rt.i16Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(self.tuple[0], f), (f: rt.Formatter) => rt.fmtBool(self.tuple[1], f), (f: rt.Formatter) => rt.fmtStr(self.tuple[2], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(self.single[0], f)], f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(self.empty), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtUnit(self.unit, f), (f: rt.Formatter) => Kind.fmt$fmt_Debug(self.boxed, f)]; - return rt.fmtDebugStructFields(f, "Nested", names, values); -} - -export interface Nested { - name: string; - point: Point.Point; - shape: shapes_Shape.Shape; - tags: rt.ByteVec; - pairs: fmt_Pair.Pair[]; - maybe: fmt_Pair.Pair | undefined; - none: rt.u8 | undefined; - result: rt.Result; - list: rt.i16[]; - tuple: [rt.u8, boolean, string]; - single: [rt.u8]; - empty: rt.ByteVec; - unit: undefined; - boxed: Kind.Kind; -} - -//# sourceMappingURL=fmt.Nested.ts.map diff --git a/ts/fixtures/lang/expected/harness.ts b/ts/fixtures/lang/expected/harness.ts deleted file mode 100644 index 7ac6fe516..000000000 --- a/ts/fixtures/lang/expected/harness.ts +++ /dev/null @@ -1,401 +0,0 @@ -// Generated by rust2-ts. Do not edit. - -import * as rt from "./rt.ts"; -import { args } from "./args.ts"; -import { fromFns, maps as arrays_maps, lent as arrays_lent, asSlices, given, flattened as arrays_flattened } from "./arrays.ts"; -import { bytes as ascii_bytes, chars as ascii_chars, slices as ascii_slices, parts as ascii_parts } from "./ascii.ts"; -import { atomics } from "./atomics.ts"; -import { borrows as borrows_borrows, guards, maps as borrows_maps, tries, leaks } from "./borrows.ts"; -import { bounds as bounds_bounds } from "./bounds.ts"; -import { boxes, places as boxes_places, impls as boxes_impls } from "./boxes.ts"; -import { vecs as capacity_vecs, deques as capacity_deques, heaps as capacity_heaps, collects, maps as capacity_maps } from "./capacity.ts"; -import { captures } from "./captures.ts"; -import { cells as cells_cells } from "./cells.ts"; -import { chars as chars_chars } from "./chars.ts"; -import { chunks } from "./chunks.ts"; -import { iters as clones_iters } from "./clones.ts"; -import { hashMaps, sets, btreeMaps, deques as collections_deques, dequeRanges, 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"; -import { defaults as defaults_defaults } from "./defaults.ts"; -import { durations } from "./durations.ts"; -import { dyns, shared as dyns_shared, anys, fns, iters as dyns_iters, pointers } from "./dyns.ts"; -import { edits as edits_edits, bytes as edits_bytes } from "./edits.ts"; -import { vecs as elements_vecs, arrays as elements_arrays, segments as elements_segments, inline, edges as elements_edges, rawSlices, emptyParts } from "./elements.ts"; -import { ends as ends_ends } from "./ends.ts"; -import { eqs, objects as errors_objects } from "./errors.ts"; -import { fields as fields_fields } from "./fields.ts"; -import { floats, mulAdds as floats_mulAdds, formats as floats_formats, parses as floats_parses } from "./floats.ts"; -import { ints, strings, derived, written as fmt_written, counts as fmt_counts, rounding, panics as fmt_panics, wrapped as fmt_wrapped, collections, enums, iters as fmt_iters, writes as fmt_writes, objects as fmt_objects } from "./fmt.ts"; -import { folds } from "./folds.ts"; -import { methods, runs } from "./generics.ts"; -import { values as hashes_values, random, bytes as hashes_bytes, own as hashes_own } from "./hashes.ts"; -import { spills, remnants, layouts } from "./heap.ts"; -import { hints, reserves } from "./hints.ts"; -import { holds } from "./holds.ts"; -import { u8Op, u16Op, u32Op, u64Op, u128Op, usizeOp, i8Op, i16Op, i32Op, i64Op, i128Op, isizeOp, i8Neg, i16Neg, i32Neg, i64Neg, i128Neg, isizeNeg, cast as ints_cast, convert, parses as ints_parses, widenings } from "./ints.ts"; -import { adaptors, consumers as iters_consumers, reducers, peekedOthers, skips, ranked as iters_ranked, ranges as iters_ranges, options as iters_options, optionItems, own as iters_own, values as iters_values, returned, zips, zipsBack, rangeFroms, rangeMethods, compares, lent as iters_lent } from "./iters.ts"; -import { joins } from "./joins.ts"; -import { keys as keys_keys, overrides, bytes as keys_bytes, lentKeys, lentValues, arrays as keys_arrays, byteRefs } from "./keys.ts"; -import { lengths } from "./lengths.ts"; -import { lists as lists_lists } from "./lists.ts"; -import { locals } from "./locals.ts"; -import { locks, relock, rwlocks, mapped, mutexMapped, printed as locks_printed, downgraded } from "./locks.ts"; -import { arcs as manual_arcs } from "./manual.ts"; -import { u8s as methods_u8s, u16s as methods_u16s, u32s as methods_u32s, u64s as methods_u64s, u128s as methods_u128s, usizes as methods_usizes, i8s as methods_i8s, i16s as methods_i16s, i32s as methods_i32s, i64s as methods_i64s, i128s as methods_i128s, isizes as methods_isizes } from "./methods.ts"; -import { nested as nested_nested } from "./nested.ts"; -import { objects as objects_objects } from "./objects.ts"; -import { orders, bytes as orders_bytes, tuples as orders_tuples, held as orders_held, btrees as orders_btrees } from "./orders.ts"; -import { lists as pointers_lists, shared as pointers_shared, places as pointers_places, unchecked, nested as pointers_nested, copies as pointers_copies, sentinels, cells as pointers_cells, rebound as pointers_rebound, lapsed, writers, made as pointers_made, segments as pointers_segments, uninitRuns, iteratedRuns, besideWritten, waiters, taken as pointers_taken, bytes as pointers_bytes, loaded, reattached, partWritten, aimed } from "./pointers.ts"; -import { refs, toRefs, adapted as refs_adapted, compared } from "./refs.ts"; -import { results as results_results } from "./results.ts"; -import { returns } from "./returns.ts"; -import { slices as rings_slices } from "./rings.ts"; -import { u8s as saturates_u8s, u16s as saturates_u16s, u32s as saturates_u32s, u64s as saturates_u64s, u128s as saturates_u128s, usizes as saturates_usizes, i8s as saturates_i8s, i16s as saturates_i16s, i32s as saturates_i32s, i64s as saturates_i64s, i128s as saturates_i128s, isizes as saturates_isizes } from "./saturates.ts"; -import { searches, texts } from "./searches.ts"; -import { separated } from "./separated.ts"; -import { copies as shapes_copies, order as shapes_order, discriminants, loops, patterns, uninhabited, closures as shapes_closures, library, flows } from "./shapes.ts"; -import { singles, mulAdds as singles_mulAdds, formats as singles_formats, parses as singles_parses } from "./singles.ts"; -import { parts as slices_parts, chunked, subslices, drains as slices_drains, ranges as slices_ranges, edits as slices_edits } from "./slices.ts"; -import { sorts, disorders, btrees as sorts_btrees } from "./sorts.ts"; -import { splits } from "./splits.ts"; -import { statics, cells as statics_cells, onces } from "./statics.ts"; -import { strs, slices as strs_slices, edits as strs_edits, parses as strs_parses, iters as strs_iters, drains as strs_drains, hinted, gets } from "./strs.ts"; -import { tuples as tuples_tuples } from "./tuples.ts"; -import { decodes } from "./utf8.ts"; -import { wrappers } from "./wrappers.ts"; -import { u8s as wraps_u8s, u16s as wraps_u16s, u32s as wraps_u32s, u64s as wraps_u64s, u128s as wraps_u128s, usizes as wraps_usizes, i8s as wraps_i8s, i16s as wraps_i16s, i32s as wraps_i32s, i64s as wraps_i64s, i128s as wraps_i128s, isizes as wraps_isizes } from "./wraps.ts"; -import { zeros, impls as zeros_impls, keys as zeros_keys, unread, writes as zeros_writes } from "./zeros.ts"; - -/** - * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo - * their count, so a case added at the end moves no other. - */ -export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { - return [["ints::u8_op", u8Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::u16_op", u16Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::u32_op", u32Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::u64_op", u64Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::u128_op", u128Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::usize_op", usizeOp as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::i8_op", i8Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::i16_op", i16Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::i32_op", i32Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::i64_op", i64Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::i128_op", i128Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::isize_op", isizeOp as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::neg", neg as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::cast", cast as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::convert", (_2100: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { - convert(data, out); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::copies", (_2101: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { - shapes_copies(data2, out2); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::loops", (_2102: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { - loops(data3, out3); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::patterns", (_2103: rt.u8, data4: rt.ByteSlice, out4: rt.ByteVec): undefined => { - patterns(data4, out4); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::closures", (_2104: rt.u8, data5: rt.ByteSlice, out5: rt.ByteVec): undefined => { - shapes_closures(data5, out5); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::discriminants", (_2105: rt.u8, data6: rt.ByteSlice, out6: rt.ByteVec): undefined => { - discriminants(data6, out6); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::library", (_2106: rt.u8, data7: rt.ByteSlice, out7: rt.ByteVec): undefined => { - library(data7, out7); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::ints", ints as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::strings", (_2107: rt.u8, data8: rt.ByteSlice, out8: rt.ByteVec): undefined => { - strings(data8, out8); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::derived", (_2108: rt.u8, data9: rt.ByteSlice, out9: rt.ByteVec): undefined => { - derived(data9, out9); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::written", (_2109: rt.u8, data10: rt.ByteSlice, out10: rt.ByteVec): undefined => { - fmt_written(data10, out10); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::panics", fmt_panics as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["generics::methods", (_2110: rt.u8, data11: rt.ByteSlice, out11: rt.ByteVec): undefined => { - methods(data11, out11); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::adaptors", adaptors as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::consumers", iters_consumers as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::ranges", (_2111: rt.u8, data12: rt.ByteSlice, out12: rt.ByteVec): undefined => { - iters_ranges(data12, out12); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::options", (_2112: rt.u8, data13: rt.ByteSlice, out13: rt.ByteVec): undefined => { - iters_options(data13, out13); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::own", (_2113: rt.u8, data14: rt.ByteSlice, out14: rt.ByteVec): undefined => { - iters_own(data14, out14); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::values", (_2114: rt.u8, data15: rt.ByteSlice, out15: rt.ByteVec): undefined => { - iters_values(data15, out15); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::order", (_2115: rt.u8, data16: rt.ByteSlice, out16: rt.ByteVec): undefined => { - shapes_order(data16, out16); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::hash_maps", hashMaps as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::sets", sets as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::btree_maps", btreeMaps as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::deques", (_2116: rt.u8, data17: rt.ByteSlice, out17: rt.ByteVec): undefined => { - collections_deques(data17, out17); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::flows", (_2117: rt.u8, data18: rt.ByteSlice, out18: rt.ByteVec): undefined => { - flows(data18, out18); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["keys::keys", keys_keys as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["chars::chars", chars_chars as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::strs", strs as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::vecs", (_2118: rt.u8, data19: rt.ByteSlice, out19: rt.ByteVec): undefined => { - collections_vecs(data19, out19); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::slices", strs_slices as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::stores", (_2119: rt.u8, data20: rt.ByteSlice, out20: rt.ByteVec): undefined => { - stores(data20, out20); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["chunks::chunks", chunks as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["cows::cows", cows as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["durations::durations", durations as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["combinators::combinators", combinators as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["splits::splits", splits as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["nested::nested", nested_nested as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["refs::refs", (_2120: rt.u8, data21: rt.ByteSlice, out21: rt.ByteVec): undefined => { - refs(data21, out21); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::counts", (_2121: rt.u8, data22: rt.ByteSlice, out22: rt.ByteVec): undefined => { - fmt_counts(data22, out22); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::rounding", (_2122: rt.u8, _3100: rt.ByteSlice, out23: rt.ByteVec): undefined => { - rounding(out23); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::skips", skips as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wrappers::wrappers", wrappers as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["edits::edits", edits_edits as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["utf8::decodes", decodes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["floats::floats", floats as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["atomics::atomics", atomics as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["keys::overrides", overrides as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["dyns::dyns", (_2123: rt.u8, data23: rt.ByteSlice, out24: rt.ByteVec): undefined => { - dyns(data23.data, data23.start, data23.length, out24); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["cells::cells", cells_cells as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["dyns::shared", (_2124: rt.u8, data24: rt.ByteSlice, out25: rt.ByteVec): undefined => { - dyns_shared(data24.data, data24.start, data24.length, out25); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::ranked", iters_ranked as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["captures::captures", captures as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::locks", (_2125: rt.u8, data25: rt.ByteSlice, out26: rt.ByteVec): undefined => { - locks(data25, out26); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::relock", (_2126: rt.u8, data26: rt.ByteSlice, out27: rt.ByteVec): undefined => { - relock(data26, out27); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locals::locals", (_2127: rt.u8, data27: rt.ByteSlice, out28: rt.ByteVec): undefined => { - locals(data27, out28); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["statics::statics", (_2128: rt.u8, data28: rt.ByteSlice, out29: rt.ByteVec): undefined => { - statics(data28, out29); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::rwlocks", (_2129: rt.u8, data29: rt.ByteSlice, out30: rt.ByteVec): undefined => { - rwlocks(data29, out30); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["borrows::borrows", (_2130: rt.u8, data30: rt.ByteSlice, out31: rt.ByteVec): undefined => { - borrows_borrows(data30, out31); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["defaults::defaults", (_2131: rt.u8, data31: rt.ByteSlice, out32: rt.ByteVec): undefined => { - defaults_defaults(data31, out32); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::arcs", (_2132: rt.u8, data32: rt.ByteSlice, out33: rt.ByteVec): undefined => { - counts_arcs(data32, out33); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::rcs", (_2133: rt.u8, data33: rt.ByteSlice, out34: rt.ByteVec): undefined => { - rcs(data33, out34); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::cyclic_arcs", (_2134: rt.u8, data34: rt.ByteSlice, out35: rt.ByteVec): undefined => { - cyclicArcs(data34, out35); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::cyclic_rcs", (_2135: rt.u8, data35: rt.ByteSlice, out36: rt.ByteVec): undefined => { - cyclicRcs(data35, out36); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::unique_arcs", (_2136: rt.u8, data36: rt.ByteSlice, out37: rt.ByteVec): undefined => { - uniqueArcs(data36, out37); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::unique_rcs", (_2137: rt.u8, data37: rt.ByteSlice, out38: rt.ByteVec): undefined => { - uniqueRcs(data37, out38); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["dyns::anys", (_2138: rt.u8, data38: rt.ByteSlice, out39: rt.ByteVec): undefined => { - anys(data38.data, data38.start, data38.length, out39); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["dyns::fns", (_2139: rt.u8, data39: rt.ByteSlice, out40: rt.ByteVec): undefined => { - fns(data39, out40); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::copies", (_2140: rt.u8, data40: rt.ByteSlice, out41: rt.ByteVec): undefined => { - pointers_copies(data40, out41); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::lists", (_2141: rt.u8, data41: rt.ByteSlice, out42: rt.ByteVec): undefined => { - pointers_lists(data41.data, data41.start, data41.length, out42); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::nested", (_2142: rt.u8, data42: rt.ByteSlice, out43: rt.ByteVec): undefined => { - pointers_nested(data42, out43); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::places", (_2143: rt.u8, data43: rt.ByteSlice, out44: rt.ByteVec): undefined => { - pointers_places(data43, out44); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::sentinels", (_2144: rt.u8, data44: rt.ByteSlice, out45: rt.ByteVec): undefined => { - sentinels(data44, out45); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::shared", (_2145: rt.u8, data45: rt.ByteSlice, out46: rt.ByteVec): undefined => { - pointers_shared(data45.data, data45.start, data45.length, out46); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::unchecked", (_2146: rt.u8, data46: rt.ByteSlice, out47: rt.ByteVec): undefined => { - unchecked(data46, out47); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["edits::bytes", edits_bytes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["arrays::from_fns", (_2147: rt.u8, data47: rt.ByteSlice, out48: rt.ByteVec): undefined => { - fromFns(data47, out48); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::optionals", optionals as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["objects::objects", (_2148: rt.u8, data48: rt.ByteSlice, out49: rt.ByteVec): undefined => { - objects_objects(data48, out49); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["holds::holds", holds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::wrapped", (_2149: rt.u8, data49: rt.ByteSlice, out50: rt.ByteVec): undefined => { - fmt_wrapped(data49, out50); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["refs::to_refs", (_2150: rt.u8, data50: rt.ByteSlice, out51: rt.ByteVec): undefined => { - toRefs(data50, out51); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["orders::orders", orders as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::cloned_arcs", (_2151: rt.u8, data51: rt.ByteSlice, out52: rt.ByteVec): undefined => { - clonedArcs(data51, out52); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::cloned_rcs", (_2152: rt.u8, data52: rt.ByteSlice, out53: rt.ByteVec): undefined => { - clonedRcs(data52, out53); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["counts::copies", (_2153: rt.u8, data53: rt.ByteSlice, out54: rt.ByteVec): undefined => { - counts_copies(data53, out54); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["statics::cells", (_2154: rt.u8, data54: rt.ByteSlice, out55: rt.ByteVec): undefined => { - statics_cells(data54, out55); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::returned", (_2155: rt.u8, data55: rt.ByteSlice, out56: rt.ByteVec): undefined => { - returned(data55, out56); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["hashes::values", hashes_values as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["hashes::random", (_2156: rt.u8, data56: rt.ByteSlice, out57: rt.ByteVec): undefined => { - random(data56, out57); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["floats::formats", floats_formats as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["floats::parses", floats_parses as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["orders::bytes", (_2157: rt.u8, data57: rt.ByteSlice, out58: rt.ByteVec): undefined => { - orders_bytes(data57, out58); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["slices::parts", slices_parts as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["slices::drains", slices_drains as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["slices::chunked", chunked as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["statics::onces", (_2158: rt.u8, data58: rt.ByteSlice, out59: rt.ByteVec): undefined => { - onces(data58, out59); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::writes", (_2159: rt.u8, data59: rt.ByteSlice, out60: rt.ByteVec): undefined => { - fmt_writes(data59, out60); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["bounds::bounds", bounds_bounds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::cells", (_2160: rt.u8, data60: rt.ByteSlice, out61: rt.ByteVec): undefined => { - pointers_cells(data60, out61); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::parses", (a053: rt.u8, a153: rt.ByteSlice, a253: rt.ByteVec): undefined => { - ints_parses(a053, a153.data, a153.start, a153.length, a253); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::edits", (a054: rt.u8, a154: rt.ByteSlice, a254: rt.ByteVec): undefined => { - strs_edits(a054, a154.data, a154.start, a154.length, a254); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["slices::subslices", subslices as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["hashes::bytes", (_2161: rt.u8, data61: rt.ByteSlice, out62: rt.ByteVec): undefined => { - hashes_bytes(data61, out62); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["keys::bytes", keys_bytes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::parses", strs_parses as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::rebound", (_2162: rt.u8, data62: rt.ByteSlice, out63: rt.ByteVec): undefined => { - pointers_rebound(data62, out63); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["slices::ranges", slices_ranges as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::reducers", (_2163: rt.u8, data63: rt.ByteSlice, out64: rt.ByteVec): undefined => { - reducers(data63, out64); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::writers", (_2164: rt.u8, data64: rt.ByteSlice, out65: rt.ByteVec): undefined => { - writers(data64, out65); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["errors::eqs", eqs as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["slices::edits", slices_edits as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::iters", strs_iters as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::drains", (a062: rt.u8, a162: rt.ByteSlice, a262: rt.ByteVec): undefined => { - strs_drains(a062, a162.data, a162.start, a162.length, a262); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::hinted", hinted as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::made", (_2165: rt.u8, data65: rt.ByteSlice, out66: rt.ByteVec): undefined => { - pointers_made(data65, out66); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["arrays::as_slices", (_2166: rt.u8, data66: rt.ByteSlice, out67: rt.ByteVec): undefined => { - asSlices(data66, out67); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::widenings", widenings as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::uninhabited", (_2167: rt.u8, data67: rt.ByteSlice, out68: rt.ByteVec): undefined => { - uninhabited(data67, out68); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["keys::lent_keys", lentKeys as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["keys::lent_values", lentValues as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["singles::singles", singles as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["singles::formats", singles_formats as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["singles::parses", singles_parses as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::peeked_others", (_2168: rt.u8, data68: rt.ByteSlice, out69: rt.ByteVec): undefined => { - peekedOthers(data68, out69); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["hints::hints", hints as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["hints::reserves", reserves as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::set_ops", setOps as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["folds::folds", folds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::zeros", zeros as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["arrays::maps", (_2169: rt.u8, data69: rt.ByteSlice, out70: rt.ByteVec): undefined => { - arrays_maps(data69, out70); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["arrays::lent", (_2170: rt.u8, data70: rt.ByteSlice, out71: rt.ByteVec): undefined => { - arrays_lent(data70, out71); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["floats::mul_adds", floats_mulAdds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["singles::mul_adds", singles_mulAdds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::collections", (_2171: rt.u8, data71: rt.ByteSlice, out72: rt.ByteVec): undefined => { - collections(data71, out72); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::unlike_eqs", unlikeEqs as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::impls", zeros_impls as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::keys", zeros_keys as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["keys::arrays", keys_arrays as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::zips", zips as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::zips_back", zipsBack as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::own_nes", ownNes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::iters", (_2172: rt.u8, data72: rt.ByteSlice, out73: rt.ByteVec): undefined => { - fmt_iters(data72, out73); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::unread", unread as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::range_froms", rangeFroms as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::range_methods", rangeMethods as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["clones::iters", clones_iters as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::cell_eqs", cellEqs as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::compares", compares as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::unlike_compares", unlikeCompares as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::ref_orders", refOrders as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["cycles::cycles", cycles as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::lapsed", (_2173: rt.u8, data73: rt.ByteSlice, out74: rt.ByteVec): undefined => { - lapsed(data73, out74); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["cows::slices", cows_slices as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["cows::bytes", cows_bytes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::u8s", wraps_u8s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::u16s", wraps_u16s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::u32s", wraps_u32s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::u64s", wraps_u64s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::u128s", wraps_u128s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::usizes", wraps_usizes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::i8s", wraps_i8s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::i16s", wraps_i16s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::i32s", wraps_i32s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::i64s", wraps_i64s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::i128s", wraps_i128s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::isizes", wraps_isizes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::enums", (_2174: rt.u8, data74: rt.ByteSlice, out75: rt.ByteVec): undefined => { - enums(data74, out75); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::segments", (_2175: rt.u8, data75: rt.ByteSlice, out76: rt.ByteVec): undefined => { - pointers_segments(data75, out76); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::uninit_runs", (_2176: rt.u8, data76: rt.ByteSlice, out77: rt.ByteVec): undefined => { - uninitRuns(data76, out77); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::beside_written", (_2177: rt.u8, data77: rt.ByteSlice, out78: rt.ByteVec): undefined => { - besideWritten(data77, out78); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["keys::byte_refs", byteRefs as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["orders::held", (_2178: rt.u8, data78: rt.ByteSlice, out79: rt.ByteVec): undefined => { - orders_held(data78, out79); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["joins::joins", joins as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::iterated_runs", (_2179: rt.u8, data79: rt.ByteSlice, out80: rt.ByteVec): undefined => { - iteratedRuns(data79, out80); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::writes", (a0109: rt.u8, a1109: rt.ByteSlice, a2109: rt.ByteVec): undefined => { - zeros_writes(a0109, a1109.data, a1109.start, a1109.length, a2109); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["orders::tuples", (_2180: rt.u8, data80: rt.ByteSlice, out81: rt.ByteVec): undefined => { - orders_tuples(data80, out81); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["tuples::tuples", tuples_tuples as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::u8s", saturates_u8s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::u16s", saturates_u16s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::u32s", saturates_u32s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::u64s", saturates_u64s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::u128s", saturates_u128s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::usizes", saturates_usizes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::i8s", saturates_i8s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::i16s", saturates_i16s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::i32s", saturates_i32s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::i64s", saturates_i64s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::i128s", saturates_i128s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::isizes", saturates_isizes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::u8s", methods_u8s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::u16s", methods_u16s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::u32s", methods_u32s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::u64s", methods_u64s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::u128s", methods_u128s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::usizes", methods_usizes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::i8s", methods_i8s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::i16s", methods_i16s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::i32s", methods_i32s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::i64s", methods_i64s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::i128s", methods_i128s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::isizes", methods_isizes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["separated::separated", separated as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::waiters", (_2181: rt.u8, data81: rt.ByteSlice, out82: rt.ByteVec): undefined => { - waiters(data81, out82); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["boxes::boxes", boxes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ascii::bytes", ascii_bytes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ascii::chars", ascii_chars as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ascii::slices", ascii_slices as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["arrays::given", given as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::taken", (_2182: rt.u8, data82: rt.ByteSlice, out83: rt.ByteVec): undefined => { - pointers_taken(data82, out83); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::bytes", (_2183: rt.u8, data83: rt.ByteSlice, out84: rt.ByteVec): undefined => { - pointers_bytes(data83, out84); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::loaded", (_2184: rt.u8, data84: rt.ByteSlice, out85: rt.ByteVec): undefined => { - loaded(data84, out85); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["orders::btrees", orders_btrees as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["lengths::lengths", lengths as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::option_items", (_2185: rt.u8, data85: rt.ByteSlice, out86: rt.ByteVec): undefined => { - optionItems(data85, out86); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["lists::lists", lists_lists as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::reattached", (_2186: rt.u8, data86: rt.ByteSlice, out87: rt.ByteVec): undefined => { - reattached(data86, out87); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::part_written", (_2187: rt.u8, data87: rt.ByteSlice, out88: rt.ByteVec): undefined => { - partWritten(data87, out88); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::aimed", (_2188: rt.u8, data88: rt.ByteSlice, out89: rt.ByteVec): undefined => { - aimed(data88, out89); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ascii::parts", ascii_parts as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["boxes::places", boxes_places as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["arrays::flattened", arrays_flattened as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["args::args", args as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["returns::returns", returns as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["generics::runs", (_2189: rt.u8, data89: rt.ByteSlice, out90: rt.ByteVec): undefined => { - runs(data89, out90); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["borrows::guards", (_2190: rt.u8, data90: rt.ByteSlice, out91: rt.ByteVec): undefined => { - guards(data90, out91); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["results::results", results_results as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fields::fields", fields_fields as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::gets", gets as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["refs::adapted", (_2191: rt.u8, data91: rt.ByteSlice, out92: rt.ByteVec): undefined => { - refs_adapted(data91, out92); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["borrows::maps", (_2192: rt.u8, data92: rt.ByteSlice, out93: rt.ByteVec): undefined => { - borrows_maps(data92, out93); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::mapped", (_2193: rt.u8, data93: rt.ByteSlice, out94: rt.ByteVec): undefined => { - mapped(data93, out94); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["boxes::impls", boxes_impls as (a0: rt.u8, a1: rt.ByteSlice, a2: 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", (_2194: rt.u8, data94: rt.ByteSlice, out95: rt.ByteVec): undefined => { - tries(data94, out95); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::mutex_mapped", (_2195: rt.u8, data95: rt.ByteSlice, out96: rt.ByteVec): undefined => { - mutexMapped(data95, out96); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::printed", (_2196: rt.u8, data96: rt.ByteSlice, out97: rt.ByteVec): undefined => { - locks_printed(data96, out97); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["capacity::vecs", (a0154: rt.u8, a1154: rt.ByteSlice, a2154: rt.ByteVec): undefined => { - capacity_vecs(a0154, a1154.data, a1154.start, a1154.length, a2154); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["capacity::deques", (a0155: rt.u8, a1155: rt.ByteSlice, a2155: rt.ByteVec): undefined => { - capacity_deques(a0155, a1155.data, a1155.start, a1155.length, a2155); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["capacity::heaps", (a0156: rt.u8, a1156: rt.ByteSlice, a2156: rt.ByteVec): undefined => { - capacity_heaps(a0156, a1156.data, a1156.start, a1156.length, a2156); - }] 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", (_2197: rt.u8, data97: rt.ByteSlice, out98: rt.ByteVec): undefined => { - downgraded(data97, out98); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["borrows::leaks", (_2198: rt.u8, data98: rt.ByteSlice, out99: rt.ByteVec): undefined => { - leaks(data98, out99); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::deque_ranges", dequeRanges as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ends::ends", (a0160: rt.u8, a1160: rt.ByteSlice, a2160: rt.ByteVec): undefined => { - ends_ends(a0160, a1160.data, a1160.start, a1160.length, a2160); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["elements::vecs", (_2199: rt.u8, data99: rt.ByteSlice, out100: rt.ByteVec): undefined => { - elements_vecs(data99, out100); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["elements::arrays", (_2200: rt.u8, data100: rt.ByteSlice, out101: rt.ByteVec): undefined => { - elements_arrays(data100, out101); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["elements::segments", (_2201: rt.u8, data101: rt.ByteSlice, out102: rt.ByteVec): undefined => { - elements_segments(data101, out102); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["elements::inline", (_2202: rt.u8, data102: rt.ByteSlice, out103: rt.ByteVec): undefined => { - inline(data102, out103); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["elements::edges", (_2203: rt.u8, data103: rt.ByteSlice, out104: rt.ByteVec): undefined => { - elements_edges(data103, out104); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["heap::spills", (_2204: rt.u8, data104: rt.ByteSlice, out105: rt.ByteVec): undefined => { - spills(data104, out105); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["heap::layouts", (_2205: rt.u8, data105: rt.ByteSlice, out106: rt.ByteVec): undefined => { - layouts(data105, out106); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["heap::remnants", (_2206: rt.u8, data106: rt.ByteSlice, out107: rt.ByteVec): undefined => { - remnants(data106, out107); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["manual::arcs", (_2207: rt.u8, data107: rt.ByteSlice, out108: rt.ByteVec): undefined => { - manual_arcs(data107, out108); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["elements::raw_slices", (_2208: rt.u8, data108: rt.ByteSlice, out109: rt.ByteVec): undefined => { - rawSlices(data108, out109); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["elements::empty_parts", (_2209: rt.u8, data109: rt.ByteSlice, out110: rt.ByteVec): undefined => { - emptyParts(data109, out110); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["hashes::own", (_2210: rt.u8, data110: rt.ByteSlice, out111: rt.ByteVec): undefined => { - hashes_own(data110, out111); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["refs::compared", (a0161: rt.u8, a1161: rt.ByteSlice, a2161: rt.ByteVec): undefined => { - compared(a0161, a1161.data, a1161.start, a1161.length, a2161); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["rings::slices", (a0162: rt.u8, a1162: rt.ByteSlice, a2162: rt.ByteVec): undefined => { - rings_slices(a0162, a1162.data, a1162.start, a1162.length, a2162); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::objects", (_2211: rt.u8, data111: rt.ByteSlice, out112: rt.ByteVec): undefined => { - fmt_objects(data111, out112); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["sorts::sorts", (a0163: rt.u8, a1163: rt.ByteSlice, a2163: rt.ByteVec): undefined => { - sorts(a0163, a1163.data, a1163.start, a1163.length, a2163); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["sorts::disorders", disorders as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["sorts::btrees", (a0165: rt.u8, a1165: rt.ByteSlice, a2165: rt.ByteVec): undefined => { - sorts_btrees(a0165, a1165.data, a1165.start, a1165.length, a2165); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["dyns::pointers", (_2212: rt.u8, data112: rt.ByteSlice, out113: rt.ByteVec): undefined => { - pointers(data112.data, data112.start, data112.length, out113); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["searches::searches", searches as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["searches::texts", texts as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["dyns::iters", (_2213: rt.u8, data113: rt.ByteSlice, out114: rt.ByteVec): undefined => { - dyns_iters(data113, out114); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["errors::objects", (_2214: rt.u8, data114: rt.ByteSlice, out115: rt.ByteVec): undefined => { - errors_objects(data114.data, data114.start, data114.length, out115); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::lent", (_2215: rt.u8, data115: rt.ByteSlice, out116: rt.ByteVec): undefined => { - iters_lent(data115, out116); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; -} - -/** Run one case. */ -export function run(input: rt.ByteSlice): rt.ByteVec { - const out: rt.ByteVec = new rt.ByteVec(); - if (!(input.length >= 3)) { - return out; - } - const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); - cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); - return out; -} - -/** - * The first two bytes, as one big-endian number, that pick the case named `name`, which - * `caller.ts` targets by. - */ -export function op(name: string): rt.u16 { - const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { - return _2[0] === name; - }); - if (_11 !== undefined) { - const _20: rt.Result = rt.u16TryFrom(_11); - if (_20.ok) { - if ((_20.value >> 8) !== 255) { - return _20.value; - } - } - const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; - rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); - } else { - const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; - rt.panicFmt(["no case ", args2[0]]); - } -} - -/** Negate the signed type `kind` picks. */ -export function neg(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { - const _4: rt.u8 = rt.u8Rem(kind, 6); - if (_4 === 0) { - i8Neg(data, out); - } else if (_4 === 1) { - i16Neg(data, out); - } else if (_4 === 2) { - i32Neg(data, out); - } else if (_4 === 3) { - i64Neg(data, out); - } else if (_4 === 4) { - i128Neg(data, out); - } else { - isizeNeg(data, out); - } -} - -/** - * Cast from the type `kind` picks to the one the next byte does, or without one, to - * a type `kind` also picks. - */ -export function cast(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { - if (data.length === 0) { - ints_cast(kind, rt.u8Div(kind, 12), data, out); - } else { - ints_cast(kind, data.data[data.start], new rt.ByteSlice(data.data, data.start + 1, data.length - 1), out); - } -} - -//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/expected/hashes.Packet.ts b/ts/fixtures/lang/expected/hashes.Packet.ts deleted file mode 100644 index a0af87b51..000000000 --- a/ts/fixtures/lang/expected/hashes.Packet.ts +++ /dev/null @@ -1,48 +0,0 @@ -// Generated by rust2-ts. Do not edit. - -import * as rt from "./rt.ts"; -import * as hashes_Bare from "./hashes.Bare.ts"; -import * as Full from "./hashes.Full.ts"; -import * as hashes_Partial from "./hashes.Partial.ts"; - -export function hash$Hash_hash_DefaultHasher(self: Packet, state: rt.Hasher): void { - rt.hash64(self.id, state); - rt.hash8(self.flags, state); - rt.hashStr(self.name, state); - rt.hashInts(2)(self.tags, state); - rt.hashOption(rt.hashI32)(self.next, state); -} - -export function hash$Hash_hashes_Bare(self: Packet, state: hashes_Bare.Bare): void { - rt.hash64(self.id, new rt.OwnHasher(state, hashes_Bare.hasher$hash_Hasher)); - rt.hash8(self.flags, new rt.OwnHasher(state, hashes_Bare.hasher$hash_Hasher)); - rt.hashStr(self.name, new rt.OwnHasher(state, hashes_Bare.hasher$hash_Hasher)); - rt.hashInts(2)(self.tags, new rt.OwnHasher(state, hashes_Bare.hasher$hash_Hasher)); - rt.hashOption(rt.hashI32)(self.next, new rt.OwnHasher(state, hashes_Bare.hasher$hash_Hasher)); -} - -export function hash$Hash_hashes_Full(self: Packet, state: Full.Full): void { - rt.hash64(self.id, new rt.OwnHasher(state, Full.hasher$hash_Hasher)); - rt.hash8(self.flags, new rt.OwnHasher(state, Full.hasher$hash_Hasher)); - rt.hashStr(self.name, new rt.OwnHasher(state, Full.hasher$hash_Hasher)); - rt.hashInts(2)(self.tags, new rt.OwnHasher(state, Full.hasher$hash_Hasher)); - rt.hashOption(rt.hashI32)(self.next, new rt.OwnHasher(state, Full.hasher$hash_Hasher)); -} - -export function hash$Hash_hashes_Partial(self: Packet, state: hashes_Partial.Partial): void { - rt.hash64(self.id, new rt.OwnHasher(state, hashes_Partial.hasher$hash_Hasher)); - rt.hash8(self.flags, new rt.OwnHasher(state, hashes_Partial.hasher$hash_Hasher)); - rt.hashStr(self.name, new rt.OwnHasher(state, hashes_Partial.hasher$hash_Hasher)); - rt.hashInts(2)(self.tags, new rt.OwnHasher(state, hashes_Partial.hasher$hash_Hasher)); - rt.hashOption(rt.hashI32)(self.next, new rt.OwnHasher(state, hashes_Partial.hasher$hash_Hasher)); -} - -export interface Packet { - id: rt.u64; - flags: rt.u8; - name: string; - tags: rt.u16[]; - next: rt.i32 | undefined; -} - -//# sourceMappingURL=hashes.Packet.ts.map diff --git a/ts/fixtures/lang/expected/lib.ts b/ts/fixtures/lang/expected/lib.ts deleted file mode 100644 index aeaef3740..000000000 --- a/ts/fixtures/lang/expected/lib.ts +++ /dev/null @@ -1,1495 +0,0 @@ -// Generated by rust2-ts. Do not edit. - -import * as rt from "./rt.ts"; -import type * as borrows_Parts from "./borrows.Parts.ts"; -import type * as borrows_Tagged from "./borrows.Tagged.ts"; -import type * as boxes_Logged from "./boxes.Logged.ts"; -import type * as clones_Logged from "./clones.Logged.ts"; -import type * as collections_Picky from "./collections.Picky.ts"; -import type * as Quirky from "./collections.Quirky.ts"; -import type * as collections_Tally from "./collections.Tally.ts"; -import type * as conversions_Logged from "./conversions.Logged.ts"; -import type * as Any from "./core/any.Any.ts"; -import type * as error_Error from "./core/error.Error.ts"; -import type * as ArcReleasing from "./counts.ArcReleasing.ts"; -import type * as ArcShared from "./counts.ArcShared.ts"; -import type * as counts_Noisy from "./counts.Noisy.ts"; -import type * as RcReleasing from "./counts.RcReleasing.ts"; -import type * as RcShared from "./counts.RcShared.ts"; -import type * as durations_Window from "./durations.Window.ts"; -import type * as dyns_Noisy from "./dyns.Noisy.ts"; -import type * as Square from "./dyns.Square.ts"; -import type * as Tri from "./dyns.Tri.ts"; -import * as Inline from "./elements.Inline.ts"; -import type * as Failure from "./errors.Failure.ts"; -import type * as Couple from "./fields.Couple.ts"; -import type * as Either from "./generics.Either.ts"; -import * as Fixed from "./generics.Fixed.ts"; -import type * as generics_Run from "./generics.Run.ts"; -import type * as Ticked from "./generics.Ticked.ts"; -import * as Wrap from "./generics.Wrap.ts"; -import * as Spill from "./heap.Spill.ts"; -import type * as Bumped from "./iters.Bumped.ts"; -import type * as joins_Logged from "./joins.Logged.ts"; -import type * as Hop from "./keys.Hop.ts"; -import type * as Horizon from "./keys.Horizon.ts"; -import type * as Lopsided from "./keys.Lopsided.ts"; -import * as lengths_Tagged from "./lengths.Tagged.ts"; -import type * as locals_Twin from "./locals.Twin.ts"; -import type * as locks_Tally from "./locks.Tally.ts"; -import type * as Aimed from "./pointers.Aimed.ts"; -import type * as ByCall from "./pointers.ByCall.ts"; -import type * as ByClosure from "./pointers.ByClosure.ts"; -import type * as ByObject from "./pointers.ByObject.ts"; -import type * as Duo from "./pointers.Duo.ts"; -import type * as pointers_Halves from "./pointers.Halves.ts"; -import type * as Housed from "./pointers.Housed.ts"; -import type * as Inner from "./pointers.Inner.ts"; -import type * as Leaning from "./pointers.Leaning.ts"; -import * as List from "./pointers.List.ts"; -import type * as Outer from "./pointers.Outer.ts"; -import type * as pointers_Pair from "./pointers.Pair.ts"; -import type * as Paired from "./pointers.Paired.ts"; -import type * as results_Logged from "./results.Logged.ts"; -import * as saturates_Gauge from "./saturates.Gauge.ts"; -import type * as shapes_Gauge from "./shapes.Gauge.ts"; -import type * as shapes_Held from "./shapes.Held.ts"; -import type * as Lens from "./shapes.Lens.ts"; -import type * as Level from "./shapes.Level.ts"; -import type * as Mark from "./shapes.Mark.ts"; -import type * as Point from "./shapes.Point.ts"; -import type * as shapes_Shape from "./shapes.Shape.ts"; -import type * as slices_Pair from "./slices.Pair.ts"; -import * as statics_Lock from "./statics.Lock.ts"; -import type * as tuples_Logged from "./tuples.Logged.ts"; -import type * as Spot from "./tuples.Spot.ts"; -import type * as tuples_Tally from "./tuples.Tally.ts"; -import * as Tick from "./wraps.Tick.ts"; -import * as zeros_Lock from "./zeros.Lock.ts"; -import type * as Loud from "./zeros.Loud.ts"; - -export function copy$Option_Option_array0_u8(v: Uint8Array | undefined | rt.None): Uint8Array | undefined | rt.None { - return v === rt.None ? v : copy$Option_array0_u8(v); -} - -export function copy$Option_Option_array1_u8(v: Uint8Array | undefined | rt.None): Uint8Array | undefined | rt.None { - return v === rt.None ? v : copy$Option_array1_u8(v); -} - -export function copy$Option_Option_array5_u8(v: Uint8Array | undefined | rt.None): Uint8Array | undefined | rt.None { - return v === rt.None ? v : copy$Option_array5_u8(v); -} - -export function copy$Option_array0_u32(v: rt.u32[] | undefined): rt.u32[] | undefined { - return v === undefined ? v : copy$array_u32(v); -} - -export function copy$Option_array0_u8(v: Uint8Array | undefined): Uint8Array | undefined { - return v === undefined ? v : copy$array_u8(v); -} - -export function copy$Option_array1_u8(v: Uint8Array | undefined): Uint8Array | undefined { - return v === undefined ? v : copy$array_u8(v); -} - -export function copy$Option_array275_u32(v: rt.u32[] | undefined): rt.u32[] | undefined { - return v === undefined ? v : copy$array_u32(v); -} - -export function copy$Option_array2_Option_u8(v: Array | undefined): Array | undefined { - return v === undefined ? v : copy$array_Option_u8(v); -} - -export function copy$Option_array2_char(v: rt.char[] | undefined): rt.char[] | undefined { - return v === undefined ? v : copy$array_char(v); -} - -export function copy$Option_array2_keys_Hop(v: Hop.Hop[] | undefined): Hop.Hop[] | undefined { - return v === undefined ? v : copy$array_keys_Hop(v); -} - -export function copy$Option_array2_u16(v: rt.u16[] | undefined): rt.u16[] | undefined { - return v === undefined ? v : copy$array_u16(v); -} - -export function copy$Option_array2_u64(v: rt.u64[] | undefined): rt.u64[] | undefined { - return v === undefined ? v : copy$array_u64(v); -} - -export function copy$Option_array2_u8(v: Uint8Array | undefined): Uint8Array | undefined { - return v === undefined ? v : copy$array_u8(v); -} - -export function copy$Option_array3_u8(v: Uint8Array | undefined): Uint8Array | undefined { - return v === undefined ? v : copy$array_u8(v); -} - -export function copy$Option_array40_u8(v: Uint8Array | undefined): Uint8Array | undefined { - return v === undefined ? v : copy$array_u8(v); -} - -export function copy$Option_array5_u8(v: Uint8Array | undefined): Uint8Array | undefined { - return v === undefined ? v : copy$array_u8(v); -} - -export function copy$Option_collections_Tally(v: collections_Tally.Tally | undefined): collections_Tally.Tally | undefined { - return v === undefined ? v : copy$collections_Tally(v); -} - -export function copy$Option_keys_Hop(v: Hop.Hop | undefined): Hop.Hop | undefined { - return v === undefined ? v : copy$keys_Hop(v); -} - -export function copy$Option_lengths_Tagged_array0_u32(v: lengths_Tagged.Tagged | undefined): lengths_Tagged.Tagged | undefined { - return v === undefined ? v : copy$lengths_Tagged_array0_u32(v); -} - -export function copy$Option_lengths_Tagged_array0_u8(v: lengths_Tagged.Tagged | undefined): lengths_Tagged.Tagged | undefined { - return v === undefined ? v : copy$lengths_Tagged_array0_u8(v); -} - -export function copy$Option_lengths_Tagged_array17_u32(v: lengths_Tagged.Tagged | undefined): lengths_Tagged.Tagged | undefined { - return v === undefined ? v : copy$lengths_Tagged_array17_u32(v); -} - -export function copy$Option_lengths_Tagged_array17_u8(v: lengths_Tagged.Tagged | undefined): lengths_Tagged.Tagged | undefined { - return v === undefined ? v : copy$lengths_Tagged_array17_u8(v); -} - -export function copy$Option_lengths_Tagged_array1_u32(v: lengths_Tagged.Tagged | undefined): lengths_Tagged.Tagged | undefined { - return v === undefined ? v : copy$lengths_Tagged_array1_u32(v); -} - -export function copy$Option_lengths_Tagged_array1_u8(v: lengths_Tagged.Tagged | undefined): lengths_Tagged.Tagged | undefined { - return v === undefined ? v : copy$lengths_Tagged_array1_u8(v); -} - -export function copy$Option_lengths_Tagged_array3_u32(v: lengths_Tagged.Tagged | undefined): lengths_Tagged.Tagged | undefined { - return v === undefined ? v : copy$lengths_Tagged_array3_u32(v); -} - -export function copy$Option_lengths_Tagged_array3_u8(v: lengths_Tagged.Tagged | undefined): lengths_Tagged.Tagged | undefined { - return v === undefined ? v : copy$lengths_Tagged_array3_u8(v); -} - -export function copy$Option_pointers_Pair(v: pointers_Pair.Pair | undefined): pointers_Pair.Pair | undefined { - return v === undefined ? v : copy$pointers_Pair(v); -} - -export function copy$Option_shapes_Shape(v: shapes_Shape.Shape | undefined): shapes_Shape.Shape | undefined { - return v === undefined ? v : copy$shapes_Shape(v); -} - -export function copy$Option_tuple2_ref_sync_Mutex_u8_u8(v: [rt.Mutex, rt.u8] | undefined): [rt.Mutex, rt.u8] | undefined { - return v === undefined ? v : copy$tuple2_ref_sync_Mutex_u8_u8(v); -} - -export function copy$Option_tuple2_u64_u64(v: [rt.u64, rt.u64] | undefined): [rt.u64, rt.u64] | undefined { - return v === undefined ? v : copy$tuple2_u64_u64(v); -} - -export function copy$Option_tuple2_u8_u16(v: [rt.u8, rt.u16] | undefined): [rt.u8, rt.u16] | undefined { - return v === undefined ? v : copy$tuple2_u8_u16(v); -} - -export function copy$Option_tuple2_u8_u8(v: [rt.u8, rt.u8] | undefined): [rt.u8, rt.u8] | undefined { - return v === undefined ? v : copy$tuple2_u8_u8(v); -} - -export function copy$Result_array0_u8_u8(v: rt.Result): rt.Result { - return v.ok ? rt.Ok(copy$array_u8(v.value)) : rt.Err(v.error); -} - -export function copy$Result_array1_u8_u8(v: rt.Result): rt.Result { - return v.ok ? rt.Ok(copy$array_u8(v.value)) : rt.Err(v.error); -} - -export function copy$Result_array2_u32_u16(v: rt.Result): rt.Result { - return v.ok ? rt.Ok(copy$array_u32(v.value)) : rt.Err(v.error); -} - -export function copy$Result_array5_u8_u8(v: rt.Result): rt.Result { - return v.ok ? rt.Ok(copy$array_u8(v.value)) : rt.Err(v.error); -} - -export function copy$Result_tuple2_ref_sync_Mutex_u8_u8_u8(v: rt.Result<[rt.Mutex, rt.u8], rt.u8>): rt.Result<[rt.Mutex, rt.u8], rt.u8> { - return v.ok ? rt.Ok(copy$tuple2_ref_sync_Mutex_u8_u8(v.value)) : rt.Err(v.error); -} - -export function copy$array_Option_Option_array0_u8(v: Array): Array { - return v.map(copy$Option_Option_array0_u8); -} - -export function copy$array_Option_Option_array1_u8(v: Array): Array { - return v.map(copy$Option_Option_array1_u8); -} - -export function copy$array_Option_Option_array5_u8(v: Array): Array { - return v.map(copy$Option_Option_array5_u8); -} - -export function copy$array_Option_tuple2_u8_u8(v: Array<[rt.u8, rt.u8] | undefined>): Array<[rt.u8, rt.u8] | undefined> { - return v.map(copy$Option_tuple2_u8_u8); -} - -export function copy$array_Option_u8(v: Array): Array { - return v.slice(); -} - -export function copy$array_array0_u8(v: Uint8Array[]): Uint8Array[] { - return v.map(copy$array_u8); -} - -export function copy$array_array17_u8(v: Uint8Array[]): Uint8Array[] { - return v.map(copy$array_u8); -} - -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); -} - -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); -} - -export function copy$array_char(v: rt.char[]): rt.char[] { - return v.slice(); -} - -export function copy$array_collections_Quirky(v: Quirky.Quirky[]): Quirky.Quirky[] { - return v.map(copy$collections_Quirky); -} - -export function copy$array_generics_Either_u8_shapes_Point(v: Either.Either[]): Either.Either[] { - return v.map(copy$generics_Either_u8_shapes_Point); -} - -export function copy$array_keys_Hop(v: Hop.Hop[]): Hop.Hop[] { - return v.map(copy$keys_Hop); -} - -export function copy$array_lengths_Tagged_u32(v: lengths_Tagged.Tagged[]): lengths_Tagged.Tagged[] { - return v.slice(); -} - -export function copy$array_ptr_array4_u8(v: rt.ByteSlice[]): rt.ByteSlice[] { - return v.slice(); -} - -export function copy$array_ref_sync_Mutex_u8(v: rt.Mutex[]): rt.Mutex[] { - return v.slice(); -} - -export function copy$array_shapes_Point(v: Point.Point[]): Point.Point[] { - return v.map(copy$shapes_Point); -} - -export function copy$array_tuple2_u8_u16(v: [rt.u8, rt.u16][]): [rt.u8, rt.u16][] { - return v.map(copy$tuple2_u8_u16); -} - -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(); -} - -export function copy$array_u32(v: rt.u32[]): rt.u32[] { - return v.slice(); -} - -export function copy$array_u64(v: rt.u64[]): rt.u64[] { - return v.slice(); -} - -export function copy$array_u8(v: Uint8Array): Uint8Array { - return v.slice(); -} - -export function copy$array_unit(v: undefined[]): undefined[] { - return v.slice(); -} - -export function copy$array_usize(v: rt.usize[]): rt.usize[] { - return v.slice(); -} - -export function copy$collections_Quirky(v: Quirky.Quirky): Quirky.Quirky { - return { _0: v._0, _1: v._1 }; -} - -export function copy$collections_Tally(v: collections_Tally.Tally): collections_Tally.Tally { - return { n: v.n }; -} - -export function copy$durations_Window(v: durations_Window.Window): durations_Window.Window { - return { start: v.start, len: v.len }; -} - -export function copy$fields_Couple(v: Couple.Couple): Couple.Couple { - return { headData: v.headData, headStart: v.headStart, headLen: v.headLen, wordData: v.wordData, wordStart: v.wordStart, wordLen: v.wordLen }; -} - -export function copy$generics_Either_u8_shapes_Point(v: Either.Either): Either.Either { - if (v.tag === "Left") { - return { tag: "Left", _0: v._0 }; - } - if (v.tag === "Right") { - return { tag: "Right", value: copy$shapes_Point(v.value) }; - } - return v; -} - -export function copy$generics_Fixed_u16(v: Fixed.Fixed): Fixed.Fixed { - return new Fixed.Fixed(copy$array_u16(v.pair as rt.u16[]), v.tag); -} - -export function copy$generics_Fixed_u8(v: Fixed.Fixed): Fixed.Fixed { - return new Fixed.Fixed(copy$array_u8(v.pair as Uint8Array), v.tag); -} - -export function copy$generics_Wrap_shapes_Point(v: Wrap.Wrap): Wrap.Wrap { - return new Wrap.Wrap(copy$shapes_Point(v.value), v.count); -} - -export function copy$generics_Wrap_u8(v: Wrap.Wrap): Wrap.Wrap { - return new Wrap.Wrap(v.value, v.count); -} - -export function copy$iters_Bumped(v: Bumped.Bumped): Bumped.Bumped { - return { _0: v._0 }; -} - -export function copy$keys_Hop(v: Hop.Hop): Hop.Hop { - return { _0: v._0 }; -} - -export function copy$keys_Horizon(v: Horizon.Horizon): Horizon.Horizon { - return { exclude: copy$Option_keys_Hop(v.exclude), local: v.local }; -} - -export function copy$lengths_Tagged_array0_u32(v: lengths_Tagged.Tagged): lengths_Tagged.Tagged { - return new lengths_Tagged.Tagged(copy$array_u32(v._0), v._1); -} - -export function copy$lengths_Tagged_array0_u8(v: lengths_Tagged.Tagged): lengths_Tagged.Tagged { - return new lengths_Tagged.Tagged(copy$array_u8(v._0), v._1); -} - -export function copy$lengths_Tagged_array17_u32(v: lengths_Tagged.Tagged): lengths_Tagged.Tagged { - return new lengths_Tagged.Tagged(copy$array_u32(v._0), v._1); -} - -export function copy$lengths_Tagged_array17_u8(v: lengths_Tagged.Tagged): lengths_Tagged.Tagged { - return new lengths_Tagged.Tagged(copy$array_u8(v._0), v._1); -} - -export function copy$lengths_Tagged_array1_u32(v: lengths_Tagged.Tagged): lengths_Tagged.Tagged { - return new lengths_Tagged.Tagged(copy$array_u32(v._0), v._1); -} - -export function copy$lengths_Tagged_array1_u8(v: lengths_Tagged.Tagged): lengths_Tagged.Tagged { - return new lengths_Tagged.Tagged(copy$array_u8(v._0), v._1); -} - -export function copy$lengths_Tagged_array3_u32(v: lengths_Tagged.Tagged): lengths_Tagged.Tagged { - return new lengths_Tagged.Tagged(copy$array_u32(v._0), v._1); -} - -export function copy$lengths_Tagged_array3_u8(v: lengths_Tagged.Tagged): lengths_Tagged.Tagged { - return new lengths_Tagged.Tagged(copy$array_u8(v._0), v._1); -} - -export function copy$locals_Twin(v: locals_Twin.Twin): locals_Twin.Twin { - return { _0: v._0, _1: v._1 }; -} - -export function copy$mem_MaybeUninit_Option_tuple2_u8_u8(v: [rt.u8, rt.u8] | undefined): [rt.u8, rt.u8] | undefined { - if (v === undefined) { - return v; - } - return v === undefined ? v : copy$tuple2_u8_u8(v); -} - -export function copy$mem_MaybeUninit_Result_tuple2_u32_u32_u8(v: rt.Result<[rt.u32, rt.u32], rt.u8>): rt.Result<[rt.u32, rt.u32], rt.u8> { - if (v === undefined) { - return v; - } - return v.ok ? rt.Ok(copy$tuple2_u32_u32(v.value)) : rt.Err(v.error); -} - -export function copy$mem_MaybeUninit_array_Option_tuple2_u8_u8(v: Array<[rt.u8, rt.u8] | undefined>): Array<[rt.u8, rt.u8] | undefined> { - if (v === undefined) { - return v; - } - return v.map(copy$mem_MaybeUninit_Option_tuple2_u8_u8); -} - -export function copy$mem_MaybeUninit_array_array0_u8(v: Uint8Array[]): Uint8Array[] { - if (v === undefined) { - return v; - } - return v.map(copy$mem_MaybeUninit_array_u8); -} - -export function copy$mem_MaybeUninit_array_array17_u8(v: Uint8Array[]): Uint8Array[] { - if (v === undefined) { - return v; - } - return v.map(copy$mem_MaybeUninit_array_u8); -} - -export function copy$mem_MaybeUninit_array_array1_u8(v: Uint8Array[]): Uint8Array[] { - if (v === undefined) { - return v; - } - return v.map(copy$mem_MaybeUninit_array_u8); -} - -export function copy$mem_MaybeUninit_array_array3_u8(v: Uint8Array[]): Uint8Array[] { - if (v === undefined) { - return v; - } - return v.map(copy$mem_MaybeUninit_array_u8); -} - -export function copy$mem_MaybeUninit_array_lengths_Tagged_u32(v: lengths_Tagged.Tagged[]): lengths_Tagged.Tagged[] { - if (v === undefined) { - return v; - } - return v.slice(); -} - -export function copy$mem_MaybeUninit_array_u32(v: rt.u32[]): rt.u32[] { - if (v === undefined) { - return v; - } - return v.slice(); -} - -export function copy$mem_MaybeUninit_array_u8(v: Uint8Array): Uint8Array { - if (v === undefined) { - return v; - } - return v.slice(); -} - -export function copy$mem_MaybeUninit_mem_ManuallyDrop_tuple2_u8_u16(v: [rt.u8, rt.u16]): [rt.u8, rt.u16] { - if (v === undefined) { - return v; - } - return [v[0], v[1]]; -} - -export function copy$mem_MaybeUninit_tuple2_array0_array0_u8_tuple2_u8_u8(v: [Uint8Array[], [rt.u8, rt.u8]]): [Uint8Array[], [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_array0_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array0_lengths_Tagged_u32_tuple2_u8_u8(v: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]): [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_lengths_Tagged_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array0_u32_tuple2_u8_u8(v: [rt.u32[], [rt.u8, rt.u8]]): [rt.u32[], [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array0_u8_tuple2_u8_u8(v: [Uint8Array, [rt.u8, rt.u8]]): [Uint8Array, [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array17_array17_u8_tuple2_u8_u8(v: [Uint8Array[], [rt.u8, rt.u8]]): [Uint8Array[], [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_array17_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array17_lengths_Tagged_u32_tuple2_u8_u8(v: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]): [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_lengths_Tagged_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array17_u32_tuple2_u8_u8(v: [rt.u32[], [rt.u8, rt.u8]]): [rt.u32[], [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array17_u8_tuple2_u8_u8(v: [Uint8Array, [rt.u8, rt.u8]]): [Uint8Array, [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array1_array1_u8_tuple2_u8_u8(v: [Uint8Array[], [rt.u8, rt.u8]]): [Uint8Array[], [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_array1_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array1_lengths_Tagged_u32_tuple2_u8_u8(v: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]): [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_lengths_Tagged_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array1_u32_tuple2_u8_u8(v: [rt.u32[], [rt.u8, rt.u8]]): [rt.u32[], [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array1_u8_tuple2_u8_u8(v: [Uint8Array, [rt.u8, rt.u8]]): [Uint8Array, [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array3_array3_u8_tuple2_u8_u8(v: [Uint8Array[], [rt.u8, rt.u8]]): [Uint8Array[], [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_array3_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array3_lengths_Tagged_u32_tuple2_u8_u8(v: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]): [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_lengths_Tagged_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array3_u32_tuple2_u8_u8(v: [rt.u32[], [rt.u8, rt.u8]]): [rt.u32[], [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_array3_u8_tuple2_u8_u8(v: [Uint8Array, [rt.u8, rt.u8]]): [Uint8Array, [rt.u8, rt.u8]] { - if (v === undefined) { - return v; - } - return [copy$mem_MaybeUninit_array_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; -} - -export function copy$mem_MaybeUninit_tuple2_u8_u8(v: [rt.u8, rt.u8]): [rt.u8, rt.u8] { - if (v === undefined) { - return v; - } - return [v[0], v[1]]; -} - -export function copy$ops_ControlFlow_ref_sync_Arc_u8_array1_u8(v: rt.Result>): rt.Result> { - return v.ok ? rt.Ok(copy$array_u8(v.value)) : rt.Err(v.error); -} - -export function copy$ops_ControlFlow_unit_array2_u8(v: rt.Result): rt.Result { - return v.ok ? rt.Ok(copy$array_u8(v.value)) : rt.Err(v.error); -} - -export function copy$pointers_Aimed_Cell_u8(v: Aimed.Aimed>): Aimed.Aimed> { - return { at: v.at as rt.Place>, seen: v.seen as rt.Place>, held: v.held as rt.Place>, maybe: v.maybe as rt.Place> | undefined, tagged: copy$tuple2_mutPtr_Cell_u8_u8(v.tagged as [rt.Place>, rt.u8]), to: v.to, read: (v.read as (a0: rt.Place>) => rt.u8) as (a0: rt.Ptr>) => rt.u8 }; -} - -export function copy$pointers_Aimed_array2_u16(v: Aimed.Aimed): Aimed.Aimed { - return { at: v.at as rt.u16[], seen: v.seen as rt.u16[], held: v.held as rt.u16[], maybe: v.maybe as rt.u16[] | undefined, tagged: copy$tuple2_mutPtr_array2_u16_u8(v.tagged as [rt.u16[], rt.u8]), to: v.to, read: (v.read as (a0: rt.u16[]) => rt.u8) as (a0: rt.Ptr) => rt.u8 }; -} - -export function copy$pointers_Aimed_array4_u8(v: Aimed.Aimed): Aimed.Aimed { - return { at: v.at as rt.ByteSlice, seen: v.seen as rt.ByteSlice, held: v.held as rt.ByteSlice, maybe: v.maybe as rt.ByteSlice | undefined, tagged: copy$tuple2_mutPtr_array4_u8_u8(v.tagged as [rt.ByteSlice, rt.u8]), to: v.to, read: (v.read as (a0: rt.ByteSlice) => rt.u8) as (a0: rt.Ptr) => rt.u8 }; -} - -export function copy$pointers_Aimed_pointers_Housed_u8(v: Aimed.Aimed>): Aimed.Aimed> { - return { at: v.at as Housed.Housed, seen: v.seen as Housed.Housed, held: v.held as Housed.Housed, maybe: v.maybe as Housed.Housed | undefined, tagged: copy$tuple2_mutPtr_pointers_Housed_u8_u8(v.tagged as [Housed.Housed, rt.u8]), to: v.to, read: (v.read as (a0: Housed.Housed) => rt.u8) as (a0: rt.Ptr>) => rt.u8 }; -} - -export function copy$pointers_Aimed_pointers_Leaning(v: Aimed.Aimed): Aimed.Aimed { - return { at: v.at as rt.Place, seen: v.seen as rt.Place, held: v.held as rt.Place, maybe: v.maybe as rt.Place | undefined, tagged: copy$tuple2_mutPtr_pointers_Leaning_u8(v.tagged as [rt.Place, rt.u8]), to: v.to, read: (v.read as (a0: rt.Place) => rt.u8) as (a0: rt.Ptr) => rt.u8 }; -} - -export function copy$pointers_Aimed_pointers_Paired(v: Aimed.Aimed): Aimed.Aimed { - return { at: v.at as Paired.Paired, seen: v.seen as Paired.Paired, held: v.held as Paired.Paired, maybe: v.maybe as Paired.Paired | undefined, tagged: copy$tuple2_mutPtr_pointers_Paired_u8(v.tagged as [Paired.Paired, rt.u8]), to: v.to, read: (v.read as (a0: Paired.Paired) => rt.u8) as (a0: rt.Ptr) => rt.u8 }; -} - -export function copy$pointers_Aimed_u8(v: Aimed.Aimed): Aimed.Aimed { - return { at: v.at as rt.Place, seen: v.seen as rt.Place, held: v.held as rt.Place, maybe: v.maybe as rt.Place | undefined, tagged: copy$tuple2_mutPtr_u8_u8(v.tagged as [rt.Place, rt.u8]), to: v.to, read: (v.read as (a0: rt.Place) => rt.u8) as (a0: rt.Ptr) => rt.u8 }; -} - -export function copy$pointers_ByCall(v: ByCall.ByCall): ByCall.ByCall { - return { _0: v._0, _1: v._1 }; -} - -export function copy$pointers_ByClosure(v: ByClosure.ByClosure): ByClosure.ByClosure { - return { _0: v._0, _1: v._1 }; -} - -export function copy$pointers_ByObject(v: ByObject.ByObject): ByObject.ByObject { - return { _0: v._0, _1: v._1 }; -} - -export function copy$pointers_Duo(v: Duo.Duo): Duo.Duo { - return { _0: v._0, _1: v._1 }; -} - -export function copy$pointers_Halves(v: pointers_Halves.Halves): pointers_Halves.Halves { - return ({ at0: copy$mem_MaybeUninit_array_u32(v.at0) } as unknown) as pointers_Halves.Halves; -} - -export function copy$pointers_Inner(v: Inner.Inner): Inner.Inner { - return { a: v.a, b: v.b }; -} - -export function copy$pointers_Outer(v: Outer.Outer): Outer.Outer { - return { inner: copy$pointers_Inner(v.inner), pair: copy$tuple2_u32_u32(v.pair), n: v.n }; -} - -export function copy$pointers_Pair(v: pointers_Pair.Pair): pointers_Pair.Pair { - return { a: v.a, b: v.b }; -} - -export function copy$saturates_Gauge_i128(v: saturates_Gauge.Gauge): saturates_Gauge.Gauge { - return new saturates_Gauge.Gauge(v._0); -} - -export function copy$saturates_Gauge_i16(v: saturates_Gauge.Gauge): saturates_Gauge.Gauge { - return new saturates_Gauge.Gauge(v._0); -} - -export function copy$saturates_Gauge_i32(v: saturates_Gauge.Gauge): saturates_Gauge.Gauge { - return new saturates_Gauge.Gauge(v._0); -} - -export function copy$saturates_Gauge_i64(v: saturates_Gauge.Gauge): saturates_Gauge.Gauge { - return new saturates_Gauge.Gauge(v._0); -} - -export function copy$saturates_Gauge_i8(v: saturates_Gauge.Gauge): saturates_Gauge.Gauge { - return new saturates_Gauge.Gauge(v._0); -} - -export function copy$saturates_Gauge_isize(v: saturates_Gauge.Gauge): saturates_Gauge.Gauge { - return new saturates_Gauge.Gauge(v._0); -} - -export function copy$saturates_Gauge_u128(v: saturates_Gauge.Gauge): saturates_Gauge.Gauge { - return new saturates_Gauge.Gauge(v._0); -} - -export function copy$saturates_Gauge_u16(v: saturates_Gauge.Gauge): saturates_Gauge.Gauge { - return new saturates_Gauge.Gauge(v._0); -} - -export function copy$saturates_Gauge_u32(v: saturates_Gauge.Gauge): saturates_Gauge.Gauge { - return new saturates_Gauge.Gauge(v._0); -} - -export function copy$saturates_Gauge_u64(v: saturates_Gauge.Gauge): saturates_Gauge.Gauge { - return new saturates_Gauge.Gauge(v._0); -} - -export function copy$saturates_Gauge_u8(v: saturates_Gauge.Gauge): saturates_Gauge.Gauge { - return new saturates_Gauge.Gauge(v._0); -} - -export function copy$saturates_Gauge_usize(v: saturates_Gauge.Gauge): saturates_Gauge.Gauge { - return new saturates_Gauge.Gauge(v._0); -} - -export function copy$shapes_Gauge(v: shapes_Gauge.Gauge): shapes_Gauge.Gauge { - return { level: v.level }; -} - -export function copy$shapes_Held(v: shapes_Held.Held): shapes_Held.Held { - return { at: copy$shapes_Point(v.at) }; -} - -export function copy$shapes_Lens(v: Lens.Lens): Lens.Lens { - return { slot: v.slot, n: v.n }; -} - -export function copy$shapes_Level(v: Level.Level): Level.Level { - return { _0: v._0 }; -} - -export function copy$shapes_Mark(v: Mark.Mark): Mark.Mark { - return { at: v.at }; -} - -export function copy$shapes_Point(v: Point.Point): Point.Point { - return { x: v.x, y: v.y }; -} - -export function copy$shapes_Shape(v: shapes_Shape.Shape): shapes_Shape.Shape { - if (v.tag === "Line") { - return { tag: "Line", _0: copy$shapes_Point(v._0), _1: copy$shapes_Point(v._1) }; - } - if (v.tag === "Rect") { - return { tag: "Rect", corner: copy$shapes_Point(v.corner), width: v.width, height: v.height }; - } - return v; -} - -export function copy$slices_Pair(v: slices_Pair.Pair): slices_Pair.Pair { - return { a: v.a, b: v.b }; -} - -export function copy$task_Poll_array1_u8(v: rt.Poll): rt.Poll { - return v === rt.Pending ? v : copy$array_u8(v); -} - -export function copy$tuple2_array2_u32_u8(v: [rt.u32[], rt.u8]): [rt.u32[], rt.u8] { - return [copy$array_u32(v[0]), v[1]]; -} - -export function copy$tuple2_locals_Twin_locals_Twin(v: [locals_Twin.Twin, locals_Twin.Twin]): [locals_Twin.Twin, locals_Twin.Twin] { - return [copy$locals_Twin(v[0]), copy$locals_Twin(v[1])]; -} - -export function copy$tuple2_mutPtr_Cell_u8_u8(v: [rt.Place>, rt.u8]): [rt.Place>, rt.u8] { - return [v[0], v[1]]; -} - -export function copy$tuple2_mutPtr_array2_u16_u8(v: [rt.u16[], rt.u8]): [rt.u16[], rt.u8] { - return [v[0], v[1]]; -} - -export function copy$tuple2_mutPtr_array4_u8_u8(v: [rt.ByteSlice, rt.u8]): [rt.ByteSlice, rt.u8] { - return [v[0], v[1]]; -} - -export function copy$tuple2_mutPtr_pointers_Housed_u8_u8(v: [Housed.Housed, rt.u8]): [Housed.Housed, rt.u8] { - return [v[0], v[1]]; -} - -export function copy$tuple2_mutPtr_pointers_Leaning_u8(v: [rt.Place, rt.u8]): [rt.Place, rt.u8] { - return [v[0], v[1]]; -} - -export function copy$tuple2_mutPtr_pointers_Paired_u8(v: [Paired.Paired, rt.u8]): [Paired.Paired, rt.u8] { - return [v[0], v[1]]; -} - -export function copy$tuple2_mutPtr_u8_u8(v: [rt.Place, rt.u8]): [rt.Place, rt.u8] { - return [v[0], v[1]]; -} - -export function copy$tuple2_ref_sync_Mutex_u8_u8(v: [rt.Mutex, rt.u8]): [rt.Mutex, rt.u8] { - return [v[0], v[1]]; -} - -export function copy$tuple2_shapes_Point_u8(v: [Point.Point, rt.u8]): [Point.Point, rt.u8] { - return [copy$shapes_Point(v[0]), v[1]]; -} - -export function copy$tuple2_u32_u32(v: [rt.u32, rt.u32]): [rt.u32, rt.u32] { - return [v[0], v[1]]; -} - -export function copy$tuple2_u64_u64(v: [rt.u64, rt.u64]): [rt.u64, rt.u64] { - return [v[0], v[1]]; -} - -export function copy$tuple2_u64_u8(v: [rt.u64, rt.u8]): [rt.u64, rt.u8] { - return [v[0], v[1]]; -} - -export function copy$tuple2_u8_String(v: [rt.u8, string]): [rt.u8, string] { - return [v[0], v[1]]; -} - -export function copy$tuple2_u8_collections_Tally(v: [rt.u8, collections_Tally.Tally]): [rt.u8, collections_Tally.Tally] { - return [v[0], copy$collections_Tally(v[1])]; -} - -export function copy$tuple2_u8_keys_Horizon(v: [rt.u8, Horizon.Horizon]): [rt.u8, Horizon.Horizon] { - return [v[0], copy$keys_Horizon(v[1])]; -} - -export function copy$tuple2_u8_sync_Arc_u8(v: [rt.u8, rt.Arc]): [rt.u8, rt.Arc] { - return [v[0], v[1]]; -} - -export function copy$tuple2_u8_u16(v: [rt.u8, rt.u16]): [rt.u8, rt.u16] { - return [v[0], v[1]]; -} - -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 }; -} - -export function copy$wraps_Tick_i128(v: Tick.Tick): Tick.Tick { - return new Tick.Tick(v._0); -} - -export function copy$wraps_Tick_i16(v: Tick.Tick): Tick.Tick { - return new Tick.Tick(v._0); -} - -export function copy$wraps_Tick_i32(v: Tick.Tick): Tick.Tick { - return new Tick.Tick(v._0); -} - -export function copy$wraps_Tick_i64(v: Tick.Tick): Tick.Tick { - return new Tick.Tick(v._0); -} - -export function copy$wraps_Tick_i8(v: Tick.Tick): Tick.Tick { - return new Tick.Tick(v._0); -} - -export function copy$wraps_Tick_isize(v: Tick.Tick): Tick.Tick { - return new Tick.Tick(v._0); -} - -export function copy$wraps_Tick_u128(v: Tick.Tick): Tick.Tick { - return new Tick.Tick(v._0); -} - -export function copy$wraps_Tick_u16(v: Tick.Tick): Tick.Tick { - return new Tick.Tick(v._0); -} - -export function copy$wraps_Tick_u32(v: Tick.Tick): Tick.Tick { - return new Tick.Tick(v._0); -} - -export function copy$wraps_Tick_u64(v: Tick.Tick): Tick.Tick { - return new Tick.Tick(v._0); -} - -export function copy$wraps_Tick_u8(v: Tick.Tick): Tick.Tick { - return new Tick.Tick(v._0); -} - -export function copy$wraps_Tick_usize(v: Tick.Tick): Tick.Tick { - return new Tick.Tick(v._0); -} - -export function drop$Option_cell_RefMut_borrows_Tagged(_1: rt.RefCell | undefined): void { - if (_1 !== undefined) { - rt.refMutRelease(_1); - } -} - -export function drop$Option_cell_Ref_borrows_Tagged(_1: rt.RefCell | undefined): void { - if (_1 !== undefined) { - rt.refRelease(_1); - } -} - -export function drop$Result_Rc_dyns_Noisy_Rc_dyn_Any(_1: rt.Result, rt.Arc>): void { - if (_1.ok) { - _1.value[Symbol.dispose](); - } else { - _1.error[Symbol.dispose](); - } -} - -export function drop$Result_Rc_dyns_Square_Rc_dyn_Any(_1: rt.Result, rt.Arc>): void { - if (_1.ok) { - _1.value[Symbol.dispose](); - } else { - _1.error[Symbol.dispose](); - } -} - -export function drop$Result_Rc_dyns_Tri_Rc_dyn_Any(_1: rt.Result, rt.Arc>): void { - if (_1.ok) { - _1.value[Symbol.dispose](); - } else { - _1.error[Symbol.dispose](); - } -} - -export function drop$Result_Result_sync_MappedMutexGuard_u64_sync_MappedMutexGuard_u64_sync_MutexGuard_locks_Tally(_1: rt.Result, rt.Mutex>, rt.Mutex>): void { - if (_1.ok) { - drop$Result_sync_MappedMutexGuard_u64_sync_MappedMutexGuard_u64(_1.value); - } else { - rt.mutexUnlock(_1.error); - } -} - -export function drop$Result_Result_sync_MappedRwLockWriteGuard_u64_sync_MappedRwLockWriteGuard_u64_sync_RwLockWriteGuard_locks_Tally(_1: rt.Result, rt.RefCell>, rt.RefCell>): void { - if (_1.ok) { - drop$Result_sync_MappedRwLockWriteGuard_u64_sync_MappedRwLockWriteGuard_u64(_1.value); - } else { - rt.refMutRelease(_1.error); - } -} - -export function drop$Result_boxed_Box_array1_boxes_Logged_boxed_Box_slice_boxes_Logged(_1: rt.Result): void { - if (_1.ok) { - rt.dropAll(_1.value); - } else { - rt.dropAll(_1.error); - } -} - -export function drop$Result_cell_RefMut_Vec_u8_cell_BorrowMutError(_1: rt.Result, rt.BorrowMutError>): void { - if (_1.ok) { - rt.refMutRelease(_1.value); - } -} - -export function drop$Result_cell_RefMut_array4_u8_cell_BorrowMutError(_1: rt.Result, rt.BorrowMutError>): void { - if (_1.ok) { - rt.refMutRelease(_1.value); - } -} - -export function drop$Result_cell_RefMut_borrows_Parts_cell_BorrowMutError(_1: rt.Result, rt.BorrowMutError>): void { - if (_1.ok) { - rt.refMutRelease(_1.value); - } -} - -export function drop$Result_cell_RefMut_borrows_Tagged_cell_BorrowMutError(_1: rt.Result, rt.BorrowMutError>): void { - if (_1.ok) { - rt.refMutRelease(_1.value); - } -} - -export function drop$Result_cell_RefMut_tuple2_u16_Vec_u8_cell_BorrowMutError(_1: rt.Result, rt.BorrowMutError>): void { - if (_1.ok) { - rt.refMutRelease(_1.value); - } -} - -export function drop$Result_cell_RefMut_u32_cell_BorrowMutError(_1: rt.Result, rt.BorrowMutError>): void { - if (_1.ok) { - rt.refMutRelease(_1.value); - } -} - -export function drop$Result_cell_RefMut_u32_tuple2_cell_RefMut_borrows_Parts_unit(_1: rt.Result, [rt.RefCell, undefined]>): void { - if (_1.ok) { - rt.refMutRelease(_1.value); - } else { - drop$tuple2_cell_RefMut_borrows_Parts_unit(_1.error); - } -} - -export function drop$Result_cell_Ref_Vec_u8_cell_BorrowError(_1: rt.Result, rt.BorrowError>): void { - if (_1.ok) { - rt.refRelease(_1.value); - } -} - -export function drop$Result_cell_Ref_array4_u8_cell_BorrowError(_1: rt.Result, rt.BorrowError>): void { - if (_1.ok) { - rt.refRelease(_1.value); - } -} - -export function drop$Result_cell_Ref_borrows_Parts_cell_BorrowError(_1: rt.Result, rt.BorrowError>): void { - if (_1.ok) { - rt.refRelease(_1.value); - } -} - -export function drop$Result_cell_Ref_ref_str_tuple2_cell_Ref_tuple2_u8_ref_str_u8(_1: rt.Result, [rt.RefCell<[rt.u8, string]>, rt.u8]>): void { - if (_1.ok) { - rt.refRelease(_1.value); - } else { - drop$tuple2_cell_Ref_tuple2_u8_ref_str_u8(_1.error); - } -} - -export function drop$Result_cell_Ref_tuple2_u16_Vec_u8_cell_BorrowError(_1: rt.Result, rt.BorrowError>): void { - if (_1.ok) { - rt.refRelease(_1.value); - } -} - -export function drop$Result_cell_Ref_u32_cell_BorrowError(_1: rt.Result, rt.BorrowError>): void { - if (_1.ok) { - rt.refRelease(_1.value); - } -} - -export function drop$Result_cell_Ref_u32_cell_Ref_borrows_Parts(_1: rt.Result, rt.RefCell>): void { - if (_1.ok) { - rt.refRelease(_1.value); - } else { - rt.refRelease(_1.error); - } -} - -export function drop$Result_cell_Ref_u32_tuple2_cell_Ref_borrows_Parts_unit(_1: rt.Result, [rt.RefCell, undefined]>): void { - if (_1.ok) { - rt.refRelease(_1.value); - } else { - drop$tuple2_cell_Ref_borrows_Parts_unit(_1.error); - } -} - -export function drop$Result_results_Logged_results_Logged(_1: rt.Result): void { - if (_1.ok) { - _1.value[Symbol.dispose](); - } else { - _1.error[Symbol.dispose](); - } -} - -export function drop$Result_sync_Arc_u32_sync_Arc_dyn_Any_marker_Sync_marker_Send(_1: rt.Result, rt.Arc>): void { - if (_1.ok) { - _1.value[Symbol.dispose](); - } else { - _1.error[Symbol.dispose](); - } -} - -export function drop$Result_sync_MappedMutexGuard_u64_sync_MappedMutexGuard_u64(_1: rt.Result, rt.Mutex>): void { - if (_1.ok) { - rt.mutexUnlock(_1.value); - } else { - rt.mutexUnlock(_1.error); - } -} - -export function drop$Result_sync_MappedRwLockReadGuard_u8_sync_RwLockReadGuard_locks_Tally(_1: rt.Result, rt.RefCell>): void { - if (_1.ok) { - rt.refRelease(_1.value); - } else { - rt.refRelease(_1.error); - } -} - -export function drop$Result_sync_MappedRwLockWriteGuard_u64_sync_MappedRwLockWriteGuard_u64(_1: rt.Result, rt.RefCell>): void { - if (_1.ok) { - rt.refMutRelease(_1.value); - } else { - rt.refMutRelease(_1.error); - } -} - -export function drop$Result_sync_MutexGuard_array4_u8_sync_TryLockError_sync_MutexGuard_array4_u8(_1: rt.Result, rt.TryLockError>>): void { - if (_1.ok) { - rt.mutexUnlock(_1.value); - } else { - drop$sync_TryLockError_sync_MutexGuard_array4_u8(_1.error); - } -} - -export function drop$Result_sync_MutexGuard_locks_Tally_sync_TryLockError_sync_MutexGuard_locks_Tally(_1: rt.Result, rt.TryLockError>>): void { - if (_1.ok) { - rt.mutexUnlock(_1.value); - } else { - drop$sync_TryLockError_sync_MutexGuard_locks_Tally(_1.error); - } -} - -export function drop$Result_sync_MutexGuard_u32_sync_TryLockError_sync_MutexGuard_u32(_1: rt.Result, rt.TryLockError>>): void { - if (_1.ok) { - rt.mutexUnlock(_1.value); - } else { - drop$sync_TryLockError_sync_MutexGuard_u32(_1.error); - } -} - -export function drop$Result_sync_MutexGuard_u8_sync_TryLockError_sync_MutexGuard_u8(_1: rt.Result, rt.TryLockError>>): void { - if (_1.ok) { - rt.mutexUnlock(_1.value); - } else { - drop$sync_TryLockError_sync_MutexGuard_u8(_1.error); - } -} - -export function drop$Result_sync_RwLockReadGuard_array4_u8_sync_TryLockError_sync_RwLockReadGuard_array4_u8(_1: rt.Result, rt.TryLockError>>): void { - if (_1.ok) { - rt.refRelease(_1.value); - } else { - drop$sync_TryLockError_sync_RwLockReadGuard_array4_u8(_1.error); - } -} - -export function drop$Result_sync_RwLockReadGuard_locks_Tally_sync_TryLockError_sync_RwLockReadGuard_locks_Tally(_1: rt.Result, rt.TryLockError>>): void { - if (_1.ok) { - rt.refRelease(_1.value); - } else { - drop$sync_TryLockError_sync_RwLockReadGuard_locks_Tally(_1.error); - } -} - -export function drop$Result_sync_RwLockReadGuard_u32_sync_TryLockError_sync_RwLockReadGuard_u32(_1: rt.Result, rt.TryLockError>>): void { - if (_1.ok) { - rt.refRelease(_1.value); - } else { - drop$sync_TryLockError_sync_RwLockReadGuard_u32(_1.error); - } -} - -export function drop$Result_sync_RwLockWriteGuard_array4_u8_sync_TryLockError_sync_RwLockWriteGuard_array4_u8(_1: rt.Result, rt.TryLockError>>): void { - if (_1.ok) { - rt.refMutRelease(_1.value); - } else { - drop$sync_TryLockError_sync_RwLockWriteGuard_array4_u8(_1.error); - } -} - -export function drop$Result_sync_RwLockWriteGuard_locks_Tally_sync_TryLockError_sync_RwLockWriteGuard_locks_Tally(_1: rt.Result, rt.TryLockError>>): void { - if (_1.ok) { - rt.refMutRelease(_1.value); - } else { - drop$sync_TryLockError_sync_RwLockWriteGuard_locks_Tally(_1.error); - } -} - -export function drop$Result_sync_RwLockWriteGuard_u32_sync_TryLockError_sync_RwLockWriteGuard_u32(_1: rt.Result, rt.TryLockError>>): void { - if (_1.ok) { - rt.refMutRelease(_1.value); - } else { - drop$sync_TryLockError_sync_RwLockWriteGuard_u32(_1.error); - } -} - -export function drop$Result_tuple2_tuples_Logged_u8_u8(_1: rt.Result<[tuples_Logged.Logged, rt.u8], rt.u8>): void { - if (_1.ok) { - drop$tuple2_tuples_Logged_u8(_1.value); - } -} - -export function drop$Result_tuple2_usize_u8_sync_Arc_dyn_Any_marker_Sync_marker_Send(_1: rt.Result<[rt.usize, rt.u8], rt.Arc>): void { - if (!_1.ok) { - _1.error[Symbol.dispose](); - } -} - -export function drop$Result_u8_boxed_Box_dyn_Error_marker_Sync_marker_Send(_1: rt.Result): void { - if (!_1.ok) { - rt.drop(_1.error); - } -} - -export function drop$Vec_Rc_counts_Noisy(value: rt.Arc[]): void { - rt.dropAll(value); -} - -export function drop$Vec_clones_Logged(value: clones_Logged.Logged[]): void { - rt.dropAll(value); -} - -export function drop$Vec_joins_Logged(value: joins_Logged.Logged[]): void { - rt.dropAll(value); -} - -export function drop$Vec_sync_Arc_counts_Noisy(value: rt.Arc[]): void { - rt.dropAll(value); -} - -export function drop$array2_joins_Logged(value: joins_Logged.Logged[]): void { - rt.dropAll(value); -} - -export function drop$boxed_Box_slice_joins_Logged(value: joins_Logged.Logged[]): void { - rt.dropAll(value); -} - -export function drop$cell_RefCell_Vec_Rc_counts_RcReleasing(value: rt.RefCell[]>): void { - rt.dropAll(value.value); -} - -export function drop$cell_RefCell_Vec_sync_Arc_counts_ArcReleasing(value: rt.RefCell[]>): void { - rt.dropAll(value.value); -} - -export function drop$elements_Inline_Option_tuple2_u8_u8(_1: Inline.Inline<[rt.u8, rt.u8] | undefined>): void { - Inline.drop$ops_Drop_Option_tuple2_u8_u8(_1); -} - -export function drop$elements_Inline_sync_Arc_u8(_1: Inline.Inline>): void { - Inline.drop$ops_Drop_sync_Arc_u8(_1); -} - -export function drop$errors_Failure(_1: Failure.Failure): void { - if (_1.tag === "Wrapped") { - _1._0[Symbol.dispose](); - } -} - -export function drop$generics_Run_generics_Ticked(_1: generics_Run.Run): void { - if (_1.tag === "Listed") { - rt.dropAll(_1._0 as Ticked.Ticked[]); - } else if (_1.tag === "Fixed") { - rt.dropAll(_1.array as Ticked.Ticked[]); - } -} - -export function drop$heap_Spill_Option_tuple2_u8_u16(_1: Spill.Spill<[rt.u8, rt.u16] | undefined>): void { - Spill.drop$ops_Drop_Option_tuple2_u8_u16(_1); -} - -export function drop$heap_Spill_sync_Arc_u8(_1: Spill.Spill>): void { - Spill.drop$ops_Drop_sync_Arc_u8(_1); -} - -export function drop$heap_Spill_u32(_1: Spill.Spill): void { - Spill.drop$ops_Drop_u32(_1); -} - -export function drop$pointers_List_String(_1: List.List): void { - List.drop$ops_Drop_String(_1); -} - -export function drop$pointers_List_sync_Arc_u8(_1: List.List>): void { - List.drop$ops_Drop_sync_Arc_u8(_1); -} - -export function drop$statics_Lock_Rc_unit(_1: statics_Lock.Lock>): void { - statics_Lock.drop$ops_Drop_Rc_unit(_1); -} - -export function drop$statics_Lock_tuple2_u8_Rc_unit(_1: statics_Lock.Lock<[rt.u8, rt.Arc]>): void { - statics_Lock.drop$ops_Drop_tuple2_u8_Rc_unit(_1); -} - -export function drop$sync_TryLockError_sync_MutexGuard_array4_u8(_1: rt.TryLockError>): void { - if (_1.tag === "Poisoned") { - rt.mutexUnlock((_1 as { tag: "Poisoned"; _0: rt.Mutex })._0); - } -} - -export function drop$sync_TryLockError_sync_MutexGuard_locks_Tally(_1: rt.TryLockError>): void { - if (_1.tag === "Poisoned") { - rt.mutexUnlock((_1 as { tag: "Poisoned"; _0: rt.Mutex })._0); - } -} - -export function drop$sync_TryLockError_sync_MutexGuard_u32(_1: rt.TryLockError>): void { - if (_1.tag === "Poisoned") { - rt.mutexUnlock((_1 as { tag: "Poisoned"; _0: rt.Mutex })._0); - } -} - -export function drop$sync_TryLockError_sync_MutexGuard_u8(_1: rt.TryLockError>): void { - if (_1.tag === "Poisoned") { - rt.mutexUnlock((_1 as { tag: "Poisoned"; _0: rt.Mutex })._0); - } -} - -export function drop$sync_TryLockError_sync_RwLockReadGuard_array4_u8(_1: rt.TryLockError>): void { - if (_1.tag === "Poisoned") { - rt.refRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell })._0); - } -} - -export function drop$sync_TryLockError_sync_RwLockReadGuard_locks_Tally(_1: rt.TryLockError>): void { - if (_1.tag === "Poisoned") { - rt.refRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell })._0); - } -} - -export function drop$sync_TryLockError_sync_RwLockReadGuard_u32(_1: rt.TryLockError>): void { - if (_1.tag === "Poisoned") { - rt.refRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell })._0); - } -} - -export function drop$sync_TryLockError_sync_RwLockWriteGuard_array4_u8(_1: rt.TryLockError>): void { - if (_1.tag === "Poisoned") { - rt.refMutRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell })._0); - } -} - -export function drop$sync_TryLockError_sync_RwLockWriteGuard_locks_Tally(_1: rt.TryLockError>): void { - if (_1.tag === "Poisoned") { - rt.refMutRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell })._0); - } -} - -export function drop$sync_TryLockError_sync_RwLockWriteGuard_u32(_1: rt.TryLockError>): void { - if (_1.tag === "Poisoned") { - rt.refMutRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell })._0); - } -} - -export function drop$tuple2_Option_cell_Ref_borrows_Tagged_Option_cell_RefMut_borrows_Tagged(_1: [rt.RefCell | undefined, rt.RefCell | undefined]): void { - drop$Option_cell_Ref_borrows_Tagged(_1[0]); - drop$Option_cell_RefMut_borrows_Tagged(_1[1]); -} - -export function drop$tuple2_Result_cell_Ref_Vec_u8_cell_BorrowError_cell_Ref_Vec_u8(_1: [rt.Result, rt.BorrowError>, rt.RefCell]): void { - drop$Result_cell_Ref_Vec_u8_cell_BorrowError(_1[0]); - rt.refRelease(_1[1]); -} - -export function drop$tuple2_Vec_tuples_Logged_tuples_Tally(_1: [tuples_Logged.Logged[], tuples_Tally.Tally]): void { - rt.dropAll(_1[0]); -} - -export function drop$tuple2_cell_RefMut_borrows_Parts_unit(_1: [rt.RefCell, undefined]): void { - rt.refMutRelease(_1[0]); -} - -export function drop$tuple2_cell_RefMut_slice_u8_cell_RefMut_slice_u8(_1: [rt.RefCell, rt.RefCell]): void { - rt.refMutRelease(_1[0]); - rt.refMutRelease(_1[1]); -} - -export function drop$tuple2_cell_Ref_Vec_u8_cell_Ref_u8(_1: [rt.RefCell, rt.RefCell]): void { - rt.refRelease(_1[0]); - rt.refRelease(_1[1]); -} - -export function drop$tuple2_cell_Ref_borrows_Parts_unit(_1: [rt.RefCell, undefined]): void { - rt.refRelease(_1[0]); -} - -export function drop$tuple2_cell_Ref_str_cell_RefMut_u32(_1: [rt.RefCell, rt.RefCell]): void { - rt.refRelease(_1[0]); - rt.refMutRelease(_1[1]); -} - -export function drop$tuple2_cell_Ref_tuple2_u8_ref_str_u8(_1: [rt.RefCell<[rt.u8, string]>, rt.u8]): void { - rt.refRelease(_1[0]); -} - -export function drop$tuple2_conversions_Logged_u8(_1: [conversions_Logged.Logged, rt.u8]): void { - _1[0][Symbol.dispose](); -} - -export function drop$tuple2_sync_Arc_collections_Picky_u8(_1: [rt.Arc, rt.u8]): void { - _1[0][Symbol.dispose](); -} - -export function drop$tuple2_tuples_Logged_u8(_1: [tuples_Logged.Logged, rt.u8]): void { - _1[0][Symbol.dispose](); -} - -export function drop$tuple2_u8_Rc_unit(_1: [rt.u8, rt.Arc]): void { - _1[1][Symbol.dispose](); -} - -export function drop$tuple2_u8_cmp_Reverse_sync_Arc_keys_Lopsided(_1: [rt.u8, rt.Arc]): void { - _1[1][Symbol.dispose](); -} - -export function drop$tuple2_u8_sync_Arc_u8(_1: [rt.u8, rt.Arc]): void { - _1[1][Symbol.dispose](); -} - -export function drop$tuple2_u8_tuples_Logged(_1: [rt.u8, tuples_Logged.Logged]): void { - _1[1][Symbol.dispose](); -} - -export function drop$tuple3_cell_Ref_String_cell_Ref_array4_u8_cell_Ref_u32(_1: [rt.RefCell, rt.RefCell, rt.RefCell]): void { - rt.refRelease(_1[0]); - rt.refRelease(_1[1]); - rt.refRelease(_1[2]); -} - -export function drop$tuple4_Vec_Vec_joins_Logged_array2_array2_joins_Logged_joins_Logged_Vec_joins_Logged(_1: [joins_Logged.Logged[][], joins_Logged.Logged[][], joins_Logged.Logged, joins_Logged.Logged[]]): void { - rt.dropAll(_1[0], drop$Vec_joins_Logged); - rt.dropAll(_1[1], drop$array2_joins_Logged); - _1[2][Symbol.dispose](); - rt.dropAll(_1[3]); -} - -export function drop$tuple5_Vec_Rc_counts_Noisy_Vec_Rc_counts_Noisy_Vec_counts_RcShared_Vec_counts_Noisy_Vec_Vec_Rc_counts_Noisy(_1: [rt.Arc[], rt.Arc[], RcShared.RcShared[], counts_Noisy.Noisy[], rt.Arc[][]]): void { - rt.dropAll(_1[0]); - rt.dropAll(_1[1]); - rt.dropAll(_1[2]); - rt.dropAll(_1[3]); - rt.dropAll(_1[4], drop$Vec_Rc_counts_Noisy); -} - -export function drop$tuple5_Vec_sync_Arc_counts_Noisy_Vec_sync_Arc_counts_Noisy_Vec_counts_ArcShared_Vec_counts_Noisy_Vec_Vec_sync_Arc_counts_Noisy(_1: [rt.Arc[], rt.Arc[], ArcShared.ArcShared[], counts_Noisy.Noisy[], rt.Arc[][]]): void { - rt.dropAll(_1[0]); - rt.dropAll(_1[1]); - rt.dropAll(_1[2]); - rt.dropAll(_1[3]); - rt.dropAll(_1[4], drop$Vec_sync_Arc_counts_Noisy); -} - -export function drop$zeros_Lock_u32(_1: zeros_Lock.Lock): void { - zeros_Lock.drop$ops_Drop_u32(_1); -} - -export function drop$zeros_Lock_zeros_Loud(_1: zeros_Lock.Lock): void { - zeros_Lock.drop$ops_Drop_zeros_Loud(_1); -} - -export const out$bool: { p: boolean } = { p: undefined as never }; - -export const out$ref_slice_u8: { pData: Uint8Array; pStart: number; pLen: number } = { pData: undefined as never, pStart: undefined as never, pLen: undefined as never }; - -export const out$tuple2_f64_char: { err: unknown; p_1: rt.char } = { err: undefined, p_1: undefined as never }; - -export const out$tuple2_i64_u64: { err: unknown; p_1: rt.u64 } = { err: undefined, p_1: undefined as never }; - -export const out$tuple2_ref_array4_u8_ref_slice_u8: { p_0Data: Uint8Array; p_0Start: number; p_0Len: number; p_1Data: Uint8Array; p_1Start: number; p_1Len: number } = { p_0Data: undefined as never, p_0Start: undefined as never, p_0Len: undefined as never, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never }; - -export const out$tuple2_ref_slice_u8_ref_slice_u8: { p_0Data: Uint8Array; p_0Start: number; p_0Len: number; p_1Data: Uint8Array; p_1Start: number; p_1Len: number } = { p_0Data: undefined as never, p_0Start: undefined as never, p_0Len: undefined as never, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never }; - -export const out$tuple2_u16_ref_slice_u8: { err: unknown; p_1Data: Uint8Array; p_1Start: number; p_1Len: number } = { err: undefined, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never }; - -export const out$tuple2_u32_ref_slice_u8: { err: unknown; p_1Data: Uint8Array; p_1Start: number; p_1Len: number } = { err: undefined, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never }; - -export const out$tuple2_u64_ref_slice_u8: { err: unknown; p_1Data: Uint8Array; p_1Start: number; p_1Len: number } = { err: undefined, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never }; - -export const out$tuple2_u8_ref_slice_u8: { err: unknown; p_1Data: Uint8Array; p_1Start: number; p_1Len: number } = { err: undefined, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never }; - -export const out$tuple3_ref_slice_u8_ref_array2_u8_ref_slice_u8: { p_0Data: Uint8Array; p_0Start: number; p_0Len: number; p_1Data: Uint8Array; p_1Start: number; p_1Len: number; p_2Data: Uint8Array; p_2Start: number; p_2Len: number } = { p_0Data: undefined as never, p_0Start: undefined as never, p_0Len: undefined as never, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never, p_2Data: undefined as never, p_2Start: undefined as never, p_2Len: undefined as never }; - -export const out$tuple3_u64_u64_ref_slice_u8: { err: unknown; p_1: rt.u64; p_2Data: Uint8Array; p_2Start: number; p_2Len: number } = { err: undefined, p_1: undefined as never, p_2Data: undefined as never, p_2Start: undefined as never, p_2Len: undefined as never }; - -export const out$tuple3_u8_u16_ref_slice_u8: { err: unknown; p_1: rt.u16; p_2Data: Uint8Array; p_2Start: number; p_2Len: number } = { err: undefined, p_1: undefined as never, p_2Data: undefined as never, p_2Start: undefined as never, p_2Len: undefined as never }; - -export const out$u32: { err: unknown } = { err: undefined }; - -export const out$u64: { err: unknown } = { err: undefined }; - -export const out$u8: { err: unknown } = { err: undefined }; - -//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/pointers.Links.ts b/ts/fixtures/lang/expected/pointers.Links.ts deleted file mode 100644 index 51bd55ce1..000000000 --- a/ts/fixtures/lang/expected/pointers.Links.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by rust2-ts. Do not edit. - -import type * as pointers_Node from "./pointers.Node.ts"; - -export interface Links { - next: pointers_Node.Node; - prev: pointers_Node.Node; -} - -//# sourceMappingURL=pointers.Links.ts.map diff --git a/ts/fixtures/lang/expected/shapes.Filled.ts b/ts/fixtures/lang/expected/shapes.Filled.ts deleted file mode 100644 index 7e0fa7f2b..000000000 --- a/ts/fixtures/lang/expected/shapes.Filled.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Generated by rust2-ts. Do not edit. - -import * as rt from "./rt.ts"; -import { copy$shapes_Point } from "./lib.ts"; -import * as Point from "./shapes.Point.ts"; -import type * as shapes_Shape from "./shapes.Shape.ts"; - -/** An `Option` a method matches, filling it between its matches. */ -export interface Filled { - shape: shapes_Shape.Shape | undefined; -} - -export function fill(self: Filled): void { - let _2!: shapes_Shape.Shape | undefined; - if (self.shape === undefined) { - _2 = { tag: "Line", _0: copy$shapes_Point(Point.new(5, 6)), _1: copy$shapes_Point(Point.new(7, 8)) } as shapes_Shape.Shape; - } else if (self.shape.tag === "Dot") { - _2 = { tag: "Line", _0: copy$shapes_Point(Point.new(1, 2)), _1: copy$shapes_Point(Point.new(3, 4)) } as shapes_Shape.Shape; - } else { - _2 = undefined; - } - self.shape = _2; -} - -export function run(self: Filled): rt.u8 { - if (self.shape === undefined) { - fill(self); - if ((self.shape as shapes_Shape.Shape | undefined) === undefined) { - return 41; - } - if (((self.shape as shapes_Shape.Shape | undefined) as shapes_Shape.Shape).tag === "Line") { - return copy$shapes_Point((((self.shape as shapes_Shape.Shape | undefined) as shapes_Shape.Shape) as { tag: "Line"; _0: Point.Point; _1: Point.Point })._1).y & 0xff; - } - return 40; - } - if (self.shape.tag === "Dot") { - fill(self); - if ((self.shape as shapes_Shape.Shape | undefined) !== undefined) { - if ((self.shape as shapes_Shape.Shape).tag === "Line") { - return copy$shapes_Point(((self.shape as shapes_Shape.Shape) as { tag: "Line"; _0: Point.Point; _1: Point.Point })._0).x & 0xff; - } - } - return 42; - } - fill(self); - return 43; -} - -//# sourceMappingURL=shapes.Filled.ts.map diff --git a/ts/fixtures/lang/fields/Cargo.toml b/ts/fixtures/lang/fields/Cargo.toml new file mode 100644 index 000000000..59767dd2a --- /dev/null +++ b/ts/fixtures/lang/fields/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-fields-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/fields/expected/core/option.ts b/ts/fixtures/lang/fields/expected/core/option.ts new file mode 100644 index 000000000..659e3e1e0 --- /dev/null +++ b/ts/fixtures/lang/fields/expected/core/option.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function okOr$1w08zpl(self: rt.ByteSlice | undefined, err: rt.usize): rt.Result { + if (self === undefined) { + return rt.Err(err); + } + return rt.Ok(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/fields/expected/core/result.ts b/ts/fixtures/lang/fields/expected/core/result.ts new file mode 100644 index 000000000..d90131781 --- /dev/null +++ b/ts/fixtures/lang/fields/expected/core/result.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function ok$04yj0hm(self: rt.Result): rt.ByteSlice | undefined { + if (self.ok) { + return self.value; + } + return undefined; +} + +export function inspectErr$0g3nypv(self: rt.Result, f: (a0: rt.usize) => undefined): rt.Result { + if (!self.ok) { + f(self.error); + } + return self; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/expected/fields.Couple.ts b/ts/fixtures/lang/fields/expected/fields.Couple.ts similarity index 100% rename from ts/fixtures/lang/expected/fields.Couple.ts rename to ts/fixtures/lang/fields/expected/fields.Couple.ts diff --git a/ts/fixtures/lang/expected/fields.Exposed.ts b/ts/fixtures/lang/fields/expected/fields.Exposed.ts similarity index 100% rename from ts/fixtures/lang/expected/fields.Exposed.ts rename to ts/fixtures/lang/fields/expected/fields.Exposed.ts diff --git a/ts/fixtures/lang/expected/fields.Glued.ts b/ts/fixtures/lang/fields/expected/fields.Glued.ts similarity index 100% rename from ts/fixtures/lang/expected/fields.Glued.ts rename to ts/fixtures/lang/fields/expected/fields.Glued.ts diff --git a/ts/fixtures/lang/expected/fields.Labeled.ts b/ts/fixtures/lang/fields/expected/fields.Labeled.ts similarity index 100% rename from ts/fixtures/lang/expected/fields.Labeled.ts rename to ts/fixtures/lang/fields/expected/fields.Labeled.ts diff --git a/ts/fixtures/lang/expected/fields.Scanner.ts b/ts/fixtures/lang/fields/expected/fields.Scanner.ts similarity index 100% rename from ts/fixtures/lang/expected/fields.Scanner.ts rename to ts/fixtures/lang/fields/expected/fields.Scanner.ts diff --git a/ts/fixtures/lang/expected/fields.Sentry.ts b/ts/fixtures/lang/fields/expected/fields.Sentry.ts similarity index 100% rename from ts/fixtures/lang/expected/fields.Sentry.ts rename to ts/fixtures/lang/fields/expected/fields.Sentry.ts diff --git a/ts/fixtures/lang/expected/fields.ts b/ts/fixtures/lang/fields/expected/fields.ts similarity index 100% rename from ts/fixtures/lang/expected/fields.ts rename to ts/fixtures/lang/fields/expected/fields.ts diff --git a/ts/fixtures/lang/fields/expected/harness.ts b/ts/fixtures/lang/fields/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/fields/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/fields/expected/lib.ts b/ts/fixtures/lang/fields/expected/lib.ts new file mode 100644 index 000000000..9ad092385 --- /dev/null +++ b/ts/fixtures/lang/fields/expected/lib.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { fields } from "./fields.ts"; +import type * as Couple from "./fields.Couple.ts"; + +export function copy$fields_Couple(v: Couple.Couple): Couple.Couple { + return { headData: v.headData, headStart: v.headStart, headLen: v.headLen, wordData: v.wordData, wordStart: v.wordStart, wordLen: v.wordLen }; +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["fields::fields", fields as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/fields.rs b/ts/fixtures/lang/fields/src/fields.rs similarity index 100% rename from ts/fixtures/lang/src/fields.rs rename to ts/fixtures/lang/fields/src/fields.rs diff --git a/ts/fixtures/lang/fields/src/lib.rs b/ts/fixtures/lang/fields/src/lib.rs new file mode 100644 index 000000000..92c184b07 --- /dev/null +++ b/ts/fixtures/lang/fields/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod fields; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("fields::fields", fields::fields)] +} diff --git a/ts/fixtures/lang/fields/ts.toml b/ts/fixtures/lang/fields/ts.toml new file mode 100644 index 000000000..3b5d6c22e --- /dev/null +++ b/ts/fixtures/lang/fields/ts.toml @@ -0,0 +1,2 @@ +package = "lang-fields-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/floats/Cargo.toml b/ts/fixtures/lang/floats/Cargo.toml new file mode 100644 index 000000000..08e9f533d --- /dev/null +++ b/ts/fixtures/lang/floats/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-floats-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/floats/caller.ts b/ts/fixtures/lang/floats/caller.ts new file mode 100644 index 000000000..a32e3e947 --- /dev/null +++ b/ts/fixtures/lang/floats/caller.ts @@ -0,0 +1,81 @@ +// The inputs `floats`' cases name, which run with the generated ones. + +import { mulAddsWithin } from "./fma.ts"; +import { op as pick } from "./harness.ts"; +import { double, mulAdds, op, picked, ulpsWithin, wides } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `floats`' operands: each side of a half, of 2^52 and 2^53, where each integer type + * saturates, of a nanosecond and `u64::MAX` seconds, subnormals, infinities, and NaNs, + * one of them negative and one with a payload. + */ +const doubles: (number | bigint)[] = [ + 0, -0, 0.5, -0.5, 1.5, 2.5, -2.5, 0.49999999999999994, 1, -1, 3, 0.1, 1 / 3, 2 ** 52 - 0.5, 2 ** 52, 2 ** 53, 2 ** 53 + 2, + 255.5, -128.5, 2147483647.5, -2147483648.5, 4294967295.9, 2 ** 63, -(2 ** 63), -(2 ** 63) - 2048, 2 ** 64, 2 ** 64 - 2048, + 2 ** 127, 2 ** 128, -(2 ** 128), 1e-9, 0.5e-9, 1.5e-9, 0.999999999, 0.9999999995, 1.0000000005, 4.656612873077393e-10, + 1e-310, 5e-324, 2.2250738585072014e-308, Number.MAX_VALUE, -Number.MAX_VALUE, Infinity, -Infinity, NaN, + 0xfff8000000000000n, 0x7ff0000000000001n, +]; + +const floatsOp = op("floats::floats"); + +const floats = [ + ...Array.from({ length: 10 }, (_, kind) => doubles.flatMap((a) => doubles.map((b) => Uint8Array.of(...floatsOp, kind, ...double(a), ...double(b), 1)))).flat(), + // `from_secs_f64`, `mul_f64`, and `div_f64` panicking, and `Duration::MAX.mul_f64`. + ...[18, 28, 38].flatMap((kind) => doubles.map((a) => Uint8Array.of(...floatsOp, kind, ...double(a), ...double(a), 3))), + ...wides.map((v) => { + const bytes = new Uint8Array(16); + new DataView(bytes.buffer).setBigUint64(0, BigInt.asUintN(64, v >> 64n)); + new DataView(bytes.buffer).setBigUint64(8, BigInt.asUintN(64, v)); + return Uint8Array.of(...floatsOp, 2, ...bytes); + }), +]; + +/** + * `floats::formats`' doubles: ties at each precision, which std rounds half to even on the + * exact value, carries through nines, each side of where `Debug` takes an exponent, the + * shortest digits that are not the nearest ones, and the extremes. + */ +const formatted: (number | bigint)[] = [ + ...doubles, + 0.125, 0.375, 0.625, 0.875, 0.0625, 3.5, 4.5, 9.5, 99.5, 999.5, 0.95, 9.995, 1.25, 1.35, 2.675, 1e-4, 9.999999999999999e-5, + 1e16, 9999999999999998, 1e21, 1e22, 1e23, 5e-324, 2.225073858507201e-308, 123456789.125, 1.5e300, -1.5e-300, 2 ** -1022 * 1.5, + 0.1 + 0.2, 100, 1e15, 1e-7, 0.000123, -9.5, -0.5, +]; +const formatsOp = op("floats::formats"); +const formats = [ + ...formatted.flatMap((a) => Array.from({ length: 22 }, (_, p) => Uint8Array.of(...formatsOp, 0, ...double(a), p))), + ...formatted.flatMap((a) => [1, 3, 4].map((kind) => Uint8Array.of(...formatsOp, kind, ...double(a), 0))), + // Seeds for `parses`' decimals, a signaling NaN's bits among them, which a seed keeps. + ...doubles.map((a) => Uint8Array.of(...op("floats::parses"), 2, ...double(a))), + ...formatted.flatMap((a) => [[1, 2], [2, 1], [NaN, 1], [1, NaN], [-0, 0], [0, -0]].map(([b, c]) => Uint8Array.of(...formatsOp, 2, ...double(a), ...double(b), ...double(c)))), +]; + +/** + * `floats::parses`' texts: std's grammar at each edge, past each end of a double's range, + * and digits that round half to even, or just off it past 19 digits. + */ +const parsed = [ + "", "+", "-", ".", "+.", "-.", "e5", ".e5", "1e", "1e+", "1e-", "1.e5", ".5", "5.", "-.5e-3", "+1", "++1", "+-1", "1_000", "0x10", " 1", + "1 ", "1,5", "1.5.5", "1e5e5", "1E+05", "1e400", "-1e400", "1e-400", "1e99999999999999999999", "0e99999999999", "-0", "+0.0e-5", + "0000.0000", "inf", "-inf", "+inf", "infinity", "INFINITY", "InFiNiTy", "infin", "in", "infinityy", "nan", "NaN", "-nan", "+NAN", + "nan1", "Infinity", "i\u0307nf", "\u0131nf", "2.2250738585072011e-308", "2.2250738585072012e-308", "4.9406564584124654e-324", + "2.4703282292062327e-324", "2.4703282292062328e-324", "1.7976931348623157e308", "1.7976931348623158e308", "1.7976931348623159e308", + "9007199254740993", "9007199254740993.0000000000000000001", "9007199254740992.9999999999999999999", "123456789012345678901234567890", + "0.1000000000000000055511151231257827021181583404541015625", "1e23", "8.98846567431158e307", `0.${"0".repeat(400)}1e400`, + `1${"0".repeat(800)}e-800`, `${"9".repeat(800)}e-1100`, "1e65535", `1e-65536`, `0.${"0".repeat(70000)}1e70000`, +].map((text) => Uint8Array.of(...op("floats::parses"), 0, ...new TextEncoder().encode(text))); + +const floatsMulAdds = mulAdds(Number.MAX_VALUE, 5e-324, 2 ** -52, op("floats::mul_adds"), double); + +const [floatsAt, mulAddsAt] = [pick("floats::floats"), pick("floats::mul_adds")]; + +export function within(input: Uint8Array, native: Uint8Array, translated: Uint8Array): boolean { + const at = picked(input); + if (at === mulAddsAt) return mulAddsWithin(native, translated); + return at === floatsAt && input[2] % 10 === 7 && ulpsWithin(8, native, translated); +} + +export const cases: Uint8Array[] = [...floats, ...formats, ...parsed, ...floatsMulAdds]; diff --git a/ts/fixtures/lang/floats/expected/core/option.ts b/ts/fixtures/lang/floats/expected/core/option.ts new file mode 100644 index 000000000..e5dca53c1 --- /dev/null +++ b/ts/fixtures/lang/floats/expected/core/option.ts @@ -0,0 +1,33 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$1ayoj7n(self: rt.f64 | undefined, default_: rt.f64): rt.f64 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function mapOr$1e4a1e0(self: rt.Ordering | undefined, default_: rt.u8, f: (a0: rt.Ordering) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$15zxk73(self: rt.u8 | undefined, default_: rt.u64, f: (a0: rt.u8) => rt.u64): rt.u64 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/expected/floats.Gauge.ts b/ts/fixtures/lang/floats/expected/floats.Gauge.ts similarity index 100% rename from ts/fixtures/lang/expected/floats.Gauge.ts rename to ts/fixtures/lang/floats/expected/floats.Gauge.ts diff --git a/ts/fixtures/lang/expected/floats.Reading.ts b/ts/fixtures/lang/floats/expected/floats.Reading.ts similarity index 100% rename from ts/fixtures/lang/expected/floats.Reading.ts rename to ts/fixtures/lang/floats/expected/floats.Reading.ts diff --git a/ts/fixtures/lang/expected/floats.ts b/ts/fixtures/lang/floats/expected/floats.ts similarity index 88% rename from ts/fixtures/lang/expected/floats.ts rename to ts/fixtures/lang/floats/expected/floats.ts index e1411a2db..3cddea903 100644 --- a/ts/fixtures/lang/expected/floats.ts +++ b/ts/fixtures/lang/floats/expected/floats.ts @@ -2,9 +2,9 @@ import * as rt from "./rt.ts"; import { unwrapOr$1ayoj7n as option_unwrapOr$1ayoj7n, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, mapOr$1e4a1e0 as option_mapOr$1e4a1e0, mapOr$15zxk73 as option_mapOr$15zxk73 } from "./core/option.ts"; -import * as floats_Gauge from "./floats.Gauge.ts"; -import * as floats_Reading from "./floats.Reading.ts"; -import { put as fmt_put } from "./fmt.ts"; +import * as Gauge from "./floats.Gauge.ts"; +import * as Reading from "./floats.Reading.ts"; +import { put } from "./harness.ts"; /** An `f64` from the front of `data`, its bits big-endian and zero-padded. */ export function take(data: rt.ByteSlice): [rt.f64, rt.ByteSlice] { @@ -43,7 +43,7 @@ export function putSecs(out: rt.ByteVec, d: rt.Result rt.fmtTryFromFloatSecsErrorDisplay(e, f), (f: rt.Formatter) => rt.fmtTryFromFloatSecsErrorDebug(e, f)]; - fmt_put(out, rt.fmtFormat([args2[0], "|", args2[1], "|", rt.fmtSpec({ alternate: true }, args2[1])])); + put(out, rt.fmtFormat([args2[0], "|", args2[1], "|", rt.fmtSpec({ alternate: true }, args2[1])])); } } @@ -249,7 +249,7 @@ export function floats(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { putF64(out, rt.iterSum(rt.iterSlice(_403), rt.f64Add, -0.0)); putF64(out, rt.iterSum(rt.iterSlice([-0.0, -0.0]), rt.f64Add, -0.0)); putF64(out, 0.0); - const g: floats_Gauge.Gauge = { level: a, peak: b }; + const g: Gauge.Gauge = { level: a, peak: b }; raise(rt.place(() => g.level, (value) => g.level = value), b); if (g.peak !== undefined) { const _417: rt.f64 = rt.f64Max(g.peak, g.level); @@ -257,8 +257,8 @@ export function floats(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } putF64(out, g.level); putF64(out, option_unwrapOr$1ayoj7n(g.peak, -1.0)); - const _430: floats_Gauge.Gauge = floats_Gauge.default$Default(); - rt.byteVecPush(out, floats_Gauge.eq$cmp_PartialEq(g, _430) ? 1 : 0); + const _430: Gauge.Gauge = Gauge.default$Default(); + rt.byteVecPush(out, Gauge.eq$cmp_PartialEq(g, _430) ? 1 : 0); rt.byteVecPush(out, g.peak === b ? 1 : 0); let local: rt.f64 = a; raise(rt.place(() => local, (value2) => local = value2), 1.0); @@ -389,13 +389,13 @@ export function formats(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const _13: rt.u8 = rt.u8Rem(kind, 5); if (_13 === 0) { const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.f64Display(a, f), (f: rt.Formatter) => rt.f64Debug(a, f), (f: rt.Formatter) => rt.f64LowerExp(a, f), (f: rt.Formatter) => rt.f64UpperExp(a, f), rt.fmtCount(p)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[0]), " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[1]), " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[2]), " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[3]), " ", rt.fmtSpec({ plus: true }, args2[0]), " ", rt.fmtSpec({ plus: true }, args2[1]), " ", rt.fmtSpec({ plus: true, precision: rt.fmtCountOf(args2[4]) }, args2[2])])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[0]), " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[1]), " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[2]), " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[3]), " ", rt.fmtSpec({ plus: true }, args2[0]), " ", rt.fmtSpec({ plus: true }, args2[1]), " ", rt.fmtSpec({ plus: true, precision: rt.fmtCountOf(args2[4]) }, args2[2])])); const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.f64Display(a, f), (f: rt.Formatter) => rt.f64LowerExp(a, f), (f: rt.Formatter) => rt.f64Debug(a, f), (f: rt.Formatter) => rt.f64UpperExp(a, f), rt.fmtCount(w), rt.fmtCount(p)]; - fmt_put(out, rt.fmtFormat([rt.fmtSpec({ zero: true, width: 8, precision: 3 }, args4[0]), "|", rt.fmtSpec({ plus: true, zero: true, width: 12 }, args4[1]), "|", rt.fmtSpec({ align: "<", width: 9 }, args4[0]), "|", rt.fmtSpec({ align: "^", width: 12 }, args4[2]), "|", rt.fmtSpec({ fill: "*", align: ">", width: 10, precision: 1 }, args4[0]), "|", rt.fmtSpec({ alternate: true }, args4[2]), "|", rt.fmtSpec({ debugHex: "x" }, args4[2]), "|", rt.fmtSpec({ fill: "-", align: "^", plus: true, width: 15, precision: 2 }, args4[3]), "|", rt.fmtSpec({ zero: true, width: 10 }, args4[0]), "|", rt.fmtSpec({ plus: true, zero: true, width: 10 }, args4[2]), "|", rt.fmtSpec({ align: ">", width: rt.fmtCountOf(args4[4]), precision: rt.fmtCountOf(args4[5]) }, args4[0]), "|", rt.fmtSpec({ fill: "é", align: "<", width: rt.fmtCountOf(args4[4]) }, args4[2])])); - fmt_put(out, rt.fmtToString((f: rt.Formatter) => rt.f64Display(a, f))); + put(out, rt.fmtFormat([rt.fmtSpec({ zero: true, width: 8, precision: 3 }, args4[0]), "|", rt.fmtSpec({ plus: true, zero: true, width: 12 }, args4[1]), "|", rt.fmtSpec({ align: "<", width: 9 }, args4[0]), "|", rt.fmtSpec({ align: "^", width: 12 }, args4[2]), "|", rt.fmtSpec({ fill: "*", align: ">", width: 10, precision: 1 }, args4[0]), "|", rt.fmtSpec({ alternate: true }, args4[2]), "|", rt.fmtSpec({ debugHex: "x" }, args4[2]), "|", rt.fmtSpec({ fill: "-", align: "^", plus: true, width: 15, precision: 2 }, args4[3]), "|", rt.fmtSpec({ zero: true, width: 10 }, args4[0]), "|", rt.fmtSpec({ plus: true, zero: true, width: 10 }, args4[2]), "|", rt.fmtSpec({ align: ">", width: rt.fmtCountOf(args4[4]), precision: rt.fmtCountOf(args4[5]) }, args4[0]), "|", rt.fmtSpec({ fill: "é", align: "<", width: rt.fmtCountOf(args4[4]) }, args4[2])])); + put(out, rt.fmtToString((f: rt.Formatter) => rt.f64Display(a, f))); } else if (_13 === 1) { const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.f64Display(a, f), (f: rt.Formatter) => rt.f64LowerExp(a, f), (f: rt.Formatter) => rt.f64Debug(a, f)]; - fmt_put(out, rt.fmtFormat([rt.fmtSpec({ precision: 1100 }, args6[0]), " ", rt.fmtSpec({ precision: 800 }, args6[1]), " ", rt.fmtSpec({ precision: 1100 }, args6[2]), " ", rt.fmtSpec({ precision: 65535 }, args6[0])])); + put(out, rt.fmtFormat([rt.fmtSpec({ precision: 1100 }, args6[0]), " ", rt.fmtSpec({ precision: 800 }, args6[1]), " ", rt.fmtSpec({ precision: 1100 }, args6[2]), " ", rt.fmtSpec({ precision: 65535 }, args6[0])])); } else if (_13 === 2) { const _72: [rt.f64, rt.ByteSlice] = take(_6[1]); const b: rt.f64 = _72[0]; @@ -405,8 +405,8 @@ export function formats(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const _78: rt.f64 | undefined = a * 0.5; const _80: rt.f64[] = [a, -0.0, 1e-7, 1e16, NaN]; const part = { level: a, peak: _78, history: _80 }; - const args8: rt.Fmt[] = [(f: rt.Formatter) => floats_Reading.fmt$fmt_Debug(part, f)]; - fmt_put(out, rt.fmtFormat([args8[0], "|", rt.fmtSpec({ alternate: true }, args8[0]), "|", rt.fmtSpec({ precision: 2 }, args8[0]), "|", rt.fmtSpec({ plus: true, zero: true, width: 12 }, args8[0])])); + const args8: rt.Fmt[] = [(f: rt.Formatter) => Reading.fmt$fmt_Debug(part, f)]; + put(out, rt.fmtFormat([args8[0], "|", rt.fmtSpec({ alternate: true }, args8[0]), "|", rt.fmtSpec({ precision: 2 }, args8[0]), "|", rt.fmtSpec({ plus: true, zero: true, width: 12 }, args8[0])])); } else { let state: rt.u64 = rt.u64Or(takeBits(data)[0], 1); let iterStart: rt.i32 = 0; @@ -414,7 +414,7 @@ export function formats(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void while (iterStart++ < iterEnd) { const x: rt.f64 = rt.f64FromBits(step(rt.place(() => state, (value) => state = value))); const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.f64Display(x, f), (f: rt.Formatter) => rt.f64Debug(x, f), (f: rt.Formatter) => rt.f64LowerExp(x, f)]; - fmt_put(out, rt.fmtFormat([args10[0], " ", args10[1], " ", args10[2]])); + put(out, rt.fmtFormat([args10[0], " ", args10[1], " ", args10[2]])); } let iterStart2: rt.i32 = 0; const iterEnd2: rt.i32 = 64; @@ -425,7 +425,7 @@ export function formats(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const r2: rt.u64 = step(rt.place(() => state, (value2) => state = value2)); const x2: rt.f64 = rt.u64ToF64(rt.u64Shr(r2, 11)) / rt.u64ToF64(rt.u64Shl(1, rt.u64Add(rt.u64Rem(r2, 24), 1))); const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.f64Debug(x2, f), (f: rt.Formatter) => rt.f64LowerExp(x2, f)]; - fmt_put(out, rt.fmtFormat([args12[0], " ", args12[1]])); + put(out, rt.fmtFormat([args12[0], " ", args12[1]])); } } } @@ -489,11 +489,11 @@ export function one(s: string, out: rt.ByteVec): void { const v: rt.f64 = _4.value; putF64(out, v); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.f64Debug(v, f)]; - fmt_put(out, rt.fmtFormat([args2[0]])); + put(out, rt.fmtFormat([args2[0]])); } else { const e: rt.ParseFloatError = _4.error; const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseFloatErrorDisplay(e, f), (f: rt.Formatter) => rt.fmtParseFloatErrorDebug(e, f)]; - fmt_put(out, rt.fmtFormat([args4[0], "|", args4[1], "|", rt.fmtSpec({ alternate: true }, args4[1]), "|", rt.fmtSpec({ align: ">", width: 30 }, args4[0]), "|", rt.fmtSpec({ precision: 7 }, args4[0])])); + put(out, rt.fmtFormat([args4[0], "|", args4[1], "|", rt.fmtSpec({ alternate: true }, args4[1]), "|", rt.fmtSpec({ align: ">", width: 30 }, args4[0]), "|", rt.fmtSpec({ precision: 7 }, args4[0])])); } rt.byteVecPush(out, rt.f64FromStr(s).ok ? 1 : 0); } diff --git a/ts/fixtures/lang/floats/expected/harness.ts b/ts/fixtures/lang/floats/expected/harness.ts new file mode 100644 index 000000000..3b7bbcfb0 --- /dev/null +++ b/ts/fixtures/lang/floats/expected/harness.ts @@ -0,0 +1,46 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/floats/expected/lib.ts b/ts/fixtures/lang/floats/expected/lib.ts new file mode 100644 index 000000000..abad13a31 --- /dev/null +++ b/ts/fixtures/lang/floats/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { floats, mulAdds, formats, parses } from "./floats.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["floats::floats", floats as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["floats::formats", formats as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["floats::parses", parses as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["floats::mul_adds", mulAdds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/fma.ts b/ts/fixtures/lang/floats/fma.ts similarity index 97% rename from ts/fixtures/lang/fma.ts rename to ts/fixtures/lang/floats/fma.ts index ab510650e..ea495dd8d 100644 --- a/ts/fixtures/lang/fma.ts +++ b/ts/fixtures/lang/floats/fma.ts @@ -1,4 +1,4 @@ -// The one difference from native Rust that the lang fixture accepts in `floats::mul_adds`: +// The one difference from native Rust that the `floats` fixture accepts in `floats::mul_adds`: // wasm32's `fma`, compiler-builtins' generic libm, rounds some near-ties a last place off // (rust-lang/compiler-builtins#1353, fixed by #1358). `/quest/m3/ts-fma-allowance.md` // removes this once the toolchain ships the fix. diff --git a/ts/fixtures/lang/src/floats.rs b/ts/fixtures/lang/floats/src/floats.rs similarity index 99% rename from ts/fixtures/lang/src/floats.rs rename to ts/fixtures/lang/floats/src/floats.rs index 0e2d2e056..d1fe88f99 100644 --- a/ts/fixtures/lang/src/floats.rs +++ b/ts/fixtures/lang/floats/src/floats.rs @@ -9,7 +9,7 @@ use std::f64::consts; use std::time::Duration; -use crate::fmt::put; +use crate::harness::put; /// An `f64` from the front of `data`, its bits big-endian and zero-padded. fn take(data: &[u8]) -> (f64, &[u8]) { diff --git a/ts/fixtures/lang/floats/src/lib.rs b/ts/fixtures/lang/floats/src/lib.rs new file mode 100644 index 000000000..5a9f789d1 --- /dev/null +++ b/ts/fixtures/lang/floats/src/lib.rs @@ -0,0 +1,24 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod floats; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("floats::floats", floats::floats), + ("floats::formats", floats::formats), + ("floats::parses", floats::parses), + ("floats::mul_adds", floats::mul_adds), + ] +} diff --git a/ts/fixtures/lang/floats/ts.toml b/ts/fixtures/lang/floats/ts.toml new file mode 100644 index 000000000..0632fa862 --- /dev/null +++ b/ts/fixtures/lang/floats/ts.toml @@ -0,0 +1,2 @@ +package = "lang-floats-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/folds/Cargo.toml b/ts/fixtures/lang/folds/Cargo.toml new file mode 100644 index 000000000..e2d4d5398 --- /dev/null +++ b/ts/fixtures/lang/folds/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-folds-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/folds/expected/core/bool.ts b/ts/fixtures/lang/folds/expected/core/bool.ts new file mode 100644 index 000000000..34b3adb7e --- /dev/null +++ b/ts/fixtures/lang/folds/expected/core/bool.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0tjggir(self: boolean, t: rt.i64): rt.i64 | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function thenSome$0d5am30(self: boolean, t: rt.u8): rt.u8 | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/folds/expected/core/option.ts b/ts/fixtures/lang/folds/expected/core/option.ts new file mode 100644 index 000000000..9fcc4e708 --- /dev/null +++ b/ts/fixtures/lang/folds/expected/core/option.ts @@ -0,0 +1,26 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$1mp7tga(self: rt.i64[] | undefined, f: (a0: rt.i64[]) => rt.usize): rt.usize | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$1c7fhtg(self: rt.ByteVec | undefined, f: (a0: rt.ByteVec) => rt.usize): rt.usize | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/folds/expected/core/result.ts b/ts/fixtures/lang/folds/expected/core/result.ts new file mode 100644 index 000000000..e22912f23 --- /dev/null +++ b/ts/fixtures/lang/folds/expected/core/result.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function map$0d4vpmj(self: rt.Result, op: (a0: rt.i64[]) => rt.usize): rt.Result { + if (self.ok) { + return rt.Ok(op(self.value)); + } + return rt.ERR; +} + +export function map$1w3j91w(self: rt.Result, op: (a0: rt.ByteVec) => rt.usize): rt.Result { + if (self.ok) { + return rt.Ok(op(self.value)); + } + return rt.ERR; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/expected/folds.ts b/ts/fixtures/lang/folds/expected/folds.ts similarity index 96% rename from ts/fixtures/lang/expected/folds.ts rename to ts/fixtures/lang/folds/expected/folds.ts index 5e4508ff9..d3b54b94f 100644 --- a/ts/fixtures/lang/expected/folds.ts +++ b/ts/fixtures/lang/folds/expected/folds.ts @@ -4,7 +4,7 @@ import * as rt from "./rt.ts"; import { thenSome$0tjggir, thenSome$0d5am30 } from "./core/bool.ts"; import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$1mp7tga as option_map$1mp7tga, map$1c7fhtg as option_map$1c7fhtg } from "./core/option.ts"; import { map$0d4vpmj as result_map$0d4vpmj, map$1w3j91w as result_map$1w3j91w } from "./core/result.ts"; -import { put as fmt_put } from "./fmt.ts"; +import { put } from "./harness.ts"; /** `r`'s state after `v`, what read it returned. */ export function state$i64_Option_i64(out: rt.ByteVec, v: rt.i64 | undefined, r: rt.RangeInclusive): void { @@ -12,7 +12,7 @@ export function state$i64_Option_i64(out: rt.ByteVec, v: rt.i64 | undefined, r: const _14: rt.i64 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(v, f, rt.i64Debug), (f: rt.Formatter) => rt.i64Debug(_12, f), (f: rt.Formatter) => rt.i64Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.i64Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -21,7 +21,7 @@ export function state$i64_Option_tuple2_i64_usize(out: rt.ByteVec, v: [rt.i64, r const _14: rt.i64 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(v, f, (value: [rt.i64, rt.usize], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.i64Debug(value[0], f), (f: rt.Formatter) => rt.usizeDebug(value[1], f)], f)), (f: rt.Formatter) => rt.i64Debug(_12, f), (f: rt.Formatter) => rt.i64Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.i64Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -30,7 +30,7 @@ export function state$i64_Option_tuple2_usize_i64(out: rt.ByteVec, v: [rt.usize, const _14: rt.i64 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(v, f, (value: [rt.usize, rt.i64], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(value[0], f), (f: rt.Formatter) => rt.i64Debug(value[1], f)], f)), (f: rt.Formatter) => rt.i64Debug(_12, f), (f: rt.Formatter) => rt.i64Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.i64Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -39,7 +39,7 @@ export function state$i64_Option_usize(out: rt.ByteVec, v: rt.usize | undefined, const _14: rt.i64 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(v, f, rt.usizeDebug), (f: rt.Formatter) => rt.i64Debug(_12, f), (f: rt.Formatter) => rt.i64Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.i64Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -48,7 +48,7 @@ export function state$i64_Result_usize_unit(out: rt.ByteVec, v: rt.Result rt.fmtResult(v, f, rt.usizeDebug, rt.fmtUnit), (f: rt.Formatter) => rt.i64Debug(_12, f), (f: rt.Formatter) => rt.i64Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.i64Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -57,7 +57,7 @@ export function state$i64_bool(out: rt.ByteVec, v: boolean, r: rt.RangeInclusive const _14: rt.i64 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(v, f), (f: rt.Formatter) => rt.i64Debug(_12, f), (f: rt.Formatter) => rt.i64Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.i64Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -66,7 +66,7 @@ export function state$i64_tuple2_Option_i64_Option_i64(out: rt.ByteVec, v: [rt.i const _14: rt.i64 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(v[0], f, rt.i64Debug), (f: rt.Formatter) => rt.fmtOption(v[1], f, rt.i64Debug)], f), (f: rt.Formatter) => rt.i64Debug(_12, f), (f: rt.Formatter) => rt.i64Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.i64Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -75,7 +75,7 @@ export function state$i64_tuple2_Option_i64_Option_usize(out: rt.ByteVec, v: [rt const _14: rt.i64 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(v[0], f, rt.i64Debug), (f: rt.Formatter) => rt.fmtOption(v[1], f, rt.usizeDebug)], f), (f: rt.Formatter) => rt.i64Debug(_12, f), (f: rt.Formatter) => rt.i64Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.i64Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -84,7 +84,7 @@ export function state$i64_tuple2_Option_i64_usize(out: rt.ByteVec, v: [rt.i64 | const _14: rt.i64 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(v[0], f, rt.i64Debug), (f: rt.Formatter) => rt.usizeDebug(v[1], f)], f), (f: rt.Formatter) => rt.i64Debug(_12, f), (f: rt.Formatter) => rt.i64Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.i64Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -93,7 +93,7 @@ export function state$i64_unit(out: rt.ByteVec, _: undefined, r: rt.RangeInclusi const _14: rt.i64 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtUnit(undefined, f), (f: rt.Formatter) => rt.i64Debug(_12, f), (f: rt.Formatter) => rt.i64Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.i64Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -102,7 +102,7 @@ export function state$i64_usize(out: rt.ByteVec, v: rt.usize, r: rt.RangeInclusi const _14: rt.i64 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDebug(v, f), (f: rt.Formatter) => rt.i64Debug(_12, f), (f: rt.Formatter) => rt.i64Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.i64Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -111,7 +111,7 @@ export function state$u8_Option_tuple2_u8_usize(out: rt.ByteVec, v: [rt.u8, rt.u const _14: rt.u8 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(v, f, (value: [rt.u8, rt.usize], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(value[0], f), (f: rt.Formatter) => rt.usizeDebug(value[1], f)], f)), (f: rt.Formatter) => rt.u8Debug(_12, f), (f: rt.Formatter) => rt.u8Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -120,7 +120,7 @@ export function state$u8_Option_tuple2_usize_u8(out: rt.ByteVec, v: [rt.usize, r const _14: rt.u8 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(v, f, (value: [rt.usize, rt.u8], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(value[0], f), (f: rt.Formatter) => rt.u8Debug(value[1], f)], f)), (f: rt.Formatter) => rt.u8Debug(_12, f), (f: rt.Formatter) => rt.u8Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -129,7 +129,7 @@ export function state$u8_Option_u8(out: rt.ByteVec, v: rt.u8 | undefined, r: rt. const _14: rt.u8 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(v, f, rt.u8Debug), (f: rt.Formatter) => rt.u8Debug(_12, f), (f: rt.Formatter) => rt.u8Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -138,7 +138,7 @@ export function state$u8_Option_usize(out: rt.ByteVec, v: rt.usize | undefined, const _14: rt.u8 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(v, f, rt.usizeDebug), (f: rt.Formatter) => rt.u8Debug(_12, f), (f: rt.Formatter) => rt.u8Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -147,7 +147,7 @@ export function state$u8_Result_usize_unit(out: rt.ByteVec, v: rt.Result rt.fmtResult(v, f, rt.usizeDebug, rt.fmtUnit), (f: rt.Formatter) => rt.u8Debug(_12, f), (f: rt.Formatter) => rt.u8Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -156,7 +156,7 @@ export function state$u8_bool(out: rt.ByteVec, v: boolean, r: rt.RangeInclusive< const _14: rt.u8 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(v, f), (f: rt.Formatter) => rt.u8Debug(_12, f), (f: rt.Formatter) => rt.u8Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -165,7 +165,7 @@ export function state$u8_tuple2_Option_u8_Option_u8(out: rt.ByteVec, v: [rt.u8 | const _14: rt.u8 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(v[0], f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(v[1], f, rt.u8Debug)], f), (f: rt.Formatter) => rt.u8Debug(_12, f), (f: rt.Formatter) => rt.u8Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -174,7 +174,7 @@ export function state$u8_tuple2_Option_u8_Option_usize(out: rt.ByteVec, v: [rt.u const _14: rt.u8 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(v[0], f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(v[1], f, rt.usizeDebug)], f), (f: rt.Formatter) => rt.u8Debug(_12, f), (f: rt.Formatter) => rt.u8Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -183,7 +183,7 @@ export function state$u8_tuple2_Option_u8_usize(out: rt.ByteVec, v: [rt.u8 | und const _14: rt.u8 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(v[0], f, rt.u8Debug), (f: rt.Formatter) => rt.usizeDebug(v[1], f)], f), (f: rt.Formatter) => rt.u8Debug(_12, f), (f: rt.Formatter) => rt.u8Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -192,7 +192,7 @@ export function state$u8_unit(out: rt.ByteVec, _: undefined, r: rt.RangeInclusiv const _14: rt.u8 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtUnit(undefined, f), (f: rt.Formatter) => rt.u8Debug(_12, f), (f: rt.Formatter) => rt.u8Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** `r`'s state after `v`, what read it returned. */ @@ -201,7 +201,7 @@ export function state$u8_usize(out: rt.ByteVec, v: rt.usize, r: rt.RangeInclusiv const _14: rt.u8 = rt.rangeInclusiveEnd(r); const _16: boolean = rt.rangeInclusiveIsEmpty(r); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDebug(v, f), (f: rt.Formatter) => rt.u8Debug(_12, f), (f: rt.Formatter) => rt.u8Debug(_14, f), (f: rt.Formatter) => rt.fmtBool(_16, f), (f: rt.Formatter) => rt.fmtRangeInclusive(r, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4]])); } /** diff --git a/ts/fixtures/lang/folds/expected/harness.ts b/ts/fixtures/lang/folds/expected/harness.ts new file mode 100644 index 000000000..3b7bbcfb0 --- /dev/null +++ b/ts/fixtures/lang/folds/expected/harness.ts @@ -0,0 +1,46 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/folds/expected/lib.ts b/ts/fixtures/lang/folds/expected/lib.ts new file mode 100644 index 000000000..8cbed1164 --- /dev/null +++ b/ts/fixtures/lang/folds/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { folds } from "./folds.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["folds::folds", folds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/folds.rs b/ts/fixtures/lang/folds/src/folds.rs similarity index 99% rename from ts/fixtures/lang/src/folds.rs rename to ts/fixtures/lang/folds/src/folds.rs index 74636cadf..07039db91 100644 --- a/ts/fixtures/lang/src/folds.rs +++ b/ts/fixtures/lang/folds/src/folds.rs @@ -7,7 +7,7 @@ use std::fmt::Debug; use std::ops::RangeInclusive; -use crate::fmt::put; +use crate::harness::put; /// `r`'s state after `v`, what read it returned. fn state(out: &mut Vec, v: impl Debug, r: &RangeInclusive) { diff --git a/ts/fixtures/lang/folds/src/lib.rs b/ts/fixtures/lang/folds/src/lib.rs new file mode 100644 index 000000000..1090b0f1a --- /dev/null +++ b/ts/fixtures/lang/folds/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod folds; +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("folds::folds", folds::folds)] +} diff --git a/ts/fixtures/lang/folds/ts.toml b/ts/fixtures/lang/folds/ts.toml new file mode 100644 index 000000000..153ce8f98 --- /dev/null +++ b/ts/fixtures/lang/folds/ts.toml @@ -0,0 +1,2 @@ +package = "lang-folds-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/harness.rs b/ts/fixtures/lang/harness.rs new file mode 100644 index 000000000..c554e9a2f --- /dev/null +++ b/ts/fixtures/lang/harness.rs @@ -0,0 +1,65 @@ +//! The entry point both sides of a fixture's differential test run, and what its cases +//! share. The first two bytes pick one of the crate's `cases` and the rest is its input. + +/// What a case runs on the third byte and the rest. +pub type Case = fn(u8, &[u8], &mut Vec); + +/// Run one case. +pub fn run(input: &[u8]) -> Vec { + let mut out = Vec::new(); + let [high, low, kind, data @ ..] = input else { + return out; + }; + let cases = crate::cases(); + let (_, case) = cases[usize::from(u16::from_be_bytes([*high, *low])) % cases.len()]; + case(*kind, data, &mut out); + out +} + +/// The first two bytes, as one big-endian number, that pick the case named `name`, which +/// `lang.ts` targets by. +pub fn op(name: &str) -> u16 { + let Some(i) = crate::cases().iter().position(|&(n, _)| n == name) else { + panic!("no case {name}"); + }; + // A first byte of 0xff is left to the crate's `entry`, as `shapes` prints a `Fault`. + match u16::try_from(i) { + Ok(op) if op >> 8 != 0xff => op, + _ => panic!("case {name} is past what two bytes pick"), + } +} + +/// Write `s` and the byte no UTF-8 holds, which ends it. +pub fn put(out: &mut Vec, s: &str) { + out.extend_from_slice(s.as_bytes()); + out.push(0xff); +} + +/// Separators, digits, and chars where a UTF-8 or UTF-16 length changes. +pub const ALPHABET: [char; 16] = [ + '/', + '\\', + 'a', + '0', + '9', + '\u{7f}', + '\u{80}', + 'é', + '\u{7ff}', + '\u{800}', + '\u{d7ff}', + '\u{e000}', + '\u{ffff}', + '\u{10000}', + '😀', + '\u{10ffff}', +]; + +/// A char of the alphabet for each byte, by its low bits. +pub fn text(data: &[u8]) -> String { + let mut s = String::new(); + for &b in data { + s.push(ALPHABET[(b % 16) as usize]); + } + s +} diff --git a/ts/fixtures/lang/hashes/Cargo.toml b/ts/fixtures/lang/hashes/Cargo.toml new file mode 100644 index 000000000..ce1996a80 --- /dev/null +++ b/ts/fixtures/lang/hashes/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-hashes-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/hashes/expected/core/bool.ts b/ts/fixtures/lang/hashes/expected/core/bool.ts new file mode 100644 index 000000000..5207f04fe --- /dev/null +++ b/ts/fixtures/lang/hashes/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0n2gkz4(self: boolean, t: rt.i32): rt.i32 | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/hashes/expected/core/option.ts b/ts/fixtures/lang/hashes/expected/core/option.ts new file mode 100644 index 000000000..a1a70d4eb --- /dev/null +++ b/ts/fixtures/lang/hashes/expected/core/option.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0k15iai(self: rt.char | undefined, default_: rt.char): rt.char { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/hashes/expected/core/result.ts b/ts/fixtures/lang/hashes/expected/core/result.ts new file mode 100644 index 000000000..9f3171569 --- /dev/null +++ b/ts/fixtures/lang/hashes/expected/core/result.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$01jdcm7(self: rt.Result, default_: string): string { + if (self.ok) { + return self.value; + } + return default_; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/hashes/expected/harness.ts b/ts/fixtures/lang/hashes/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/hashes/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/expected/hashes.Bare.ts b/ts/fixtures/lang/hashes/expected/hashes.Bare.ts similarity index 100% rename from ts/fixtures/lang/expected/hashes.Bare.ts rename to ts/fixtures/lang/hashes/expected/hashes.Bare.ts diff --git a/ts/fixtures/lang/expected/hashes.Build.ts b/ts/fixtures/lang/hashes/expected/hashes.Build.ts similarity index 100% rename from ts/fixtures/lang/expected/hashes.Build.ts rename to ts/fixtures/lang/hashes/expected/hashes.Build.ts diff --git a/ts/fixtures/lang/expected/hashes.Counted.ts b/ts/fixtures/lang/hashes/expected/hashes.Counted.ts similarity index 100% rename from ts/fixtures/lang/expected/hashes.Counted.ts rename to ts/fixtures/lang/hashes/expected/hashes.Counted.ts diff --git a/ts/fixtures/lang/expected/hashes.Dir.ts b/ts/fixtures/lang/hashes/expected/hashes.Dir.ts similarity index 66% rename from ts/fixtures/lang/expected/hashes.Dir.ts rename to ts/fixtures/lang/hashes/expected/hashes.Dir.ts index 8d3f460dd..8b3cb2d20 100644 --- a/ts/fixtures/lang/expected/hashes.Dir.ts +++ b/ts/fixtures/lang/hashes/expected/hashes.Dir.ts @@ -1,24 +1,24 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import * as hashes_Bare from "./hashes.Bare.ts"; +import * as Bare from "./hashes.Bare.ts"; import * as Full from "./hashes.Full.ts"; -import * as hashes_Partial from "./hashes.Partial.ts"; +import * as Partial from "./hashes.Partial.ts"; export function hash$Hash_hash_DefaultHasher(self: Dir, state: rt.Hasher): void { rt.hashIsize({ Up: 0, Down: 1 }[self], state); } -export function hash$Hash_hashes_Bare(self: Dir, state: hashes_Bare.Bare): void { - rt.hashIsize({ Up: 0, Down: 1 }[self], new rt.OwnHasher(state, hashes_Bare.hasher$hash_Hasher)); +export function hash$Hash_hashes_Bare(self: Dir, state: Bare.Bare): void { + rt.hashIsize({ Up: 0, Down: 1 }[self], new rt.OwnHasher(state, Bare.hasher$hash_Hasher)); } export function hash$Hash_hashes_Full(self: Dir, state: Full.Full): void { rt.hashIsize({ Up: 0, Down: 1 }[self], new rt.OwnHasher(state, Full.hasher$hash_Hasher)); } -export function hash$Hash_hashes_Partial(self: Dir, state: hashes_Partial.Partial): void { - rt.hashIsize({ Up: 0, Down: 1 }[self], new rt.OwnHasher(state, hashes_Partial.hasher$hash_Hasher)); +export function hash$Hash_hashes_Partial(self: Dir, state: Partial.Partial): void { + rt.hashIsize({ Up: 0, Down: 1 }[self], new rt.OwnHasher(state, Partial.hasher$hash_Hasher)); } /** A fieldless enum, which is a JS string, hashed by its `isize` discriminant. */ diff --git a/ts/fixtures/lang/expected/hashes.Full.ts b/ts/fixtures/lang/hashes/expected/hashes.Full.ts similarity index 100% rename from ts/fixtures/lang/expected/hashes.Full.ts rename to ts/fixtures/lang/hashes/expected/hashes.Full.ts diff --git a/ts/fixtures/lang/expected/hashes.Logged.ts b/ts/fixtures/lang/hashes/expected/hashes.Logged.ts similarity index 100% rename from ts/fixtures/lang/expected/hashes.Logged.ts rename to ts/fixtures/lang/hashes/expected/hashes.Logged.ts diff --git a/ts/fixtures/lang/expected/hashes.Nibble.ts b/ts/fixtures/lang/hashes/expected/hashes.Nibble.ts similarity index 54% rename from ts/fixtures/lang/expected/hashes.Nibble.ts rename to ts/fixtures/lang/hashes/expected/hashes.Nibble.ts index 3576fa6e8..6b241653f 100644 --- a/ts/fixtures/lang/expected/hashes.Nibble.ts +++ b/ts/fixtures/lang/hashes/expected/hashes.Nibble.ts @@ -1,9 +1,9 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import * as hashes_Bare from "./hashes.Bare.ts"; +import * as Bare from "./hashes.Bare.ts"; import * as Full from "./hashes.Full.ts"; -import * as hashes_Partial from "./hashes.Partial.ts"; +import * as Partial from "./hashes.Partial.ts"; /** A key whose `Hash` sees only its low nibble. */ export interface Nibble { @@ -14,16 +14,16 @@ export function hash$Hash_hash_DefaultHasher(self: Nibble, state: rt.Hasher): vo rt.hash8(self._0 & 15, state); } -export function hash$Hash_hashes_Bare(self: Nibble, state: hashes_Bare.Bare): void { - rt.hash8(self._0 & 15, new rt.OwnHasher(state, hashes_Bare.hasher$hash_Hasher)); +export function hash$Hash_hashes_Bare(self: Nibble, state: Bare.Bare): void { + rt.hash8(self._0 & 15, new rt.OwnHasher(state, Bare.hasher$hash_Hasher)); } export function hash$Hash_hashes_Full(self: Nibble, state: Full.Full): void { rt.hash8(self._0 & 15, new rt.OwnHasher(state, Full.hasher$hash_Hasher)); } -export function hash$Hash_hashes_Partial(self: Nibble, state: hashes_Partial.Partial): void { - rt.hash8(self._0 & 15, new rt.OwnHasher(state, hashes_Partial.hasher$hash_Hasher)); +export function hash$Hash_hashes_Partial(self: Nibble, state: Partial.Partial): void { + rt.hash8(self._0 & 15, new rt.OwnHasher(state, Partial.hasher$hash_Hasher)); } //# sourceMappingURL=hashes.Nibble.ts.map diff --git a/ts/fixtures/lang/hashes/expected/hashes.Packet.ts b/ts/fixtures/lang/hashes/expected/hashes.Packet.ts new file mode 100644 index 000000000..4df3a738e --- /dev/null +++ b/ts/fixtures/lang/hashes/expected/hashes.Packet.ts @@ -0,0 +1,48 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import * as Bare from "./hashes.Bare.ts"; +import * as Full from "./hashes.Full.ts"; +import * as Partial from "./hashes.Partial.ts"; + +export function hash$Hash_hash_DefaultHasher(self: Packet, state: rt.Hasher): void { + rt.hash64(self.id, state); + rt.hash8(self.flags, state); + rt.hashStr(self.name, state); + rt.hashInts(2)(self.tags, state); + rt.hashOption(rt.hashI32)(self.next, state); +} + +export function hash$Hash_hashes_Bare(self: Packet, state: Bare.Bare): void { + rt.hash64(self.id, new rt.OwnHasher(state, Bare.hasher$hash_Hasher)); + rt.hash8(self.flags, new rt.OwnHasher(state, Bare.hasher$hash_Hasher)); + rt.hashStr(self.name, new rt.OwnHasher(state, Bare.hasher$hash_Hasher)); + rt.hashInts(2)(self.tags, new rt.OwnHasher(state, Bare.hasher$hash_Hasher)); + rt.hashOption(rt.hashI32)(self.next, new rt.OwnHasher(state, Bare.hasher$hash_Hasher)); +} + +export function hash$Hash_hashes_Full(self: Packet, state: Full.Full): void { + rt.hash64(self.id, new rt.OwnHasher(state, Full.hasher$hash_Hasher)); + rt.hash8(self.flags, new rt.OwnHasher(state, Full.hasher$hash_Hasher)); + rt.hashStr(self.name, new rt.OwnHasher(state, Full.hasher$hash_Hasher)); + rt.hashInts(2)(self.tags, new rt.OwnHasher(state, Full.hasher$hash_Hasher)); + rt.hashOption(rt.hashI32)(self.next, new rt.OwnHasher(state, Full.hasher$hash_Hasher)); +} + +export function hash$Hash_hashes_Partial(self: Packet, state: Partial.Partial): void { + rt.hash64(self.id, new rt.OwnHasher(state, Partial.hasher$hash_Hasher)); + rt.hash8(self.flags, new rt.OwnHasher(state, Partial.hasher$hash_Hasher)); + rt.hashStr(self.name, new rt.OwnHasher(state, Partial.hasher$hash_Hasher)); + rt.hashInts(2)(self.tags, new rt.OwnHasher(state, Partial.hasher$hash_Hasher)); + rt.hashOption(rt.hashI32)(self.next, new rt.OwnHasher(state, Partial.hasher$hash_Hasher)); +} + +export interface Packet { + id: rt.u64; + flags: rt.u8; + name: string; + tags: rt.u16[]; + next: rt.i32 | undefined; +} + +//# sourceMappingURL=hashes.Packet.ts.map diff --git a/ts/fixtures/lang/expected/hashes.Partial.ts b/ts/fixtures/lang/hashes/expected/hashes.Partial.ts similarity index 100% rename from ts/fixtures/lang/expected/hashes.Partial.ts rename to ts/fixtures/lang/hashes/expected/hashes.Partial.ts diff --git a/ts/fixtures/lang/expected/hashes.Priorities$random.ts b/ts/fixtures/lang/hashes/expected/hashes.Priorities$random.ts similarity index 100% rename from ts/fixtures/lang/expected/hashes.Priorities$random.ts rename to ts/fixtures/lang/hashes/expected/hashes.Priorities$random.ts diff --git a/ts/fixtures/lang/expected/hashes.Shape.ts b/ts/fixtures/lang/hashes/expected/hashes.Shape.ts similarity index 60% rename from ts/fixtures/lang/expected/hashes.Shape.ts rename to ts/fixtures/lang/hashes/expected/hashes.Shape.ts index 48365d84e..fd605850f 100644 --- a/ts/fixtures/lang/expected/hashes.Shape.ts +++ b/ts/fixtures/lang/hashes/expected/hashes.Shape.ts @@ -1,9 +1,9 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import * as hashes_Bare from "./hashes.Bare.ts"; +import * as Bare from "./hashes.Bare.ts"; import * as Full from "./hashes.Full.ts"; -import * as hashes_Partial from "./hashes.Partial.ts"; +import * as Partial from "./hashes.Partial.ts"; export function hash$Hash_hash_DefaultHasher(self: Shape, state: rt.Hasher): void { rt.hashIsize({ Dot: 0, Line: 1, Rect: 2 }[self.tag], state); @@ -15,13 +15,13 @@ export function hash$Hash_hash_DefaultHasher(self: Shape, state: rt.Hasher): voi } } -export function hash$Hash_hashes_Bare(self: Shape, state: hashes_Bare.Bare): void { - rt.hashIsize({ Dot: 0, Line: 1, Rect: 2 }[self.tag], new rt.OwnHasher(state, hashes_Bare.hasher$hash_Hasher)); +export function hash$Hash_hashes_Bare(self: Shape, state: Bare.Bare): void { + rt.hashIsize({ Dot: 0, Line: 1, Rect: 2 }[self.tag], new rt.OwnHasher(state, Bare.hasher$hash_Hasher)); if (self.tag === "Line") { - rt.hash32(self._0, new rt.OwnHasher(state, hashes_Bare.hasher$hash_Hasher)); + rt.hash32(self._0, new rt.OwnHasher(state, Bare.hasher$hash_Hasher)); } else if (self.tag === "Rect") { - rt.hashI16(self.w, new rt.OwnHasher(state, hashes_Bare.hasher$hash_Hasher)); - rt.hashI16(self.h, new rt.OwnHasher(state, hashes_Bare.hasher$hash_Hasher)); + rt.hashI16(self.w, new rt.OwnHasher(state, Bare.hasher$hash_Hasher)); + rt.hashI16(self.h, new rt.OwnHasher(state, Bare.hasher$hash_Hasher)); } } @@ -35,13 +35,13 @@ export function hash$Hash_hashes_Full(self: Shape, state: Full.Full): void { } } -export function hash$Hash_hashes_Partial(self: Shape, state: hashes_Partial.Partial): void { - rt.hashIsize({ Dot: 0, Line: 1, Rect: 2 }[self.tag], new rt.OwnHasher(state, hashes_Partial.hasher$hash_Hasher)); +export function hash$Hash_hashes_Partial(self: Shape, state: Partial.Partial): void { + rt.hashIsize({ Dot: 0, Line: 1, Rect: 2 }[self.tag], new rt.OwnHasher(state, Partial.hasher$hash_Hasher)); if (self.tag === "Line") { - rt.hash32(self._0, new rt.OwnHasher(state, hashes_Partial.hasher$hash_Hasher)); + rt.hash32(self._0, new rt.OwnHasher(state, Partial.hasher$hash_Hasher)); } else if (self.tag === "Rect") { - rt.hashI16(self.w, new rt.OwnHasher(state, hashes_Partial.hasher$hash_Hasher)); - rt.hashI16(self.h, new rt.OwnHasher(state, hashes_Partial.hasher$hash_Hasher)); + rt.hashI16(self.w, new rt.OwnHasher(state, Partial.hasher$hash_Hasher)); + rt.hashI16(self.h, new rt.OwnHasher(state, Partial.hasher$hash_Hasher)); } } diff --git a/ts/fixtures/lang/expected/hashes.Small.ts b/ts/fixtures/lang/hashes/expected/hashes.Small.ts similarity index 54% rename from ts/fixtures/lang/expected/hashes.Small.ts rename to ts/fixtures/lang/hashes/expected/hashes.Small.ts index ba5997340..91e9c056e 100644 --- a/ts/fixtures/lang/expected/hashes.Small.ts +++ b/ts/fixtures/lang/hashes/expected/hashes.Small.ts @@ -1,24 +1,24 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import * as hashes_Bare from "./hashes.Bare.ts"; +import * as Bare from "./hashes.Bare.ts"; import * as Full from "./hashes.Full.ts"; -import * as hashes_Partial from "./hashes.Partial.ts"; +import * as Partial from "./hashes.Partial.ts"; export function hash$Hash_hash_DefaultHasher(self: Small, state: rt.Hasher): void { rt.hash8({ Low: 3, High: 200 }[self], state); } -export function hash$Hash_hashes_Bare(self: Small, state: hashes_Bare.Bare): void { - rt.hash8({ Low: 3, High: 200 }[self], new rt.OwnHasher(state, hashes_Bare.hasher$hash_Hasher)); +export function hash$Hash_hashes_Bare(self: Small, state: Bare.Bare): void { + rt.hash8({ Low: 3, High: 200 }[self], new rt.OwnHasher(state, Bare.hasher$hash_Hasher)); } export function hash$Hash_hashes_Full(self: Small, state: Full.Full): void { rt.hash8({ Low: 3, High: 200 }[self], new rt.OwnHasher(state, Full.hasher$hash_Hasher)); } -export function hash$Hash_hashes_Partial(self: Small, state: hashes_Partial.Partial): void { - rt.hash8({ Low: 3, High: 200 }[self], new rt.OwnHasher(state, hashes_Partial.hasher$hash_Hasher)); +export function hash$Hash_hashes_Partial(self: Small, state: Partial.Partial): void { + rt.hash8({ Low: 3, High: 200 }[self], new rt.OwnHasher(state, Partial.hasher$hash_Hasher)); } /** A `u8` discriminant, which the derive writes as a byte. */ diff --git a/ts/fixtures/lang/expected/hashes.ts b/ts/fixtures/lang/hashes/expected/hashes.ts similarity index 78% rename from ts/fixtures/lang/expected/hashes.ts rename to ts/fixtures/lang/hashes/expected/hashes.ts index 75dfafc9a..fc39c83fc 100644 --- a/ts/fixtures/lang/expected/hashes.ts +++ b/ts/fixtures/lang/hashes/expected/hashes.ts @@ -1,21 +1,20 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { copy$array_u8 } from "./lib.ts"; import { thenSome$0n2gkz4 } from "./core/bool.ts"; import { unwrapOr$0k15iai as option_unwrapOr$0k15iai, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr } from "./core/option.ts"; import { unwrapOr$01jdcm7 as result_unwrapOr$01jdcm7 } from "./core/result.ts"; -import * as hashes_Bare from "./hashes.Bare.ts"; +import * as Bare from "./hashes.Bare.ts"; import * as Build from "./hashes.Build.ts"; -import * as hashes_Counted from "./hashes.Counted.ts"; -import * as hashes_Dir from "./hashes.Dir.ts"; +import * as Counted from "./hashes.Counted.ts"; +import * as Dir from "./hashes.Dir.ts"; import * as Full from "./hashes.Full.ts"; -import * as hashes_Logged from "./hashes.Logged.ts"; -import * as hashes_Nibble from "./hashes.Nibble.ts"; +import * as Logged from "./hashes.Logged.ts"; +import * as Nibble from "./hashes.Nibble.ts"; import * as Packet from "./hashes.Packet.ts"; -import * as hashes_Partial from "./hashes.Partial.ts"; +import * as Partial from "./hashes.Partial.ts"; import * as Priorities$random from "./hashes.Priorities$random.ts"; -import * as hashes_Shape from "./hashes.Shape.ts"; +import * as Shape from "./hashes.Shape.ts"; import * as Small from "./hashes.Small.ts"; /** `DefaultHasher::new`'s hash of `value`, little-endian. */ @@ -82,9 +81,9 @@ export function digest$array0_u8(value: rt.ByteSlice, out: rt.ByteVec): void { } /** `DefaultHasher::new`'s hash of `value`, little-endian. */ -export function digest$array2_hashes_Dir(value: hashes_Dir.Dir[], out: rt.ByteVec): void { +export function digest$array2_hashes_Dir(value: Dir.Dir[], out: rt.ByteVec): void { const h: rt.Hasher = rt.hasher(); - rt.hashSlice(hashes_Dir.hash$Hash_hash_DefaultHasher as (a0: hashes_Dir.Dir, a1: rt.Hasher) => undefined)(value, h); + rt.hashSlice(Dir.hash$Hash_hash_DefaultHasher as (a0: Dir.Dir, a1: rt.Hasher) => undefined)(value, h); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u64ToBeBytes(rt.hashFinish(h)).reverse())); } @@ -138,9 +137,9 @@ export function digest$cmp_Reverse_u16(value: rt.u16, out: rt.ByteVec): void { } /** `DefaultHasher::new`'s hash of `value`, little-endian. */ -export function digest$hashes_Nibble(value: hashes_Nibble.Nibble, out: rt.ByteVec): void { +export function digest$hashes_Nibble(value: Nibble.Nibble, out: rt.ByteVec): void { const h: rt.Hasher = rt.hasher(); - hashes_Nibble.hash$Hash_hash_DefaultHasher(value, h); + Nibble.hash$Hash_hash_DefaultHasher(value, h); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u64ToBeBytes(rt.hashFinish(h)).reverse())); } @@ -152,9 +151,9 @@ export function digest$hashes_Packet(value: Packet.Packet, out: rt.ByteVec): voi } /** `DefaultHasher::new`'s hash of `value`, little-endian. */ -export function digest$hashes_Shape(value: hashes_Shape.Shape, out: rt.ByteVec): void { +export function digest$hashes_Shape(value: Shape.Shape, out: rt.ByteVec): void { const h: rt.Hasher = rt.hasher(); - hashes_Shape.hash$Hash_hash_DefaultHasher(value, h); + Shape.hash$Hash_hash_DefaultHasher(value, h); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u64ToBeBytes(rt.hashFinish(h)).reverse())); } @@ -350,7 +349,7 @@ export function wide(data: rt.ByteSlice, at: rt.usize, n: rt.usize): rt.u128 { /** The hash of a value of each type `kind` picks, made of `data`. */ export function values(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { - let shape!: hashes_Shape.Shape; + let shape!: Shape.Shape; const w: (a0: rt.usize, a1: rt.usize) => rt.u128 = (at: rt.usize, n3: rt.usize): rt.u128 => { return wide(data, at, n3); }; @@ -408,14 +407,14 @@ export function values(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { }), undefined, 2, true), next: thenSome$0n2gkz4(rt.u64Rem(n2, 3) !== 0, rt.u64Low(n2) | 0) }, out); const _188: rt.u64 = rt.u64Rem(n2, 3); if (_188 === 0) { - shape = { tag: "Dot" } as hashes_Shape.Shape; + shape = { tag: "Dot" } as Shape.Shape; } else if (_188 === 1) { - shape = { tag: "Line", _0: rt.u64Low(n2) } as hashes_Shape.Shape; + shape = { tag: "Line", _0: rt.u64Low(n2) } as Shape.Shape; } else { - shape = { tag: "Rect", w: (rt.u64Low(n2) << 16) >> 16, h: (rt.u64Low(rt.u64Shr(n2, 16)) << 16) >> 16 } as hashes_Shape.Shape; + shape = { tag: "Rect", w: (rt.u64Low(n2) << 16) >> 16, h: (rt.u64Low(rt.u64Shr(n2, 16)) << 16) >> 16 } as Shape.Shape; } digest$hashes_Shape(shape, out); - digest$array2_hashes_Dir(["Up" as hashes_Dir.Dir, "Down" as hashes_Dir.Dir], out); + digest$array2_hashes_Dir(["Up" as Dir.Dir, "Down" as Dir.Dir], out); digest$tuple2_hashes_Small_hashes_Small(["Low" as Small.Small, "High" as Small.Small], out); digest$hashes_Nibble({ _0: rt.u64Low(n2) & 0xff }, out); } else { @@ -490,16 +489,16 @@ export function random(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, rt.u64Eq(rt.hashOne(rt.buildHasher(s), n, rt.hash64), rt.hashOne(rt.buildHasher(s), n, rt.hash64)) ? 1 : 0); rt.byteVecPush(out, rt.u64Eq(rt.hashOne(rt.buildHasher(other.state), text, rt.hashStr), rt.hashOne(rt.buildHasher(other.state), text, rt.hashStr)) ? 1 : 0); rt.byteVecPush(out, rt.u64Eq(rt.hashOne(rt.buildHasher(s), [b, text] as [rt.u8, string], rt.hashTuple([rt.hash8, rt.hashStr])), rt.hashOne(rt.buildHasher(copy), [b, text] as [rt.u8, string], rt.hashTuple([rt.hash8, rt.hashStr]))) ? 1 : 0); - rt.byteVecPush(out, rt.u64Eq(rt.hashOne(rt.buildHasher(s), { _0: b }, hashes_Nibble.hash$Hash_hash_DefaultHasher as (a0: hashes_Nibble.Nibble, a1: rt.Hasher) => undefined), rt.hashOne(rt.buildHasher(s), { _0: b ^ 240 }, hashes_Nibble.hash$Hash_hash_DefaultHasher as (a0: hashes_Nibble.Nibble, a1: rt.Hasher) => undefined)) ? 1 : 0); + rt.byteVecPush(out, rt.u64Eq(rt.hashOne(rt.buildHasher(s), { _0: b }, Nibble.hash$Hash_hash_DefaultHasher as (a0: Nibble.Nibble, a1: rt.Hasher) => undefined), rt.hashOne(rt.buildHasher(s), { _0: b ^ 240 }, Nibble.hash$Hash_hash_DefaultHasher as (a0: Nibble.Nibble, a1: rt.Hasher) => undefined)) ? 1 : 0); const arc: rt.Arc = new rt.Arc(text); const _84: rt.Arc = rt.arcClone(arc); rt.byteVecPush(out, rt.u64Eq(rt.hashOne(rt.buildHasher(s), _84, rt.hashArc(rt.hashStr), rt.drop), rt.hashOne(rt.buildHasher(s), arc, rt.hashArc(rt.hashStr))) ? 1 : 0); rt.byteVecPush(out, arc.strong & 0xff); const drops: rt.Cell = new rt.Cell(0); - const counted: hashes_Counted.Counted = new hashes_Counted.Counted(b, drops); - const _99: rt.u64 = rt.hashOne(rt.buildHasher(s), counted, hashes_Counted.hash$Hash_hash_DefaultHasher as (a0: hashes_Counted.Counted, a1: rt.Hasher) => undefined); - const _104: hashes_Counted.Counted = new hashes_Counted.Counted(b, drops); - rt.byteVecPush(out, rt.u64Eq(_99, rt.hashOne(rt.buildHasher(s), _104, hashes_Counted.hash$Hash_hash_DefaultHasher as (a0: hashes_Counted.Counted, a1: rt.Hasher) => undefined, rt.drop)) ? 1 : 0); + const counted: Counted.Counted = new Counted.Counted(b, drops); + const _99: rt.u64 = rt.hashOne(rt.buildHasher(s), counted, Counted.hash$Hash_hash_DefaultHasher as (a0: Counted.Counted, a1: rt.Hasher) => undefined); + const _104: Counted.Counted = new Counted.Counted(b, drops); + rt.byteVecPush(out, rt.u64Eq(_99, rt.hashOne(rt.buildHasher(s), _104, Counted.hash$Hash_hash_DefaultHasher as (a0: Counted.Counted, a1: rt.Hasher) => undefined, rt.drop)) ? 1 : 0); rt.byteVecPush(out, drops.v); counted[Symbol.dispose](); rt.byteVecPush(out, drops.v); @@ -562,7 +561,7 @@ export function bytes(data: rt.ByteSlice, out: rt.ByteVec): void { digest$array2_u8(rt.byteSliceFrom(pair), out); digest$tuple2_array2_u8_array3_u8([pair, a] as [Uint8Array, Uint8Array], out); digest$Option_array2_u8(pair, out); - const _83: rt.Arc = new rt.Arc(copy$array_u8(a)); + const _83: rt.Arc = new rt.Arc(a); digest$sync_Arc_array3_u8(_83, out); _83[Symbol.dispose](); const _87: rt.u64 = rt.hashOne(rt.buildHasher(state), a, rt.hashBytes); @@ -592,82 +591,82 @@ export function record(log: rt.RefCell, tag: rt.u8, bytes: rt.ByteSl } /** Hash values of std's types and the crate's, made of `data`, into `h`. */ -export function hashInto$hashes_Bare(h: hashes_Bare.Bare, data: rt.ByteSlice): void { +export function hashInto$hashes_Bare(h: Bare.Bare, data: rt.ByteSlice): void { const w: (a0: rt.usize, a1: rt.usize) => rt.u128 = (at: rt.usize, n: rt.usize): rt.u128 => { return wide(data, at, n); }; const _6: [rt.u128, rt.u64] = [w(0, 16), rt.u64Cast(w(3, 8))]; const a: rt.u128 = _6[0]; const b: rt.u64 = _6[1]; - rt.hash8(rt.u128Low(a) & 0xff, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hash16(rt.u128Low(a) & 0xffff, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hash32(rt.u128Low(a), new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hash64(b, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hash64(rt.u64Shr(b, rt.usizeRem(data.length, 64)), new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hash128(a, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashI8((rt.u128Low(a) << 24) >> 24, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashI16((rt.u128Low(a) << 16) >> 16, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashI32(rt.u128Low(a) | 0, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashI64(rt.i64Cast(b), new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashI64(rt.i64Shr(rt.i64Cast(b), 11), new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashI128(rt.i128Cast(a), new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashI128(rt.i128Shr(rt.i128Cast(a), 70), new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashUsize(rt.u128Low(a), new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashIsize(rt.u128Low(a) | 0, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hash8(rt.u128And(a, 1) === 1, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hash32(option_unwrapOr$0k15iai(rt.charFromU32((rt.u128Low(a) & 2097151) >>> 0), 1114111), new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.hash8(rt.u128Low(a) & 0xff, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hash16(rt.u128Low(a) & 0xffff, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hash32(rt.u128Low(a), new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hash64(b, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hash64(rt.u64Shr(b, rt.usizeRem(data.length, 64)), new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hash128(a, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashI8((rt.u128Low(a) << 24) >> 24, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashI16((rt.u128Low(a) << 16) >> 16, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashI32(rt.u128Low(a) | 0, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashI64(rt.i64Cast(b), new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashI64(rt.i64Shr(rt.i64Cast(b), 11), new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashI128(rt.i128Cast(a), new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashI128(rt.i128Shr(rt.i128Cast(a), 70), new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashUsize(rt.u128Low(a), new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashIsize(rt.u128Low(a) | 0, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hash8(rt.u128And(a, 1) === 1, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hash32(option_unwrapOr$0k15iai(rt.charFromU32((rt.u128Low(a) & 2097151) >>> 0), 1114111), new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const text: string = result_unwrapOr$01jdcm7(rt.strFromUtf8(data), "é ✓ 😀"); - rt.hashStr(text, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashStr(text, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashNothing(undefined, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.hashStr(text, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashStr(text, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashNothing(undefined, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const _88: [string, rt.u8, rt.u64 | undefined] = [text, rt.u128Low(a) & 0xff, b]; - rt.hashTuple([rt.hashStr, rt.hash8, rt.hashOption(rt.hash64)])(_88, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashOption(rt.hash32)(undefined, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.hashTuple([rt.hashStr, rt.hash8, rt.hashOption(rt.hash64)])(_88, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashOption(rt.hash32)(undefined, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const _95: rt.Arc = new rt.Arc(text); - rt.hashArc(rt.hashStr)(_95, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.hashArc(rt.hashStr)(_95, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); _95[Symbol.dispose](); - rt.hashBytes(data, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashBytes(rt.byteSliceToByteVec(data), new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashBytes(rt.byteSliceFrom(Uint8Array.of(rt.u128Low(a) & 0xff, rt.u64Low(b) & 0xff)), new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.hashBytes(data, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashBytes(rt.byteSliceToByteVec(data), new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashBytes(rt.byteSliceFrom(Uint8Array.of(rt.u128Low(a) & 0xff, rt.u64Low(b) & 0xff)), new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const words: rt.u16[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): rt.u16 => { return rt.u16Mul(_2 as rt.u16, 257); }), undefined, 2, true); - rt.hashInts(2)(words, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.hashInts(2)(words, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const _111: rt.u16[] = rt.sliceRange(words, rt.usizeDiv(words.length, 2)); - rt.hashInts(2)(_111, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.hashInts(2)(_111, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const _120: rt.u64[] = [b, rt.u64Shl(b, 40), rt.u64Sub({ hi: 0xffffffff, lo: 0xffffffff } as rt.u64, b)]; - rt.hashInts(8)(_120, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.hashInts(8)(_120, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const _128: rt.i128[] = [rt.i128Cast(a), rt.i128Neg(rt.i128Cast(a))]; - rt.hashInts(16)(_128, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.hashInts(16)(_128, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const _135: rt.isize[] = [rt.u128Low(a) | 0, -1]; - rt.hashInts(4)(_135, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.hashInts(4)(_135, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const _139: boolean[] = [rt.u128And(a, 1) === 0, true]; - rt.hashSlice(rt.hash8)(_139, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashSlice(rt.hash32)([233, 120], new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.hashSlice(rt.hash8)(_139, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashSlice(rt.hash32)([233, 120], new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const _146: rt.u16[] = [rt.u128Low(a) & 0xffff, 3]; - rt.hashSlice(rt.hash16)(_146, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.hashSlice(rt.hash16)(_146, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const _152: [rt.u8, string][] = [[rt.u128Low(a) & 0xff, "pair"] as [rt.u8, string], [0, ""] as [rt.u8, string]]; - rt.hashSlice(rt.hashTuple([rt.hash8, rt.hashStr]))(_152, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashI8(rt.cmp(rt.u128Low(a) & 0xff, rt.u64Low(b) & 0xff), new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.durationHash(rt.durationNew(b, rt.u32Rem(rt.u128Low(a), 1000000000)), new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hash16(rt.u128Low(a) & 0xffff, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.hashSlice(rt.hashTuple([rt.hash8, rt.hashStr]))(_152, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashI8(rt.cmp(rt.u128Low(a) & 0xff, rt.u64Low(b) & 0xff), new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.durationHash(rt.durationNew(b, rt.u32Rem(rt.u128Low(a), 1000000000)), new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hash16(rt.u128Low(a) & 0xffff, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const _177: rt.u32 | undefined = rt.nonZero((rt.u128Low(a) | 1) >>> 0); - rt.hashOption(rt.hash32)(_177, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.hashOption(rt.hash32)(_177, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const _182: rt.Range = new rt.Range(rt.u128Low(a) & 0xff, rt.u64Low(b) & 0xff); - rt.rangeHash(rt.hash8)(_182, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.rangeHash(rt.hash8)(_182, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const _187: rt.RangeInclusive = new rt.RangeInclusive(rt.u128Low(a) & 0xff, rt.u64Low(b) & 0xff, rt.u8Step); - rt.rangeHash(rt.hash8)(_187, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + rt.rangeHash(rt.hash8)(_187, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); const _193: rt.u8 = rt.u128Low(a) & 0xff; const _194: string = text; const _195: rt.i32 | undefined = thenSome$0n2gkz4(rt.u64Rem(b, 3) !== 0, rt.u64Low(b) | 0); Packet.hash$Hash_hashes_Bare({ id: b, flags: _193, name: _194, tags: words, next: _195 }, h); - hashes_Shape.hash$Hash_hashes_Bare({ tag: "Rect", w: (rt.u128Low(a) << 16) >> 16, h: -1 } as hashes_Shape.Shape, h); - rt.hashSlice(rt.hashOwn(hashes_Dir.hash$Hash_hashes_Bare as (a0: hashes_Dir.Dir, a1: hashes_Bare.Bare) => undefined))(["Up" as hashes_Dir.Dir, "Down" as hashes_Dir.Dir], new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashTuple([rt.hashOwn(Small.hash$Hash_hashes_Bare as (a0: Small.Small, a1: hashes_Bare.Bare) => undefined), rt.hashOwn(Small.hash$Hash_hashes_Bare as (a0: Small.Small, a1: hashes_Bare.Bare) => undefined)])(["Low" as Small.Small, "High" as Small.Small], new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - hashes_Nibble.hash$Hash_hashes_Bare({ _0: rt.u128Low(a) & 0xff }, h); - rt.hashI32(rt.u128Low(a) | 0, new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashIsize(rt.isizeNeg(rt.u128Low(a) | 0), new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); - rt.hashI64(rt.i64Neg(rt.i64Cast(b)), new rt.OwnHasher(h, hashes_Bare.hasher$hash_Hasher)); + Shape.hash$Hash_hashes_Bare({ tag: "Rect", w: (rt.u128Low(a) << 16) >> 16, h: -1 } as Shape.Shape, h); + rt.hashSlice(rt.hashOwn(Dir.hash$Hash_hashes_Bare as (a0: Dir.Dir, a1: Bare.Bare) => undefined))(["Up" as Dir.Dir, "Down" as Dir.Dir], new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashTuple([rt.hashOwn(Small.hash$Hash_hashes_Bare as (a0: Small.Small, a1: Bare.Bare) => undefined), rt.hashOwn(Small.hash$Hash_hashes_Bare as (a0: Small.Small, a1: Bare.Bare) => undefined)])(["Low" as Small.Small, "High" as Small.Small], new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + Nibble.hash$Hash_hashes_Bare({ _0: rt.u128Low(a) & 0xff }, h); + rt.hashI32(rt.u128Low(a) | 0, new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashIsize(rt.isizeNeg(rt.u128Low(a) | 0), new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); + rt.hashI64(rt.i64Neg(rt.i64Cast(b)), new rt.OwnHasher(h, Bare.hasher$hash_Hasher)); } /** Hash values of std's types and the crate's, made of `data`, into `h`. */ @@ -740,92 +739,92 @@ export function hashInto$hashes_Full(h: Full.Full, data: rt.ByteSlice): void { const _194: string = text; const _195: rt.i32 | undefined = thenSome$0n2gkz4(rt.u64Rem(b, 3) !== 0, rt.u64Low(b) | 0); Packet.hash$Hash_hashes_Full({ id: b, flags: _193, name: _194, tags: words, next: _195 }, h); - hashes_Shape.hash$Hash_hashes_Full({ tag: "Rect", w: (rt.u128Low(a) << 16) >> 16, h: -1 } as hashes_Shape.Shape, h); - rt.hashSlice(rt.hashOwn(hashes_Dir.hash$Hash_hashes_Full as (a0: hashes_Dir.Dir, a1: Full.Full) => undefined))(["Up" as hashes_Dir.Dir, "Down" as hashes_Dir.Dir], new rt.OwnHasher(h, Full.hasher$hash_Hasher)); + Shape.hash$Hash_hashes_Full({ tag: "Rect", w: (rt.u128Low(a) << 16) >> 16, h: -1 } as Shape.Shape, h); + rt.hashSlice(rt.hashOwn(Dir.hash$Hash_hashes_Full as (a0: Dir.Dir, a1: Full.Full) => undefined))(["Up" as Dir.Dir, "Down" as Dir.Dir], new rt.OwnHasher(h, Full.hasher$hash_Hasher)); rt.hashTuple([rt.hashOwn(Small.hash$Hash_hashes_Full as (a0: Small.Small, a1: Full.Full) => undefined), rt.hashOwn(Small.hash$Hash_hashes_Full as (a0: Small.Small, a1: Full.Full) => undefined)])(["Low" as Small.Small, "High" as Small.Small], new rt.OwnHasher(h, Full.hasher$hash_Hasher)); - hashes_Nibble.hash$Hash_hashes_Full({ _0: rt.u128Low(a) & 0xff }, h); + Nibble.hash$Hash_hashes_Full({ _0: rt.u128Low(a) & 0xff }, h); Full.writeI32$hash_Hasher(h, rt.u128Low(a) | 0); Full.writeIsize$hash_Hasher(h, rt.isizeNeg(rt.u128Low(a) | 0)); Full.writeI64$hash_Hasher(h, rt.i64Neg(rt.i64Cast(b))); } /** Hash values of std's types and the crate's, made of `data`, into `h`. */ -export function hashInto$hashes_Partial(h: hashes_Partial.Partial, data: rt.ByteSlice): void { +export function hashInto$hashes_Partial(h: Partial.Partial, data: rt.ByteSlice): void { const w: (a0: rt.usize, a1: rt.usize) => rt.u128 = (at: rt.usize, n: rt.usize): rt.u128 => { return wide(data, at, n); }; const _6: [rt.u128, rt.u64] = [w(0, 16), rt.u64Cast(w(3, 8))]; const a: rt.u128 = _6[0]; const b: rt.u64 = _6[1]; - rt.hash8(rt.u128Low(a) & 0xff, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hash16(rt.u128Low(a) & 0xffff, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hash32(rt.u128Low(a), new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hash64(b, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hash64(rt.u64Shr(b, rt.usizeRem(data.length, 64)), new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hash128(a, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashI8((rt.u128Low(a) << 24) >> 24, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashI16((rt.u128Low(a) << 16) >> 16, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashI32(rt.u128Low(a) | 0, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashI64(rt.i64Cast(b), new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashI64(rt.i64Shr(rt.i64Cast(b), 11), new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashI128(rt.i128Cast(a), new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashI128(rt.i128Shr(rt.i128Cast(a), 70), new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashUsize(rt.u128Low(a), new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashIsize(rt.u128Low(a) | 0, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hash8(rt.u128And(a, 1) === 1, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hash32(option_unwrapOr$0k15iai(rt.charFromU32((rt.u128Low(a) & 2097151) >>> 0), 1114111), new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.hash8(rt.u128Low(a) & 0xff, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hash16(rt.u128Low(a) & 0xffff, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hash32(rt.u128Low(a), new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hash64(b, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hash64(rt.u64Shr(b, rt.usizeRem(data.length, 64)), new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hash128(a, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashI8((rt.u128Low(a) << 24) >> 24, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashI16((rt.u128Low(a) << 16) >> 16, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashI32(rt.u128Low(a) | 0, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashI64(rt.i64Cast(b), new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashI64(rt.i64Shr(rt.i64Cast(b), 11), new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashI128(rt.i128Cast(a), new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashI128(rt.i128Shr(rt.i128Cast(a), 70), new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashUsize(rt.u128Low(a), new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashIsize(rt.u128Low(a) | 0, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hash8(rt.u128And(a, 1) === 1, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hash32(option_unwrapOr$0k15iai(rt.charFromU32((rt.u128Low(a) & 2097151) >>> 0), 1114111), new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const text: string = result_unwrapOr$01jdcm7(rt.strFromUtf8(data), "é ✓ 😀"); - rt.hashStr(text, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashStr(text, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashNothing(undefined, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.hashStr(text, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashStr(text, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashNothing(undefined, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const _88: [string, rt.u8, rt.u64 | undefined] = [text, rt.u128Low(a) & 0xff, b]; - rt.hashTuple([rt.hashStr, rt.hash8, rt.hashOption(rt.hash64)])(_88, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashOption(rt.hash32)(undefined, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.hashTuple([rt.hashStr, rt.hash8, rt.hashOption(rt.hash64)])(_88, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashOption(rt.hash32)(undefined, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const _95: rt.Arc = new rt.Arc(text); - rt.hashArc(rt.hashStr)(_95, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.hashArc(rt.hashStr)(_95, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); _95[Symbol.dispose](); - rt.hashBytes(data, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashBytes(rt.byteSliceToByteVec(data), new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashBytes(rt.byteSliceFrom(Uint8Array.of(rt.u128Low(a) & 0xff, rt.u64Low(b) & 0xff)), new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.hashBytes(data, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashBytes(rt.byteSliceToByteVec(data), new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashBytes(rt.byteSliceFrom(Uint8Array.of(rt.u128Low(a) & 0xff, rt.u64Low(b) & 0xff)), new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const words: rt.u16[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): rt.u16 => { return rt.u16Mul(_2 as rt.u16, 257); }), undefined, 2, true); - rt.hashInts(2)(words, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.hashInts(2)(words, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const _111: rt.u16[] = rt.sliceRange(words, rt.usizeDiv(words.length, 2)); - rt.hashInts(2)(_111, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.hashInts(2)(_111, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const _120: rt.u64[] = [b, rt.u64Shl(b, 40), rt.u64Sub({ hi: 0xffffffff, lo: 0xffffffff } as rt.u64, b)]; - rt.hashInts(8)(_120, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.hashInts(8)(_120, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const _128: rt.i128[] = [rt.i128Cast(a), rt.i128Neg(rt.i128Cast(a))]; - rt.hashInts(16)(_128, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.hashInts(16)(_128, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const _135: rt.isize[] = [rt.u128Low(a) | 0, -1]; - rt.hashInts(4)(_135, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.hashInts(4)(_135, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const _139: boolean[] = [rt.u128And(a, 1) === 0, true]; - rt.hashSlice(rt.hash8)(_139, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashSlice(rt.hash32)([233, 120], new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.hashSlice(rt.hash8)(_139, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashSlice(rt.hash32)([233, 120], new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const _146: rt.u16[] = [rt.u128Low(a) & 0xffff, 3]; - rt.hashSlice(rt.hash16)(_146, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.hashSlice(rt.hash16)(_146, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const _152: [rt.u8, string][] = [[rt.u128Low(a) & 0xff, "pair"] as [rt.u8, string], [0, ""] as [rt.u8, string]]; - rt.hashSlice(rt.hashTuple([rt.hash8, rt.hashStr]))(_152, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashI8(rt.cmp(rt.u128Low(a) & 0xff, rt.u64Low(b) & 0xff), new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.durationHash(rt.durationNew(b, rt.u32Rem(rt.u128Low(a), 1000000000)), new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hash16(rt.u128Low(a) & 0xffff, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.hashSlice(rt.hashTuple([rt.hash8, rt.hashStr]))(_152, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashI8(rt.cmp(rt.u128Low(a) & 0xff, rt.u64Low(b) & 0xff), new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.durationHash(rt.durationNew(b, rt.u32Rem(rt.u128Low(a), 1000000000)), new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hash16(rt.u128Low(a) & 0xffff, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const _177: rt.u32 | undefined = rt.nonZero((rt.u128Low(a) | 1) >>> 0); - rt.hashOption(rt.hash32)(_177, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.hashOption(rt.hash32)(_177, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const _182: rt.Range = new rt.Range(rt.u128Low(a) & 0xff, rt.u64Low(b) & 0xff); - rt.rangeHash(rt.hash8)(_182, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.rangeHash(rt.hash8)(_182, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const _187: rt.RangeInclusive = new rt.RangeInclusive(rt.u128Low(a) & 0xff, rt.u64Low(b) & 0xff, rt.u8Step); - rt.rangeHash(rt.hash8)(_187, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + rt.rangeHash(rt.hash8)(_187, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); const _193: rt.u8 = rt.u128Low(a) & 0xff; const _194: string = text; const _195: rt.i32 | undefined = thenSome$0n2gkz4(rt.u64Rem(b, 3) !== 0, rt.u64Low(b) | 0); Packet.hash$Hash_hashes_Partial({ id: b, flags: _193, name: _194, tags: words, next: _195 }, h); - hashes_Shape.hash$Hash_hashes_Partial({ tag: "Rect", w: (rt.u128Low(a) << 16) >> 16, h: -1 } as hashes_Shape.Shape, h); - rt.hashSlice(rt.hashOwn(hashes_Dir.hash$Hash_hashes_Partial as (a0: hashes_Dir.Dir, a1: hashes_Partial.Partial) => undefined))(["Up" as hashes_Dir.Dir, "Down" as hashes_Dir.Dir], new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashTuple([rt.hashOwn(Small.hash$Hash_hashes_Partial as (a0: Small.Small, a1: hashes_Partial.Partial) => undefined), rt.hashOwn(Small.hash$Hash_hashes_Partial as (a0: Small.Small, a1: hashes_Partial.Partial) => undefined)])(["Low" as Small.Small, "High" as Small.Small], new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - hashes_Nibble.hash$Hash_hashes_Partial({ _0: rt.u128Low(a) & 0xff }, h); - rt.hashI32(rt.u128Low(a) | 0, new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashIsize(rt.isizeNeg(rt.u128Low(a) | 0), new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); - rt.hashI64(rt.i64Neg(rt.i64Cast(b)), new rt.OwnHasher(h, hashes_Partial.hasher$hash_Hasher)); + Shape.hash$Hash_hashes_Partial({ tag: "Rect", w: (rt.u128Low(a) << 16) >> 16, h: -1 } as Shape.Shape, h); + rt.hashSlice(rt.hashOwn(Dir.hash$Hash_hashes_Partial as (a0: Dir.Dir, a1: Partial.Partial) => undefined))(["Up" as Dir.Dir, "Down" as Dir.Dir], new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashTuple([rt.hashOwn(Small.hash$Hash_hashes_Partial as (a0: Small.Small, a1: Partial.Partial) => undefined), rt.hashOwn(Small.hash$Hash_hashes_Partial as (a0: Small.Small, a1: Partial.Partial) => undefined)])(["Low" as Small.Small, "High" as Small.Small], new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + Nibble.hash$Hash_hashes_Partial({ _0: rt.u128Low(a) & 0xff }, h); + rt.hashI32(rt.u128Low(a) | 0, new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashIsize(rt.isizeNeg(rt.u128Low(a) | 0), new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); + rt.hashI64(rt.i64Neg(rt.i64Cast(b)), new rt.OwnHasher(h, Partial.hasher$hash_Hasher)); } /** @@ -840,25 +839,25 @@ export function own(data: rt.ByteSlice, out: rt.ByteVec): void { hashInto$hashes_Full(full, data); const finish: rt.u64 = Full.finish$hash_Hasher(full); full[Symbol.dispose](); - const bare: hashes_Bare.Bare = { _0: log }; + const bare: Bare.Bare = { _0: log }; hashInto$hashes_Bare(bare, data); - const partial: hashes_Partial.Partial = { _0: log }; + const partial: Partial.Partial = { _0: log }; hashInto$hashes_Partial(partial, data); const build: Build.Build = { _0: log }; const text: string = result_unwrapOr$01jdcm7(rt.strFromUtf8(data), "✓"); const n: rt.u16 = rt.u128Low(wide(data, 0, 2)) & 0xffff; - const _29: rt.u64 = hashes_Bare.finish$hash_Hasher(bare); - const _31: rt.u64 = hashes_Partial.finish$hash_Hasher(partial); + const _29: rt.u64 = Bare.finish$hash_Hasher(bare); + const _31: rt.u64 = Partial.finish$hash_Hasher(partial); const _33: rt.u64 = rt.hashOne(new rt.OwnHasher(Build.buildHasher$hash_BuildHasher(build), Full.hasher$hash_Hasher), n, rt.hash16, undefined, rt.drop); const _36: rt.u64 = rt.hashOne(new rt.OwnHasher(Build.buildHasher$hash_BuildHasher(build), Full.hasher$hash_Hasher), text, rt.hashStr, undefined, rt.drop); const _41: rt.Arc = new rt.Arc(text); const _38: rt.u64 = rt.hashOne(new rt.OwnHasher(Build.buildHasher$hash_BuildHasher(build), Full.hasher$hash_Hasher), _41, rt.hashArc(rt.hashStr), undefined, rt.drop); const _44: [rt.u8, string] = [n & 0xff, text]; const _42: rt.u64 = rt.hashOne(new rt.OwnHasher(Build.buildHasher$hash_BuildHasher(build), Full.hasher$hash_Hasher), _44, rt.hashTuple([rt.hash8, rt.hashStr]), undefined, rt.drop); - const _48: hashes_Logged.Logged = new hashes_Logged.Logged((n << 16) >> 16, log); - const _46: rt.u64 = rt.hashOne(new rt.OwnHasher(Build.buildHasher$hash_BuildHasher(build), Full.hasher$hash_Hasher), _48, rt.hashOwn(hashes_Logged.hash$Hash_hashes_Full as (a0: hashes_Logged.Logged, a1: Full.Full) => undefined), rt.drop, rt.drop); - const _54: hashes_Logged.Logged = new hashes_Logged.Logged(-1, log); - const hashes: rt.u64[] = [finish, _29, _31, _33, _36, _38, _42, _46, rt.hashOne(new rt.OwnHasher(Build.buildHasher$hash_BuildHasher(build), Full.hasher$hash_Hasher), _54, rt.hashOwn(hashes_Logged.hash$Hash_hashes_Full as (a0: hashes_Logged.Logged, a1: Full.Full) => undefined), undefined, rt.drop)]; + const _48: Logged.Logged = new Logged.Logged((n << 16) >> 16, log); + const _46: rt.u64 = rt.hashOne(new rt.OwnHasher(Build.buildHasher$hash_BuildHasher(build), Full.hasher$hash_Hasher), _48, rt.hashOwn(Logged.hash$Hash_hashes_Full as (a0: Logged.Logged, a1: Full.Full) => undefined), rt.drop, rt.drop); + const _54: Logged.Logged = new Logged.Logged(-1, log); + const hashes: rt.u64[] = [finish, _29, _31, _33, _36, _38, _42, _46, rt.hashOne(new rt.OwnHasher(Build.buildHasher$hash_BuildHasher(build), Full.hasher$hash_Hasher), _54, rt.hashOwn(Logged.hash$Hash_hashes_Full as (a0: Logged.Logged, a1: Full.Full) => undefined), undefined, rt.drop)]; _54[Symbol.dispose](); _41[Symbol.dispose](); const iter: rt.Iter = rt.iterSlice(hashes); diff --git a/ts/fixtures/lang/hashes/expected/lib.ts b/ts/fixtures/lang/hashes/expected/lib.ts new file mode 100644 index 000000000..c4f54d953 --- /dev/null +++ b/ts/fixtures/lang/hashes/expected/lib.ts @@ -0,0 +1,20 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { values, random, bytes, own } from "./hashes.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["hashes::values", values as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["hashes::random", (_22: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + random(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["hashes::bytes", (_23: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + bytes(data2, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["hashes::own", (_24: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + own(data3, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/hashes.rs b/ts/fixtures/lang/hashes/src/hashes.rs similarity index 100% rename from ts/fixtures/lang/src/hashes.rs rename to ts/fixtures/lang/hashes/src/hashes.rs diff --git a/ts/fixtures/lang/hashes/src/lib.rs b/ts/fixtures/lang/hashes/src/lib.rs new file mode 100644 index 000000000..262d67509 --- /dev/null +++ b/ts/fixtures/lang/hashes/src/lib.rs @@ -0,0 +1,26 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#![feature(hasher_prefixfree_extras)] + +#[path = "../../harness.rs"] +pub mod harness; +mod hashes; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("hashes::values", hashes::values), + ("hashes::random", |_, data, out| hashes::random(data, out)), + ("hashes::bytes", |_, data, out| hashes::bytes(data, out)), + ("hashes::own", |_, data, out| hashes::own(data, out)), + ] +} diff --git a/ts/fixtures/lang/hashes/ts.toml b/ts/fixtures/lang/hashes/ts.toml new file mode 100644 index 000000000..132d34624 --- /dev/null +++ b/ts/fixtures/lang/hashes/ts.toml @@ -0,0 +1,2 @@ +package = "lang-hashes-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/heap/Cargo.toml b/ts/fixtures/lang/heap/Cargo.toml new file mode 100644 index 000000000..48317c1bb --- /dev/null +++ b/ts/fixtures/lang/heap/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-heap-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/heap/expected/core/bool.ts b/ts/fixtures/lang/heap/expected/core/bool.ts new file mode 100644 index 000000000..f2fe3b556 --- /dev/null +++ b/ts/fixtures/lang/heap/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0j2n934(self: boolean, t: [rt.u8, rt.u16]): [rt.u8, rt.u16] | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/heap/expected/core/option.ts b/ts/fixtures/lang/heap/expected/core/option.ts new file mode 100644 index 000000000..e8fe34dd4 --- /dev/null +++ b/ts/fixtures/lang/heap/expected/core/option.ts @@ -0,0 +1,41 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Fault from "../heap.Fault.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function mapOr$0hi5qhf(self: [rt.u8, rt.u16] | undefined, default_: rt.u8, f: (a0: [rt.u8, rt.u16]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1qo6t0j(self: rt.u8 | undefined, default_: rt.u32, _: (a0: rt.u8) => rt.u32): rt.u32 { + if (self === undefined) { + return default_; + } + return self as rt.u32; +} + +export function okOr$1rxv64q(self: rt.Place | undefined, err: Fault.Fault): rt.Result, Fault.Fault> { + if (self === undefined) { + return rt.Err(err); + } + return rt.Ok(self); +} + +export function okOr$169x1m6(self: rt.usize | undefined, err: Fault.Fault): rt.Result { + if (self === undefined) { + return rt.Err(err); + } + return rt.Ok(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/heap/expected/core/result.ts b/ts/fixtures/lang/heap/expected/core/result.ts new file mode 100644 index 000000000..4e95691c7 --- /dev/null +++ b/ts/fixtures/lang/heap/expected/core/result.ts @@ -0,0 +1,13 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Fault from "../heap.Fault.ts"; + +export function mapErr$0fesv1f(self: rt.Result, op: (a0: rt.LayoutError) => Fault.Fault): rt.Result { + if (self.ok) { + return self as rt.Result; + } + return rt.Err(op(self.error)); +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/heap/expected/harness.ts b/ts/fixtures/lang/heap/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/heap/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/expected/heap.Fault.ts b/ts/fixtures/lang/heap/expected/heap.Fault.ts similarity index 100% rename from ts/fixtures/lang/expected/heap.Fault.ts rename to ts/fixtures/lang/heap/expected/heap.Fault.ts diff --git a/ts/fixtures/lang/expected/heap.Spill.ts b/ts/fixtures/lang/heap/expected/heap.Spill.ts similarity index 67% rename from ts/fixtures/lang/expected/heap.Spill.ts rename to ts/fixtures/lang/heap/expected/heap.Spill.ts index d843584cc..a08cf48ac 100644 --- a/ts/fixtures/lang/expected/heap.Spill.ts +++ b/ts/fixtures/lang/heap/expected/heap.Spill.ts @@ -1,10 +1,9 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { copy$Option_tuple2_u8_u16 } from "./lib.ts"; import { okOr$1rxv64q as option_okOr$1rxv64q } from "./core/option.ts"; import { layoutArray$Option_tuple2_u8_u16, layoutArray$sync_Arc_u8, layoutArray$u32, deallocate$Option_tuple2_u8_u16, deallocate$sync_Arc_u8, deallocate$u32 } from "./heap.ts"; -import type * as heap_Fault from "./heap.Fault.ts"; +import type * as Fault from "./heap.Fault.ts"; /** A spilled vector's storage: `len` of `cap` values written into memory from `alloc`. */ export class Spill { @@ -19,12 +18,12 @@ export class Spill { } } -export function new$Option_tuple2_u8_u16(cap: rt.usize): rt.Result, heap_Fault.Fault> { - const _2: rt.Result = layoutArray$Option_tuple2_u8_u16(cap); +export function new$Option_tuple2_u8_u16(cap: rt.usize): rt.Result, Fault.Fault> { + const _2: rt.Result = layoutArray$Option_tuple2_u8_u16(cap); if (_2.ok) { const layout: rt.Layout = _2.value; const pointer = rt.alloc(layout); - const _8: rt.Result, heap_Fault.Fault> = option_okOr$1rxv64q(pointer === rt.NULL ? undefined : pointer, { tag: "Alloc", layout } as heap_Fault.Fault); + const _8: rt.Result, Fault.Fault> = option_okOr$1rxv64q(pointer === rt.NULL ? undefined : pointer, { tag: "Alloc", layout } as Fault.Fault); if (_8.ok) { return rt.Ok(new Spill(rt.allocAs(_8.value, 6, "std::option::Option<(u8, u16)>"), cap, 0)); } @@ -33,12 +32,12 @@ export function new$Option_tuple2_u8_u16(cap: rt.usize): rt.Result>, heap_Fault.Fault> { - const _2: rt.Result = layoutArray$sync_Arc_u8(cap); +export function new$sync_Arc_u8(cap: rt.usize): rt.Result>, Fault.Fault> { + const _2: rt.Result = layoutArray$sync_Arc_u8(cap); if (_2.ok) { const layout: rt.Layout = _2.value; const pointer = rt.alloc(layout); - const _8: rt.Result, heap_Fault.Fault> = option_okOr$1rxv64q(pointer === rt.NULL ? undefined : pointer, { tag: "Alloc", layout } as heap_Fault.Fault); + const _8: rt.Result, Fault.Fault> = option_okOr$1rxv64q(pointer === rt.NULL ? undefined : pointer, { tag: "Alloc", layout } as Fault.Fault); if (_8.ok) { return rt.Ok(new Spill(rt.allocAs(_8.value, 4, "std::sync::Arc"), cap, 0)); } @@ -47,12 +46,12 @@ export function new$sync_Arc_u8(cap: rt.usize): rt.Result>, return _2; } -export function new$u32(cap: rt.usize): rt.Result, heap_Fault.Fault> { - const _2: rt.Result = layoutArray$u32(cap); +export function new$u32(cap: rt.usize): rt.Result, Fault.Fault> { + const _2: rt.Result = layoutArray$u32(cap); if (_2.ok) { const layout: rt.Layout = _2.value; const pointer = rt.alloc(layout); - const _8: rt.Result, heap_Fault.Fault> = option_okOr$1rxv64q(pointer === rt.NULL ? undefined : pointer, { tag: "Alloc", layout } as heap_Fault.Fault); + const _8: rt.Result, Fault.Fault> = option_okOr$1rxv64q(pointer === rt.NULL ? undefined : pointer, { tag: "Alloc", layout } as Fault.Fault); if (_8.ok) { return rt.Ok(new Spill(rt.allocAs(_8.value, 4, "u32"), cap, 0)); } @@ -62,18 +61,18 @@ export function new$u32(cap: rt.usize): rt.Result, heap_Fault.Faul } /** Grows or shrinks to `cap`, dropping what no longer fits. */ -export function resize$Option_tuple2_u8_u16(self: Spill<[rt.u8, rt.u16] | undefined>, cap: rt.usize): rt.Result { +export function resize$Option_tuple2_u8_u16(self: Spill<[rt.u8, rt.u16] | undefined>, cap: rt.usize): rt.Result { while (self.len > cap) { self.len = rt.usizeSub(self.len, 1); rt.ptrAdd(self.ptr as rt.Place<[rt.u8, rt.u16] | undefined>, self.len); } - const _11: rt.Result = layoutArray$Option_tuple2_u8_u16(self.cap); + const _11: rt.Result = layoutArray$Option_tuple2_u8_u16(self.cap); if (_11.ok) { - const _18: rt.Result = layoutArray$Option_tuple2_u8_u16(cap); + const _18: rt.Result = layoutArray$Option_tuple2_u8_u16(cap); if (_18.ok) { const layout: rt.Layout = _18.value; const pointer = rt.realloc(rt.allocBytes(self.ptr as rt.Place<[rt.u8, rt.u16] | undefined>, 6, "std::option::Option<(u8, u16)>"), layout.size); - const _30: rt.Result, heap_Fault.Fault> = option_okOr$1rxv64q(pointer === rt.NULL ? undefined : pointer, { tag: "Alloc", layout } as heap_Fault.Fault); + const _30: rt.Result, Fault.Fault> = option_okOr$1rxv64q(pointer === rt.NULL ? undefined : pointer, { tag: "Alloc", layout } as Fault.Fault); if (_30.ok) { const _29: rt.Place<[rt.u8, rt.u16] | undefined> = rt.allocAs(_30.value, 6, "std::option::Option<(u8, u16)>"); (self.ptr as rt.Place<[rt.u8, rt.u16] | undefined>) = _29; @@ -88,18 +87,18 @@ export function resize$Option_tuple2_u8_u16(self: Spill<[rt.u8, rt.u16] | undefi } /** Grows or shrinks to `cap`, dropping what no longer fits. */ -export function resize$sync_Arc_u8(self: Spill>, cap: rt.usize): rt.Result { +export function resize$sync_Arc_u8(self: Spill>, cap: rt.usize): rt.Result { while (self.len > cap) { self.len = rt.usizeSub(self.len, 1); rt.ptrAdd(self.ptr as rt.Place>, self.len).v[Symbol.dispose](); } - const _11: rt.Result = layoutArray$sync_Arc_u8(self.cap); + const _11: rt.Result = layoutArray$sync_Arc_u8(self.cap); if (_11.ok) { - const _18: rt.Result = layoutArray$sync_Arc_u8(cap); + const _18: rt.Result = layoutArray$sync_Arc_u8(cap); if (_18.ok) { const layout: rt.Layout = _18.value; const pointer = rt.realloc(rt.allocBytes(self.ptr as rt.Place>, 4, "std::sync::Arc"), layout.size); - const _30: rt.Result, heap_Fault.Fault> = option_okOr$1rxv64q(pointer === rt.NULL ? undefined : pointer, { tag: "Alloc", layout } as heap_Fault.Fault); + const _30: rt.Result, Fault.Fault> = option_okOr$1rxv64q(pointer === rt.NULL ? undefined : pointer, { tag: "Alloc", layout } as Fault.Fault); if (_30.ok) { const _29: rt.Place> = rt.allocAs(_30.value, 4, "std::sync::Arc"); (self.ptr as rt.Place>) = _29; @@ -114,18 +113,18 @@ export function resize$sync_Arc_u8(self: Spill>, cap: rt.usize): r } /** Grows or shrinks to `cap`, dropping what no longer fits. */ -export function resize$u32(self: Spill, cap: rt.usize): rt.Result { +export function resize$u32(self: Spill, cap: rt.usize): rt.Result { while (self.len > cap) { self.len = rt.usizeSub(self.len, 1); rt.ptrAdd(self.ptr as rt.Place, self.len); } - const _11: rt.Result = layoutArray$u32(self.cap); + const _11: rt.Result = layoutArray$u32(self.cap); if (_11.ok) { - const _18: rt.Result = layoutArray$u32(cap); + const _18: rt.Result = layoutArray$u32(cap); if (_18.ok) { const layout: rt.Layout = _18.value; const pointer = rt.realloc(rt.allocBytes(self.ptr as rt.Place, 4, "u32"), layout.size); - const _30: rt.Result, heap_Fault.Fault> = option_okOr$1rxv64q(pointer === rt.NULL ? undefined : pointer, { tag: "Alloc", layout } as heap_Fault.Fault); + const _30: rt.Result, Fault.Fault> = option_okOr$1rxv64q(pointer === rt.NULL ? undefined : pointer, { tag: "Alloc", layout } as Fault.Fault); if (_30.ok) { const _29: rt.Place = rt.allocAs(_30.value, 4, "u32"); (self.ptr as rt.Place) = _29; @@ -139,10 +138,9 @@ export function resize$u32(self: Spill, cap: rt.usize): rt.Result, value: [rt.u8, rt.u16] | undefined): rt.Result { - value = copy$Option_tuple2_u8_u16(value); +export function push$Option_tuple2_u8_u16(self: Spill<[rt.u8, rt.u16] | undefined>, value: [rt.u8, rt.u16] | undefined): rt.Result { if (self.len === self.cap) { - const _6: rt.Result = resize$Option_tuple2_u8_u16(self, rt.usizeAdd(rt.usizeMul(self.cap, 2), 1)); + const _6: rt.Result = resize$Option_tuple2_u8_u16(self, rt.usizeAdd(rt.usizeMul(self.cap, 2), 1)); if (!_6.ok) { return _6; } @@ -152,9 +150,9 @@ export function push$Option_tuple2_u8_u16(self: Spill<[rt.u8, rt.u16] | undefine return rt.OK; } -export function push$sync_Arc_u8(self: Spill>, value: rt.Arc): rt.Result { +export function push$sync_Arc_u8(self: Spill>, value: rt.Arc): rt.Result { if (self.len === self.cap) { - const _6: rt.Result = resize$sync_Arc_u8(self, rt.usizeAdd(rt.usizeMul(self.cap, 2), 1)); + const _6: rt.Result = resize$sync_Arc_u8(self, rt.usizeAdd(rt.usizeMul(self.cap, 2), 1)); if (!_6.ok) { value[Symbol.dispose](); return _6; @@ -165,9 +163,9 @@ export function push$sync_Arc_u8(self: Spill>, value: rt.Arc, value: rt.u32): rt.Result { +export function push$u32(self: Spill, value: rt.u32): rt.Result { if (self.len === self.cap) { - const _6: rt.Result = resize$u32(self, rt.usizeAdd(rt.usizeMul(self.cap, 2), 1)); + const _6: rt.Result = resize$u32(self, rt.usizeAdd(rt.usizeMul(self.cap, 2), 1)); if (!_6.ok) { return _6; } diff --git a/ts/fixtures/lang/expected/heap.ts b/ts/fixtures/lang/heap/expected/heap.ts similarity index 77% rename from ts/fixtures/lang/expected/heap.ts rename to ts/fixtures/lang/heap/expected/heap.ts index 64ea6128c..811eb770d 100644 --- a/ts/fixtures/lang/expected/heap.ts +++ b/ts/fixtures/lang/heap/expected/heap.ts @@ -5,51 +5,51 @@ import { drop$heap_Spill_Option_tuple2_u8_u16, drop$heap_Spill_sync_Arc_u8, drop import { thenSome$0j2n934 } from "./core/bool.ts"; import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, mapOr$0hi5qhf as option_mapOr$0hi5qhf, mapOr$1qo6t0j as option_mapOr$1qo6t0j, okOr$169x1m6 as option_okOr$169x1m6 } from "./core/option.ts"; import { mapErr$0fesv1f as result_mapErr$0fesv1f } from "./core/result.ts"; -import * as heap_Fault from "./heap.Fault.ts"; +import * as Fault from "./heap.Fault.ts"; import * as Spill from "./heap.Spill.ts"; -export function layoutArray$Option_tuple2_u8_u16(n: rt.usize): rt.Result { - const _2: rt.Result = option_okOr$169x1m6(rt.usizeCheckedMul(6, n), { tag: "Overflow" } as heap_Fault.Fault); +export function layoutArray$Option_tuple2_u8_u16(n: rt.usize): rt.Result { + const _2: rt.Result = option_okOr$169x1m6(rt.usizeCheckedMul(6, n), { tag: "Overflow" } as Fault.Fault); if (_2.ok) { - return result_mapErr$0fesv1f(rt.layoutFromSizeAlign(_2.value, 2), (_22: rt.LayoutError): heap_Fault.Fault => { - return { tag: "Overflow" } as heap_Fault.Fault; + return result_mapErr$0fesv1f(rt.layoutFromSizeAlign(_2.value, 2), (_22: rt.LayoutError): Fault.Fault => { + return { tag: "Overflow" } as Fault.Fault; }); } return _2; } -export function layoutArray$sync_Arc_u8(n: rt.usize): rt.Result { - const _2: rt.Result = option_okOr$169x1m6(rt.usizeCheckedMul(4, n), { tag: "Overflow" } as heap_Fault.Fault); +export function layoutArray$sync_Arc_u8(n: rt.usize): rt.Result { + const _2: rt.Result = option_okOr$169x1m6(rt.usizeCheckedMul(4, n), { tag: "Overflow" } as Fault.Fault); if (_2.ok) { - return result_mapErr$0fesv1f(rt.layoutFromSizeAlign(_2.value, 4), (_22: rt.LayoutError): heap_Fault.Fault => { - return { tag: "Overflow" } as heap_Fault.Fault; + return result_mapErr$0fesv1f(rt.layoutFromSizeAlign(_2.value, 4), (_22: rt.LayoutError): Fault.Fault => { + return { tag: "Overflow" } as Fault.Fault; }); } return _2; } -export function layoutArray$u32(n: rt.usize): rt.Result { - const _2: rt.Result = option_okOr$169x1m6(rt.usizeCheckedMul(4, n), { tag: "Overflow" } as heap_Fault.Fault); +export function layoutArray$u32(n: rt.usize): rt.Result { + const _2: rt.Result = option_okOr$169x1m6(rt.usizeCheckedMul(4, n), { tag: "Overflow" } as Fault.Fault); if (_2.ok) { - return result_mapErr$0fesv1f(rt.layoutFromSizeAlign(_2.value, 4), (_22: rt.LayoutError): heap_Fault.Fault => { - return { tag: "Overflow" } as heap_Fault.Fault; + return result_mapErr$0fesv1f(rt.layoutFromSizeAlign(_2.value, 4), (_22: rt.LayoutError): Fault.Fault => { + return { tag: "Overflow" } as Fault.Fault; }); } return _2; } export function deallocate$Option_tuple2_u8_u16(ptr: rt.Place<[rt.u8, rt.u16] | undefined>, cap: rt.usize): void { - rt.resultUnwrap(layoutArray$Option_tuple2_u8_u16(cap), (value: heap_Fault.Fault, f: rt.Formatter) => heap_Fault.fmt$fmt_Debug(value, f)); + rt.resultUnwrap(layoutArray$Option_tuple2_u8_u16(cap), (value: Fault.Fault, f: rt.Formatter) => Fault.fmt$fmt_Debug(value, f)); rt.dealloc(rt.allocBytes(ptr, 6, "std::option::Option<(u8, u16)>")); } export function deallocate$sync_Arc_u8(ptr: rt.Place>, cap: rt.usize): void { - rt.resultUnwrap(layoutArray$sync_Arc_u8(cap), (value: heap_Fault.Fault, f: rt.Formatter) => heap_Fault.fmt$fmt_Debug(value, f)); + rt.resultUnwrap(layoutArray$sync_Arc_u8(cap), (value: Fault.Fault, f: rt.Formatter) => Fault.fmt$fmt_Debug(value, f)); rt.dealloc(rt.allocBytes(ptr, 4, "std::sync::Arc")); } export function deallocate$u32(ptr: rt.Place, cap: rt.usize): void { - rt.resultUnwrap(layoutArray$u32(cap), (value: heap_Fault.Fault, f: rt.Formatter) => heap_Fault.fmt$fmt_Debug(value, f)); + rt.resultUnwrap(layoutArray$u32(cap), (value: Fault.Fault, f: rt.Formatter) => Fault.fmt$fmt_Debug(value, f)); rt.dealloc(rt.allocBytes(ptr, 4, "u32")); } @@ -59,23 +59,23 @@ export function deallocate$u32(ptr: rt.Place, cap: rt.usize): void { */ export function spills(data: rt.ByteSlice, out: rt.ByteVec): void { const shared: rt.Arc = new rt.Arc(7); - const ints: Spill.Spill = rt.resultUnwrap(Spill.new$u32(1), (value: heap_Fault.Fault, f: rt.Formatter) => heap_Fault.fmt$fmt_Debug(value, f)); - const arcs: Spill.Spill> = rt.resultUnwrap(Spill.new$sync_Arc_u8(2), (value: heap_Fault.Fault, f: rt.Formatter) => heap_Fault.fmt$fmt_Debug(value, f)); - const pairs: Spill.Spill<[rt.u8, rt.u16] | undefined> = rt.resultUnwrap(Spill.new$Option_tuple2_u8_u16(1), (value: heap_Fault.Fault, f: rt.Formatter) => heap_Fault.fmt$fmt_Debug(value, f)); + const ints: Spill.Spill = rt.resultUnwrap(Spill.new$u32(1), (value: Fault.Fault, f: rt.Formatter) => Fault.fmt$fmt_Debug(value, f)); + const arcs: Spill.Spill> = rt.resultUnwrap(Spill.new$sync_Arc_u8(2), (value: Fault.Fault, f: rt.Formatter) => Fault.fmt$fmt_Debug(value, f)); + const pairs: Spill.Spill<[rt.u8, rt.u16] | undefined> = rt.resultUnwrap(Spill.new$Option_tuple2_u8_u16(1), (value: Fault.Fault, f: rt.Formatter) => Fault.fmt$fmt_Debug(value, f)); for (const b of rt.byteSliceView(data)) { const _17: rt.u8 = rt.u8Rem(b, 4); if (_17 === 0) { - rt.resultUnwrap(Spill.push$u32(ints, rt.u32Mul(b as rt.u32, 1000)), (value: heap_Fault.Fault, f: rt.Formatter) => heap_Fault.fmt$fmt_Debug(value, f)); + rt.resultUnwrap(Spill.push$u32(ints, rt.u32Mul(b as rt.u32, 1000)), (value: Fault.Fault, f: rt.Formatter) => Fault.fmt$fmt_Debug(value, f)); } else if (_17 === 1) { const _26: rt.Arc = rt.arcClone(shared); - rt.resultUnwrap(Spill.push$sync_Arc_u8(arcs, _26), (value: heap_Fault.Fault, f: rt.Formatter) => heap_Fault.fmt$fmt_Debug(value, f)); + rt.resultUnwrap(Spill.push$sync_Arc_u8(arcs, _26), (value: Fault.Fault, f: rt.Formatter) => Fault.fmt$fmt_Debug(value, f)); } else if (_17 === 2) { const _30: [rt.u8, rt.u16] | undefined = thenSome$0j2n934((b & 8) !== 0, [b, (((b as rt.u16)) << 4) & 0xffff] as [rt.u8, rt.u16]); - rt.resultUnwrap(Spill.push$Option_tuple2_u8_u16(pairs, _30), (value: heap_Fault.Fault, f: rt.Formatter) => heap_Fault.fmt$fmt_Debug(value, f)); + rt.resultUnwrap(Spill.push$Option_tuple2_u8_u16(pairs, _30), (value: Fault.Fault, f: rt.Formatter) => Fault.fmt$fmt_Debug(value, f)); } else { const cap: rt.usize = rt.usizeAdd(rt.usizeRem(b >> 2 as rt.usize, 5), 1); - rt.resultUnwrap(Spill.resize$u32(ints, cap), (value: heap_Fault.Fault, f: rt.Formatter) => heap_Fault.fmt$fmt_Debug(value, f)); - rt.resultUnwrap(Spill.resize$sync_Arc_u8(arcs, cap), (value: heap_Fault.Fault, f: rt.Formatter) => heap_Fault.fmt$fmt_Debug(value, f)); + rt.resultUnwrap(Spill.resize$u32(ints, cap), (value: Fault.Fault, f: rt.Formatter) => Fault.fmt$fmt_Debug(value, f)); + rt.resultUnwrap(Spill.resize$sync_Arc_u8(arcs, cap), (value: Fault.Fault, f: rt.Formatter) => Fault.fmt$fmt_Debug(value, f)); } rt.byteVecPush(out, shared.strong & 0xff); } @@ -178,13 +178,13 @@ export function layouts(data: rt.ByteSlice, out: rt.ByteVec): void { const unit: rt.Layout = rt.resultUnwrap(rt.layoutArray(size, 0, 1), rt.fmtLayoutErrorDebug); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(unit.size & 0xff, unit.align & 0xff)), undefined, true); } - const _92: heap_Fault.Fault = { tag: "Alloc", layout: { size: 16, align: 8 } }; + const _92: Fault.Fault = { tag: "Alloc", layout: { size: 16, align: 8 } }; const _94: rt.Layout = { size: 4, align: 4 }; - const args6: rt.Fmt[] = [(f: rt.Formatter) => heap_Fault.fmt$fmt_Debug(_92, f), (f: rt.Formatter) => rt.fmtLayoutDebug(_94, f)]; + const args6: rt.Fmt[] = [(f: rt.Formatter) => Fault.fmt$fmt_Debug(_92, f), (f: rt.Formatter) => rt.fmtLayoutDebug(_94, f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args6[0], " ", args6[1]])), undefined, true); rt.byteVecPush(out, 8 & 0xff); - const arg = { tag: "Overflow" } as heap_Fault.Fault; - const args8: rt.Fmt[] = [(f: rt.Formatter) => heap_Fault.fmt$fmt_Debug(arg, f)]; + const arg = { tag: "Overflow" } as Fault.Fault; + const args8: rt.Fmt[] = [(f: rt.Formatter) => Fault.fmt$fmt_Debug(arg, f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args8[0]])), undefined, true); } diff --git a/ts/fixtures/lang/heap/expected/lib.ts b/ts/fixtures/lang/heap/expected/lib.ts new file mode 100644 index 000000000..1aabd6f10 --- /dev/null +++ b/ts/fixtures/lang/heap/expected/lib.ts @@ -0,0 +1,33 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { spills, remnants, layouts } from "./heap.ts"; +import * as Spill from "./heap.Spill.ts"; + +export function drop$heap_Spill_Option_tuple2_u8_u16(_1: Spill.Spill<[rt.u8, rt.u16] | undefined>): void { + Spill.drop$ops_Drop_Option_tuple2_u8_u16(_1); +} + +export function drop$heap_Spill_sync_Arc_u8(_1: Spill.Spill>): void { + Spill.drop$ops_Drop_sync_Arc_u8(_1); +} + +export function drop$heap_Spill_u32(_1: Spill.Spill): void { + Spill.drop$ops_Drop_u32(_1); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["heap::spills", (_22: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + spills(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["heap::layouts", (_23: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + layouts(data2, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["heap::remnants", (_24: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + remnants(data3, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/heap.rs b/ts/fixtures/lang/heap/src/heap.rs similarity index 100% rename from ts/fixtures/lang/src/heap.rs rename to ts/fixtures/lang/heap/src/heap.rs diff --git a/ts/fixtures/lang/heap/src/lib.rs b/ts/fixtures/lang/heap/src/lib.rs new file mode 100644 index 000000000..1462c94ce --- /dev/null +++ b/ts/fixtures/lang/heap/src/lib.rs @@ -0,0 +1,23 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod heap; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("heap::spills", |_, data, out| heap::spills(data, out)), + ("heap::layouts", |_, data, out| heap::layouts(data, out)), + ("heap::remnants", |_, data, out| heap::remnants(data, out)), + ] +} diff --git a/ts/fixtures/lang/heap/ts.toml b/ts/fixtures/lang/heap/ts.toml new file mode 100644 index 000000000..6c90385f8 --- /dev/null +++ b/ts/fixtures/lang/heap/ts.toml @@ -0,0 +1,2 @@ +package = "lang-heap-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/hints/Cargo.toml b/ts/fixtures/lang/hints/Cargo.toml new file mode 100644 index 000000000..88bbd9bbd --- /dev/null +++ b/ts/fixtures/lang/hints/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-hints-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/hints/caller.ts b/ts/fixtures/lang/hints/caller.ts new file mode 100644 index 000000000..be5b92348 --- /dev/null +++ b/ts/fixtures/lang/hints/caller.ts @@ -0,0 +1,24 @@ +// The inputs `hints`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `hints::hints` of each iterator, each pair of lengths, and each of its arms, read three + * times each way, with as many bytes as the first length's index. + */ +const hintsOp = op("hints::hints"); +const hints = Array.from({ length: 24 * 8 * 8 * 8 * 2 }, (_, i) => { + const [kind, n, m, arm, back] = [i % 24, Math.floor(i / 24) % 8, Math.floor(i / 192) % 8, Math.floor(i / 1536) % 8, Math.floor(i / 12288)]; + const steps = (arm << 5) | ((back ? 0b101 : 0b010) << 2) | 3; + return Uint8Array.of(...hintsOp, kind, n, m, steps, ...Array.from({ length: n }, (_, b) => b * 37)); +}); + +/** `hints::reserves` of each collection and element type, each shape, length, and limit on what it reads. */ +const reservesOp = op("hints::reserves"); +const reserves = Array.from({ length: 13 * 6 * 5 * 4 * 5 }, (_, i) => + Uint8Array.of(...reservesOp, i % 78, Math.floor(i / 78) % 5, Math.floor(i / 390) % 4, Math.floor(i / 1560)), +); + +export const cases: Uint8Array[] = [...hints, ...reserves]; diff --git a/ts/fixtures/lang/hints/expected/core/bool.ts b/ts/fixtures/lang/hints/expected/core/bool.ts new file mode 100644 index 000000000..492c81ecd --- /dev/null +++ b/ts/fixtures/lang/hints/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$1ugl8af(self: boolean, t: rt.u64): rt.u64 | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/hints/expected/core/option.ts b/ts/fixtures/lang/hints/expected/core/option.ts new file mode 100644 index 000000000..15d0ff61e --- /dev/null +++ b/ts/fixtures/lang/hints/expected/core/option.ts @@ -0,0 +1,62 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Unit from "../hints.Unit.ts"; + +export function unwrapOr$1rbuegs(self: rt.ByteSlice | undefined, default_: rt.ByteSlice): rt.ByteSlice { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function mapOr$0ow0wo0(self: rt.u32[][] | undefined, default_: rt.usize, f: (a0: rt.u32[][]) => rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0r2th8w(self: Unit.Unit[] | undefined, default_: rt.usize, f: (a0: Unit.Unit[]) => rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0pdoq6p(self: [rt.u64, rt.u8][] | undefined, default_: rt.usize, f: (a0: [rt.u64, rt.u8][]) => rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0amk6zv(self: [rt.u8, rt.u8, rt.u8][] | undefined, default_: rt.usize, f: (a0: [rt.u8, rt.u8, rt.u8][]) => rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1umcrqz(self: rt.u32[] | undefined, default_: rt.usize, f: (a0: rt.u32[]) => rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$08xwngs(self: rt.ByteVec | undefined, default_: rt.usize, f: (a0: rt.ByteVec) => rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/hints/expected/core/result.ts b/ts/fixtures/lang/hints/expected/core/result.ts new file mode 100644 index 000000000..56fd6599d --- /dev/null +++ b/ts/fixtures/lang/hints/expected/core/result.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0u9zzk3(self: rt.Result, default_: rt.u32): rt.u32 { + if (self.ok) { + return self.value; + } + return default_; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/hints/expected/harness.ts b/ts/fixtures/lang/hints/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/hints/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/expected/hints.Countdown.ts b/ts/fixtures/lang/hints/expected/hints.Countdown.ts similarity index 100% rename from ts/fixtures/lang/expected/hints.Countdown.ts rename to ts/fixtures/lang/hints/expected/hints.Countdown.ts diff --git a/ts/fixtures/lang/expected/hints.Endless.ts b/ts/fixtures/lang/hints/expected/hints.Endless.ts similarity index 100% rename from ts/fixtures/lang/expected/hints.Endless.ts rename to ts/fixtures/lang/hints/expected/hints.Endless.ts diff --git a/ts/fixtures/lang/expected/hints.Most.ts b/ts/fixtures/lang/hints/expected/hints.Most.ts similarity index 100% rename from ts/fixtures/lang/expected/hints.Most.ts rename to ts/fixtures/lang/hints/expected/hints.Most.ts diff --git a/ts/fixtures/lang/expected/hints.Unit.ts b/ts/fixtures/lang/hints/expected/hints.Unit.ts similarity index 100% rename from ts/fixtures/lang/expected/hints.Unit.ts rename to ts/fixtures/lang/hints/expected/hints.Unit.ts diff --git a/ts/fixtures/lang/expected/hints.ts b/ts/fixtures/lang/hints/expected/hints.ts similarity index 90% rename from ts/fixtures/lang/expected/hints.ts rename to ts/fixtures/lang/hints/expected/hints.ts index bc9e248aa..5bf1fc50a 100644 --- a/ts/fixtures/lang/expected/hints.ts +++ b/ts/fixtures/lang/hints/expected/hints.ts @@ -1,14 +1,13 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { copy$array_u32, copy$array_u64, copy$tuple2_u64_u8 } from "./lib.ts"; import { thenSome$1ugl8af } from "./core/bool.ts"; import { unwrapOr$1rbuegs as option_unwrapOr$1rbuegs, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, mapOr$0ow0wo0 as option_mapOr$0ow0wo0, mapOr$0r2th8w as option_mapOr$0r2th8w, mapOr$0pdoq6p as option_mapOr$0pdoq6p, mapOr$0amk6zv as option_mapOr$0amk6zv, mapOr$1umcrqz as option_mapOr$1umcrqz, mapOr$08xwngs as option_mapOr$08xwngs } from "./core/option.ts"; import { unwrapOr$0u9zzk3 as result_unwrapOr$0u9zzk3 } from "./core/result.ts"; -import * as hints_Countdown from "./hints.Countdown.ts"; +import * as Countdown from "./hints.Countdown.ts"; import * as Endless from "./hints.Endless.ts"; import type * as Most from "./hints.Most.ts"; -import * as hints_Unit from "./hints.Unit.ts"; +import * as Unit from "./hints.Unit.ts"; /** A hint, as four bytes each, the upper bound after whether it has one. */ export function put(out: rt.ByteVec, _2: [rt.usize, rt.usize | undefined]): void { @@ -1368,14 +1367,14 @@ export function walkFront$collections_hash_set_Iter_u8(it: rt.Iter, steps } /** As `walk`, of an iterator that reads only from the front. */ -export function walkFront$hints_Countdown(it: hints_Countdown.Countdown, steps: rt.u8, out: rt.ByteVec): void { - put(out, rt.iterFrom(it, (it: hints_Countdown.Countdown) => hints_Countdown.next$iter_Iterator(it)).sizeHint()); +export function walkFront$hints_Countdown(it: Countdown.Countdown, steps: rt.u8, out: rt.ByteVec): void { + put(out, rt.iterFrom(it, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it)).sizeHint()); const _9: rt.u8 = rt.u8Rem(steps, 4); let iterStart: rt.u8 = 0; const iterEnd: rt.u8 = _9; while (iterStart++ < iterEnd) { - rt.iterToOption(hints_Countdown.next$iter_Iterator(it)); - put(out, rt.iterFrom(it, (it: hints_Countdown.Countdown) => hints_Countdown.next$iter_Iterator(it)).sizeHint()); + rt.iterToOption(Countdown.next$iter_Iterator(it)); + put(out, rt.iterFrom(it, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it)).sizeHint()); } } @@ -1872,7 +1871,7 @@ export function hints(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } else if (_219 === 2) { walk$iter_Fuse_ops_Range_u64(rt.iterFuse(new rt.Range(0, n, rt.u64Step)), steps, out); } else { - walkFront$iter_Fuse_hints_Countdown(rt.iterFuse(rt.iterFrom({ _0: rt.u64Low(n) & 0xff }, (it: hints_Countdown.Countdown) => hints_Countdown.next$iter_Iterator(it))), steps, out); + walkFront$iter_Fuse_hints_Countdown(rt.iterFuse(rt.iterFrom({ _0: rt.u64Low(n) & 0xff }, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it))), steps, out); } } else if (_37 === 11) { it = rt.iterPeekable(rt.iterChain(new rt.Range(0, n, rt.u64Step), new rt.Range(0, m, rt.u64Step))); @@ -1919,11 +1918,11 @@ export function hints(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { }, (value: rt.u64[]) => rt.iterSlice(value), false, 0, true).sizeHint()); } else { walk$iter_FlatMap_ops_Range_u64_iter_Flatten_array_IntoIter_array2_u64_2_hints_hints_closure14(rt.iterFlatMap(new rt.Range(0, n, rt.u64Step), (i11: rt.u64): rt.Iter => { - const item = copy$array_u64(Array.from({ length: 2 }, (): rt.u64 => { + const _514: rt.u64[] = Array.from({ length: 2 }, (): rt.u64 => { return i11; - })); + }); return rt.iterFlatten(rt.iterSlice(Array.from({ length: 2 }, (): rt.u64[] => { - return copy$array_u64(item); + return _514; })), (value: rt.u64[]) => rt.iterSlice(value), false, 2); }), steps, out); } @@ -2165,7 +2164,7 @@ export function reserves(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void return [i2 as rt.u64, i2 & 0xff] as [rt.u64, rt.u8]; }, { vec: 134217727, pairs: 89478485, set: 58720256, map: 58720256 }, out); } else if (_4 === 5) { - typed$hints_Unit_hints_reserves_closure4(kind, data, (_2: rt.u32): hints_Unit.Unit => { + typed$hints_Unit_hints_reserves_closure4(kind, data, (_2: rt.u32): Unit.Unit => { return {}; }, { vec: 4294967295, pairs: 536870911, set: 536870911, map: 234881024 }, out); } else { @@ -2250,7 +2249,7 @@ export function typed$array275_u32_hints_reserves_closure5(kind: rt.u8, data: rt } /** `reserves` of elements `make` makes. */ -export function typed$hints_Unit_hints_reserves_closure4(kind: rt.u8, data: rt.ByteSlice, make: (a0: rt.u32) => hints_Unit.Unit, most: Most.Most, out: rt.ByteVec): void { +export function typed$hints_Unit_hints_reserves_closure4(kind: rt.u8, data: rt.ByteSlice, make: (a0: rt.u32) => Unit.Unit, most: Most.Most, out: rt.ByteVec): void { let _20!: [rt.u64, rt.u64]; let past!: rt.u64; let count!: rt.u64; @@ -2295,9 +2294,9 @@ export function typed$hints_Unit_hints_reserves_closure4(kind: rt.u8, data: rt.B count = 4294967296; } const last: rt.u32 = rt.resultUnwrap(rt.u32TryFrom(rt.u64Sub(rt.u64Min(count, 4294967296), 1)), rt.fmtTryFromIntErrorDebug); - const seed: hints_Unit.Unit = make(7); + const seed: Unit.Unit = make(7); const calls: rt.Cell = new rt.Cell(0); - const f: (a0: rt.u32) => hints_Unit.Unit = (i2: rt.u32): hints_Unit.Unit => { + const f: (a0: rt.u32) => Unit.Unit = (i2: rt.u32): Unit.Unit => { rt.cellSet(calls, rt.u8Add(calls.v, 1)); if (!(calls.v <= limit)) { rt.panicFmt(["consumed"]); @@ -2310,7 +2309,7 @@ export function typed$hints_Unit_hints_reserves_closure4(kind: rt.u8, data: rt.B } else if (shape === 1) { fill$hints_Unit_iter_Skip_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_hints_Unit_hints_reserves_closure4(coll, rt.iterSkip(rt.iterMap(new rt.RangeInclusive(0, last, rt.u32Step), f), 1), seed, out); } else if (shape === 2) { - fill$hints_Unit_iter_Filter_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_hints_Unit_hints_reserves_closure4_hints_typed_closure2_hints_Unit_hints_reserves_closure4(coll, rt.iterFilter(rt.iterMap(new rt.RangeInclusive(0, last, rt.u32Step), f), (_2: hints_Unit.Unit): boolean => { + fill$hints_Unit_iter_Filter_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_hints_Unit_hints_reserves_closure4_hints_typed_closure2_hints_Unit_hints_reserves_closure4(coll, rt.iterFilter(rt.iterMap(new rt.RangeInclusive(0, last, rt.u32Step), f), (_2: Unit.Unit): boolean => { return true; }), seed, out); } else if (shape === 3) { @@ -2612,7 +2611,6 @@ export function typed$u8_hints_reserves_closure0(kind: rt.u8, data: rt.ByteSlice /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ export function fill$array275_u32_iter_Filter_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_array275_u32_hints_reserves_closure5_hints_typed_closure2_array275_u32_hints_reserves_closure5(coll: rt.u8, items: rt.Iter, seed: rt.u32[], out: rt.ByteVec): void { let len!: rt.usize; - seed = copy$array_u32(seed); if (coll === 0) { len = rt.iterToArray(items, "next", 1100).length; } else if (coll === 1) { @@ -2620,19 +2618,19 @@ export function fill$array275_u32_iter_Filter_iter_Map_ops_RangeInclusive_u32_hi rt.iterExtend(v, items, "next", 1100); len = v.length; } else if (coll === 2) { - const v2: rt.u32[][] = rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32); + const v2: rt.u32[][] = rt.vecFromElem(seed, 2, undefined); rt.iterExtend(v2, items, "next", 1100); len = v2.length; } else if (coll === 3) { len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 1100), 1100) as rt.VecDeque)).n; } else if (coll === 4) { - const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32), 1100) as rt.VecDeque; + const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(seed, 2, undefined), 1100) as rt.VecDeque; rt.dequeExtend(q, items, "next"); len = q.n; } else if (coll === 5) { len = rt.heapFrom(rt.iterToArray(items, "next", 1100), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))); + const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(seed, 2, undefined), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))); rt.heapExtend(h, items, rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp)), "next", 1100); len = h.d.length; } else if (coll === 7) { @@ -2682,7 +2680,6 @@ export function fill$array275_u32_iter_Filter_iter_Map_ops_RangeInclusive_u32_hi /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ export function fill$array275_u32_iter_Map_iter_Flatten_array_IntoIter_ops_RangeInclusive_u32_2_hints_typed_closure1_array275_u32_hints_reserves_closure5(coll: rt.u8, items: rt.Iter, seed: rt.u32[], out: rt.ByteVec): void { let len!: rt.usize; - seed = copy$array_u32(seed); if (coll === 0) { len = rt.iterToArray(items, "next", 1100).length; } else if (coll === 1) { @@ -2690,19 +2687,19 @@ export function fill$array275_u32_iter_Map_iter_Flatten_array_IntoIter_ops_Range rt.iterExtend(v, items, "next", 1100); len = v.length; } else if (coll === 2) { - const v2: rt.u32[][] = rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32); + const v2: rt.u32[][] = rt.vecFromElem(seed, 2, undefined); rt.iterExtend(v2, items, "next", 1100); len = v2.length; } else if (coll === 3) { len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 1100), 1100) as rt.VecDeque)).n; } else if (coll === 4) { - const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32), 1100) as rt.VecDeque; + const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(seed, 2, undefined), 1100) as rt.VecDeque; rt.dequeExtend(q, items, "next"); len = q.n; } else if (coll === 5) { len = rt.heapFrom(rt.iterToArray(items, "next", 1100), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))); + const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(seed, 2, undefined), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))); rt.heapExtend(h, items, rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp)), "next", 1100); len = h.d.length; } else if (coll === 7) { @@ -2752,7 +2749,6 @@ export function fill$array275_u32_iter_Map_iter_Flatten_array_IntoIter_ops_Range /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ export function fill$array275_u32_iter_Map_iter_Flatten_array_IntoIter_ops_RangeInclusive_u32_3_hints_typed_closure1_array275_u32_hints_reserves_closure5(coll: rt.u8, items: rt.Iter, seed: rt.u32[], out: rt.ByteVec): void { let len!: rt.usize; - seed = copy$array_u32(seed); if (coll === 0) { len = rt.iterToArray(items, "next", 1100).length; } else if (coll === 1) { @@ -2760,19 +2756,19 @@ export function fill$array275_u32_iter_Map_iter_Flatten_array_IntoIter_ops_Range rt.iterExtend(v, items, "next", 1100); len = v.length; } else if (coll === 2) { - const v2: rt.u32[][] = rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32); + const v2: rt.u32[][] = rt.vecFromElem(seed, 2, undefined); rt.iterExtend(v2, items, "next", 1100); len = v2.length; } else if (coll === 3) { len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 1100), 1100) as rt.VecDeque)).n; } else if (coll === 4) { - const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32), 1100) as rt.VecDeque; + const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(seed, 2, undefined), 1100) as rt.VecDeque; rt.dequeExtend(q, items, "next"); len = q.n; } else if (coll === 5) { len = rt.heapFrom(rt.iterToArray(items, "next", 1100), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))); + const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(seed, 2, undefined), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))); rt.heapExtend(h, items, rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp)), "next", 1100); len = h.d.length; } else if (coll === 7) { @@ -2822,7 +2818,6 @@ export function fill$array275_u32_iter_Map_iter_Flatten_array_IntoIter_ops_Range /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ export function fill$array275_u32_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_array275_u32_hints_reserves_closure5(coll: rt.u8, items: rt.Iter, seed: rt.u32[], out: rt.ByteVec): void { let len!: rt.usize; - seed = copy$array_u32(seed); if (coll === 0) { len = rt.iterToArray(items, undefined, 1100, true).length; } else if (coll === 1) { @@ -2830,19 +2825,19 @@ export function fill$array275_u32_iter_Map_ops_RangeInclusive_u32_hints_typed_cl rt.iterExtend(v, items, undefined, 1100, true); len = v.length; } else if (coll === 2) { - const v2: rt.u32[][] = rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32); + const v2: rt.u32[][] = rt.vecFromElem(seed, 2, undefined); rt.iterExtend(v2, items, undefined, 1100, true); len = v2.length; } else if (coll === 3) { len = ((rt.dequeFromVec(rt.iterToArray(items, undefined, 1100, true), 1100) as rt.VecDeque)).n; } else if (coll === 4) { - const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32), 1100) as rt.VecDeque; + const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(seed, 2, undefined), 1100) as rt.VecDeque; rt.dequeExtend(q, items, undefined, true); len = q.n; } else if (coll === 5) { len = rt.heapFrom(rt.iterToArray(items, undefined, 1100, true), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))); + const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(seed, 2, undefined), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))); rt.heapExtend(h, items, rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp)), undefined, 1100, true); len = h.d.length; } else if (coll === 7) { @@ -2892,7 +2887,6 @@ export function fill$array275_u32_iter_Map_ops_RangeInclusive_u32_hints_typed_cl /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ export function fill$array275_u32_iter_Skip_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_array275_u32_hints_reserves_closure5(coll: rt.u8, items: rt.Iter, seed: rt.u32[], out: rt.ByteVec): void { let len!: rt.usize; - seed = copy$array_u32(seed); if (coll === 0) { len = rt.iterToArray(items, "next", 1100).length; } else if (coll === 1) { @@ -2900,19 +2894,19 @@ export function fill$array275_u32_iter_Skip_iter_Map_ops_RangeInclusive_u32_hint rt.iterExtend(v, items, "next", 1100); len = v.length; } else if (coll === 2) { - const v2: rt.u32[][] = rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32); + const v2: rt.u32[][] = rt.vecFromElem(seed, 2, undefined); rt.iterExtend(v2, items, "next", 1100); len = v2.length; } else if (coll === 3) { len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 1100), 1100) as rt.VecDeque)).n; } else if (coll === 4) { - const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32), 1100) as rt.VecDeque; + const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(seed, 2, undefined), 1100) as rt.VecDeque; rt.dequeExtend(q, items, "next"); len = q.n; } else if (coll === 5) { len = rt.heapFrom(rt.iterToArray(items, "next", 1100), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(copy$array_u32(copy$array_u32(seed)), 2, copy$array_u32), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))); + const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(seed, 2, undefined), rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp))); rt.heapExtend(h, items, rt.cmpLe(rt.cmpSlice(rt.cmp)), rt.cmpGe(rt.cmpSlice(rt.cmp)), rt.cmpLt(rt.cmpSlice(rt.cmp)), "next", 1100); len = h.d.length; } else if (coll === 7) { @@ -2960,65 +2954,65 @@ export function fill$array275_u32_iter_Skip_iter_Map_ops_RangeInclusive_u32_hint } /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ -export function fill$hints_Unit_iter_Filter_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_hints_Unit_hints_reserves_closure4_hints_typed_closure2_hints_Unit_hints_reserves_closure4(coll: rt.u8, items: rt.Iter, seed: hints_Unit.Unit, out: rt.ByteVec): void { +export function fill$hints_Unit_iter_Filter_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_hints_Unit_hints_reserves_closure4_hints_typed_closure2_hints_Unit_hints_reserves_closure4(coll: rt.u8, items: rt.Iter, seed: Unit.Unit, out: rt.ByteVec): void { let len!: rt.usize; if (coll === 0) { len = rt.iterToArray(items, "next", 0).length; } else if (coll === 1) { - const v: hints_Unit.Unit[] = []; + const v: Unit.Unit[] = []; rt.iterExtend(v, items, "next", 0); len = v.length; } else if (coll === 2) { - const v2: hints_Unit.Unit[] = rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone); + const v2: Unit.Unit[] = rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone); rt.iterExtend(v2, items, "next", 0); len = v2.length; } else if (coll === 3) { - len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 0), 0) as rt.VecDeque)).n; + len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 0), 0) as rt.VecDeque)).n; } else if (coll === 4) { - const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone), 0) as rt.VecDeque; + const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone), 0) as rt.VecDeque; rt.dequeExtend(q, items, "next"); len = q.n; } else if (coll === 5) { - len = rt.heapFrom(rt.iterToArray(items, "next", 0), rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd)).d.length; + len = rt.heapFrom(rt.iterToArray(items, "next", 0), rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd)).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone), rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd)); - rt.heapExtend(h, items, rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd), "next", 0); + const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone), rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd)); + rt.heapExtend(h, items, rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd), "next", 0); len = h.d.length; } else if (coll === 7) { - len = rt.btreeLen(rt.btreeExtendKeys(rt.btreeNew(hints_Unit.cmp$cmp_Ord) as rt.BTreeSet, items, true, undefined, "next", 0)); + len = rt.btreeLen(rt.btreeExtendKeys(rt.btreeNew(Unit.cmp$cmp_Ord) as rt.BTreeSet, items, true, undefined, "next", 0)); } else if (coll === 8) { - len = rt.hashLen(rt.hashExtendKeys(rt.hashNew(rt.hashing(hints_Unit.hash$Hash_hash_DefaultHasher as (a0: hints_Unit.Unit, a1: rt.Hasher) => undefined, hints_Unit.eq$cmp_PartialEq)) as rt.HashSet, items, undefined, undefined, 536870911)); + len = rt.hashLen(rt.hashExtendKeys(rt.hashNew(rt.hashing(Unit.hash$Hash_hash_DefaultHasher as (a0: Unit.Unit, a1: rt.Hasher) => undefined, Unit.eq$cmp_PartialEq)) as rt.HashSet, items, undefined, undefined, 536870911)); } else if (coll === 9) { - const _41: [hints_Unit.Unit, rt.u32][] = [[seed, 0] as [hints_Unit.Unit, rt.u32]]; - const m: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(hints_Unit.hash$Hash_hash_DefaultHasher as (a0: hints_Unit.Unit, a1: rt.Hasher) => undefined, hints_Unit.eq$cmp_PartialEq)) as rt.HashMap, rt.iterSlice(_41), undefined, undefined, undefined, 234881024); - const _46: rt.Iter<[hints_Unit.Unit, rt.u32]> = rt.iterMap(items, (t3: hints_Unit.Unit): [hints_Unit.Unit, rt.u32] => { - return [t3, 1] as [hints_Unit.Unit, rt.u32]; + const _41: [Unit.Unit, rt.u32][] = [[seed, 0] as [Unit.Unit, rt.u32]]; + const m: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(Unit.hash$Hash_hash_DefaultHasher as (a0: Unit.Unit, a1: rt.Hasher) => undefined, Unit.eq$cmp_PartialEq)) as rt.HashMap, rt.iterSlice(_41), undefined, undefined, undefined, 234881024); + const _46: rt.Iter<[Unit.Unit, rt.u32]> = rt.iterMap(items, (t3: Unit.Unit): [Unit.Unit, rt.u32] => { + return [t3, 1] as [Unit.Unit, rt.u32]; }); rt.hashExtend(m, _46, undefined, undefined, undefined, 234881024); len = rt.hashLen(m); } else if (coll === 10) { - const _50: rt.Iter<[hints_Unit.Unit, rt.u32]> = rt.iterMap(items, (t2: hints_Unit.Unit): [hints_Unit.Unit, rt.u32] => { - return [t2, 1] as [hints_Unit.Unit, rt.u32]; + const _50: rt.Iter<[Unit.Unit, rt.u32]> = rt.iterMap(items, (t2: Unit.Unit): [Unit.Unit, rt.u32] => { + return [t2, 1] as [Unit.Unit, rt.u32]; }); - len = rt.btreeLen(rt.btreeExtend(rt.btreeNew(hints_Unit.cmp$cmp_Ord) as rt.BTreeMap, _50, true, undefined, undefined, "next", 4)); + len = rt.btreeLen(rt.btreeExtend(rt.btreeNew(Unit.cmp$cmp_Ord) as rt.BTreeMap, _50, true, undefined, undefined, "next", 4)); } else if (coll === 11) { - len = option_mapOr$0r2th8w(rt.iterCollectOption(rt.iterMap(items, (a0: hints_Unit.Unit): hints_Unit.Unit | undefined => { + len = option_mapOr$0r2th8w(rt.iterCollectOption(rt.iterMap(items, (a0: Unit.Unit): Unit.Unit | undefined => { return a0; - }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)), 255, (v4: hints_Unit.Unit[]): rt.usize => { + }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)), 255, (v4: Unit.Unit[]): rt.usize => { return v4.length; }); } else { - const _53: rt.Result = rt.iterCollectResult(rt.iterMap(rt.iterEnumerate(items), (_2: [rt.usize, hints_Unit.Unit]): rt.Result => { - let _0!: rt.Result; + const _53: rt.Result = rt.iterCollectResult(rt.iterMap(rt.iterEnumerate(items), (_2: [rt.usize, Unit.Unit]): rt.Result => { + let _0!: rt.Result; const i2: rt.usize = _2[0]; - const t: hints_Unit.Unit = _2[1]; + const t: Unit.Unit = _2[1]; if (!(i2 < 3)) { _0 = rt.Err(i2); } else { _0 = rt.Ok(t); } return _0; - }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)); + }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)); if (_53.ok) { len = _53.value.length; } else { @@ -3029,65 +3023,65 @@ export function fill$hints_Unit_iter_Filter_iter_Map_ops_RangeInclusive_u32_hint } /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ -export function fill$hints_Unit_iter_Map_iter_Flatten_array_IntoIter_ops_RangeInclusive_u32_2_hints_typed_closure1_hints_Unit_hints_reserves_closure4(coll: rt.u8, items: rt.Iter, seed: hints_Unit.Unit, out: rt.ByteVec): void { +export function fill$hints_Unit_iter_Map_iter_Flatten_array_IntoIter_ops_RangeInclusive_u32_2_hints_typed_closure1_hints_Unit_hints_reserves_closure4(coll: rt.u8, items: rt.Iter, seed: Unit.Unit, out: rt.ByteVec): void { let len!: rt.usize; if (coll === 0) { len = rt.iterToArray(items, "next", 0).length; } else if (coll === 1) { - const v: hints_Unit.Unit[] = []; + const v: Unit.Unit[] = []; rt.iterExtend(v, items, "next", 0); len = v.length; } else if (coll === 2) { - const v2: hints_Unit.Unit[] = rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone); + const v2: Unit.Unit[] = rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone); rt.iterExtend(v2, items, "next", 0); len = v2.length; } else if (coll === 3) { - len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 0), 0) as rt.VecDeque)).n; + len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 0), 0) as rt.VecDeque)).n; } else if (coll === 4) { - const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone), 0) as rt.VecDeque; + const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone), 0) as rt.VecDeque; rt.dequeExtend(q, items, "next"); len = q.n; } else if (coll === 5) { - len = rt.heapFrom(rt.iterToArray(items, "next", 0), rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd)).d.length; + len = rt.heapFrom(rt.iterToArray(items, "next", 0), rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd)).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone), rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd)); - rt.heapExtend(h, items, rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd), "next", 0); + const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone), rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd)); + rt.heapExtend(h, items, rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd), "next", 0); len = h.d.length; } else if (coll === 7) { - len = rt.btreeLen(rt.btreeExtendKeys(rt.btreeNew(hints_Unit.cmp$cmp_Ord) as rt.BTreeSet, items, true, undefined, "next", 0)); + len = rt.btreeLen(rt.btreeExtendKeys(rt.btreeNew(Unit.cmp$cmp_Ord) as rt.BTreeSet, items, true, undefined, "next", 0)); } else if (coll === 8) { - len = rt.hashLen(rt.hashExtendKeys(rt.hashNew(rt.hashing(hints_Unit.hash$Hash_hash_DefaultHasher as (a0: hints_Unit.Unit, a1: rt.Hasher) => undefined, hints_Unit.eq$cmp_PartialEq)) as rt.HashSet, items, undefined, undefined, 536870911)); + len = rt.hashLen(rt.hashExtendKeys(rt.hashNew(rt.hashing(Unit.hash$Hash_hash_DefaultHasher as (a0: Unit.Unit, a1: rt.Hasher) => undefined, Unit.eq$cmp_PartialEq)) as rt.HashSet, items, undefined, undefined, 536870911)); } else if (coll === 9) { - const _41: [hints_Unit.Unit, rt.u32][] = [[seed, 0] as [hints_Unit.Unit, rt.u32]]; - const m: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(hints_Unit.hash$Hash_hash_DefaultHasher as (a0: hints_Unit.Unit, a1: rt.Hasher) => undefined, hints_Unit.eq$cmp_PartialEq)) as rt.HashMap, rt.iterSlice(_41), undefined, undefined, undefined, 234881024); - const _46: rt.Iter<[hints_Unit.Unit, rt.u32]> = rt.iterMap(items, (t3: hints_Unit.Unit): [hints_Unit.Unit, rt.u32] => { - return [t3, 1] as [hints_Unit.Unit, rt.u32]; + const _41: [Unit.Unit, rt.u32][] = [[seed, 0] as [Unit.Unit, rt.u32]]; + const m: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(Unit.hash$Hash_hash_DefaultHasher as (a0: Unit.Unit, a1: rt.Hasher) => undefined, Unit.eq$cmp_PartialEq)) as rt.HashMap, rt.iterSlice(_41), undefined, undefined, undefined, 234881024); + const _46: rt.Iter<[Unit.Unit, rt.u32]> = rt.iterMap(items, (t3: Unit.Unit): [Unit.Unit, rt.u32] => { + return [t3, 1] as [Unit.Unit, rt.u32]; }); rt.hashExtend(m, _46, undefined, undefined, undefined, 234881024); len = rt.hashLen(m); } else if (coll === 10) { - const _50: rt.Iter<[hints_Unit.Unit, rt.u32]> = rt.iterMap(items, (t2: hints_Unit.Unit): [hints_Unit.Unit, rt.u32] => { - return [t2, 1] as [hints_Unit.Unit, rt.u32]; + const _50: rt.Iter<[Unit.Unit, rt.u32]> = rt.iterMap(items, (t2: Unit.Unit): [Unit.Unit, rt.u32] => { + return [t2, 1] as [Unit.Unit, rt.u32]; }); - len = rt.btreeLen(rt.btreeExtend(rt.btreeNew(hints_Unit.cmp$cmp_Ord) as rt.BTreeMap, _50, true, undefined, undefined, "next", 4)); + len = rt.btreeLen(rt.btreeExtend(rt.btreeNew(Unit.cmp$cmp_Ord) as rt.BTreeMap, _50, true, undefined, undefined, "next", 4)); } else if (coll === 11) { - len = option_mapOr$0r2th8w(rt.iterCollectOption(rt.iterMap(items, (a0: hints_Unit.Unit): hints_Unit.Unit | undefined => { + len = option_mapOr$0r2th8w(rt.iterCollectOption(rt.iterMap(items, (a0: Unit.Unit): Unit.Unit | undefined => { return a0; - }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)), 255, (v4: hints_Unit.Unit[]): rt.usize => { + }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)), 255, (v4: Unit.Unit[]): rt.usize => { return v4.length; }); } else { - const _53: rt.Result = rt.iterCollectResult(rt.iterMap(rt.iterEnumerate(items), (_2: [rt.usize, hints_Unit.Unit]): rt.Result => { - let _0!: rt.Result; + const _53: rt.Result = rt.iterCollectResult(rt.iterMap(rt.iterEnumerate(items), (_2: [rt.usize, Unit.Unit]): rt.Result => { + let _0!: rt.Result; const i2: rt.usize = _2[0]; - const t: hints_Unit.Unit = _2[1]; + const t: Unit.Unit = _2[1]; if (!(i2 < 3)) { _0 = rt.Err(i2); } else { _0 = rt.Ok(t); } return _0; - }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)); + }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)); if (_53.ok) { len = _53.value.length; } else { @@ -3098,65 +3092,65 @@ export function fill$hints_Unit_iter_Map_iter_Flatten_array_IntoIter_ops_RangeIn } /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ -export function fill$hints_Unit_iter_Map_iter_Flatten_array_IntoIter_ops_RangeInclusive_u32_3_hints_typed_closure1_hints_Unit_hints_reserves_closure4(coll: rt.u8, items: rt.Iter, seed: hints_Unit.Unit, out: rt.ByteVec): void { +export function fill$hints_Unit_iter_Map_iter_Flatten_array_IntoIter_ops_RangeInclusive_u32_3_hints_typed_closure1_hints_Unit_hints_reserves_closure4(coll: rt.u8, items: rt.Iter, seed: Unit.Unit, out: rt.ByteVec): void { let len!: rt.usize; if (coll === 0) { len = rt.iterToArray(items, "next", 0).length; } else if (coll === 1) { - const v: hints_Unit.Unit[] = []; + const v: Unit.Unit[] = []; rt.iterExtend(v, items, "next", 0); len = v.length; } else if (coll === 2) { - const v2: hints_Unit.Unit[] = rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone); + const v2: Unit.Unit[] = rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone); rt.iterExtend(v2, items, "next", 0); len = v2.length; } else if (coll === 3) { - len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 0), 0) as rt.VecDeque)).n; + len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 0), 0) as rt.VecDeque)).n; } else if (coll === 4) { - const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone), 0) as rt.VecDeque; + const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone), 0) as rt.VecDeque; rt.dequeExtend(q, items, "next"); len = q.n; } else if (coll === 5) { - len = rt.heapFrom(rt.iterToArray(items, "next", 0), rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd)).d.length; + len = rt.heapFrom(rt.iterToArray(items, "next", 0), rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd)).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone), rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd)); - rt.heapExtend(h, items, rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd), "next", 0); + const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone), rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd)); + rt.heapExtend(h, items, rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd), "next", 0); len = h.d.length; } else if (coll === 7) { - len = rt.btreeLen(rt.btreeExtendKeys(rt.btreeNew(hints_Unit.cmp$cmp_Ord) as rt.BTreeSet, items, true, undefined, "next", 0)); + len = rt.btreeLen(rt.btreeExtendKeys(rt.btreeNew(Unit.cmp$cmp_Ord) as rt.BTreeSet, items, true, undefined, "next", 0)); } else if (coll === 8) { - len = rt.hashLen(rt.hashExtendKeys(rt.hashNew(rt.hashing(hints_Unit.hash$Hash_hash_DefaultHasher as (a0: hints_Unit.Unit, a1: rt.Hasher) => undefined, hints_Unit.eq$cmp_PartialEq)) as rt.HashSet, items, undefined, undefined, 536870911)); + len = rt.hashLen(rt.hashExtendKeys(rt.hashNew(rt.hashing(Unit.hash$Hash_hash_DefaultHasher as (a0: Unit.Unit, a1: rt.Hasher) => undefined, Unit.eq$cmp_PartialEq)) as rt.HashSet, items, undefined, undefined, 536870911)); } else if (coll === 9) { - const _41: [hints_Unit.Unit, rt.u32][] = [[seed, 0] as [hints_Unit.Unit, rt.u32]]; - const m: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(hints_Unit.hash$Hash_hash_DefaultHasher as (a0: hints_Unit.Unit, a1: rt.Hasher) => undefined, hints_Unit.eq$cmp_PartialEq)) as rt.HashMap, rt.iterSlice(_41), undefined, undefined, undefined, 234881024); - const _46: rt.Iter<[hints_Unit.Unit, rt.u32]> = rt.iterMap(items, (t3: hints_Unit.Unit): [hints_Unit.Unit, rt.u32] => { - return [t3, 1] as [hints_Unit.Unit, rt.u32]; + const _41: [Unit.Unit, rt.u32][] = [[seed, 0] as [Unit.Unit, rt.u32]]; + const m: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(Unit.hash$Hash_hash_DefaultHasher as (a0: Unit.Unit, a1: rt.Hasher) => undefined, Unit.eq$cmp_PartialEq)) as rt.HashMap, rt.iterSlice(_41), undefined, undefined, undefined, 234881024); + const _46: rt.Iter<[Unit.Unit, rt.u32]> = rt.iterMap(items, (t3: Unit.Unit): [Unit.Unit, rt.u32] => { + return [t3, 1] as [Unit.Unit, rt.u32]; }); rt.hashExtend(m, _46, undefined, undefined, undefined, 234881024); len = rt.hashLen(m); } else if (coll === 10) { - const _50: rt.Iter<[hints_Unit.Unit, rt.u32]> = rt.iterMap(items, (t2: hints_Unit.Unit): [hints_Unit.Unit, rt.u32] => { - return [t2, 1] as [hints_Unit.Unit, rt.u32]; + const _50: rt.Iter<[Unit.Unit, rt.u32]> = rt.iterMap(items, (t2: Unit.Unit): [Unit.Unit, rt.u32] => { + return [t2, 1] as [Unit.Unit, rt.u32]; }); - len = rt.btreeLen(rt.btreeExtend(rt.btreeNew(hints_Unit.cmp$cmp_Ord) as rt.BTreeMap, _50, true, undefined, undefined, "next", 4)); + len = rt.btreeLen(rt.btreeExtend(rt.btreeNew(Unit.cmp$cmp_Ord) as rt.BTreeMap, _50, true, undefined, undefined, "next", 4)); } else if (coll === 11) { - len = option_mapOr$0r2th8w(rt.iterCollectOption(rt.iterMap(items, (a0: hints_Unit.Unit): hints_Unit.Unit | undefined => { + len = option_mapOr$0r2th8w(rt.iterCollectOption(rt.iterMap(items, (a0: Unit.Unit): Unit.Unit | undefined => { return a0; - }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)), 255, (v4: hints_Unit.Unit[]): rt.usize => { + }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)), 255, (v4: Unit.Unit[]): rt.usize => { return v4.length; }); } else { - const _53: rt.Result = rt.iterCollectResult(rt.iterMap(rt.iterEnumerate(items), (_2: [rt.usize, hints_Unit.Unit]): rt.Result => { - let _0!: rt.Result; + const _53: rt.Result = rt.iterCollectResult(rt.iterMap(rt.iterEnumerate(items), (_2: [rt.usize, Unit.Unit]): rt.Result => { + let _0!: rt.Result; const i2: rt.usize = _2[0]; - const t: hints_Unit.Unit = _2[1]; + const t: Unit.Unit = _2[1]; if (!(i2 < 3)) { _0 = rt.Err(i2); } else { _0 = rt.Ok(t); } return _0; - }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)); + }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)); if (_53.ok) { len = _53.value.length; } else { @@ -3167,65 +3161,65 @@ export function fill$hints_Unit_iter_Map_iter_Flatten_array_IntoIter_ops_RangeIn } /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ -export function fill$hints_Unit_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_hints_Unit_hints_reserves_closure4(coll: rt.u8, items: rt.Iter, seed: hints_Unit.Unit, out: rt.ByteVec): void { +export function fill$hints_Unit_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_hints_Unit_hints_reserves_closure4(coll: rt.u8, items: rt.Iter, seed: Unit.Unit, out: rt.ByteVec): void { let len!: rt.usize; if (coll === 0) { len = rt.iterToArray(items, undefined, 0, true).length; } else if (coll === 1) { - const v: hints_Unit.Unit[] = []; + const v: Unit.Unit[] = []; rt.iterExtend(v, items, undefined, 0, true); len = v.length; } else if (coll === 2) { - const v2: hints_Unit.Unit[] = rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone); + const v2: Unit.Unit[] = rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone); rt.iterExtend(v2, items, undefined, 0, true); len = v2.length; } else if (coll === 3) { - len = ((rt.dequeFromVec(rt.iterToArray(items, undefined, 0, true), 0) as rt.VecDeque)).n; + len = ((rt.dequeFromVec(rt.iterToArray(items, undefined, 0, true), 0) as rt.VecDeque)).n; } else if (coll === 4) { - const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone), 0) as rt.VecDeque; + const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone), 0) as rt.VecDeque; rt.dequeExtend(q, items, undefined, true); len = q.n; } else if (coll === 5) { - len = rt.heapFrom(rt.iterToArray(items, undefined, 0, true), rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd)).d.length; + len = rt.heapFrom(rt.iterToArray(items, undefined, 0, true), rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd)).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone), rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd)); - rt.heapExtend(h, items, rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd), undefined, 0, true); + const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone), rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd)); + rt.heapExtend(h, items, rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd), undefined, 0, true); len = h.d.length; } else if (coll === 7) { - len = rt.btreeLen(rt.btreeExtendKeys(rt.btreeNew(hints_Unit.cmp$cmp_Ord) as rt.BTreeSet, items, true, undefined, undefined, 0, true)); + len = rt.btreeLen(rt.btreeExtendKeys(rt.btreeNew(Unit.cmp$cmp_Ord) as rt.BTreeSet, items, true, undefined, undefined, 0, true)); } else if (coll === 8) { - len = rt.hashLen(rt.hashExtendKeys(rt.hashNew(rt.hashing(hints_Unit.hash$Hash_hash_DefaultHasher as (a0: hints_Unit.Unit, a1: rt.Hasher) => undefined, hints_Unit.eq$cmp_PartialEq)) as rt.HashSet, items, undefined, undefined, 536870911)); + len = rt.hashLen(rt.hashExtendKeys(rt.hashNew(rt.hashing(Unit.hash$Hash_hash_DefaultHasher as (a0: Unit.Unit, a1: rt.Hasher) => undefined, Unit.eq$cmp_PartialEq)) as rt.HashSet, items, undefined, undefined, 536870911)); } else if (coll === 9) { - const _41: [hints_Unit.Unit, rt.u32][] = [[seed, 0] as [hints_Unit.Unit, rt.u32]]; - const m: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(hints_Unit.hash$Hash_hash_DefaultHasher as (a0: hints_Unit.Unit, a1: rt.Hasher) => undefined, hints_Unit.eq$cmp_PartialEq)) as rt.HashMap, rt.iterSlice(_41), undefined, undefined, undefined, 234881024); - const _46: rt.Iter<[hints_Unit.Unit, rt.u32]> = rt.iterMap(items, (t3: hints_Unit.Unit): [hints_Unit.Unit, rt.u32] => { - return [t3, 1] as [hints_Unit.Unit, rt.u32]; + const _41: [Unit.Unit, rt.u32][] = [[seed, 0] as [Unit.Unit, rt.u32]]; + const m: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(Unit.hash$Hash_hash_DefaultHasher as (a0: Unit.Unit, a1: rt.Hasher) => undefined, Unit.eq$cmp_PartialEq)) as rt.HashMap, rt.iterSlice(_41), undefined, undefined, undefined, 234881024); + const _46: rt.Iter<[Unit.Unit, rt.u32]> = rt.iterMap(items, (t3: Unit.Unit): [Unit.Unit, rt.u32] => { + return [t3, 1] as [Unit.Unit, rt.u32]; }); rt.hashExtend(m, _46, undefined, undefined, undefined, 234881024); len = rt.hashLen(m); } else if (coll === 10) { - const _50: rt.Iter<[hints_Unit.Unit, rt.u32]> = rt.iterMap(items, (t2: hints_Unit.Unit): [hints_Unit.Unit, rt.u32] => { - return [t2, 1] as [hints_Unit.Unit, rt.u32]; + const _50: rt.Iter<[Unit.Unit, rt.u32]> = rt.iterMap(items, (t2: Unit.Unit): [Unit.Unit, rt.u32] => { + return [t2, 1] as [Unit.Unit, rt.u32]; }); - len = rt.btreeLen(rt.btreeExtend(rt.btreeNew(hints_Unit.cmp$cmp_Ord) as rt.BTreeMap, _50, true, undefined, undefined, undefined, 4, true)); + len = rt.btreeLen(rt.btreeExtend(rt.btreeNew(Unit.cmp$cmp_Ord) as rt.BTreeMap, _50, true, undefined, undefined, undefined, 4, true)); } else if (coll === 11) { - len = option_mapOr$0r2th8w(rt.iterCollectOption(rt.iterMap(items, (a0: hints_Unit.Unit): hints_Unit.Unit | undefined => { + len = option_mapOr$0r2th8w(rt.iterCollectOption(rt.iterMap(items, (a0: Unit.Unit): Unit.Unit | undefined => { return a0; - }), (values: rt.Iter) => rt.iterToArray(values, undefined, 0)), 255, (v4: hints_Unit.Unit[]): rt.usize => { + }), (values: rt.Iter) => rt.iterToArray(values, undefined, 0)), 255, (v4: Unit.Unit[]): rt.usize => { return v4.length; }); } else { - const _53: rt.Result = rt.iterCollectResult(rt.iterMap(rt.iterEnumerate(items), (_2: [rt.usize, hints_Unit.Unit]): rt.Result => { - let _0!: rt.Result; + const _53: rt.Result = rt.iterCollectResult(rt.iterMap(rt.iterEnumerate(items), (_2: [rt.usize, Unit.Unit]): rt.Result => { + let _0!: rt.Result; const i2: rt.usize = _2[0]; - const t: hints_Unit.Unit = _2[1]; + const t: Unit.Unit = _2[1]; if (!(i2 < 3)) { _0 = rt.Err(i2); } else { _0 = rt.Ok(t); } return _0; - }), (values: rt.Iter) => rt.iterToArray(values, undefined, 0)); + }), (values: rt.Iter) => rt.iterToArray(values, undefined, 0)); if (_53.ok) { len = _53.value.length; } else { @@ -3236,65 +3230,65 @@ export function fill$hints_Unit_iter_Map_ops_RangeInclusive_u32_hints_typed_clos } /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ -export function fill$hints_Unit_iter_Skip_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_hints_Unit_hints_reserves_closure4(coll: rt.u8, items: rt.Iter, seed: hints_Unit.Unit, out: rt.ByteVec): void { +export function fill$hints_Unit_iter_Skip_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_hints_Unit_hints_reserves_closure4(coll: rt.u8, items: rt.Iter, seed: Unit.Unit, out: rt.ByteVec): void { let len!: rt.usize; if (coll === 0) { len = rt.iterToArray(items, "next", 0).length; } else if (coll === 1) { - const v: hints_Unit.Unit[] = []; + const v: Unit.Unit[] = []; rt.iterExtend(v, items, "next", 0); len = v.length; } else if (coll === 2) { - const v2: hints_Unit.Unit[] = rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone); + const v2: Unit.Unit[] = rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone); rt.iterExtend(v2, items, "next", 0); len = v2.length; } else if (coll === 3) { - len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 0), 0) as rt.VecDeque)).n; + len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 0), 0) as rt.VecDeque)).n; } else if (coll === 4) { - const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone), 0) as rt.VecDeque; + const q: rt.VecDeque = rt.dequeFromVec(rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone), 0) as rt.VecDeque; rt.dequeExtend(q, items, "next"); len = q.n; } else if (coll === 5) { - len = rt.heapFrom(rt.iterToArray(items, "next", 0), rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd)).d.length; + len = rt.heapFrom(rt.iterToArray(items, "next", 0), rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd)).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(hints_Unit.clone$Clone(seed), 2, hints_Unit.clone$Clone), rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd)); - rt.heapExtend(h, items, rt.cmpLe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(hints_Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(hints_Unit.partialCmp$cmp_PartialOrd), "next", 0); + const h: rt.BinaryHeap = rt.heapFrom(rt.vecFromElem(Unit.clone$Clone(seed), 2, Unit.clone$Clone), rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd)); + rt.heapExtend(h, items, rt.cmpLe(Unit.partialCmp$cmp_PartialOrd), rt.cmpGe(Unit.partialCmp$cmp_PartialOrd), rt.cmpLt(Unit.partialCmp$cmp_PartialOrd), "next", 0); len = h.d.length; } else if (coll === 7) { - len = rt.btreeLen(rt.btreeExtendKeys(rt.btreeNew(hints_Unit.cmp$cmp_Ord) as rt.BTreeSet, items, true, undefined, "next", 0)); + len = rt.btreeLen(rt.btreeExtendKeys(rt.btreeNew(Unit.cmp$cmp_Ord) as rt.BTreeSet, items, true, undefined, "next", 0)); } else if (coll === 8) { - len = rt.hashLen(rt.hashExtendKeys(rt.hashNew(rt.hashing(hints_Unit.hash$Hash_hash_DefaultHasher as (a0: hints_Unit.Unit, a1: rt.Hasher) => undefined, hints_Unit.eq$cmp_PartialEq)) as rt.HashSet, items, undefined, undefined, 536870911)); + len = rt.hashLen(rt.hashExtendKeys(rt.hashNew(rt.hashing(Unit.hash$Hash_hash_DefaultHasher as (a0: Unit.Unit, a1: rt.Hasher) => undefined, Unit.eq$cmp_PartialEq)) as rt.HashSet, items, undefined, undefined, 536870911)); } else if (coll === 9) { - const _41: [hints_Unit.Unit, rt.u32][] = [[seed, 0] as [hints_Unit.Unit, rt.u32]]; - const m: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(hints_Unit.hash$Hash_hash_DefaultHasher as (a0: hints_Unit.Unit, a1: rt.Hasher) => undefined, hints_Unit.eq$cmp_PartialEq)) as rt.HashMap, rt.iterSlice(_41), undefined, undefined, undefined, 234881024); - const _46: rt.Iter<[hints_Unit.Unit, rt.u32]> = rt.iterMap(items, (t3: hints_Unit.Unit): [hints_Unit.Unit, rt.u32] => { - return [t3, 1] as [hints_Unit.Unit, rt.u32]; + const _41: [Unit.Unit, rt.u32][] = [[seed, 0] as [Unit.Unit, rt.u32]]; + const m: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(Unit.hash$Hash_hash_DefaultHasher as (a0: Unit.Unit, a1: rt.Hasher) => undefined, Unit.eq$cmp_PartialEq)) as rt.HashMap, rt.iterSlice(_41), undefined, undefined, undefined, 234881024); + const _46: rt.Iter<[Unit.Unit, rt.u32]> = rt.iterMap(items, (t3: Unit.Unit): [Unit.Unit, rt.u32] => { + return [t3, 1] as [Unit.Unit, rt.u32]; }); rt.hashExtend(m, _46, undefined, undefined, undefined, 234881024); len = rt.hashLen(m); } else if (coll === 10) { - const _50: rt.Iter<[hints_Unit.Unit, rt.u32]> = rt.iterMap(items, (t2: hints_Unit.Unit): [hints_Unit.Unit, rt.u32] => { - return [t2, 1] as [hints_Unit.Unit, rt.u32]; + const _50: rt.Iter<[Unit.Unit, rt.u32]> = rt.iterMap(items, (t2: Unit.Unit): [Unit.Unit, rt.u32] => { + return [t2, 1] as [Unit.Unit, rt.u32]; }); - len = rt.btreeLen(rt.btreeExtend(rt.btreeNew(hints_Unit.cmp$cmp_Ord) as rt.BTreeMap, _50, true, undefined, undefined, "next", 4)); + len = rt.btreeLen(rt.btreeExtend(rt.btreeNew(Unit.cmp$cmp_Ord) as rt.BTreeMap, _50, true, undefined, undefined, "next", 4)); } else if (coll === 11) { - len = option_mapOr$0r2th8w(rt.iterCollectOption(rt.iterMap(items, (a0: hints_Unit.Unit): hints_Unit.Unit | undefined => { + len = option_mapOr$0r2th8w(rt.iterCollectOption(rt.iterMap(items, (a0: Unit.Unit): Unit.Unit | undefined => { return a0; - }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)), 255, (v4: hints_Unit.Unit[]): rt.usize => { + }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)), 255, (v4: Unit.Unit[]): rt.usize => { return v4.length; }); } else { - const _53: rt.Result = rt.iterCollectResult(rt.iterMap(rt.iterEnumerate(items), (_2: [rt.usize, hints_Unit.Unit]): rt.Result => { - let _0!: rt.Result; + const _53: rt.Result = rt.iterCollectResult(rt.iterMap(rt.iterEnumerate(items), (_2: [rt.usize, Unit.Unit]): rt.Result => { + let _0!: rt.Result; const i2: rt.usize = _2[0]; - const t: hints_Unit.Unit = _2[1]; + const t: Unit.Unit = _2[1]; if (!(i2 < 3)) { _0 = rt.Err(i2); } else { _0 = rt.Ok(t); } return _0; - }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)); + }), (values: rt.Iter) => rt.iterToArray(values, "next", 0)); if (_53.ok) { len = _53.value.length; } else { @@ -3307,7 +3301,6 @@ export function fill$hints_Unit_iter_Skip_iter_Map_ops_RangeInclusive_u32_hints_ /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ export function fill$tuple2_u64_u8_iter_Filter_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_tuple2_u64_u8_hints_reserves_closure3_hints_typed_closure2_tuple2_u64_u8_hints_reserves_closure3(coll: rt.u8, items: rt.Iter<[rt.u64, rt.u8]>, seed: [rt.u64, rt.u8], out: rt.ByteVec): void { let len!: rt.usize; - seed = copy$tuple2_u64_u8(seed); if (coll === 0) { len = rt.iterToArray(items, "next", 16).length; } else if (coll === 1) { @@ -3315,19 +3308,19 @@ export function fill$tuple2_u64_u8_iter_Filter_iter_Map_ops_RangeInclusive_u32_h rt.iterExtend(v, items, "next", 16); len = v.length; } else if (coll === 2) { - const v2: [rt.u64, rt.u8][] = rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8); + const v2: [rt.u64, rt.u8][] = rt.vecFromElem(seed, 2, undefined); rt.iterExtend(v2, items, "next", 16); len = v2.length; } else if (coll === 3) { len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 16), 16) as rt.VecDeque<[rt.u64, rt.u8]>)).n; } else if (coll === 4) { - const q: rt.VecDeque<[rt.u64, rt.u8]> = rt.dequeFromVec(rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8), 16) as rt.VecDeque<[rt.u64, rt.u8]>; + const q: rt.VecDeque<[rt.u64, rt.u8]> = rt.dequeFromVec(rt.vecFromElem(seed, 2, undefined), 16) as rt.VecDeque<[rt.u64, rt.u8]>; rt.dequeExtend(q, items, "next"); len = q.n; } else if (coll === 5) { len = rt.heapFrom(rt.iterToArray(items, "next", 16), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap<[rt.u64, rt.u8]> = rt.heapFrom(rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))); + const h: rt.BinaryHeap<[rt.u64, rt.u8]> = rt.heapFrom(rt.vecFromElem(seed, 2, undefined), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))); rt.heapExtend(h, items, rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), "next", 16); len = h.d.length; } else if (coll === 7) { @@ -3377,7 +3370,6 @@ export function fill$tuple2_u64_u8_iter_Filter_iter_Map_ops_RangeInclusive_u32_h /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ export function fill$tuple2_u64_u8_iter_Map_iter_Flatten_array_IntoIter_ops_RangeInclusive_u32_2_hints_typed_closure1_tuple2_u64_u8_hints_reserves_closure3(coll: rt.u8, items: rt.Iter<[rt.u64, rt.u8]>, seed: [rt.u64, rt.u8], out: rt.ByteVec): void { let len!: rt.usize; - seed = copy$tuple2_u64_u8(seed); if (coll === 0) { len = rt.iterToArray(items, "next", 16).length; } else if (coll === 1) { @@ -3385,19 +3377,19 @@ export function fill$tuple2_u64_u8_iter_Map_iter_Flatten_array_IntoIter_ops_Rang rt.iterExtend(v, items, "next", 16); len = v.length; } else if (coll === 2) { - const v2: [rt.u64, rt.u8][] = rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8); + const v2: [rt.u64, rt.u8][] = rt.vecFromElem(seed, 2, undefined); rt.iterExtend(v2, items, "next", 16); len = v2.length; } else if (coll === 3) { len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 16), 16) as rt.VecDeque<[rt.u64, rt.u8]>)).n; } else if (coll === 4) { - const q: rt.VecDeque<[rt.u64, rt.u8]> = rt.dequeFromVec(rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8), 16) as rt.VecDeque<[rt.u64, rt.u8]>; + const q: rt.VecDeque<[rt.u64, rt.u8]> = rt.dequeFromVec(rt.vecFromElem(seed, 2, undefined), 16) as rt.VecDeque<[rt.u64, rt.u8]>; rt.dequeExtend(q, items, "next"); len = q.n; } else if (coll === 5) { len = rt.heapFrom(rt.iterToArray(items, "next", 16), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap<[rt.u64, rt.u8]> = rt.heapFrom(rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))); + const h: rt.BinaryHeap<[rt.u64, rt.u8]> = rt.heapFrom(rt.vecFromElem(seed, 2, undefined), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))); rt.heapExtend(h, items, rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), "next", 16); len = h.d.length; } else if (coll === 7) { @@ -3447,7 +3439,6 @@ export function fill$tuple2_u64_u8_iter_Map_iter_Flatten_array_IntoIter_ops_Rang /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ export function fill$tuple2_u64_u8_iter_Map_iter_Flatten_array_IntoIter_ops_RangeInclusive_u32_3_hints_typed_closure1_tuple2_u64_u8_hints_reserves_closure3(coll: rt.u8, items: rt.Iter<[rt.u64, rt.u8]>, seed: [rt.u64, rt.u8], out: rt.ByteVec): void { let len!: rt.usize; - seed = copy$tuple2_u64_u8(seed); if (coll === 0) { len = rt.iterToArray(items, "next", 16).length; } else if (coll === 1) { @@ -3455,19 +3446,19 @@ export function fill$tuple2_u64_u8_iter_Map_iter_Flatten_array_IntoIter_ops_Rang rt.iterExtend(v, items, "next", 16); len = v.length; } else if (coll === 2) { - const v2: [rt.u64, rt.u8][] = rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8); + const v2: [rt.u64, rt.u8][] = rt.vecFromElem(seed, 2, undefined); rt.iterExtend(v2, items, "next", 16); len = v2.length; } else if (coll === 3) { len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 16), 16) as rt.VecDeque<[rt.u64, rt.u8]>)).n; } else if (coll === 4) { - const q: rt.VecDeque<[rt.u64, rt.u8]> = rt.dequeFromVec(rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8), 16) as rt.VecDeque<[rt.u64, rt.u8]>; + const q: rt.VecDeque<[rt.u64, rt.u8]> = rt.dequeFromVec(rt.vecFromElem(seed, 2, undefined), 16) as rt.VecDeque<[rt.u64, rt.u8]>; rt.dequeExtend(q, items, "next"); len = q.n; } else if (coll === 5) { len = rt.heapFrom(rt.iterToArray(items, "next", 16), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap<[rt.u64, rt.u8]> = rt.heapFrom(rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))); + const h: rt.BinaryHeap<[rt.u64, rt.u8]> = rt.heapFrom(rt.vecFromElem(seed, 2, undefined), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))); rt.heapExtend(h, items, rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), "next", 16); len = h.d.length; } else if (coll === 7) { @@ -3517,7 +3508,6 @@ export function fill$tuple2_u64_u8_iter_Map_iter_Flatten_array_IntoIter_ops_Rang /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ export function fill$tuple2_u64_u8_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_tuple2_u64_u8_hints_reserves_closure3(coll: rt.u8, items: rt.Iter<[rt.u64, rt.u8]>, seed: [rt.u64, rt.u8], out: rt.ByteVec): void { let len!: rt.usize; - seed = copy$tuple2_u64_u8(seed); if (coll === 0) { len = rt.iterToArray(items, undefined, 16, true).length; } else if (coll === 1) { @@ -3525,19 +3515,19 @@ export function fill$tuple2_u64_u8_iter_Map_ops_RangeInclusive_u32_hints_typed_c rt.iterExtend(v, items, undefined, 16, true); len = v.length; } else if (coll === 2) { - const v2: [rt.u64, rt.u8][] = rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8); + const v2: [rt.u64, rt.u8][] = rt.vecFromElem(seed, 2, undefined); rt.iterExtend(v2, items, undefined, 16, true); len = v2.length; } else if (coll === 3) { len = ((rt.dequeFromVec(rt.iterToArray(items, undefined, 16, true), 16) as rt.VecDeque<[rt.u64, rt.u8]>)).n; } else if (coll === 4) { - const q: rt.VecDeque<[rt.u64, rt.u8]> = rt.dequeFromVec(rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8), 16) as rt.VecDeque<[rt.u64, rt.u8]>; + const q: rt.VecDeque<[rt.u64, rt.u8]> = rt.dequeFromVec(rt.vecFromElem(seed, 2, undefined), 16) as rt.VecDeque<[rt.u64, rt.u8]>; rt.dequeExtend(q, items, undefined, true); len = q.n; } else if (coll === 5) { len = rt.heapFrom(rt.iterToArray(items, undefined, 16, true), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap<[rt.u64, rt.u8]> = rt.heapFrom(rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))); + const h: rt.BinaryHeap<[rt.u64, rt.u8]> = rt.heapFrom(rt.vecFromElem(seed, 2, undefined), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))); rt.heapExtend(h, items, rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), undefined, 16, true); len = h.d.length; } else if (coll === 7) { @@ -3587,7 +3577,6 @@ export function fill$tuple2_u64_u8_iter_Map_ops_RangeInclusive_u32_hints_typed_c /** `items` collected into the collection `coll` picks, or extended into one holding `seed`. */ export function fill$tuple2_u64_u8_iter_Skip_iter_Map_ops_RangeInclusive_u32_hints_typed_closure1_tuple2_u64_u8_hints_reserves_closure3(coll: rt.u8, items: rt.Iter<[rt.u64, rt.u8]>, seed: [rt.u64, rt.u8], out: rt.ByteVec): void { let len!: rt.usize; - seed = copy$tuple2_u64_u8(seed); if (coll === 0) { len = rt.iterToArray(items, "next", 16).length; } else if (coll === 1) { @@ -3595,19 +3584,19 @@ export function fill$tuple2_u64_u8_iter_Skip_iter_Map_ops_RangeInclusive_u32_hin rt.iterExtend(v, items, "next", 16); len = v.length; } else if (coll === 2) { - const v2: [rt.u64, rt.u8][] = rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8); + const v2: [rt.u64, rt.u8][] = rt.vecFromElem(seed, 2, undefined); rt.iterExtend(v2, items, "next", 16); len = v2.length; } else if (coll === 3) { len = ((rt.dequeFromVec(rt.iterToArray(items, "next", 16), 16) as rt.VecDeque<[rt.u64, rt.u8]>)).n; } else if (coll === 4) { - const q: rt.VecDeque<[rt.u64, rt.u8]> = rt.dequeFromVec(rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8), 16) as rt.VecDeque<[rt.u64, rt.u8]>; + const q: rt.VecDeque<[rt.u64, rt.u8]> = rt.dequeFromVec(rt.vecFromElem(seed, 2, undefined), 16) as rt.VecDeque<[rt.u64, rt.u8]>; rt.dequeExtend(q, items, "next"); len = q.n; } else if (coll === 5) { len = rt.heapFrom(rt.iterToArray(items, "next", 16), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))).d.length; } else if (coll === 6) { - const h: rt.BinaryHeap<[rt.u64, rt.u8]> = rt.heapFrom(rt.vecFromElem(copy$tuple2_u64_u8(copy$tuple2_u64_u8(seed)), 2, copy$tuple2_u64_u8), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))); + const h: rt.BinaryHeap<[rt.u64, rt.u8]> = rt.heapFrom(rt.vecFromElem(seed, 2, undefined), rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp]))); rt.heapExtend(h, items, rt.cmpLe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpGe(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), rt.cmpLt(rt.cmpTuple<[rt.u64, rt.u8], rt.Ordering | undefined>([rt.cmp, rt.cmp])), "next", 16); len = h.d.length; } else if (coll === 7) { diff --git a/ts/fixtures/lang/hints/expected/lib.ts b/ts/fixtures/lang/hints/expected/lib.ts new file mode 100644 index 000000000..fcf3537f5 --- /dev/null +++ b/ts/fixtures/lang/hints/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { hints, reserves } from "./hints.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["hints::hints", hints as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["hints::reserves", reserves as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/hints.rs b/ts/fixtures/lang/hints/src/hints.rs similarity index 100% rename from ts/fixtures/lang/src/hints.rs rename to ts/fixtures/lang/hints/src/hints.rs diff --git a/ts/fixtures/lang/hints/src/lib.rs b/ts/fixtures/lang/hints/src/lib.rs new file mode 100644 index 000000000..54dee1788 --- /dev/null +++ b/ts/fixtures/lang/hints/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod hints; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("hints::hints", hints::hints), ("hints::reserves", hints::reserves)] +} diff --git a/ts/fixtures/lang/hints/ts.toml b/ts/fixtures/lang/hints/ts.toml new file mode 100644 index 000000000..5b5e000a2 --- /dev/null +++ b/ts/fixtures/lang/hints/ts.toml @@ -0,0 +1,2 @@ +package = "lang-hints-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/holds/Cargo.toml b/ts/fixtures/lang/holds/Cargo.toml new file mode 100644 index 000000000..172da6e80 --- /dev/null +++ b/ts/fixtures/lang/holds/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-holds-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/holds/expected/core/option.ts b/ts/fixtures/lang/holds/expected/core/option.ts new file mode 100644 index 000000000..dbe0e10a0 --- /dev/null +++ b/ts/fixtures/lang/holds/expected/core/option.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function mapOr$02k4ito(self: rt.usize | undefined, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/holds/expected/harness.ts b/ts/fixtures/lang/holds/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/holds/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/expected/holds.Row.ts b/ts/fixtures/lang/holds/expected/holds.Row.ts similarity index 100% rename from ts/fixtures/lang/expected/holds.Row.ts rename to ts/fixtures/lang/holds/expected/holds.Row.ts diff --git a/ts/fixtures/lang/expected/holds.ts b/ts/fixtures/lang/holds/expected/holds.ts similarity index 100% rename from ts/fixtures/lang/expected/holds.ts rename to ts/fixtures/lang/holds/expected/holds.ts diff --git a/ts/fixtures/lang/holds/expected/lib.ts b/ts/fixtures/lang/holds/expected/lib.ts new file mode 100644 index 000000000..d814969c0 --- /dev/null +++ b/ts/fixtures/lang/holds/expected/lib.ts @@ -0,0 +1,18 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { holds } from "./holds.ts"; + +export function copy$array_u8(v: Uint8Array): Uint8Array { + return v.slice(); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["holds::holds", holds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/holds.rs b/ts/fixtures/lang/holds/src/holds.rs similarity index 100% rename from ts/fixtures/lang/src/holds.rs rename to ts/fixtures/lang/holds/src/holds.rs diff --git a/ts/fixtures/lang/holds/src/lib.rs b/ts/fixtures/lang/holds/src/lib.rs new file mode 100644 index 000000000..660f6a317 --- /dev/null +++ b/ts/fixtures/lang/holds/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod holds; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("holds::holds", holds::holds)] +} diff --git a/ts/fixtures/lang/holds/ts.toml b/ts/fixtures/lang/holds/ts.toml new file mode 100644 index 000000000..d91b2dd43 --- /dev/null +++ b/ts/fixtures/lang/holds/ts.toml @@ -0,0 +1,2 @@ +package = "lang-holds-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/ints/Cargo.toml b/ts/fixtures/lang/ints/Cargo.toml new file mode 100644 index 000000000..7abd77d57 --- /dev/null +++ b/ts/fixtures/lang/ints/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-ints-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/ints/caller.ts b/ts/fixtures/lang/ints/caller.ts new file mode 100644 index 000000000..7b360fdda --- /dev/null +++ b/ts/fixtures/lang/ints/caller.ts @@ -0,0 +1,80 @@ +// The inputs `ints`' cases name, which run with the generated ones. + +import { be, edges, op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * The 64- and 128-bit cases over operands that random bytes rarely make: every pair of + * values next to a power of two. + */ +function ints(): Uint8Array[] { + const [u64, u128, i64, i128] = ["ints::u64_op", "ints::u128_op", "ints::i64_op", "ints::i128_op"].map(op); + const [neg, cast, convert] = ["ints::neg", "ints::cast", "ints::convert"].map(op); + const cases: Uint8Array[] = []; + const values = edges(); + // Shift amounts in and past each limb, and past the width, which panics. + const shifts = [0, 1, 7, 31, 32, 33, 63, 64, 65, 95, 96, 127, 128, 200]; + let i = 0; + for (const x of values) { + for (const y of values) { + // A 64-bit case's operands are `x` and `y`. A 128-bit case's are `x:y` and `u:v`, + // whose high halves are equal a third of the time, so the low half decides. + const u = i % 3 === 0 ? x : values[(i * 7) % values.length]; + const v = values[(i * 13 + 5) % values.length]; + const shift = shifts[i++ % shifts.length]; + for (let kind = 0; kind < 31; kind++) { + for (const o of [u64, i64]) cases.push(Uint8Array.of(...o, kind, ...be(x), ...be(y), shift)); + for (const o of [u128, i128]) cases.push(Uint8Array.of(...o, kind, ...be(x), ...be(y), ...be(u), ...be(v), shift)); + } + // `clamp` between two values of the sweep, whose third operand follows the shift's place. + for (const o of [u64, i64]) cases.push(Uint8Array.of(...o, 26, ...be(x), ...be(y), ...be(u))); + for (const o of [u128, i128]) cases.push(Uint8Array.of(...o, 26, ...be(x), ...be(y), ...be(u), ...be(v), ...be(y), ...be(x))); + // Negating an `i64` and an `i128`. + cases.push(Uint8Array.of(...neg, 3, ...be(x)), Uint8Array.of(...neg, 4, ...be(x), ...be(y))); + // `x * y`, `checked_mul`, `saturating_mul`, and `wrapping_mul` at 128 bits, extended in + // each type's sign: a product of two numbers, past 2^53, multiplies their halves. + const signs = (v: bigint) => (v >> 63n === 1n ? 0xffffffffffffffffn : 0n); + for (const kind of [2, 13, 24, 25]) { + cases.push(Uint8Array.of(...u128, kind, ...be(0n), ...be(x), ...be(0n), ...be(y))); + cases.push(Uint8Array.of(...i128, kind, ...be(signs(x)), ...be(x), ...be(signs(y)), ...be(y))); + } + // `x:y / d`, `x:y % d`, `div_ceil`, and `is_multiple_of` at 128 bits by a divisor + // below 2^32 in magnitude, which divides limbs by a number, extended in each type's + // sign: -1 overflows `i128::MIN`. + for (const d of [3n, 1_000_000n, 0xffffffffn, -1n, -0xffffffffn]) { + for (const kind of [3, 4, 27, 28]) { + for (const o of [u128, i128]) cases.push(Uint8Array.of(...o, kind, ...be(x), ...be(y), ...be(signs(d & 0xffffffffffffffffn)), ...be(d & 0xffffffffffffffffn))); + } + } + } + // Conversions, and halves joined back. + cases.push(Uint8Array.of(...convert, 0, ...be(x), ...be(x))); + for (const y of [0n, 1n, 1n << 32n, 1n << 63n, 0xffffffffffffffffn]) { + for (const from of [3, 4, 9, 10]) { + // A cast to every type. + for (let to = 0; to < 12; to++) cases.push(Uint8Array.of(...cast, from, to, ...be(x), ...be(y))); + } + } + } + return cases; +} + +/** + * The first eight cases, each integer type's operators, over full-width values: each + * `u64` boundary 2^k - 1, 2^k, and 2^k + 1, as each operand and with each selector. + */ +function boundaries(): Uint8Array[] { + const cases: Uint8Array[] = []; + for (const name of ["u8_op", "u16_op", "u32_op", "u64_op", "u128_op", "usize_op", "i8_op", "i16_op"]) { + for (let k = 0n; k <= 64n; k++) { + for (const delta of [-1n, 0n, 1n]) { + const value = be(((1n << k) + delta) & 0xffffffffffffffffn); + for (const selector of [0, 1, 2, 3, 4, 5, 6]) cases.push(Uint8Array.of(...op(`ints::${name}`), selector, ...value, ...value, ...value)); + } + } + } + return cases; +} + +export const cases: Uint8Array[] = [...ints(), ...boundaries()]; diff --git a/ts/fixtures/lang/ints/expected/core/char/methods.ts b/ts/fixtures/lang/ints/expected/core/char/methods.ts new file mode 100644 index 000000000..992b1a141 --- /dev/null +++ b/ts/fixtures/lang/ints/expected/core/char/methods.ts @@ -0,0 +1,27 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../../rt.ts"; + +export function toDigit$01k9ewn(self: rt.char, radix: rt.u32): rt.u32 | undefined { + let value!: rt.u32; + if (radix >= 2) { + if (radix <= 36) { + b1: { + if (self > 57) { + if (radix > 10) { + value = rt.u32Add((rt.u32WrappingSub(self as rt.u32, 65 as rt.u32) & 4294967263) >>> 0, 10); + break b1; + } + } + value = rt.u32WrappingSub(self as rt.u32, 48 as rt.u32); + } + if (!(value < radix)) { + return undefined; + } + return value; + } + } + rt.panicFmt(["to_digit: invalid radix -- radix must be in the range 2 to 36 inclusive"]); +} + +//# sourceMappingURL=methods.ts.map diff --git a/ts/fixtures/lang/expected/core/num.ts b/ts/fixtures/lang/ints/expected/core/num.ts similarity index 100% rename from ts/fixtures/lang/expected/core/num.ts rename to ts/fixtures/lang/ints/expected/core/num.ts diff --git a/ts/fixtures/lang/ints/expected/core/option.ts b/ts/fixtures/lang/ints/expected/core/option.ts new file mode 100644 index 000000000..6740bb7ac --- /dev/null +++ b/ts/fixtures/lang/ints/expected/core/option.ts @@ -0,0 +1,26 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function isSomeAnd$09tpccf(self: rt.u8 | undefined, f: (a0: rt.u8) => boolean): boolean { + if (self === undefined) { + return false; + } + return f(self); +} + +export function unwrapOr$11c0we2(self: rt.u32 | undefined, default_: rt.u32): rt.u32 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/ints/expected/core/result.ts b/ts/fixtures/lang/ints/expected/core/result.ts new file mode 100644 index 000000000..5ceae2928 --- /dev/null +++ b/ts/fixtures/lang/ints/expected/core/result.ts @@ -0,0 +1,146 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function eq$0pee78b(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return rt.i128Eq(self.value, (other as { ok: true; value: rt.i128 }).value); + } + return true; +} + +export function eq$1mi4cle(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.i16 }).value; + } + return true; +} + +export function eq$1ukayff(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.i32 }).value; + } + return true; +} + +export function eq$1hy1is1(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return rt.i64Eq(self.value, (other as { ok: true; value: rt.i64 }).value); + } + return true; +} + +export function eq$1hd8lo9(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.i8 }).value; + } + return true; +} + +export function eq$0w2dfat(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.isize }).value; + } + return true; +} + +export function eq$06vyx9e(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return rt.u128Eq(self.value, (other as { ok: true; value: rt.u128 }).value); + } + return true; +} + +export function eq$08241oi(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.u16 }).value; + } + return true; +} + +export function eq$0nbftnc(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.u32 }).value; + } + return true; +} + +export function eq$1gq81ib(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return rt.u64Eq(self.value, (other as { ok: true; value: rt.u64 }).value); + } + return true; +} + +export function eq$12e5exx(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.u8 }).value; + } + return true; +} + +export function eq$1xhgva4(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.usize }).value; + } + return true; +} + +export function unwrapOr$01jdcm7(self: rt.Result, default_: string): string { + if (self.ok) { + return self.value; + } + return default_; +} + +export function unwrapOr$0nhd29g(self: rt.Result, default_: rt.u16): rt.u16 { + if (self.ok) { + return self.value; + } + return default_; +} + +export function unwrapOr$09i71ei(self: rt.Result, default_: rt.u64): rt.u64 { + if (self.ok) { + return self.value; + } + return default_; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/ints/expected/core/str.ts b/ts/fixtures/lang/ints/expected/core/str.ts new file mode 100644 index 000000000..1ac4d1abd --- /dev/null +++ b/ts/fixtures/lang/ints/expected/core/str.ts @@ -0,0 +1,54 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import { fromStr$0zyj6he as num_fromStr$0zyj6he, fromStr$17ewwma as num_fromStr$17ewwma, fromStr$0zhqfgx as num_fromStr$0zhqfgx, fromStr$116mp4t as num_fromStr$116mp4t, fromStr$0ovlgjd as num_fromStr$0ovlgjd, fromStr$1grmucc as num_fromStr$1grmucc, fromStr$0qvzsmz as num_fromStr$0qvzsmz, fromStr$0yqu2i9 as num_fromStr$0yqu2i9, fromStr$08wf09w as num_fromStr$08wf09w, fromStr$1ypcnp8 as num_fromStr$1ypcnp8, fromStr$1hq0zfa as num_fromStr$1hq0zfa, fromStr$10ypyht as num_fromStr$10ypyht } from "../core/num.ts"; + +export function parse$082ztwj(self: string): rt.Result { + return num_fromStr$0zyj6he(self); +} + +export function parse$0xnscjy(self: string): rt.Result { + return num_fromStr$17ewwma(self); +} + +export function parse$12szghw(self: string): rt.Result { + return num_fromStr$0zhqfgx(self); +} + +export function parse$11m1f1e(self: string): rt.Result { + return num_fromStr$116mp4t(self); +} + +export function parse$1ci7nyc(self: string): rt.Result { + return num_fromStr$0ovlgjd(self); +} + +export function parse$07xyv4i(self: string): rt.Result { + return num_fromStr$1grmucc(self); +} + +export function parse$069o3rw(self: string): rt.Result { + return num_fromStr$0qvzsmz(self); +} + +export function parse$0fi19ig(self: string): rt.Result { + return num_fromStr$0yqu2i9(self); +} + +export function parse$1aq2uo0(self: string): rt.Result { + return num_fromStr$08wf09w(self); +} + +export function parse$0o4ono0(self: string): rt.Result { + return num_fromStr$1ypcnp8(self); +} + +export function parse$0at0fdl(self: string): rt.Result { + return num_fromStr$1hq0zfa(self); +} + +export function parse$08wetap(self: string): rt.Result { + return num_fromStr$10ypyht(self); +} + +//# sourceMappingURL=str.ts.map diff --git a/ts/fixtures/lang/ints/expected/harness.ts b/ts/fixtures/lang/ints/expected/harness.ts new file mode 100644 index 000000000..3b7bbcfb0 --- /dev/null +++ b/ts/fixtures/lang/ints/expected/harness.ts @@ -0,0 +1,46 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/expected/ints.Scaled.ts b/ts/fixtures/lang/ints/expected/ints.Scaled.ts similarity index 100% rename from ts/fixtures/lang/expected/ints.Scaled.ts rename to ts/fixtures/lang/ints/expected/ints.Scaled.ts diff --git a/ts/fixtures/lang/expected/ints.ts b/ts/fixtures/lang/ints/expected/ints.ts similarity index 95% rename from ts/fixtures/lang/expected/ints.ts rename to ts/fixtures/lang/ints/expected/ints.ts index 49b37a30a..f3490b02b 100644 --- a/ts/fixtures/lang/expected/ints.ts +++ b/ts/fixtures/lang/ints/expected/ints.ts @@ -3,10 +3,10 @@ import * as rt from "./rt.ts"; import { toDigit$01k9ewn } from "./core/char/methods.ts"; import { fromStr$0zyj6he as num_fromStr$0zyj6he, fromStr$17ewwma as num_fromStr$17ewwma, fromStr$0zhqfgx as num_fromStr$0zhqfgx, fromStr$116mp4t as num_fromStr$116mp4t, fromStr$0ovlgjd as num_fromStr$0ovlgjd, fromStr$1grmucc as num_fromStr$1grmucc, fromStrRadix$0366bau as num_fromStrRadix$0366bau, fromStrRadix$02mhuxs as num_fromStrRadix$02mhuxs, fromStrRadix$1bgm1z0 as num_fromStrRadix$1bgm1z0, fromStrRadix$11y6fsf as num_fromStrRadix$11y6fsf, fromStrRadix$0s9rspw as num_fromStrRadix$0s9rspw, fromStrRadix$1473bi0 as num_fromStrRadix$1473bi0, fromStr$0qvzsmz as num_fromStr$0qvzsmz, fromStr$0yqu2i9 as num_fromStr$0yqu2i9, fromStr$08wf09w as num_fromStr$08wf09w, fromStr$1ypcnp8 as num_fromStr$1ypcnp8, fromStr$1hq0zfa as num_fromStr$1hq0zfa, fromStr$10ypyht as num_fromStr$10ypyht, fromStrRadix$0g0g31i as num_fromStrRadix$0g0g31i, fromStrRadix$1ku3myt as num_fromStrRadix$1ku3myt, fromStrRadix$05zvwcf as num_fromStrRadix$05zvwcf, fromStrRadix$1gp4jqq as num_fromStrRadix$1gp4jqq, fromStrRadix$0nj08um as num_fromStrRadix$0nj08um, fromStrRadix$0tjqkb6 as num_fromStrRadix$0tjqkb6 } from "./core/num.ts"; -import { isSomeAnd$09tpccf, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOr$11c0we2 as option_unwrapOr$11c0we2 } from "./core/option.ts"; +import { isSomeAnd$09tpccf, unwrapOr$11c0we2 as option_unwrapOr$11c0we2, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr } from "./core/option.ts"; import { eq$0pee78b as result_eq$0pee78b, eq$1mi4cle as result_eq$1mi4cle, eq$1ukayff as result_eq$1ukayff, eq$1hy1is1 as result_eq$1hy1is1, eq$1hd8lo9 as result_eq$1hd8lo9, eq$0w2dfat as result_eq$0w2dfat, eq$06vyx9e as result_eq$06vyx9e, eq$08241oi as result_eq$08241oi, eq$0nbftnc as result_eq$0nbftnc, eq$1gq81ib as result_eq$1gq81ib, eq$12e5exx as result_eq$12e5exx, eq$1xhgva4 as result_eq$1xhgva4, unwrapOr$01jdcm7 as result_unwrapOr$01jdcm7, unwrapOr$0nhd29g as result_unwrapOr$0nhd29g, unwrapOr$09i71ei as result_unwrapOr$09i71ei } from "./core/result.ts"; import { parse$082ztwj, parse$0xnscjy, parse$12szghw, parse$11m1f1e, parse$1ci7nyc, parse$07xyv4i, parse$069o3rw, parse$0fi19ig, parse$1aq2uo0, parse$0o4ono0, parse$0at0fdl, parse$08wetap } from "./core/str.ts"; -import { put as fmt_put } from "./fmt.ts"; +import { put } from "./harness.ts"; import * as Scaled from "./ints.Scaled.ts"; /** Apply operation `op` to operands taken from `data`. */ @@ -3065,7 +3065,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_40.ok) { const arg48 = _40.value; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(arg48, f)]; - fmt_put(out, rt.fmtFormat([args2[0]])); + put(out, rt.fmtFormat([args2[0]])); } else { const e: rt.ParseIntError = _40.error; const _56: rt.IntErrorKind = e.kind; @@ -3087,7 +3087,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _76: rt.IntErrorKind = e.kind; const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _76), (f: rt.Formatter) => rt.i32Display(kind2, f), (f: rt.Formatter) => rt.fmtBool(over, f)]; - fmt_put(out, rt.fmtFormat([args4[0], "|", args4[1], "|", args4[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args4[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args4[0]), "|", args4[3], "|", args4[4]])); + put(out, rt.fmtFormat([args4[0], "|", args4[1], "|", args4[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args4[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args4[0]), "|", args4[3], "|", args4[4]])); } if (radix2 === 10) { const parsed: rt.Result = parse$0at0fdl(_19.value); @@ -3114,7 +3114,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_131.ok) { const arg47 = _131.value; const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(arg47, f)]; - fmt_put(out, rt.fmtFormat([args6[0]])); + put(out, rt.fmtFormat([args6[0]])); } else { const e2: rt.ParseIntError = _131.error; const _147: rt.IntErrorKind = e2.kind; @@ -3136,7 +3136,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _167: rt.IntErrorKind = e2.kind; const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e2, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e2, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _167), (f: rt.Formatter) => rt.i32Display(kind3, f), (f: rt.Formatter) => rt.fmtBool(over2, f)]; - fmt_put(out, rt.fmtFormat([args8[0], "|", args8[1], "|", args8[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args8[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args8[0]), "|", args8[3], "|", args8[4]])); + put(out, rt.fmtFormat([args8[0], "|", args8[1], "|", args8[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args8[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args8[0]), "|", args8[3], "|", args8[4]])); } if (radix3 === 10) { const parsed2: rt.Result = parse$0at0fdl(_128); @@ -3163,7 +3163,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_218.ok) { const arg46 = _218.value; const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(arg46, f)]; - fmt_put(out, rt.fmtFormat([args10[0]])); + put(out, rt.fmtFormat([args10[0]])); } else { const e3: rt.ParseIntError = _218.error; const _234: rt.IntErrorKind = e3.kind; @@ -3185,7 +3185,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _254: rt.IntErrorKind = e3.kind; const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e3, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e3, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _254), (f: rt.Formatter) => rt.i32Display(kind4, f), (f: rt.Formatter) => rt.fmtBool(over3, f)]; - fmt_put(out, rt.fmtFormat([args12[0], "|", args12[1], "|", args12[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args12[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args12[0]), "|", args12[3], "|", args12[4]])); + put(out, rt.fmtFormat([args12[0], "|", args12[1], "|", args12[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args12[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args12[0]), "|", args12[3], "|", args12[4]])); } if (radix5 === 10) { const parsed3: rt.Result = parse$0at0fdl(_207); @@ -3217,7 +3217,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_315.ok) { const arg45 = _315.value; const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(arg45, f)]; - fmt_put(out, rt.fmtFormat([args14[0]])); + put(out, rt.fmtFormat([args14[0]])); } else { const e4: rt.ParseIntError = _315.error; const _331: rt.IntErrorKind = e4.kind; @@ -3239,7 +3239,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _351: rt.IntErrorKind = e4.kind; const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e4, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e4, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _351), (f: rt.Formatter) => rt.i32Display(kind5, f), (f: rt.Formatter) => rt.fmtBool(over4, f)]; - fmt_put(out, rt.fmtFormat([args16[0], "|", args16[1], "|", args16[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args16[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args16[0]), "|", args16[3], "|", args16[4]])); + put(out, rt.fmtFormat([args16[0], "|", args16[1], "|", args16[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args16[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args16[0]), "|", args16[3], "|", args16[4]])); } if (radix7 === 10) { const parsed4: rt.Result = parse$0at0fdl(_310); @@ -3275,7 +3275,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_414.ok) { const arg44 = _414.value; const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.u16Display(arg44, f)]; - fmt_put(out, rt.fmtFormat([args18[0]])); + put(out, rt.fmtFormat([args18[0]])); } else { const e5: rt.ParseIntError = _414.error; const _430: rt.IntErrorKind = e5.kind; @@ -3297,7 +3297,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _450: rt.IntErrorKind = e5.kind; const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e5, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e5, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _450), (f: rt.Formatter) => rt.i32Display(kind6, f), (f: rt.Formatter) => rt.fmtBool(over5, f)]; - fmt_put(out, rt.fmtFormat([args20[0], "|", args20[1], "|", args20[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args20[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args20[0]), "|", args20[3], "|", args20[4]])); + put(out, rt.fmtFormat([args20[0], "|", args20[1], "|", args20[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args20[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args20[0]), "|", args20[3], "|", args20[4]])); } if (radix9 === 10) { const parsed5: rt.Result = parse$0fi19ig(_393.value); @@ -3324,7 +3324,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_505.ok) { const arg43 = _505.value; const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.u16Display(arg43, f)]; - fmt_put(out, rt.fmtFormat([args22[0]])); + put(out, rt.fmtFormat([args22[0]])); } else { const e6: rt.ParseIntError = _505.error; const _521: rt.IntErrorKind = e6.kind; @@ -3346,7 +3346,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _541: rt.IntErrorKind = e6.kind; const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e6, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e6, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _541), (f: rt.Formatter) => rt.i32Display(kind7, f), (f: rt.Formatter) => rt.fmtBool(over6, f)]; - fmt_put(out, rt.fmtFormat([args24[0], "|", args24[1], "|", args24[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args24[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args24[0]), "|", args24[3], "|", args24[4]])); + put(out, rt.fmtFormat([args24[0], "|", args24[1], "|", args24[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args24[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args24[0]), "|", args24[3], "|", args24[4]])); } if (radix10 === 10) { const parsed6: rt.Result = parse$0fi19ig(_502); @@ -3373,7 +3373,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_592.ok) { const arg42 = _592.value; const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.u16Display(arg42, f)]; - fmt_put(out, rt.fmtFormat([args26[0]])); + put(out, rt.fmtFormat([args26[0]])); } else { const e7: rt.ParseIntError = _592.error; const _608: rt.IntErrorKind = e7.kind; @@ -3395,7 +3395,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _628: rt.IntErrorKind = e7.kind; const args28: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e7, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e7, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _628), (f: rt.Formatter) => rt.i32Display(kind8, f), (f: rt.Formatter) => rt.fmtBool(over7, f)]; - fmt_put(out, rt.fmtFormat([args28[0], "|", args28[1], "|", args28[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args28[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args28[0]), "|", args28[3], "|", args28[4]])); + put(out, rt.fmtFormat([args28[0], "|", args28[1], "|", args28[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args28[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args28[0]), "|", args28[3], "|", args28[4]])); } if (radix12 === 10) { const parsed7: rt.Result = parse$0fi19ig(_581); @@ -3427,7 +3427,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_689.ok) { const arg41 = _689.value; const args30: rt.Fmt[] = [(f: rt.Formatter) => rt.u16Display(arg41, f)]; - fmt_put(out, rt.fmtFormat([args30[0]])); + put(out, rt.fmtFormat([args30[0]])); } else { const e8: rt.ParseIntError = _689.error; const _705: rt.IntErrorKind = e8.kind; @@ -3449,7 +3449,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _725: rt.IntErrorKind = e8.kind; const args32: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e8, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e8, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _725), (f: rt.Formatter) => rt.i32Display(kind9, f), (f: rt.Formatter) => rt.fmtBool(over8, f)]; - fmt_put(out, rt.fmtFormat([args32[0], "|", args32[1], "|", args32[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args32[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args32[0]), "|", args32[3], "|", args32[4]])); + put(out, rt.fmtFormat([args32[0], "|", args32[1], "|", args32[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args32[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args32[0]), "|", args32[3], "|", args32[4]])); } if (radix14 === 10) { const parsed8: rt.Result = parse$0fi19ig(_684); @@ -3485,7 +3485,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_788.ok) { const arg40 = _788.value; const args34: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(arg40, f)]; - fmt_put(out, rt.fmtFormat([args34[0]])); + put(out, rt.fmtFormat([args34[0]])); } else { const e9: rt.ParseIntError = _788.error; const _804: rt.IntErrorKind = e9.kind; @@ -3507,7 +3507,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _824: rt.IntErrorKind = e9.kind; const args36: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e9, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e9, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _824), (f: rt.Formatter) => rt.i32Display(kind10, f), (f: rt.Formatter) => rt.fmtBool(over9, f)]; - fmt_put(out, rt.fmtFormat([args36[0], "|", args36[1], "|", args36[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args36[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args36[0]), "|", args36[3], "|", args36[4]])); + put(out, rt.fmtFormat([args36[0], "|", args36[1], "|", args36[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args36[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args36[0]), "|", args36[3], "|", args36[4]])); } if (radix16 === 10) { const parsed9: rt.Result = parse$1aq2uo0(_767.value); @@ -3534,7 +3534,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_879.ok) { const arg39 = _879.value; const args38: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(arg39, f)]; - fmt_put(out, rt.fmtFormat([args38[0]])); + put(out, rt.fmtFormat([args38[0]])); } else { const e10: rt.ParseIntError = _879.error; const _895: rt.IntErrorKind = e10.kind; @@ -3556,7 +3556,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _915: rt.IntErrorKind = e10.kind; const args40: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e10, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e10, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _915), (f: rt.Formatter) => rt.i32Display(kind11, f), (f: rt.Formatter) => rt.fmtBool(over10, f)]; - fmt_put(out, rt.fmtFormat([args40[0], "|", args40[1], "|", args40[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args40[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args40[0]), "|", args40[3], "|", args40[4]])); + put(out, rt.fmtFormat([args40[0], "|", args40[1], "|", args40[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args40[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args40[0]), "|", args40[3], "|", args40[4]])); } if (radix17 === 10) { const parsed10: rt.Result = parse$1aq2uo0(_876); @@ -3583,7 +3583,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_966.ok) { const arg38 = _966.value; const args42: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(arg38, f)]; - fmt_put(out, rt.fmtFormat([args42[0]])); + put(out, rt.fmtFormat([args42[0]])); } else { const e11: rt.ParseIntError = _966.error; const _982: rt.IntErrorKind = e11.kind; @@ -3605,7 +3605,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _1002: rt.IntErrorKind = e11.kind; const args44: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e11, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e11, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _1002), (f: rt.Formatter) => rt.i32Display(kind12, f), (f: rt.Formatter) => rt.fmtBool(over11, f)]; - fmt_put(out, rt.fmtFormat([args44[0], "|", args44[1], "|", args44[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args44[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args44[0]), "|", args44[3], "|", args44[4]])); + put(out, rt.fmtFormat([args44[0], "|", args44[1], "|", args44[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args44[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args44[0]), "|", args44[3], "|", args44[4]])); } if (radix19 === 10) { const parsed11: rt.Result = parse$1aq2uo0(_955); @@ -3637,7 +3637,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_1063.ok) { const arg37 = _1063.value; const args46: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(arg37, f)]; - fmt_put(out, rt.fmtFormat([args46[0]])); + put(out, rt.fmtFormat([args46[0]])); } else { const e12: rt.ParseIntError = _1063.error; const _1079: rt.IntErrorKind = e12.kind; @@ -3659,7 +3659,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _1099: rt.IntErrorKind = e12.kind; const args48: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e12, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e12, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _1099), (f: rt.Formatter) => rt.i32Display(kind13, f), (f: rt.Formatter) => rt.fmtBool(over12, f)]; - fmt_put(out, rt.fmtFormat([args48[0], "|", args48[1], "|", args48[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args48[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args48[0]), "|", args48[3], "|", args48[4]])); + put(out, rt.fmtFormat([args48[0], "|", args48[1], "|", args48[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args48[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args48[0]), "|", args48[3], "|", args48[4]])); } if (radix21 === 10) { const parsed12: rt.Result = parse$1aq2uo0(_1058); @@ -3695,7 +3695,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_1162.ok) { const arg36 = _1162.value; const args50: rt.Fmt[] = [(f: rt.Formatter) => rt.u64Display(arg36, f)]; - fmt_put(out, rt.fmtFormat([args50[0]])); + put(out, rt.fmtFormat([args50[0]])); } else { const e13: rt.ParseIntError = _1162.error; const _1178: rt.IntErrorKind = e13.kind; @@ -3717,7 +3717,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _1198: rt.IntErrorKind = e13.kind; const args52: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e13, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e13, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _1198), (f: rt.Formatter) => rt.i32Display(kind14, f), (f: rt.Formatter) => rt.fmtBool(over13, f)]; - fmt_put(out, rt.fmtFormat([args52[0], "|", args52[1], "|", args52[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args52[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args52[0]), "|", args52[3], "|", args52[4]])); + put(out, rt.fmtFormat([args52[0], "|", args52[1], "|", args52[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args52[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args52[0]), "|", args52[3], "|", args52[4]])); } if (radix23 === 10) { const parsed13: rt.Result = parse$0o4ono0(_1141.value); @@ -3744,7 +3744,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_1253.ok) { const arg35 = _1253.value; const args54: rt.Fmt[] = [(f: rt.Formatter) => rt.u64Display(arg35, f)]; - fmt_put(out, rt.fmtFormat([args54[0]])); + put(out, rt.fmtFormat([args54[0]])); } else { const e14: rt.ParseIntError = _1253.error; const _1269: rt.IntErrorKind = e14.kind; @@ -3766,7 +3766,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _1289: rt.IntErrorKind = e14.kind; const args56: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e14, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e14, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _1289), (f: rt.Formatter) => rt.i32Display(kind15, f), (f: rt.Formatter) => rt.fmtBool(over14, f)]; - fmt_put(out, rt.fmtFormat([args56[0], "|", args56[1], "|", args56[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args56[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args56[0]), "|", args56[3], "|", args56[4]])); + put(out, rt.fmtFormat([args56[0], "|", args56[1], "|", args56[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args56[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args56[0]), "|", args56[3], "|", args56[4]])); } if (radix24 === 10) { const parsed14: rt.Result = parse$0o4ono0(_1250); @@ -3793,7 +3793,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_1340.ok) { const arg34 = _1340.value; const args58: rt.Fmt[] = [(f: rt.Formatter) => rt.u64Display(arg34, f)]; - fmt_put(out, rt.fmtFormat([args58[0]])); + put(out, rt.fmtFormat([args58[0]])); } else { const e15: rt.ParseIntError = _1340.error; const _1356: rt.IntErrorKind = e15.kind; @@ -3815,7 +3815,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _1376: rt.IntErrorKind = e15.kind; const args60: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e15, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e15, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _1376), (f: rt.Formatter) => rt.i32Display(kind16, f), (f: rt.Formatter) => rt.fmtBool(over15, f)]; - fmt_put(out, rt.fmtFormat([args60[0], "|", args60[1], "|", args60[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args60[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args60[0]), "|", args60[3], "|", args60[4]])); + put(out, rt.fmtFormat([args60[0], "|", args60[1], "|", args60[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args60[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args60[0]), "|", args60[3], "|", args60[4]])); } if (radix26 === 10) { const parsed15: rt.Result = parse$0o4ono0(_1329); @@ -3847,7 +3847,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_1437.ok) { const arg33 = _1437.value; const args62: rt.Fmt[] = [(f: rt.Formatter) => rt.u64Display(arg33, f)]; - fmt_put(out, rt.fmtFormat([args62[0]])); + put(out, rt.fmtFormat([args62[0]])); } else { const e16: rt.ParseIntError = _1437.error; const _1453: rt.IntErrorKind = e16.kind; @@ -3869,7 +3869,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _1473: rt.IntErrorKind = e16.kind; const args64: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e16, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e16, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _1473), (f: rt.Formatter) => rt.i32Display(kind17, f), (f: rt.Formatter) => rt.fmtBool(over16, f)]; - fmt_put(out, rt.fmtFormat([args64[0], "|", args64[1], "|", args64[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args64[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args64[0]), "|", args64[3], "|", args64[4]])); + put(out, rt.fmtFormat([args64[0], "|", args64[1], "|", args64[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args64[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args64[0]), "|", args64[3], "|", args64[4]])); } if (radix28 === 10) { const parsed16: rt.Result = parse$0o4ono0(_1432); @@ -3905,7 +3905,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_1536.ok) { const arg32 = _1536.value; const args66: rt.Fmt[] = [(f: rt.Formatter) => rt.u128Display(arg32, f)]; - fmt_put(out, rt.fmtFormat([args66[0]])); + put(out, rt.fmtFormat([args66[0]])); } else { const e17: rt.ParseIntError = _1536.error; const _1552: rt.IntErrorKind = e17.kind; @@ -3927,7 +3927,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _1572: rt.IntErrorKind = e17.kind; const args68: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e17, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e17, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _1572), (f: rt.Formatter) => rt.i32Display(kind18, f), (f: rt.Formatter) => rt.fmtBool(over17, f)]; - fmt_put(out, rt.fmtFormat([args68[0], "|", args68[1], "|", args68[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args68[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args68[0]), "|", args68[3], "|", args68[4]])); + put(out, rt.fmtFormat([args68[0], "|", args68[1], "|", args68[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args68[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args68[0]), "|", args68[3], "|", args68[4]])); } if (radix30 === 10) { const parsed17: rt.Result = parse$069o3rw(_1515.value); @@ -3954,7 +3954,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_1627.ok) { const arg31 = _1627.value; const args70: rt.Fmt[] = [(f: rt.Formatter) => rt.u128Display(arg31, f)]; - fmt_put(out, rt.fmtFormat([args70[0]])); + put(out, rt.fmtFormat([args70[0]])); } else { const e18: rt.ParseIntError = _1627.error; const _1643: rt.IntErrorKind = e18.kind; @@ -3976,7 +3976,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _1663: rt.IntErrorKind = e18.kind; const args72: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e18, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e18, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _1663), (f: rt.Formatter) => rt.i32Display(kind19, f), (f: rt.Formatter) => rt.fmtBool(over18, f)]; - fmt_put(out, rt.fmtFormat([args72[0], "|", args72[1], "|", args72[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args72[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args72[0]), "|", args72[3], "|", args72[4]])); + put(out, rt.fmtFormat([args72[0], "|", args72[1], "|", args72[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args72[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args72[0]), "|", args72[3], "|", args72[4]])); } if (radix31 === 10) { const parsed18: rt.Result = parse$069o3rw(_1624); @@ -4003,7 +4003,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_1713.ok) { const arg30 = _1713.value; const args74: rt.Fmt[] = [(f: rt.Formatter) => rt.u128Display(arg30, f)]; - fmt_put(out, rt.fmtFormat([args74[0]])); + put(out, rt.fmtFormat([args74[0]])); } else { const e19: rt.ParseIntError = _1713.error; const _1729: rt.IntErrorKind = e19.kind; @@ -4025,7 +4025,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _1749: rt.IntErrorKind = e19.kind; const args76: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e19, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e19, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _1749), (f: rt.Formatter) => rt.i32Display(kind20, f), (f: rt.Formatter) => rt.fmtBool(over19, f)]; - fmt_put(out, rt.fmtFormat([args76[0], "|", args76[1], "|", args76[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args76[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args76[0]), "|", args76[3], "|", args76[4]])); + put(out, rt.fmtFormat([args76[0], "|", args76[1], "|", args76[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args76[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args76[0]), "|", args76[3], "|", args76[4]])); } if (radix33 === 10) { const parsed19: rt.Result = parse$069o3rw(_1702); @@ -4057,7 +4057,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_1810.ok) { const arg29 = _1810.value; const args78: rt.Fmt[] = [(f: rt.Formatter) => rt.u128Display(arg29, f)]; - fmt_put(out, rt.fmtFormat([args78[0]])); + put(out, rt.fmtFormat([args78[0]])); } else { const e20: rt.ParseIntError = _1810.error; const _1826: rt.IntErrorKind = e20.kind; @@ -4079,7 +4079,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _1846: rt.IntErrorKind = e20.kind; const args80: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e20, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e20, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _1846), (f: rt.Formatter) => rt.i32Display(kind21, f), (f: rt.Formatter) => rt.fmtBool(over20, f)]; - fmt_put(out, rt.fmtFormat([args80[0], "|", args80[1], "|", args80[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args80[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args80[0]), "|", args80[3], "|", args80[4]])); + put(out, rt.fmtFormat([args80[0], "|", args80[1], "|", args80[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args80[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args80[0]), "|", args80[3], "|", args80[4]])); } if (radix35 === 10) { const parsed20: rt.Result = parse$069o3rw(_1805); @@ -4115,7 +4115,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_1909.ok) { const arg28 = _1909.value; const args82: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(arg28, f)]; - fmt_put(out, rt.fmtFormat([args82[0]])); + put(out, rt.fmtFormat([args82[0]])); } else { const e21: rt.ParseIntError = _1909.error; const _1925: rt.IntErrorKind = e21.kind; @@ -4137,7 +4137,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _1945: rt.IntErrorKind = e21.kind; const args84: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e21, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e21, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _1945), (f: rt.Formatter) => rt.i32Display(kind22, f), (f: rt.Formatter) => rt.fmtBool(over21, f)]; - fmt_put(out, rt.fmtFormat([args84[0], "|", args84[1], "|", args84[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args84[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args84[0]), "|", args84[3], "|", args84[4]])); + put(out, rt.fmtFormat([args84[0], "|", args84[1], "|", args84[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args84[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args84[0]), "|", args84[3], "|", args84[4]])); } if (radix37 === 10) { const parsed21: rt.Result = parse$08wetap(_1888.value); @@ -4164,7 +4164,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_2000.ok) { const arg27 = _2000.value; const args86: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(arg27, f)]; - fmt_put(out, rt.fmtFormat([args86[0]])); + put(out, rt.fmtFormat([args86[0]])); } else { const e22: rt.ParseIntError = _2000.error; const _2016: rt.IntErrorKind = e22.kind; @@ -4186,7 +4186,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _2036: rt.IntErrorKind = e22.kind; const args88: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e22, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e22, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _2036), (f: rt.Formatter) => rt.i32Display(kind23, f), (f: rt.Formatter) => rt.fmtBool(over22, f)]; - fmt_put(out, rt.fmtFormat([args88[0], "|", args88[1], "|", args88[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args88[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args88[0]), "|", args88[3], "|", args88[4]])); + put(out, rt.fmtFormat([args88[0], "|", args88[1], "|", args88[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args88[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args88[0]), "|", args88[3], "|", args88[4]])); } if (radix38 === 10) { const parsed22: rt.Result = parse$08wetap(_1997); @@ -4213,7 +4213,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_2087.ok) { const arg26 = _2087.value; const args90: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(arg26, f)]; - fmt_put(out, rt.fmtFormat([args90[0]])); + put(out, rt.fmtFormat([args90[0]])); } else { const e23: rt.ParseIntError = _2087.error; const _2103: rt.IntErrorKind = e23.kind; @@ -4235,7 +4235,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _2123: rt.IntErrorKind = e23.kind; const args92: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e23, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e23, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _2123), (f: rt.Formatter) => rt.i32Display(kind24, f), (f: rt.Formatter) => rt.fmtBool(over23, f)]; - fmt_put(out, rt.fmtFormat([args92[0], "|", args92[1], "|", args92[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args92[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args92[0]), "|", args92[3], "|", args92[4]])); + put(out, rt.fmtFormat([args92[0], "|", args92[1], "|", args92[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args92[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args92[0]), "|", args92[3], "|", args92[4]])); } if (radix40 === 10) { const parsed23: rt.Result = parse$08wetap(_2076); @@ -4267,7 +4267,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_2184.ok) { const arg25 = _2184.value; const args94: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(arg25, f)]; - fmt_put(out, rt.fmtFormat([args94[0]])); + put(out, rt.fmtFormat([args94[0]])); } else { const e24: rt.ParseIntError = _2184.error; const _2200: rt.IntErrorKind = e24.kind; @@ -4289,7 +4289,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _2220: rt.IntErrorKind = e24.kind; const args96: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e24, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e24, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _2220), (f: rt.Formatter) => rt.i32Display(kind25, f), (f: rt.Formatter) => rt.fmtBool(over24, f)]; - fmt_put(out, rt.fmtFormat([args96[0], "|", args96[1], "|", args96[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args96[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args96[0]), "|", args96[3], "|", args96[4]])); + put(out, rt.fmtFormat([args96[0], "|", args96[1], "|", args96[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args96[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args96[0]), "|", args96[3], "|", args96[4]])); } if (radix42 === 10) { const parsed24: rt.Result = parse$08wetap(_2179); @@ -4325,7 +4325,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_2283.ok) { const arg24 = _2283.value; const args98: rt.Fmt[] = [(f: rt.Formatter) => rt.i8Display(arg24, f)]; - fmt_put(out, rt.fmtFormat([args98[0]])); + put(out, rt.fmtFormat([args98[0]])); } else { const e25: rt.ParseIntError = _2283.error; const _2299: rt.IntErrorKind = e25.kind; @@ -4347,7 +4347,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _2319: rt.IntErrorKind = e25.kind; const args100: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e25, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e25, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _2319), (f: rt.Formatter) => rt.i32Display(kind26, f), (f: rt.Formatter) => rt.fmtBool(over25, f)]; - fmt_put(out, rt.fmtFormat([args100[0], "|", args100[1], "|", args100[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args100[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args100[0]), "|", args100[3], "|", args100[4]])); + put(out, rt.fmtFormat([args100[0], "|", args100[1], "|", args100[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args100[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args100[0]), "|", args100[3], "|", args100[4]])); } if (radix44 === 10) { const parsed25: rt.Result = parse$1ci7nyc(_2262.value); @@ -4374,7 +4374,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_2374.ok) { const arg23 = _2374.value; const args102: rt.Fmt[] = [(f: rt.Formatter) => rt.i8Display(arg23, f)]; - fmt_put(out, rt.fmtFormat([args102[0]])); + put(out, rt.fmtFormat([args102[0]])); } else { const e26: rt.ParseIntError = _2374.error; const _2390: rt.IntErrorKind = e26.kind; @@ -4396,7 +4396,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _2410: rt.IntErrorKind = e26.kind; const args104: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e26, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e26, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _2410), (f: rt.Formatter) => rt.i32Display(kind27, f), (f: rt.Formatter) => rt.fmtBool(over26, f)]; - fmt_put(out, rt.fmtFormat([args104[0], "|", args104[1], "|", args104[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args104[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args104[0]), "|", args104[3], "|", args104[4]])); + put(out, rt.fmtFormat([args104[0], "|", args104[1], "|", args104[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args104[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args104[0]), "|", args104[3], "|", args104[4]])); } if (radix45 === 10) { const parsed26: rt.Result = parse$1ci7nyc(_2371); @@ -4423,7 +4423,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_2464.ok) { const arg22 = _2464.value; const args106: rt.Fmt[] = [(f: rt.Formatter) => rt.i8Display(arg22, f)]; - fmt_put(out, rt.fmtFormat([args106[0]])); + put(out, rt.fmtFormat([args106[0]])); } else { const e27: rt.ParseIntError = _2464.error; const _2480: rt.IntErrorKind = e27.kind; @@ -4445,7 +4445,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _2500: rt.IntErrorKind = e27.kind; const args108: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e27, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e27, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _2500), (f: rt.Formatter) => rt.i32Display(kind28, f), (f: rt.Formatter) => rt.fmtBool(over27, f)]; - fmt_put(out, rt.fmtFormat([args108[0], "|", args108[1], "|", args108[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args108[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args108[0]), "|", args108[3], "|", args108[4]])); + put(out, rt.fmtFormat([args108[0], "|", args108[1], "|", args108[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args108[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args108[0]), "|", args108[3], "|", args108[4]])); } if (radix47 === 10) { const parsed27: rt.Result = parse$1ci7nyc(_2453); @@ -4477,7 +4477,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_2561.ok) { const arg21 = _2561.value; const args110: rt.Fmt[] = [(f: rt.Formatter) => rt.i8Display(arg21, f)]; - fmt_put(out, rt.fmtFormat([args110[0]])); + put(out, rt.fmtFormat([args110[0]])); } else { const e28: rt.ParseIntError = _2561.error; const _2577: rt.IntErrorKind = e28.kind; @@ -4499,7 +4499,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _2597: rt.IntErrorKind = e28.kind; const args112: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e28, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e28, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _2597), (f: rt.Formatter) => rt.i32Display(kind29, f), (f: rt.Formatter) => rt.fmtBool(over28, f)]; - fmt_put(out, rt.fmtFormat([args112[0], "|", args112[1], "|", args112[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args112[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args112[0]), "|", args112[3], "|", args112[4]])); + put(out, rt.fmtFormat([args112[0], "|", args112[1], "|", args112[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args112[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args112[0]), "|", args112[3], "|", args112[4]])); } if (radix49 === 10) { const parsed28: rt.Result = parse$1ci7nyc(_2556); @@ -4535,7 +4535,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_2660.ok) { const arg20 = _2660.value; const args114: rt.Fmt[] = [(f: rt.Formatter) => rt.i16Display(arg20, f)]; - fmt_put(out, rt.fmtFormat([args114[0]])); + put(out, rt.fmtFormat([args114[0]])); } else { const e29: rt.ParseIntError = _2660.error; const _2676: rt.IntErrorKind = e29.kind; @@ -4557,7 +4557,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _2696: rt.IntErrorKind = e29.kind; const args116: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e29, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e29, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _2696), (f: rt.Formatter) => rt.i32Display(kind30, f), (f: rt.Formatter) => rt.fmtBool(over29, f)]; - fmt_put(out, rt.fmtFormat([args116[0], "|", args116[1], "|", args116[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args116[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args116[0]), "|", args116[3], "|", args116[4]])); + put(out, rt.fmtFormat([args116[0], "|", args116[1], "|", args116[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args116[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args116[0]), "|", args116[3], "|", args116[4]])); } if (radix51 === 10) { const parsed29: rt.Result = parse$0xnscjy(_2639.value); @@ -4584,7 +4584,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_2751.ok) { const arg19 = _2751.value; const args118: rt.Fmt[] = [(f: rt.Formatter) => rt.i16Display(arg19, f)]; - fmt_put(out, rt.fmtFormat([args118[0]])); + put(out, rt.fmtFormat([args118[0]])); } else { const e30: rt.ParseIntError = _2751.error; const _2767: rt.IntErrorKind = e30.kind; @@ -4606,7 +4606,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _2787: rt.IntErrorKind = e30.kind; const args120: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e30, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e30, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _2787), (f: rt.Formatter) => rt.i32Display(kind31, f), (f: rt.Formatter) => rt.fmtBool(over30, f)]; - fmt_put(out, rt.fmtFormat([args120[0], "|", args120[1], "|", args120[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args120[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args120[0]), "|", args120[3], "|", args120[4]])); + put(out, rt.fmtFormat([args120[0], "|", args120[1], "|", args120[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args120[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args120[0]), "|", args120[3], "|", args120[4]])); } if (radix52 === 10) { const parsed30: rt.Result = parse$0xnscjy(_2748); @@ -4633,7 +4633,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_2841.ok) { const arg18 = _2841.value; const args122: rt.Fmt[] = [(f: rt.Formatter) => rt.i16Display(arg18, f)]; - fmt_put(out, rt.fmtFormat([args122[0]])); + put(out, rt.fmtFormat([args122[0]])); } else { const e31: rt.ParseIntError = _2841.error; const _2857: rt.IntErrorKind = e31.kind; @@ -4655,7 +4655,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _2877: rt.IntErrorKind = e31.kind; const args124: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e31, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e31, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _2877), (f: rt.Formatter) => rt.i32Display(kind32, f), (f: rt.Formatter) => rt.fmtBool(over31, f)]; - fmt_put(out, rt.fmtFormat([args124[0], "|", args124[1], "|", args124[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args124[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args124[0]), "|", args124[3], "|", args124[4]])); + put(out, rt.fmtFormat([args124[0], "|", args124[1], "|", args124[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args124[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args124[0]), "|", args124[3], "|", args124[4]])); } if (radix54 === 10) { const parsed31: rt.Result = parse$0xnscjy(_2830); @@ -4687,7 +4687,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_2938.ok) { const arg17 = _2938.value; const args126: rt.Fmt[] = [(f: rt.Formatter) => rt.i16Display(arg17, f)]; - fmt_put(out, rt.fmtFormat([args126[0]])); + put(out, rt.fmtFormat([args126[0]])); } else { const e32: rt.ParseIntError = _2938.error; const _2954: rt.IntErrorKind = e32.kind; @@ -4709,7 +4709,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _2974: rt.IntErrorKind = e32.kind; const args128: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e32, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e32, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _2974), (f: rt.Formatter) => rt.i32Display(kind33, f), (f: rt.Formatter) => rt.fmtBool(over32, f)]; - fmt_put(out, rt.fmtFormat([args128[0], "|", args128[1], "|", args128[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args128[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args128[0]), "|", args128[3], "|", args128[4]])); + put(out, rt.fmtFormat([args128[0], "|", args128[1], "|", args128[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args128[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args128[0]), "|", args128[3], "|", args128[4]])); } if (radix56 === 10) { const parsed32: rt.Result = parse$0xnscjy(_2933); @@ -4745,7 +4745,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_3037.ok) { const arg16 = _3037.value; const args130: rt.Fmt[] = [(f: rt.Formatter) => rt.i32Display(arg16, f)]; - fmt_put(out, rt.fmtFormat([args130[0]])); + put(out, rt.fmtFormat([args130[0]])); } else { const e33: rt.ParseIntError = _3037.error; const _3053: rt.IntErrorKind = e33.kind; @@ -4767,7 +4767,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _3073: rt.IntErrorKind = e33.kind; const args132: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e33, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e33, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _3073), (f: rt.Formatter) => rt.i32Display(kind34, f), (f: rt.Formatter) => rt.fmtBool(over33, f)]; - fmt_put(out, rt.fmtFormat([args132[0], "|", args132[1], "|", args132[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args132[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args132[0]), "|", args132[3], "|", args132[4]])); + put(out, rt.fmtFormat([args132[0], "|", args132[1], "|", args132[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args132[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args132[0]), "|", args132[3], "|", args132[4]])); } if (radix58 === 10) { const parsed33: rt.Result = parse$12szghw(_3016.value); @@ -4794,7 +4794,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_3128.ok) { const arg15 = _3128.value; const args134: rt.Fmt[] = [(f: rt.Formatter) => rt.i32Display(arg15, f)]; - fmt_put(out, rt.fmtFormat([args134[0]])); + put(out, rt.fmtFormat([args134[0]])); } else { const e34: rt.ParseIntError = _3128.error; const _3144: rt.IntErrorKind = e34.kind; @@ -4816,7 +4816,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _3164: rt.IntErrorKind = e34.kind; const args136: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e34, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e34, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _3164), (f: rt.Formatter) => rt.i32Display(kind35, f), (f: rt.Formatter) => rt.fmtBool(over34, f)]; - fmt_put(out, rt.fmtFormat([args136[0], "|", args136[1], "|", args136[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args136[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args136[0]), "|", args136[3], "|", args136[4]])); + put(out, rt.fmtFormat([args136[0], "|", args136[1], "|", args136[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args136[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args136[0]), "|", args136[3], "|", args136[4]])); } if (radix59 === 10) { const parsed34: rt.Result = parse$12szghw(_3125); @@ -4843,7 +4843,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_3218.ok) { const arg14 = _3218.value; const args138: rt.Fmt[] = [(f: rt.Formatter) => rt.i32Display(arg14, f)]; - fmt_put(out, rt.fmtFormat([args138[0]])); + put(out, rt.fmtFormat([args138[0]])); } else { const e35: rt.ParseIntError = _3218.error; const _3234: rt.IntErrorKind = e35.kind; @@ -4865,7 +4865,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _3254: rt.IntErrorKind = e35.kind; const args140: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e35, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e35, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _3254), (f: rt.Formatter) => rt.i32Display(kind36, f), (f: rt.Formatter) => rt.fmtBool(over35, f)]; - fmt_put(out, rt.fmtFormat([args140[0], "|", args140[1], "|", args140[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args140[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args140[0]), "|", args140[3], "|", args140[4]])); + put(out, rt.fmtFormat([args140[0], "|", args140[1], "|", args140[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args140[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args140[0]), "|", args140[3], "|", args140[4]])); } if (radix61 === 10) { const parsed35: rt.Result = parse$12szghw(_3207); @@ -4897,7 +4897,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_3315.ok) { const arg13 = _3315.value; const args142: rt.Fmt[] = [(f: rt.Formatter) => rt.i32Display(arg13, f)]; - fmt_put(out, rt.fmtFormat([args142[0]])); + put(out, rt.fmtFormat([args142[0]])); } else { const e36: rt.ParseIntError = _3315.error; const _3331: rt.IntErrorKind = e36.kind; @@ -4919,7 +4919,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _3351: rt.IntErrorKind = e36.kind; const args144: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e36, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e36, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _3351), (f: rt.Formatter) => rt.i32Display(kind37, f), (f: rt.Formatter) => rt.fmtBool(over36, f)]; - fmt_put(out, rt.fmtFormat([args144[0], "|", args144[1], "|", args144[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args144[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args144[0]), "|", args144[3], "|", args144[4]])); + put(out, rt.fmtFormat([args144[0], "|", args144[1], "|", args144[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args144[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args144[0]), "|", args144[3], "|", args144[4]])); } if (radix63 === 10) { const parsed36: rt.Result = parse$12szghw(_3310); @@ -4955,7 +4955,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_3414.ok) { const arg12 = _3414.value; const args146: rt.Fmt[] = [(f: rt.Formatter) => rt.i64Display(arg12, f)]; - fmt_put(out, rt.fmtFormat([args146[0]])); + put(out, rt.fmtFormat([args146[0]])); } else { const e37: rt.ParseIntError = _3414.error; const _3430: rt.IntErrorKind = e37.kind; @@ -4977,7 +4977,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _3450: rt.IntErrorKind = e37.kind; const args148: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e37, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e37, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _3450), (f: rt.Formatter) => rt.i32Display(kind38, f), (f: rt.Formatter) => rt.fmtBool(over37, f)]; - fmt_put(out, rt.fmtFormat([args148[0], "|", args148[1], "|", args148[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args148[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args148[0]), "|", args148[3], "|", args148[4]])); + put(out, rt.fmtFormat([args148[0], "|", args148[1], "|", args148[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args148[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args148[0]), "|", args148[3], "|", args148[4]])); } if (radix65 === 10) { const parsed37: rt.Result = parse$11m1f1e(_3393.value); @@ -5004,7 +5004,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_3505.ok) { const arg11 = _3505.value; const args150: rt.Fmt[] = [(f: rt.Formatter) => rt.i64Display(arg11, f)]; - fmt_put(out, rt.fmtFormat([args150[0]])); + put(out, rt.fmtFormat([args150[0]])); } else { const e38: rt.ParseIntError = _3505.error; const _3521: rt.IntErrorKind = e38.kind; @@ -5026,7 +5026,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _3541: rt.IntErrorKind = e38.kind; const args152: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e38, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e38, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _3541), (f: rt.Formatter) => rt.i32Display(kind39, f), (f: rt.Formatter) => rt.fmtBool(over38, f)]; - fmt_put(out, rt.fmtFormat([args152[0], "|", args152[1], "|", args152[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args152[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args152[0]), "|", args152[3], "|", args152[4]])); + put(out, rt.fmtFormat([args152[0], "|", args152[1], "|", args152[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args152[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args152[0]), "|", args152[3], "|", args152[4]])); } if (radix66 === 10) { const parsed38: rt.Result = parse$11m1f1e(_3502); @@ -5053,7 +5053,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_3595.ok) { const arg10 = _3595.value; const args154: rt.Fmt[] = [(f: rt.Formatter) => rt.i64Display(arg10, f)]; - fmt_put(out, rt.fmtFormat([args154[0]])); + put(out, rt.fmtFormat([args154[0]])); } else { const e39: rt.ParseIntError = _3595.error; const _3611: rt.IntErrorKind = e39.kind; @@ -5075,7 +5075,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _3631: rt.IntErrorKind = e39.kind; const args156: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e39, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e39, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _3631), (f: rt.Formatter) => rt.i32Display(kind40, f), (f: rt.Formatter) => rt.fmtBool(over39, f)]; - fmt_put(out, rt.fmtFormat([args156[0], "|", args156[1], "|", args156[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args156[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args156[0]), "|", args156[3], "|", args156[4]])); + put(out, rt.fmtFormat([args156[0], "|", args156[1], "|", args156[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args156[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args156[0]), "|", args156[3], "|", args156[4]])); } if (radix68 === 10) { const parsed39: rt.Result = parse$11m1f1e(_3584); @@ -5107,7 +5107,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_3692.ok) { const arg9 = _3692.value; const args158: rt.Fmt[] = [(f: rt.Formatter) => rt.i64Display(arg9, f)]; - fmt_put(out, rt.fmtFormat([args158[0]])); + put(out, rt.fmtFormat([args158[0]])); } else { const e40: rt.ParseIntError = _3692.error; const _3708: rt.IntErrorKind = e40.kind; @@ -5129,7 +5129,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _3728: rt.IntErrorKind = e40.kind; const args160: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e40, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e40, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _3728), (f: rt.Formatter) => rt.i32Display(kind41, f), (f: rt.Formatter) => rt.fmtBool(over40, f)]; - fmt_put(out, rt.fmtFormat([args160[0], "|", args160[1], "|", args160[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args160[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args160[0]), "|", args160[3], "|", args160[4]])); + put(out, rt.fmtFormat([args160[0], "|", args160[1], "|", args160[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args160[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args160[0]), "|", args160[3], "|", args160[4]])); } if (radix70 === 10) { const parsed40: rt.Result = parse$11m1f1e(_3687); @@ -5165,7 +5165,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_3791.ok) { const arg8 = _3791.value; const args162: rt.Fmt[] = [(f: rt.Formatter) => rt.i128Display(arg8, f)]; - fmt_put(out, rt.fmtFormat([args162[0]])); + put(out, rt.fmtFormat([args162[0]])); } else { const e41: rt.ParseIntError = _3791.error; const _3807: rt.IntErrorKind = e41.kind; @@ -5187,7 +5187,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _3827: rt.IntErrorKind = e41.kind; const args164: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e41, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e41, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _3827), (f: rt.Formatter) => rt.i32Display(kind42, f), (f: rt.Formatter) => rt.fmtBool(over41, f)]; - fmt_put(out, rt.fmtFormat([args164[0], "|", args164[1], "|", args164[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args164[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args164[0]), "|", args164[3], "|", args164[4]])); + put(out, rt.fmtFormat([args164[0], "|", args164[1], "|", args164[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args164[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args164[0]), "|", args164[3], "|", args164[4]])); } if (radix72 === 10) { const parsed41: rt.Result = parse$082ztwj(_3770.value); @@ -5214,7 +5214,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_3882.ok) { const arg7 = _3882.value; const args166: rt.Fmt[] = [(f: rt.Formatter) => rt.i128Display(arg7, f)]; - fmt_put(out, rt.fmtFormat([args166[0]])); + put(out, rt.fmtFormat([args166[0]])); } else { const e42: rt.ParseIntError = _3882.error; const _3898: rt.IntErrorKind = e42.kind; @@ -5236,7 +5236,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _3918: rt.IntErrorKind = e42.kind; const args168: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e42, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e42, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _3918), (f: rt.Formatter) => rt.i32Display(kind43, f), (f: rt.Formatter) => rt.fmtBool(over42, f)]; - fmt_put(out, rt.fmtFormat([args168[0], "|", args168[1], "|", args168[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args168[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args168[0]), "|", args168[3], "|", args168[4]])); + put(out, rt.fmtFormat([args168[0], "|", args168[1], "|", args168[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args168[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args168[0]), "|", args168[3], "|", args168[4]])); } if (radix73 === 10) { const parsed42: rt.Result = parse$082ztwj(_3879); @@ -5263,7 +5263,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_3972.ok) { const arg6 = _3972.value; const args170: rt.Fmt[] = [(f: rt.Formatter) => rt.i128Display(arg6, f)]; - fmt_put(out, rt.fmtFormat([args170[0]])); + put(out, rt.fmtFormat([args170[0]])); } else { const e43: rt.ParseIntError = _3972.error; const _3988: rt.IntErrorKind = e43.kind; @@ -5285,7 +5285,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _4008: rt.IntErrorKind = e43.kind; const args172: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e43, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e43, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _4008), (f: rt.Formatter) => rt.i32Display(kind44, f), (f: rt.Formatter) => rt.fmtBool(over43, f)]; - fmt_put(out, rt.fmtFormat([args172[0], "|", args172[1], "|", args172[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args172[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args172[0]), "|", args172[3], "|", args172[4]])); + put(out, rt.fmtFormat([args172[0], "|", args172[1], "|", args172[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args172[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args172[0]), "|", args172[3], "|", args172[4]])); } if (radix75 === 10) { const parsed43: rt.Result = parse$082ztwj(_3961); @@ -5317,7 +5317,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_4069.ok) { const arg5 = _4069.value; const args174: rt.Fmt[] = [(f: rt.Formatter) => rt.i128Display(arg5, f)]; - fmt_put(out, rt.fmtFormat([args174[0]])); + put(out, rt.fmtFormat([args174[0]])); } else { const e44: rt.ParseIntError = _4069.error; const _4085: rt.IntErrorKind = e44.kind; @@ -5339,7 +5339,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _4105: rt.IntErrorKind = e44.kind; const args176: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e44, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e44, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _4105), (f: rt.Formatter) => rt.i32Display(kind45, f), (f: rt.Formatter) => rt.fmtBool(over44, f)]; - fmt_put(out, rt.fmtFormat([args176[0], "|", args176[1], "|", args176[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args176[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args176[0]), "|", args176[3], "|", args176[4]])); + put(out, rt.fmtFormat([args176[0], "|", args176[1], "|", args176[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args176[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args176[0]), "|", args176[3], "|", args176[4]])); } if (radix77 === 10) { const parsed44: rt.Result = parse$082ztwj(_4064); @@ -5375,7 +5375,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_4168.ok) { const arg4 = _4168.value; const args178: rt.Fmt[] = [(f: rt.Formatter) => rt.isizeDisplay(arg4, f)]; - fmt_put(out, rt.fmtFormat([args178[0]])); + put(out, rt.fmtFormat([args178[0]])); } else { const e45: rt.ParseIntError = _4168.error; const _4184: rt.IntErrorKind = e45.kind; @@ -5397,7 +5397,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _4204: rt.IntErrorKind = e45.kind; const args180: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e45, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e45, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _4204), (f: rt.Formatter) => rt.i32Display(kind46, f), (f: rt.Formatter) => rt.fmtBool(over45, f)]; - fmt_put(out, rt.fmtFormat([args180[0], "|", args180[1], "|", args180[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args180[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args180[0]), "|", args180[3], "|", args180[4]])); + put(out, rt.fmtFormat([args180[0], "|", args180[1], "|", args180[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args180[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args180[0]), "|", args180[3], "|", args180[4]])); } if (radix79 === 10) { const parsed45: rt.Result = parse$07xyv4i(_4147.value); @@ -5424,7 +5424,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_4259.ok) { const arg3 = _4259.value; const args182: rt.Fmt[] = [(f: rt.Formatter) => rt.isizeDisplay(arg3, f)]; - fmt_put(out, rt.fmtFormat([args182[0]])); + put(out, rt.fmtFormat([args182[0]])); } else { const e46: rt.ParseIntError = _4259.error; const _4275: rt.IntErrorKind = e46.kind; @@ -5446,7 +5446,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _4295: rt.IntErrorKind = e46.kind; const args184: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e46, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e46, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _4295), (f: rt.Formatter) => rt.i32Display(kind47, f), (f: rt.Formatter) => rt.fmtBool(over46, f)]; - fmt_put(out, rt.fmtFormat([args184[0], "|", args184[1], "|", args184[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args184[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args184[0]), "|", args184[3], "|", args184[4]])); + put(out, rt.fmtFormat([args184[0], "|", args184[1], "|", args184[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args184[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args184[0]), "|", args184[3], "|", args184[4]])); } if (radix80 === 10) { const parsed46: rt.Result = parse$07xyv4i(_4256); @@ -5473,7 +5473,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_4349.ok) { const arg2 = _4349.value; const args186: rt.Fmt[] = [(f: rt.Formatter) => rt.isizeDisplay(arg2, f)]; - fmt_put(out, rt.fmtFormat([args186[0]])); + put(out, rt.fmtFormat([args186[0]])); } else { const e47: rt.ParseIntError = _4349.error; const _4365: rt.IntErrorKind = e47.kind; @@ -5495,7 +5495,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _4385: rt.IntErrorKind = e47.kind; const args188: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e47, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e47, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _4385), (f: rt.Formatter) => rt.i32Display(kind48, f), (f: rt.Formatter) => rt.fmtBool(over47, f)]; - fmt_put(out, rt.fmtFormat([args188[0], "|", args188[1], "|", args188[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args188[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args188[0]), "|", args188[3], "|", args188[4]])); + put(out, rt.fmtFormat([args188[0], "|", args188[1], "|", args188[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args188[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args188[0]), "|", args188[3], "|", args188[4]])); } if (radix82 === 10) { const parsed47: rt.Result = parse$07xyv4i(_4338); @@ -5527,7 +5527,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat if (_4446.ok) { const arg = _4446.value; const args190: rt.Fmt[] = [(f: rt.Formatter) => rt.isizeDisplay(arg, f)]; - fmt_put(out, rt.fmtFormat([args190[0]])); + put(out, rt.fmtFormat([args190[0]])); } else { const e48: rt.ParseIntError = _4446.error; const _4462: rt.IntErrorKind = e48.kind; @@ -5549,7 +5549,7 @@ export function parses(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const _4482: rt.IntErrorKind = e48.kind; const args192: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e48, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e48, f), (f: rt.Formatter) => rt.fmtWriteStr(f, _4482), (f: rt.Formatter) => rt.i32Display(kind49, f), (f: rt.Formatter) => rt.fmtBool(over48, f)]; - fmt_put(out, rt.fmtFormat([args192[0], "|", args192[1], "|", args192[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args192[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args192[0]), "|", args192[3], "|", args192[4]])); + put(out, rt.fmtFormat([args192[0], "|", args192[1], "|", args192[2], "|", rt.fmtSpec({ align: ">", width: 42 }, args192[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args192[0]), "|", args192[3], "|", args192[4]])); } if (radix84 === 10) { const parsed48: rt.Result = parse$07xyv4i(_4441); diff --git a/ts/fixtures/lang/ints/expected/lib.ts b/ts/fixtures/lang/ints/expected/lib.ts new file mode 100644 index 000000000..c0721f889 --- /dev/null +++ b/ts/fixtures/lang/ints/expected/lib.ts @@ -0,0 +1,48 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { u8Op, u16Op, u32Op, u64Op, u128Op, usizeOp, i8Op, i16Op, i32Op, i64Op, i128Op, isizeOp, i8Neg, i16Neg, i32Neg, i64Neg, i128Neg, isizeNeg, cast as ints_cast, convert, parses, widenings } from "./ints.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["ints::u8_op", u8Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::u16_op", u16Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::u32_op", u32Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::u64_op", u64Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::u128_op", u128Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::usize_op", usizeOp as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::i8_op", i8Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::i16_op", i16Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::i32_op", i32Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::i64_op", i64Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::i128_op", i128Op as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::isize_op", isizeOp as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::neg", neg as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::cast", cast as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::convert", (_210: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + convert(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::parses", (a015: rt.u8, a115: rt.ByteSlice, a215: rt.ByteVec): undefined => { + parses(a015, a115.data, a115.start, a115.length, a215); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ints::widenings", widenings as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +/** Negate the signed type `kind` picks. */ +export function neg(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { + const _4: rt.u8 = rt.u8Rem(kind, 6); + if (_4 === 0) { + i8Neg(data, out); + } else if (_4 === 1) { + i16Neg(data, out); + } else if (_4 === 2) { + i32Neg(data, out); + } else if (_4 === 3) { + i64Neg(data, out); + } else if (_4 === 4) { + i128Neg(data, out); + } else { + isizeNeg(data, out); + } +} + +/** + * Cast from the type `kind` picks to the one the next byte does, or without one, to + * a type `kind` also picks. + */ +export function cast(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { + if (data.length === 0) { + ints_cast(kind, rt.u8Div(kind, 12), data, out); + } else { + ints_cast(kind, data.data[data.start], new rt.ByteSlice(data.data, data.start + 1, data.length - 1), out); + } +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/ints.rs b/ts/fixtures/lang/ints/src/ints.rs similarity index 99% rename from ts/fixtures/lang/src/ints.rs rename to ts/fixtures/lang/ints/src/ints.rs index 73d188522..1c95a20c8 100644 --- a/ts/fixtures/lang/src/ints.rs +++ b/ts/fixtures/lang/ints/src/ints.rs @@ -371,7 +371,7 @@ macro_rules! parse_one { ($t:ty, $s:expr, $radix:expr, $out:expr) => {{ let (s, radix, out): (&str, u32, &mut Vec) = ($s, $radix, $out); match <$t>::from_str_radix(s, radix) { - Ok(v) => crate::fmt::put(out, &format!("{v}")), + Ok(v) => crate::harness::put(out, &format!("{v}")), Err(e) => { let kind = match e.kind() { IntErrorKind::Empty => 0, @@ -381,7 +381,7 @@ macro_rules! parse_one { _ => 4, }; let over = *e.kind() == IntErrorKind::PosOverflow || e.kind() != &IntErrorKind::NegOverflow; - crate::fmt::put(out, &format!("{e}|{e:?}|{:?}|{e:>42}|{e:<3.5}|{kind}|{over}", e.kind())); + crate::harness::put(out, &format!("{e}|{e:?}|{:?}|{e:>42}|{e:<3.5}|{kind}|{over}", e.kind())); } } if radix == 10 { diff --git a/ts/fixtures/lang/ints/src/lib.rs b/ts/fixtures/lang/ints/src/lib.rs new file mode 100644 index 000000000..7db3410e8 --- /dev/null +++ b/ts/fixtures/lang/ints/src/lib.rs @@ -0,0 +1,58 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod ints; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("ints::u8_op", ints::u8_op), + ("ints::u16_op", ints::u16_op), + ("ints::u32_op", ints::u32_op), + ("ints::u64_op", ints::u64_op), + ("ints::u128_op", ints::u128_op), + ("ints::usize_op", ints::usize_op), + ("ints::i8_op", ints::i8_op), + ("ints::i16_op", ints::i16_op), + ("ints::i32_op", ints::i32_op), + ("ints::i64_op", ints::i64_op), + ("ints::i128_op", ints::i128_op), + ("ints::isize_op", ints::isize_op), + ("ints::neg", neg), + ("ints::cast", cast), + ("ints::convert", |_, data, out| ints::convert(data, out)), + ("ints::parses", ints::parses), + ("ints::widenings", ints::widenings), + ] +} + +/// Negate the signed type `kind` picks. +fn neg(kind: u8, data: &[u8], out: &mut Vec) { + match kind % 6 { + 0 => ints::i8_neg(data, out), + 1 => ints::i16_neg(data, out), + 2 => ints::i32_neg(data, out), + 3 => ints::i64_neg(data, out), + 4 => ints::i128_neg(data, out), + _ => ints::isize_neg(data, out), + } +} + +/// Cast from the type `kind` picks to the one the next byte does, or without one, to +/// a type `kind` also picks. +fn cast(kind: u8, data: &[u8], out: &mut Vec) { + match data.split_first() { + Some((&to, data)) => ints::cast(kind, to, data, out), + None => ints::cast(kind, kind / 12, data, out), + } +} diff --git a/ts/fixtures/lang/ints/ts.toml b/ts/fixtures/lang/ints/ts.toml new file mode 100644 index 000000000..e01812179 --- /dev/null +++ b/ts/fixtures/lang/ints/ts.toml @@ -0,0 +1,2 @@ +package = "lang-ints-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/iters/Cargo.toml b/ts/fixtures/lang/iters/Cargo.toml new file mode 100644 index 000000000..56b0d1511 --- /dev/null +++ b/ts/fixtures/lang/iters/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-iters-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/iters/caller.ts b/ts/fixtures/lang/iters/caller.ts new file mode 100644 index 000000000..838bb1c91 --- /dev/null +++ b/ts/fixtures/lang/iters/caller.ts @@ -0,0 +1,47 @@ +// The inputs `iters`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `iters::reducers` of no items, one, one repeated, which `next_if_eq` takes, and keys + * that all tie. + */ +const reducers = [[], [9], [9, 9], [8, 4, 12, 0x40, 0x80]].map((bytes) => Uint8Array.of(...op("iters::reducers"), 0, ...bytes)); + +/** + * `iters::peeked_others` of no items, one, a run that matches the first throughout, and + * items that each match one comparison and miss the next. + */ +const peekedOthers = [[], [3], [4, 4, 4, 4], [0, 1, 2, 3, 4, 5, 6], [1, 0, 0, 2, 5, 9]].map((bytes) => + Uint8Array.of(...op("iters::peeked_others"), 0, ...bytes), +); + +/** + * `iters::range_froms` of each case, each way its zips read the range, from each distance + * below its type's last value and from 250, on up to nine bytes: each length its zips + * panic at. + */ +const rangeFromsOp = op("iters::range_froms"); +const rangeFroms = Array.from({ length: 16 * 4 * 4 * 10 }, (_, i) => { + const kind = (i % 16) | ((Math.floor(i / 16) % 4) << 6); + const a = [0, 1, 3, 250][Math.floor(i / 64) % 4]; + const data = Array.from({ length: Math.floor(i / 256) }, (_, j) => (j === 0 ? a : (j * 37) & 0xff)); + return Uint8Array.of(...rangeFromsOp, kind, ...data); +}); + +/** `iters::range_methods` of each type's table, at each pair of its first eight values. */ +const rangeMethodsOp = op("iters::range_methods"); +const rangeMethods = Array.from({ length: 19 * 64 }, (_, i) => Uint8Array.of(...rangeMethodsOp, i % 19, Math.floor(i / 19) % 8, Math.floor(i / 152))); + +/** + * `iters::compares` of each comparison, shape, and pair, over no items, one, a run up to + * 255, which `start..` panics past and a sum overflows at, NaNs, and repeats. + */ +const comparesOp = op("iters::compares"); +const compares = [[], [5], [1, 2, 3], [250, 251, 252, 253, 254, 255], [0xff, 3, 0xff], [0, 1, 2, 3, 4, 5], [7, 7, 7, 7, 7, 7, 7, 7, 7]].flatMap((data) => + Array.from({ length: 256 }, (_, kind) => Uint8Array.of(...comparesOp, kind, ...data)), +); + +export const cases: Uint8Array[] = [...reducers, ...peekedOthers, ...rangeFroms, ...rangeMethods, ...compares]; diff --git a/ts/fixtures/lang/iters/expected/core/bool.ts b/ts/fixtures/lang/iters/expected/core/bool.ts new file mode 100644 index 000000000..f14754359 --- /dev/null +++ b/ts/fixtures/lang/iters/expected/core/bool.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0b23a33(self: boolean, t: rt.u16): rt.u16 | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function thenSome$0d5am30(self: boolean, t: rt.u8): rt.u8 | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/iters/expected/core/option.ts b/ts/fixtures/lang/iters/expected/core/option.ts new file mode 100644 index 000000000..510d2734c --- /dev/null +++ b/ts/fixtures/lang/iters/expected/core/option.ts @@ -0,0 +1,263 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Badge from "../iters.Badge.ts"; +import type * as Quarter from "../iters.Quarter.ts"; +import type * as Tilt from "../iters.Tilt.ts"; + +export function unwrapOr$0k15iai(self: rt.char | undefined, default_: rt.char): rt.char { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$00uis1j(self: rt.i64 | undefined, default_: rt.i64): rt.i64 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$14m5xjm(self: [rt.usize, rt.u8] | undefined, default_: [rt.usize, rt.u8]): [rt.usize, rt.u8] { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$1tvry1i(self: rt.u64 | undefined, default_: rt.u64): rt.u64 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOrDefault$165pyh5(self: string | undefined): string { + if (self === undefined) { + return ""; + } + return self; +} + +export function unwrapOrDefault$0wx44sw(self: rt.ByteVec | undefined): rt.ByteVec { + if (self === undefined) { + return new rt.ByteVec(); + } + return self; +} + +export function map$1uo1d4o(self: string | undefined, _: (a0: string) => string): string | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function map$1httady(self: string[] | undefined, f: (a0: string[]) => string): string | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0of9gds(self: rt.u8 | undefined, f: (a0: rt.u8) => Badge.Badge): Badge.Badge | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$1c7zybz(self: rt.u8 | undefined, _: (a0: rt.u8) => rt.u32): rt.u32 | undefined { + if (self === undefined) { + return undefined; + } + return self as rt.u32; +} + +export function map$0cs071d(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0p22lts(self: rt.u8 | undefined, f: (a0: rt.u8) => undefined): undefined | rt.None { + if (self === undefined) { + return rt.None; + } + f(self); + return undefined; +} + +export function mapOr$0lcrgk1(self: string | undefined, default_: rt.u8, f: (a0: string) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1kiffmd(self: rt.u16[] | undefined, default_: rt.u8, f: (a0: rt.u16[]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1a3irjf(self: rt.ByteVec | undefined, default_: rt.u8, f: (a0: rt.ByteVec) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0sl5app(self: Uint8Array | undefined, default_: rt.u8, f: (a0: Uint8Array) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0atjiti(self: rt.char | undefined, default_: rt.u32, _: (a0: rt.char) => rt.u32): rt.u32 { + if (self === undefined) { + return default_; + } + return self as rt.u32; +} + +export function mapOr$0okqj9y(self: rt.char | undefined, default_: rt.u8, f: (a0: rt.char) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1e4a1e0(self: rt.Ordering | undefined, default_: rt.u8, f: (a0: rt.Ordering) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1lznlgz(self: Quarter.Quarter | undefined, default_: rt.u8, f: (a0: Quarter.Quarter) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0tmtgfi(self: Tilt.Tilt | undefined, default_: rt.u8, f: (a0: Tilt.Tilt) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0ev76sb(self: rt.Place | undefined, default_: rt.u8, f: (a0: rt.Place) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1surhce(self: rt.u8 | undefined, default_: rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1t0muvr(self: rt.u8 | undefined, default_: rt.usize, f: (a0: rt.u8) => rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0a96v80(self: [rt.ByteSlice, [rt.usize, rt.u8]] | undefined, default_: rt.u8, f: (a0: [rt.ByteSlice, [rt.usize, rt.u8]]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1vjqo89(self: [rt.u8, rt.ByteSlice] | undefined, default_: rt.u8, f: (a0: [rt.u8, rt.ByteSlice]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1h04da8(self: [rt.u8, [rt.u8, rt.usize]] | undefined, default_: rt.u8, f: (a0: [rt.u8, [rt.u8, rt.usize]]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0f73bb7(self: [rt.u8, [rt.usize, rt.ByteSlice]] | undefined, default_: rt.u8, f: (a0: [rt.u8, [rt.usize, rt.ByteSlice]]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0mmpeqx(self: [rt.u8, rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u8, rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$06gg5x7(self: [rt.usize, rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.usize, rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1dmz9kd(self: [rt.usize, [rt.u8, rt.ByteSlice]] | undefined, default_: rt.u8, f: (a0: [rt.usize, [rt.u8, rt.ByteSlice]]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1sxa8ki(self: rt.u32 | undefined, default_: rt.u8, f: (a0: rt.u32) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$02k4ito(self: rt.usize | undefined, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function asDeref$0w8at8i(self: string | undefined): string | undefined { + return map$1uo1d4o(self, (a0: string): string => { + return a0; + }); +} + +export function filter$0v80fk8(self: rt.u8 | undefined, predicate: (a0: rt.u8) => boolean): rt.u8 | undefined { + if (self !== undefined) { + const x: rt.u8 = self; + if (predicate(x)) { + return x; + } + } + return undefined; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/iters/expected/core/result.ts b/ts/fixtures/lang/iters/expected/core/result.ts new file mode 100644 index 000000000..9f3171569 --- /dev/null +++ b/ts/fixtures/lang/iters/expected/core/result.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$01jdcm7(self: rt.Result, default_: string): string { + if (self.ok) { + return self.value; + } + return default_; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/iters/expected/harness.ts b/ts/fixtures/lang/iters/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/iters/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/expected/iters.Badge.ts b/ts/fixtures/lang/iters/expected/iters.Badge.ts similarity index 100% rename from ts/fixtures/lang/expected/iters.Badge.ts rename to ts/fixtures/lang/iters/expected/iters.Badge.ts diff --git a/ts/fixtures/lang/expected/iters.Bumped.ts b/ts/fixtures/lang/iters/expected/iters.Bumped.ts similarity index 100% rename from ts/fixtures/lang/expected/iters.Bumped.ts rename to ts/fixtures/lang/iters/expected/iters.Bumped.ts diff --git a/ts/fixtures/lang/expected/iters.Countdown.ts b/ts/fixtures/lang/iters/expected/iters.Countdown.ts similarity index 100% rename from ts/fixtures/lang/expected/iters.Countdown.ts rename to ts/fixtures/lang/iters/expected/iters.Countdown.ts diff --git a/ts/fixtures/lang/expected/iters.Doubled.ts b/ts/fixtures/lang/iters/expected/iters.Doubled.ts similarity index 100% rename from ts/fixtures/lang/expected/iters.Doubled.ts rename to ts/fixtures/lang/iters/expected/iters.Doubled.ts diff --git a/ts/fixtures/lang/expected/iters.Evens.ts b/ts/fixtures/lang/iters/expected/iters.Evens.ts similarity index 100% rename from ts/fixtures/lang/expected/iters.Evens.ts rename to ts/fixtures/lang/iters/expected/iters.Evens.ts diff --git a/ts/fixtures/lang/expected/iters.Gaps.ts b/ts/fixtures/lang/iters/expected/iters.Gaps.ts similarity index 100% rename from ts/fixtures/lang/expected/iters.Gaps.ts rename to ts/fixtures/lang/iters/expected/iters.Gaps.ts diff --git a/ts/fixtures/lang/expected/iters.Halving.ts b/ts/fixtures/lang/iters/expected/iters.Halving.ts similarity index 100% rename from ts/fixtures/lang/expected/iters.Halving.ts rename to ts/fixtures/lang/iters/expected/iters.Halving.ts diff --git a/ts/fixtures/lang/expected/iters.Held.ts b/ts/fixtures/lang/iters/expected/iters.Held.ts similarity index 100% rename from ts/fixtures/lang/expected/iters.Held.ts rename to ts/fixtures/lang/iters/expected/iters.Held.ts diff --git a/ts/fixtures/lang/expected/iters.Quarter.ts b/ts/fixtures/lang/iters/expected/iters.Quarter.ts similarity index 100% rename from ts/fixtures/lang/expected/iters.Quarter.ts rename to ts/fixtures/lang/iters/expected/iters.Quarter.ts diff --git a/ts/fixtures/lang/expected/iters.Tag.ts b/ts/fixtures/lang/iters/expected/iters.Tag.ts similarity index 100% rename from ts/fixtures/lang/expected/iters.Tag.ts rename to ts/fixtures/lang/iters/expected/iters.Tag.ts diff --git a/ts/fixtures/lang/expected/iters.Tilt.ts b/ts/fixtures/lang/iters/expected/iters.Tilt.ts similarity index 100% rename from ts/fixtures/lang/expected/iters.Tilt.ts rename to ts/fixtures/lang/iters/expected/iters.Tilt.ts diff --git a/ts/fixtures/lang/expected/iters.Weighed.ts b/ts/fixtures/lang/iters/expected/iters.Weighed.ts similarity index 100% rename from ts/fixtures/lang/expected/iters.Weighed.ts rename to ts/fixtures/lang/iters/expected/iters.Weighed.ts diff --git a/ts/fixtures/lang/expected/iters.Wrapper.ts b/ts/fixtures/lang/iters/expected/iters.Wrapper.ts similarity index 100% rename from ts/fixtures/lang/expected/iters.Wrapper.ts rename to ts/fixtures/lang/iters/expected/iters.Wrapper.ts diff --git a/ts/fixtures/lang/expected/iters.ts b/ts/fixtures/lang/iters/expected/iters.ts similarity index 99% rename from ts/fixtures/lang/expected/iters.ts rename to ts/fixtures/lang/iters/expected/iters.ts index 0a4c4a47c..24ac00490 100644 --- a/ts/fixtures/lang/expected/iters.ts +++ b/ts/fixtures/lang/iters/expected/iters.ts @@ -1,18 +1,17 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { copy$iters_Bumped, copy$tuple2_u8_u8 } from "./lib.ts"; -import { thenSome$0d5am30, thenSome$0b23a33 } from "./core/bool.ts"; -import { unwrapOr$0k15iai as option_unwrapOr$0k15iai, unwrapOr$00uis1j as option_unwrapOr$00uis1j, unwrapOr$1tvry1i as option_unwrapOr$1tvry1i, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOr$14m5xjm as option_unwrapOr$14m5xjm, unwrapOrDefault$165pyh5 as option_unwrapOrDefault$165pyh5, unwrapOrDefault$0wx44sw as option_unwrapOrDefault$0wx44sw, map$1uo1d4o as option_map$1uo1d4o, map$1httady as option_map$1httady, map$0p22lts as option_map$0p22lts, map$0of9gds as option_map$0of9gds, map$1c7zybz as option_map$1c7zybz, map$0cs071d as option_map$0cs071d, mapOr$0lcrgk1 as option_mapOr$0lcrgk1, mapOr$1kiffmd as option_mapOr$1kiffmd, mapOr$1a3irjf as option_mapOr$1a3irjf, mapOr$0sl5app as option_mapOr$0sl5app, mapOr$0atjiti as option_mapOr$0atjiti, mapOr$0okqj9y as option_mapOr$0okqj9y, mapOr$1e4a1e0 as option_mapOr$1e4a1e0, mapOr$1lznlgz as option_mapOr$1lznlgz, mapOr$0tmtgfi as option_mapOr$0tmtgfi, mapOr$0ev76sb as option_mapOr$0ev76sb, mapOr$1surhce as option_mapOr$1surhce, mapOr$1t0muvr as option_mapOr$1t0muvr, mapOr$02k4ito as option_mapOr$02k4ito, mapOr$0a96v80 as option_mapOr$0a96v80, mapOr$0mmpeqx as option_mapOr$0mmpeqx, mapOr$1vjqo89 as option_mapOr$1vjqo89, mapOr$1h04da8 as option_mapOr$1h04da8, mapOr$0f73bb7 as option_mapOr$0f73bb7, mapOr$06gg5x7 as option_mapOr$06gg5x7, mapOr$1dmz9kd as option_mapOr$1dmz9kd, mapOr$1sxa8ki as option_mapOr$1sxa8ki, asDeref$0w8at8i as option_asDeref$0w8at8i, filter$0v80fk8 } from "./core/option.ts"; +import { thenSome$0b23a33, thenSome$0d5am30 } from "./core/bool.ts"; +import { unwrapOr$0k15iai as option_unwrapOr$0k15iai, unwrapOr$00uis1j as option_unwrapOr$00uis1j, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOr$14m5xjm as option_unwrapOr$14m5xjm, unwrapOr$1tvry1i as option_unwrapOr$1tvry1i, unwrapOrDefault$165pyh5 as option_unwrapOrDefault$165pyh5, unwrapOrDefault$0wx44sw as option_unwrapOrDefault$0wx44sw, map$1uo1d4o as option_map$1uo1d4o, map$1httady as option_map$1httady, map$0of9gds as option_map$0of9gds, map$1c7zybz as option_map$1c7zybz, map$0cs071d as option_map$0cs071d, map$0p22lts as option_map$0p22lts, mapOr$0lcrgk1 as option_mapOr$0lcrgk1, mapOr$1kiffmd as option_mapOr$1kiffmd, mapOr$1a3irjf as option_mapOr$1a3irjf, mapOr$0sl5app as option_mapOr$0sl5app, mapOr$0atjiti as option_mapOr$0atjiti, mapOr$0okqj9y as option_mapOr$0okqj9y, mapOr$1e4a1e0 as option_mapOr$1e4a1e0, mapOr$1lznlgz as option_mapOr$1lznlgz, mapOr$0tmtgfi as option_mapOr$0tmtgfi, mapOr$0ev76sb as option_mapOr$0ev76sb, mapOr$1surhce as option_mapOr$1surhce, mapOr$1t0muvr as option_mapOr$1t0muvr, mapOr$0a96v80 as option_mapOr$0a96v80, mapOr$1vjqo89 as option_mapOr$1vjqo89, mapOr$1h04da8 as option_mapOr$1h04da8, mapOr$0f73bb7 as option_mapOr$0f73bb7, mapOr$0mmpeqx as option_mapOr$0mmpeqx, mapOr$06gg5x7 as option_mapOr$06gg5x7, mapOr$1dmz9kd as option_mapOr$1dmz9kd, mapOr$1sxa8ki as option_mapOr$1sxa8ki, mapOr$02k4ito as option_mapOr$02k4ito, asDeref$0w8at8i as option_asDeref$0w8at8i, filter$0v80fk8 } from "./core/option.ts"; import { unwrapOr$01jdcm7 as result_unwrapOr$01jdcm7 } from "./core/result.ts"; import * as Badge from "./iters.Badge.ts"; import * as Bumped from "./iters.Bumped.ts"; -import * as iters_Countdown from "./iters.Countdown.ts"; +import * as Countdown from "./iters.Countdown.ts"; import * as Doubled from "./iters.Doubled.ts"; import * as Evens from "./iters.Evens.ts"; import * as Gaps from "./iters.Gaps.ts"; import * as Halving from "./iters.Halving.ts"; -import * as iters_Held from "./iters.Held.ts"; +import * as Held from "./iters.Held.ts"; import * as Quarter from "./iters.Quarter.ts"; import * as Tag from "./iters.Tag.ts"; import * as Tilt from "./iters.Tilt.ts"; @@ -988,7 +987,7 @@ export function skips(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const b3: rt.u8 = _25; return [b3, ~b3 & 0xff] as [rt.u8, rt.u8]; }), undefined, 2, true)); - const it29: rt.Iter<[rt.u8, rt.u8]> = rt.iterCopied(rt.iterTake(rt.iterBorrow(rest14), limit), copy$tuple2_u8_u8); + const it29: rt.Iter<[rt.u8, rt.u8]> = rt.iterTake(rt.iterBorrow(rest14), limit); if (!back) { item27 = rt.iterNth(it29, n); } else { @@ -1635,20 +1634,20 @@ export function second$iter_Map_slice_Iter_u8_iters_options_closure0(items: rt.I export function own(data: rt.ByteSlice, out: rt.ByteVec): void { const left: rt.u8 = option_unwrapOr$0r2bmpr(rt.byteSliceFirst(data), 0); const step: rt.u8 = rt.max(option_unwrapOr$0r2bmpr(rt.byteSliceGet(data, 1), 1), 1); - const iter: iters_Countdown.Countdown = { left, step }; + const iter: Countdown.Countdown = { left, step }; while (true) { - const _13: rt.u8 | rt.Done = iters_Countdown.next$iter_Iterator(iter); + const _13: rt.u8 | rt.Done = Countdown.next$iter_Iterator(iter); if (_13 === rt.DONE) { break; } rt.byteVecPush(out, _13); } - rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u64ToBeBytes(rt.iterSum(rt.iterMap(rt.iterFrom({ left, step }, (it: iters_Countdown.Countdown) => iters_Countdown.next$iter_Iterator(it)), (n4: rt.u8): rt.u64 => { + rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u64ToBeBytes(rt.iterSum(rt.iterMap(rt.iterFrom({ left, step }, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it)), (n4: rt.u8): rt.u64 => { return rt.u64Div(rt.u64Mul(n4 as rt.u64, 1000), 7); }), rt.u64Add, 0)))); - const down: iters_Countdown.Countdown = { left, step }; + const down: Countdown.Countdown = { left, step }; while (true) { - const _26: rt.u8 | rt.Done = iters_Countdown.next$iter_Iterator(down); + const _26: rt.u8 | rt.Done = Countdown.next$iter_Iterator(down); if (_26 !== rt.DONE) { if (rt.u8Rem(_26, 5) === 0) { break; @@ -1705,8 +1704,8 @@ export function values(data: rt.ByteSlice, out: rt.ByteVec): void { } rt.byteVecPush(out, _8); } - const held: iters_Held.Held = { it: rt.iterSlice(rt.byteSliceView(data)) }; - rt.byteVecPush(out, iters_Held.skipOne(held)); + const held: Held.Held = { it: rt.iterSlice(rt.byteSliceView(data)) }; + rt.byteVecPush(out, Held.skipOne(held)); const iter2: rt.Iter = odds(data); while (true) { const _21: rt.u8 | rt.Done = iter2.next(); @@ -1747,7 +1746,7 @@ export function values(data: rt.ByteSlice, out: rt.ByteVec): void { rt.iterExtendBytes(out, rt.iterMap(rt.iterMap(rt.iterSlice(bumps), Bumped.clone$Clone), (b5: Bumped.Bumped): rt.u8 => { return b5._0; }), undefined, true); - rt.iterExtendBytes(out, rt.iterMap(rt.iterCopied(rt.iterSlice(bumps), copy$iters_Bumped), (b6: Bumped.Bumped): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(bumps), (b6: Bumped.Bumped): rt.u8 => { return b6._0; }), undefined, true); rt.iterExtendBytes(out, rt.iterMap(rt.iterMap(rt.iterSlice(rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_23: rt.u8): Wrapper.Wrapper => { @@ -1845,8 +1844,8 @@ export function first$iter_Map_slice_Iter_u8_iters_returned_closure0(it: rt.Iter return rt.iterToOption(it.next(), rt.None); } -export function first$iters_Countdown(it: iters_Countdown.Countdown): rt.u8 | undefined { - return rt.iterToOption(iters_Countdown.next$iter_Iterator(it)); +export function first$iters_Countdown(it: Countdown.Countdown): rt.u8 | undefined { + return rt.iterToOption(Countdown.next$iter_Iterator(it)); } export function first$iters_Gaps(it: Gaps.Gaps): rt.u8 | undefined | rt.None { @@ -9519,14 +9518,14 @@ export function lent(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.iterNth(rt.iterBorrow(twice.v), n), 187)); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.iterToOption(twice.v.next()), 204)); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.iterToOption(it.next()), 221)); - const own: iters_Countdown.Countdown = { left: rt.u8Mul(n & 0xff, 3), step: 2 }; - const other: iters_Countdown.Countdown = { left: 9, step: 4 }; - let held: iters_Countdown.Countdown = own; - rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.iterToOption(iters_Countdown.next$iter_Iterator(held)), 170)); + const own: Countdown.Countdown = { left: rt.u8Mul(n & 0xff, 3), step: 2 }; + const other: Countdown.Countdown = { left: 9, step: 4 }; + let held: Countdown.Countdown = own; + rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.iterToOption(Countdown.next$iter_Iterator(held)), 170)); held = other; - rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.iterToOption(iters_Countdown.next$iter_Iterator(held)), 187)); - rt.iterExtendBytes(out, rt.iterFrom(own, (it: iters_Countdown.Countdown) => iters_Countdown.next$iter_Iterator(it)), "next"); - rt.iterExtendBytes(out, rt.iterFrom(other, (it: iters_Countdown.Countdown) => iters_Countdown.next$iter_Iterator(it)), "next"); + rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.iterToOption(Countdown.next$iter_Iterator(held)), 187)); + rt.iterExtendBytes(out, rt.iterFrom(own, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it)), "next"); + rt.iterExtendBytes(out, rt.iterFrom(other, (it: Countdown.Countdown) => Countdown.next$iter_Iterator(it)), "next"); const range: rt.Range = new rt.Range(0, rt.u8Mul(n & 0xff, 3)); let erased: rt.Iter = rt.iterDyn(rt.iterBorrow(range)); rt.iterExtendBytes(out, rt.iterTake(rt.iterStepBy(rt.iterBorrow(erased), 2), 2), "next"); diff --git a/ts/fixtures/lang/iters/expected/lib.ts b/ts/fixtures/lang/iters/expected/lib.ts new file mode 100644 index 000000000..3a6fcf183 --- /dev/null +++ b/ts/fixtures/lang/iters/expected/lib.ts @@ -0,0 +1,32 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { adaptors, consumers, reducers, peekedOthers, skips, ranked, ranges, options, optionItems, own, values, returned, zips, zipsBack, rangeFroms, rangeMethods, compares, lent } from "./iters.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["iters::adaptors", adaptors as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::consumers", consumers as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::ranges", (_210: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + ranges(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::options", (_211: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + options(data2, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::own", (_212: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + own(data3, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::values", (_213: rt.u8, data4: rt.ByteSlice, out4: rt.ByteVec): undefined => { + values(data4, out4); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::skips", skips as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::ranked", ranked as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::returned", (_214: rt.u8, data5: rt.ByteSlice, out5: rt.ByteVec): undefined => { + returned(data5, out5); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::reducers", (_215: rt.u8, data6: rt.ByteSlice, out6: rt.ByteVec): undefined => { + reducers(data6, out6); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::peeked_others", (_216: rt.u8, data7: rt.ByteSlice, out7: rt.ByteVec): undefined => { + peekedOthers(data7, out7); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::zips", zips as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::zips_back", zipsBack as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::range_froms", rangeFroms as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::range_methods", rangeMethods as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::compares", compares as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::option_items", (_217: rt.u8, data8: rt.ByteSlice, out8: rt.ByteVec): undefined => { + optionItems(data8, out8); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::lent", (_218: rt.u8, data9: rt.ByteSlice, out9: rt.ByteVec): undefined => { + lent(data9, out9); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/iters.rs b/ts/fixtures/lang/iters/src/iters.rs similarity index 100% rename from ts/fixtures/lang/src/iters.rs rename to ts/fixtures/lang/iters/src/iters.rs diff --git a/ts/fixtures/lang/iters/src/lib.rs b/ts/fixtures/lang/iters/src/lib.rs new file mode 100644 index 000000000..3093791e8 --- /dev/null +++ b/ts/fixtures/lang/iters/src/lib.rs @@ -0,0 +1,40 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#![feature(iter_order_by)] + +#[path = "../../harness.rs"] +pub mod harness; +mod iters; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("iters::adaptors", iters::adaptors), + ("iters::consumers", iters::consumers), + ("iters::ranges", |_, data, out| iters::ranges(data, out)), + ("iters::options", |_, data, out| iters::options(data, out)), + ("iters::own", |_, data, out| iters::own(data, out)), + ("iters::values", |_, data, out| iters::values(data, out)), + ("iters::skips", iters::skips), + ("iters::ranked", iters::ranked), + ("iters::returned", |_, data, out| iters::returned(data, out)), + ("iters::reducers", |_, data, out| iters::reducers(data, out)), + ("iters::peeked_others", |_, data, out| iters::peeked_others(data, out)), + ("iters::zips", iters::zips), + ("iters::zips_back", iters::zips_back), + ("iters::range_froms", iters::range_froms), + ("iters::range_methods", iters::range_methods), + ("iters::compares", iters::compares), + ("iters::option_items", |_, data, out| iters::option_items(data, out)), + ("iters::lent", |_, data, out| iters::lent(data, out)), + ] +} diff --git a/ts/fixtures/lang/iters/ts.toml b/ts/fixtures/lang/iters/ts.toml new file mode 100644 index 000000000..29014b972 --- /dev/null +++ b/ts/fixtures/lang/iters/ts.toml @@ -0,0 +1,2 @@ +package = "lang-iters-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/joins/Cargo.toml b/ts/fixtures/lang/joins/Cargo.toml new file mode 100644 index 000000000..90c6d7b47 --- /dev/null +++ b/ts/fixtures/lang/joins/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-joins-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/joins/expected/core/option.ts b/ts/fixtures/lang/joins/expected/core/option.ts new file mode 100644 index 000000000..8cc14fcd3 --- /dev/null +++ b/ts/fixtures/lang/joins/expected/core/option.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$1j4op5y(self: rt.u16 | undefined, default_: rt.u16): rt.u16 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/joins/expected/harness.ts b/ts/fixtures/lang/joins/expected/harness.ts new file mode 100644 index 000000000..7c19e53ff --- /dev/null +++ b/ts/fixtures/lang/joins/expected/harness.ts @@ -0,0 +1,64 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +/** A char of the alphabet for each byte, by its low bits. */ +export function text(data: rt.ByteSlice): string { + let s: string = ""; + const iterS: Uint8Array = rt.byteSliceView(data); + let iterI: number = 0; + while (true) { + const _5: rt.u8 | rt.Done = iterI < iterS.length ? iterS[iterI++] : rt.DONE; + if (_5 === rt.DONE) { + return s; + } + const _13: rt.usize = rt.u8Rem(_5, 16) as rt.usize; + if (!(_13 < 16)) { + rt.panic("index out of bounds: the len is " + 16 + " but the index is " + _13); + } + s = s + String.fromCodePoint([47, 92, 97, 48, 57, 127, 128, 233, 2047, 2048, 55295, 57344, 65535, 65536, 128512, 1114111][_13]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/expected/joins.Logged.ts b/ts/fixtures/lang/joins/expected/joins.Logged.ts similarity index 100% rename from ts/fixtures/lang/expected/joins.Logged.ts rename to ts/fixtures/lang/joins/expected/joins.Logged.ts diff --git a/ts/fixtures/lang/expected/joins.Sentinel.ts b/ts/fixtures/lang/joins/expected/joins.Sentinel.ts similarity index 100% rename from ts/fixtures/lang/expected/joins.Sentinel.ts rename to ts/fixtures/lang/joins/expected/joins.Sentinel.ts diff --git a/ts/fixtures/lang/expected/joins.ts b/ts/fixtures/lang/joins/expected/joins.ts similarity index 78% rename from ts/fixtures/lang/expected/joins.ts rename to ts/fixtures/lang/joins/expected/joins.ts index 5d1391760..4b8fe65c9 100644 --- a/ts/fixtures/lang/expected/joins.ts +++ b/ts/fixtures/lang/joins/expected/joins.ts @@ -2,11 +2,10 @@ import * as rt from "./rt.ts"; import { drop$boxed_Box_slice_joins_Logged, drop$tuple4_Vec_Vec_joins_Logged_array2_array2_joins_Logged_joins_Logged_Vec_joins_Logged } from "./lib.ts"; -import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOr$1j4op5y as option_unwrapOr$1j4op5y } from "./core/option.ts"; -import { put as fmt_put } from "./fmt.ts"; -import * as joins_Logged from "./joins.Logged.ts"; +import { unwrapOr$1j4op5y as option_unwrapOr$1j4op5y, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr } from "./core/option.ts"; +import { put, text } from "./harness.ts"; +import * as Logged from "./joins.Logged.ts"; import * as Sentinel from "./joins.Sentinel.ts"; -import { text as strs_text } from "./strs.ts"; /** Puts what was logged since the last flush, after a marker. */ export function flush(log: rt.RefCell, out: rt.ByteVec): void { @@ -31,9 +30,9 @@ export function wides(v: rt.u16[], out: rt.ByteVec): void { } /** Puts the ids of `v`, then drops it. */ -export function ids(v: joins_Logged.Logged[], log: rt.RefCell, out: rt.ByteVec): void { +export function ids(v: Logged.Logged[], log: rt.RefCell, out: rt.ByteVec): void { rt.byteVecPush(out, v.length & 0xff); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(v), (l: joins_Logged.Logged): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(v), (l: Logged.Logged): rt.u8 => { return l.id; }), undefined, true); rt.dropAll(v); @@ -149,58 +148,58 @@ export function joins(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { wides(rt.slicesJoin(none, 2, rt.sliceRange(wideSeps, 0)), out); } else if (_26 === 3) { const log: rt.Arc> = new rt.Arc(new rt.RefCell(new rt.ByteVec())); - const logged: (a0: rt.u8) => joins_Logged.Logged = (id: rt.u8): joins_Logged.Logged => { - return new joins_Logged.Logged(id, rt.arcClone(log)); + const logged: (a0: rt.u8) => Logged.Logged = (id: rt.u8): Logged.Logged => { + return new Logged.Logged(id, rt.arcClone(log)); }; - const vecs: joins_Logged.Logged[][] = rt.iterToArray(rt.iterMap(rt.iterSlice(parts), (p4: rt.ByteSlice): joins_Logged.Logged[] => { - return rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(p4)), (_215: rt.u8): joins_Logged.Logged => { + const vecs: Logged.Logged[][] = rt.iterToArray(rt.iterMap(rt.iterSlice(parts), (p4: rt.ByteSlice): Logged.Logged[] => { + return rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(p4)), (_215: rt.u8): Logged.Logged => { return logged(_215 & 126); }), undefined, 8, true); }), undefined, 12, true); - const sep3: joins_Logged.Logged = logged(80); - const seps2: joins_Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(seps)), (_219: rt.u8): joins_Logged.Logged => { + const sep3: Logged.Logged = logged(80); + const seps2: Logged.Logged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(seps)), (_219: rt.u8): Logged.Logged => { return logged(_219 & 62); }), undefined, 8, true); - ids(rt.slicesJoin(vecs, 8, undefined, undefined, joins_Logged.clone$Clone), log.value, out); - ids(rt.slicesJoin(vecs, 8, [sep3], undefined, joins_Logged.clone$Clone), log.value, out); - ids(rt.slicesJoin(vecs, 8, rt.sliceRange(seps2, 0), undefined, joins_Logged.clone$Clone), log.value, out); - const slices2: joins_Logged.Logged[][] = rt.iterToArray(rt.iterMap(rt.iterSlice(vecs), (v: joins_Logged.Logged[]): joins_Logged.Logged[] => { + ids(rt.slicesJoin(vecs, 8, undefined, undefined, Logged.clone$Clone), log.value, out); + ids(rt.slicesJoin(vecs, 8, [sep3], undefined, Logged.clone$Clone), log.value, out); + ids(rt.slicesJoin(vecs, 8, rt.sliceRange(seps2, 0), undefined, Logged.clone$Clone), log.value, out); + const slices2: Logged.Logged[][] = rt.iterToArray(rt.iterMap(rt.iterSlice(vecs), (v: Logged.Logged[]): Logged.Logged[] => { return rt.sliceRange(v, 0); }), undefined, 8, true); - ids(rt.slicesJoin(slices2, 8, undefined, undefined, joins_Logged.clone$Clone), log.value, out); - ids(rt.slicesJoin(slices2, 8, [sep3], undefined, joins_Logged.clone$Clone), log.value, out); - ids(rt.slicesJoin(slices2, 8, rt.sliceRange(seps2, 0), undefined, joins_Logged.clone$Clone), log.value, out); - const boxed3: joins_Logged.Logged[][] = rt.iterToArray(rt.iterMap(rt.iterSlice(slices2), (_220: joins_Logged.Logged[]): joins_Logged.Logged[] => { - return _220.map(joins_Logged.clone$Clone); + ids(rt.slicesJoin(slices2, 8, undefined, undefined, Logged.clone$Clone), log.value, out); + ids(rt.slicesJoin(slices2, 8, [sep3], undefined, Logged.clone$Clone), log.value, out); + ids(rt.slicesJoin(slices2, 8, rt.sliceRange(seps2, 0), undefined, Logged.clone$Clone), log.value, out); + const boxed3: Logged.Logged[][] = rt.iterToArray(rt.iterMap(rt.iterSlice(slices2), (_220: Logged.Logged[]): Logged.Logged[] => { + return _220.map(Logged.clone$Clone); }), undefined, 8, true); flush(log.value, out); - ids(rt.slicesJoin(boxed3, 8, undefined, undefined, joins_Logged.clone$Clone), log.value, out); - ids(rt.slicesJoin(boxed3, 8, [sep3], undefined, joins_Logged.clone$Clone), log.value, out); + ids(rt.slicesJoin(boxed3, 8, undefined, undefined, Logged.clone$Clone), log.value, out); + ids(rt.slicesJoin(boxed3, 8, [sep3], undefined, Logged.clone$Clone), log.value, out); rt.dropAll(boxed3, drop$boxed_Box_slice_joins_Logged); flush(log.value, out); - const pairs2: joins_Logged.Logged[][] = [[logged(2), logged(4)], [logged(6), logged(8)]]; - ids(rt.slicesJoin(pairs2, 8, undefined, undefined, joins_Logged.clone$Clone), log.value, out); - ids(rt.slicesJoin(pairs2, 8, [sep3], undefined, joins_Logged.clone$Clone), log.value, out); - ids(rt.slicesJoin(pairs2, 8, rt.sliceRange(seps2, 0), undefined, joins_Logged.clone$Clone), log.value, out); - drop$tuple4_Vec_Vec_joins_Logged_array2_array2_joins_Logged_joins_Logged_Vec_joins_Logged([vecs, pairs2, sep3, seps2] as [joins_Logged.Logged[][], joins_Logged.Logged[][], joins_Logged.Logged, joins_Logged.Logged[]]); + const pairs2: Logged.Logged[][] = [[logged(2), logged(4)], [logged(6), logged(8)]]; + ids(rt.slicesJoin(pairs2, 8, undefined, undefined, Logged.clone$Clone), log.value, out); + ids(rt.slicesJoin(pairs2, 8, [sep3], undefined, Logged.clone$Clone), log.value, out); + ids(rt.slicesJoin(pairs2, 8, rt.sliceRange(seps2, 0), undefined, Logged.clone$Clone), log.value, out); + drop$tuple4_Vec_Vec_joins_Logged_array2_array2_joins_Logged_joins_Logged_Vec_joins_Logged([vecs, pairs2, sep3, seps2] as [Logged.Logged[][], Logged.Logged[][], Logged.Logged, Logged.Logged[]]); flush(log.value, out); log[Symbol.dispose](); } else if (_26 === 4) { const owned2: string[] = rt.iterToArray(rt.iterMap(rt.iterSlice(parts), (p3: rt.ByteSlice): string => { - return strs_text(p3); + return text(p3); }), undefined, 12, true); - const sep4: string = strs_text(seps); - fmt_put(out, rt.strsJoin(owned2, "")); - fmt_put(out, rt.strsJoin(owned2, sep4)); + const sep4: string = text(seps); + put(out, rt.strsJoin(owned2, "")); + put(out, rt.strsJoin(owned2, sep4)); const borrowed: string[] = rt.iterToArray(rt.iterMap(rt.iterSlice(owned2), (a02: string): string => { return a02; }), undefined, 8, true); - fmt_put(out, rt.strsJoin(borrowed, "")); - fmt_put(out, rt.strsJoin(borrowed, sep4)); + put(out, rt.strsJoin(borrowed, "")); + put(out, rt.strsJoin(borrowed, sep4)); const _437: string[] = []; - fmt_put(out, rt.strsJoin(_437, "")); + put(out, rt.strsJoin(_437, "")); const _443: string[] = []; - fmt_put(out, rt.strsJoin(_443, sep4)); + put(out, rt.strsJoin(_443, sep4)); } else if (_26 === 5) { const cows: rt.ByteCow[] = rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(parts)), (_22: [rt.usize, rt.ByteSlice]): rt.ByteCow => { const i2: rt.usize = _22[0]; @@ -229,14 +228,14 @@ export function joins(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (rt.usizeRem(_214[0], 2) === 0) { return "ab"; } - return strs_text(_214[1]); + return text(_214[1]); }), undefined, 12, true); - fmt_put(out, rt.strsJoin(texts, "")); - fmt_put(out, rt.strsJoin(texts, "--")); + put(out, rt.strsJoin(texts, "")); + put(out, rt.strsJoin(texts, "--")); } else { const big: rt.ByteVec = rt.byteVecOf(1, 1 << 16); const wide4: rt.u16[] = rt.vecFromElem(1, 1 << 16, undefined); - const text: string = strs_text(rt.byteVecSlice(big)); + const text_: string = text(rt.byteVecSlice(big)); const refs: (a0: rt.usize) => rt.ByteSlice[] = (n: rt.usize): rt.ByteSlice[] => { return rt.vecFromElem(rt.byteSliceRange(rt.byteVecSlice(big), 0), n, undefined); }; @@ -250,9 +249,9 @@ export function joins(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } else if (_512 === 3) { wides(rt.slicesJoin(rt.vecFromElem(rt.sliceRange(wide4, 0), rt.usizeAdd(1 << 14, 1), undefined), 2), out); } else if (_512 === 4) { - fmt_put(out, rt.strsJoin(rt.vecFromElem(text, rt.usizeAdd(1 << 15, 1), undefined), "")); + put(out, rt.strsJoin(rt.vecFromElem(text_, rt.usizeAdd(1 << 15, 1), undefined), "")); } else if (_512 === 5) { - fmt_put(out, rt.strsJoin(rt.vecFromElem(text, rt.usizeAdd(1 << 16, 1), undefined), "")); + put(out, rt.strsJoin(rt.vecFromElem(text_, rt.usizeAdd(1 << 16, 1), undefined), "")); } else { const sep5: Sentinel.Sentinel[] = rt.iterToArray(rt.iterMap(new rt.Range(0, 1 << 16), (i: rt.i32): Sentinel.Sentinel => { return { _0: (i & 0xff) ^ 90 }; diff --git a/ts/fixtures/lang/joins/expected/lib.ts b/ts/fixtures/lang/joins/expected/lib.ts new file mode 100644 index 000000000..efa58a6cd --- /dev/null +++ b/ts/fixtures/lang/joins/expected/lib.ts @@ -0,0 +1,34 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { joins } from "./joins.ts"; +import type * as Logged from "./joins.Logged.ts"; + +export function drop$Vec_joins_Logged(value: Logged.Logged[]): void { + rt.dropAll(value); +} + +export function drop$array2_joins_Logged(value: Logged.Logged[]): void { + rt.dropAll(value); +} + +export function drop$boxed_Box_slice_joins_Logged(value: Logged.Logged[]): void { + rt.dropAll(value); +} + +export function drop$tuple4_Vec_Vec_joins_Logged_array2_array2_joins_Logged_joins_Logged_Vec_joins_Logged(_1: [Logged.Logged[][], Logged.Logged[][], Logged.Logged, Logged.Logged[]]): void { + rt.dropAll(_1[0], drop$Vec_joins_Logged); + rt.dropAll(_1[1], drop$array2_joins_Logged); + _1[2][Symbol.dispose](); + rt.dropAll(_1[3]); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["joins::joins", joins as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/joins.rs b/ts/fixtures/lang/joins/src/joins.rs similarity index 99% rename from ts/fixtures/lang/src/joins.rs rename to ts/fixtures/lang/joins/src/joins.rs index a8b5d5d39..e86e0c974 100644 --- a/ts/fixtures/lang/src/joins.rs +++ b/ts/fixtures/lang/joins/src/joins.rs @@ -7,8 +7,7 @@ use std::borrow::Cow; use std::cell::RefCell; use std::rc::Rc; -use crate::fmt::put; -use crate::strs::text; +use crate::harness::{put, text}; /// 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. diff --git a/ts/fixtures/lang/joins/src/lib.rs b/ts/fixtures/lang/joins/src/lib.rs new file mode 100644 index 000000000..bd31685ba --- /dev/null +++ b/ts/fixtures/lang/joins/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod joins; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("joins::joins", joins::joins)] +} diff --git a/ts/fixtures/lang/joins/ts.toml b/ts/fixtures/lang/joins/ts.toml new file mode 100644 index 000000000..5e8e3f45a --- /dev/null +++ b/ts/fixtures/lang/joins/ts.toml @@ -0,0 +1,2 @@ +package = "lang-joins-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/keys/Cargo.toml b/ts/fixtures/lang/keys/Cargo.toml new file mode 100644 index 000000000..ae3513425 --- /dev/null +++ b/ts/fixtures/lang/keys/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-keys-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/keys/expected/core/bool.ts b/ts/fixtures/lang/keys/expected/core/bool.ts new file mode 100644 index 000000000..dabe97c80 --- /dev/null +++ b/ts/fixtures/lang/keys/expected/core/bool.ts @@ -0,0 +1,77 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Hop from "../keys.Hop.ts"; +import type * as Way from "../keys.Way.ts"; + +export function thenSome$0rsp0eu(self: boolean, t: Uint8Array): Uint8Array | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function then$0l8o6jo(self: boolean, f: () => rt.u32[]): rt.u32[] | undefined { + if (!self) { + return undefined; + } + return f(); +} + +export function then$0b2eeh4(self: boolean, f: () => Array): Array | undefined { + if (!self) { + return undefined; + } + return f(); +} + +export function then$1ghn4qd(self: boolean, f: () => boolean[]): boolean[] | undefined { + if (!self) { + return undefined; + } + return f(); +} + +export function then$1dhbcvy(self: boolean, f: () => rt.char[]): rt.char[] | undefined { + if (!self) { + return undefined; + } + return f(); +} + +export function then$1nf265w(self: boolean, f: () => rt.i32[]): rt.i32[] | undefined { + if (!self) { + return undefined; + } + return f(); +} + +export function then$1c9ust9(self: boolean, f: () => Hop.Hop[]): Hop.Hop[] | undefined { + if (!self) { + return undefined; + } + return f(); +} + +export function then$0l07w38(self: boolean, f: () => rt.u16[]): rt.u16[] | undefined { + if (!self) { + return undefined; + } + return f(); +} + +export function then$0uovwq9(self: boolean, f: () => rt.u64[]): rt.u64[] | undefined { + if (!self) { + return undefined; + } + return f(); +} + +export function then$18np55d(self: boolean, f: () => Way.Way | undefined): Way.Way | undefined | rt.None { + if (!self) { + return rt.None; + } + return f(); +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/keys/expected/core/option.ts b/ts/fixtures/lang/keys/expected/core/option.ts new file mode 100644 index 000000000..9bcf59ca2 --- /dev/null +++ b/ts/fixtures/lang/keys/expected/core/option.ts @@ -0,0 +1,226 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import { side, order } from "../keys.ts"; +import type * as Hop from "../keys.Hop.ts"; +import type * as Side from "../keys.Side.ts"; +import type * as Way from "../keys.Way.ts"; + +export function unwrapOr$1j4op5y(self: rt.u16 | undefined, default_: rt.u16): rt.u16 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$1tvry1i(self: rt.u64 | undefined, default_: rt.u64): rt.u64 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$146awhd(self: Hop.Hop | undefined, f: (a0: Hop.Hop) => [rt.u64, rt.u64]): [rt.u64, rt.u64] | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$120lney(self: Hop.Hop | undefined, f: (a0: Hop.Hop) => rt.u64): rt.u64 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0lcwx9x(self: Way.Way | undefined, f: (a0: Way.Way) => boolean): boolean | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0gn4nwv(self: rt.u8 | undefined, _: (a0: rt.u8) => Side.Side): Side.Side | undefined { + if (self === undefined) { + return undefined; + } + return side(self); +} + +export function mapOr$1h1mlmc(self: rt.u32[] | undefined, default_: rt.u8, f: (a0: rt.u32[]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1bumeih(self: Array | undefined, default_: rt.u8, f: (a0: Array) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0qqhf4e(self: boolean[] | undefined, default_: rt.u8, f: (a0: boolean[]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$141aobk(self: rt.char[] | undefined, default_: rt.u8, f: (a0: rt.char[]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$17y4wkx(self: rt.i32[] | undefined, default_: rt.u8, f: (a0: rt.i32[]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0rtxftk(self: Hop.Hop[] | undefined, default_: rt.u8, f: (a0: Hop.Hop[]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1kiffmd(self: rt.u16[] | undefined, default_: rt.u8, f: (a0: rt.u16[]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0nlcxqx(self: rt.u64[] | undefined, default_: rt.u8, f: (a0: rt.u64[]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1dgdmlk(self: rt.Ordering | undefined, default_: rt.u8, _: (a0: rt.Ordering) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return order(self); +} + +export function mapOr$04khdaj(self: Hop.Hop | undefined, default_: rt.u64, f: (a0: Hop.Hop) => rt.u64): rt.u64 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1a3irjf(self: rt.ByteVec | undefined, default_: rt.u8, f: (a0: rt.ByteVec) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0z7fb2w(self: rt.ByteSlice | undefined, default_: Uint8Array, f: (a0: rt.ByteSlice) => Uint8Array): Uint8Array { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1w1gbwl(self: rt.ByteSlice | undefined, default_: rt.u8, f: (a0: rt.ByteSlice) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1surhce(self: rt.u8 | undefined, default_: rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$02k4ito(self: rt.usize | undefined, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1xwgm12(self: [rt.u32[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u32[], rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$187k0x1(self: [Array, rt.u8] | undefined, default_: rt.u8, f: (a0: [Array, rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$13q9j26(self: [boolean[], rt.u8] | undefined, default_: rt.u8, f: (a0: [boolean[], rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1afbbm4(self: [rt.char[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.char[], rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$03mkmku(self: [rt.i32[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.i32[], rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0spovx0(self: [Hop.Hop[], rt.u8] | undefined, default_: rt.u8, f: (a0: [Hop.Hop[], rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0iyypgq(self: [rt.u16[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u16[], rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0vfd25u(self: [rt.u64[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u64[], rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1be3nsj(self: [rt.ByteSlice, rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.ByteSlice, rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/keys/expected/harness.ts b/ts/fixtures/lang/keys/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/keys/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/expected/keys.Dropped.ts b/ts/fixtures/lang/keys/expected/keys.Dropped.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Dropped.ts rename to ts/fixtures/lang/keys/expected/keys.Dropped.ts diff --git a/ts/fixtures/lang/expected/keys.Hop.ts b/ts/fixtures/lang/keys/expected/keys.Hop.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Hop.ts rename to ts/fixtures/lang/keys/expected/keys.Hop.ts diff --git a/ts/fixtures/lang/expected/keys.Horizon.ts b/ts/fixtures/lang/keys/expected/keys.Horizon.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Horizon.ts rename to ts/fixtures/lang/keys/expected/keys.Horizon.ts diff --git a/ts/fixtures/lang/expected/keys.Liar.ts b/ts/fixtures/lang/keys/expected/keys.Liar.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Liar.ts rename to ts/fixtures/lang/keys/expected/keys.Liar.ts diff --git a/ts/fixtures/lang/expected/keys.Lopsided.ts b/ts/fixtures/lang/keys/expected/keys.Lopsided.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Lopsided.ts rename to ts/fixtures/lang/keys/expected/keys.Lopsided.ts diff --git a/ts/fixtures/lang/expected/keys.Name.ts b/ts/fixtures/lang/keys/expected/keys.Name.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Name.ts rename to ts/fixtures/lang/keys/expected/keys.Name.ts diff --git a/ts/fixtures/lang/expected/keys.Never.ts b/ts/fixtures/lang/keys/expected/keys.Never.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Never.ts rename to ts/fixtures/lang/keys/expected/keys.Never.ts diff --git a/ts/fixtures/lang/expected/keys.Picky.ts b/ts/fixtures/lang/keys/expected/keys.Picky.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Picky.ts rename to ts/fixtures/lang/keys/expected/keys.Picky.ts diff --git a/ts/fixtures/lang/expected/keys.Rough.ts b/ts/fixtures/lang/keys/expected/keys.Rough.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Rough.ts rename to ts/fixtures/lang/keys/expected/keys.Rough.ts diff --git a/ts/fixtures/lang/expected/keys.Seen.ts b/ts/fixtures/lang/keys/expected/keys.Seen.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Seen.ts rename to ts/fixtures/lang/keys/expected/keys.Seen.ts diff --git a/ts/fixtures/lang/expected/keys.Side.ts b/ts/fixtures/lang/keys/expected/keys.Side.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Side.ts rename to ts/fixtures/lang/keys/expected/keys.Side.ts diff --git a/ts/fixtures/lang/expected/keys.Skew.ts b/ts/fixtures/lang/keys/expected/keys.Skew.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Skew.ts rename to ts/fixtures/lang/keys/expected/keys.Skew.ts diff --git a/ts/fixtures/lang/expected/keys.Skewed.ts b/ts/fixtures/lang/keys/expected/keys.Skewed.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Skewed.ts rename to ts/fixtures/lang/keys/expected/keys.Skewed.ts diff --git a/ts/fixtures/lang/expected/keys.Touchy.ts b/ts/fixtures/lang/keys/expected/keys.Touchy.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Touchy.ts rename to ts/fixtures/lang/keys/expected/keys.Touchy.ts diff --git a/ts/fixtures/lang/expected/keys.Way.ts b/ts/fixtures/lang/keys/expected/keys.Way.ts similarity index 100% rename from ts/fixtures/lang/expected/keys.Way.ts rename to ts/fixtures/lang/keys/expected/keys.Way.ts diff --git a/ts/fixtures/lang/expected/keys.ts b/ts/fixtures/lang/keys/expected/keys.ts similarity index 96% rename from ts/fixtures/lang/expected/keys.ts rename to ts/fixtures/lang/keys/expected/keys.ts index 4f280dac3..b93463b22 100644 --- a/ts/fixtures/lang/expected/keys.ts +++ b/ts/fixtures/lang/keys/expected/keys.ts @@ -1,9 +1,9 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { copy$Option_array0_u32, copy$Option_array275_u32, copy$Option_array2_Option_u8, copy$Option_array2_char, copy$Option_array2_keys_Hop, copy$Option_array2_u16, copy$Option_array2_u64, copy$Option_array2_u8, copy$Option_keys_Hop, copy$array_Option_u8, copy$array_char, copy$array_keys_Hop, copy$array_u16, copy$array_u32, copy$array_u64, copy$array_u8, copy$keys_Hop, copy$keys_Horizon, copy$tuple2_u8_keys_Horizon, drop$tuple2_u8_cmp_Reverse_sync_Arc_keys_Lopsided } from "./lib.ts"; +import { copy$Option_array2_keys_Hop, copy$Option_array2_u8, copy$Option_keys_Hop, copy$array_keys_Hop, copy$array_u8, copy$keys_Hop, copy$keys_Horizon, copy$tuple2_u8_keys_Horizon, drop$tuple2_u8_cmp_Reverse_sync_Arc_keys_Lopsided } from "./lib.ts"; import { thenSome$0rsp0eu, then$0l8o6jo, then$0b2eeh4, then$1ghn4qd, then$1dhbcvy, then$1nf265w, then$1c9ust9, then$0l07w38, then$0uovwq9, then$18np55d } from "./core/bool.ts"; -import { unwrapOr$1tvry1i as option_unwrapOr$1tvry1i, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOr$1j4op5y as option_unwrapOr$1j4op5y, map$146awhd as option_map$146awhd, map$120lney as option_map$120lney, map$0lcwx9x as option_map$0lcwx9x, map$0gn4nwv as option_map$0gn4nwv, mapOr$1kiffmd as option_mapOr$1kiffmd, mapOr$1a3irjf as option_mapOr$1a3irjf, mapOr$1h1mlmc as option_mapOr$1h1mlmc, mapOr$1bumeih as option_mapOr$1bumeih, mapOr$0qqhf4e as option_mapOr$0qqhf4e, mapOr$141aobk as option_mapOr$141aobk, mapOr$17y4wkx as option_mapOr$17y4wkx, mapOr$0rtxftk as option_mapOr$0rtxftk, mapOr$0nlcxqx as option_mapOr$0nlcxqx, mapOr$1dgdmlk as option_mapOr$1dgdmlk, mapOr$04khdaj as option_mapOr$04khdaj, mapOr$0z7fb2w as option_mapOr$0z7fb2w, mapOr$1w1gbwl as option_mapOr$1w1gbwl, mapOr$1surhce as option_mapOr$1surhce, mapOr$02k4ito as option_mapOr$02k4ito, mapOr$1xwgm12 as option_mapOr$1xwgm12, mapOr$187k0x1 as option_mapOr$187k0x1, mapOr$13q9j26 as option_mapOr$13q9j26, mapOr$1afbbm4 as option_mapOr$1afbbm4, mapOr$03mkmku as option_mapOr$03mkmku, mapOr$0spovx0 as option_mapOr$0spovx0, mapOr$0iyypgq as option_mapOr$0iyypgq, mapOr$0vfd25u as option_mapOr$0vfd25u, mapOr$1be3nsj as option_mapOr$1be3nsj } from "./core/option.ts"; +import { unwrapOr$1j4op5y as option_unwrapOr$1j4op5y, unwrapOr$1tvry1i as option_unwrapOr$1tvry1i, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$146awhd as option_map$146awhd, map$120lney as option_map$120lney, map$0lcwx9x as option_map$0lcwx9x, map$0gn4nwv as option_map$0gn4nwv, mapOr$1h1mlmc as option_mapOr$1h1mlmc, mapOr$1bumeih as option_mapOr$1bumeih, mapOr$0qqhf4e as option_mapOr$0qqhf4e, mapOr$141aobk as option_mapOr$141aobk, mapOr$17y4wkx as option_mapOr$17y4wkx, mapOr$0rtxftk as option_mapOr$0rtxftk, mapOr$1kiffmd as option_mapOr$1kiffmd, mapOr$0nlcxqx as option_mapOr$0nlcxqx, mapOr$1dgdmlk as option_mapOr$1dgdmlk, mapOr$04khdaj as option_mapOr$04khdaj, mapOr$1a3irjf as option_mapOr$1a3irjf, mapOr$0z7fb2w as option_mapOr$0z7fb2w, mapOr$1w1gbwl as option_mapOr$1w1gbwl, mapOr$1surhce as option_mapOr$1surhce, mapOr$02k4ito as option_mapOr$02k4ito, mapOr$1xwgm12 as option_mapOr$1xwgm12, mapOr$187k0x1 as option_mapOr$187k0x1, mapOr$13q9j26 as option_mapOr$13q9j26, mapOr$1afbbm4 as option_mapOr$1afbbm4, mapOr$03mkmku as option_mapOr$03mkmku, mapOr$0spovx0 as option_mapOr$0spovx0, mapOr$0iyypgq as option_mapOr$0iyypgq, mapOr$0vfd25u as option_mapOr$0vfd25u, mapOr$1be3nsj as option_mapOr$1be3nsj } from "./core/option.ts"; import * as Dropped from "./keys.Dropped.ts"; import * as Hop from "./keys.Hop.ts"; import * as Horizon from "./keys.Horizon.ts"; @@ -11,7 +11,7 @@ import * as Liar from "./keys.Liar.ts"; import * as Lopsided from "./keys.Lopsided.ts"; import * as Name from "./keys.Name.ts"; import * as Never from "./keys.Never.ts"; -import * as keys_Picky from "./keys.Picky.ts"; +import * as Picky from "./keys.Picky.ts"; import * as Rough from "./keys.Rough.ts"; import * as Seen from "./keys.Seen.ts"; import * as Side from "./keys.Side.ts"; @@ -598,16 +598,16 @@ export function options(dataData: Uint8Array, dataStart: number, dataLen: number const n: rt.Arc = _149[1]; rt.byteVecPush(out, partial(rt.cmpOption(Skew.partialCmp$cmp_PartialOrd)(p, q)) | ((partial(rt.cmpTuple<[Skew.Skew, rt.u8], rt.Ordering | undefined>([Skew.partialCmp$cmp_PartialOrd, rt.cmp])(u, v)) << 2) & 0xff) | ((partial(rt.cmpArc(Skew.partialCmp$cmp_PartialOrd)(m, n)) << 4) & 0xff)); rt.byteVecPush(out, order(rt.cmpOption(Skew.cmp$cmp_Ord)(p, q)) | ((order(rt.cmpTuple<[Skew.Skew, rt.u8], rt.Ordering>([Skew.cmp$cmp_Ord, rt.cmp])(u, v)) << 2) & 0xff) | ((order(rt.cmpArc(Skew.cmp$cmp_Ord)(m, n)) << 4) & 0xff)); - const _202: [keys_Picky.Picky | undefined, keys_Picky.Picky | undefined] = [{ _0: rt.u8Rem(c, 3) }, { _0: rt.u8Rem(d, 3) }]; - const g: keys_Picky.Picky | undefined = _202[0]; - const h: keys_Picky.Picky | undefined = _202[1]; - const _213: [[keys_Picky.Picky | undefined, rt.u8], [keys_Picky.Picky | undefined, rt.u8]] = [[{ _0: rt.u8Rem(c, 3) }, rt.u8Rem(c, 2)] as [keys_Picky.Picky | undefined, rt.u8], [{ _0: rt.u8Rem(d, 3) }, rt.u8Rem(d, 2)] as [keys_Picky.Picky | undefined, rt.u8]]; - const j: [keys_Picky.Picky | undefined, rt.u8] = _213[0]; - const k: [keys_Picky.Picky | undefined, rt.u8] = _213[1]; - const _230: [rt.Arc, rt.Arc] = [new rt.Arc({ _0: rt.u8Rem(c, 3) }), new rt.Arc({ _0: rt.u8Rem(d, 3) })]; - const r: rt.Arc = _230[0]; - const s2: rt.Arc = _230[1]; - rt.byteVecPush(out, (!rt.eqOption(keys_Picky.eq$cmp_PartialEq)(g, h) ? 1 : 0) | (((!rt.eqTuple([rt.eqOption(keys_Picky.eq$cmp_PartialEq), rt.same])(j, k) ? 1 : 0) << 1) & 0xff) | (((!rt.eqArc(rt.eqOption(keys_Picky.eq$cmp_PartialEq))(r, s2) ? 1 : 0) << 2) & 0xff)); + const _202: [Picky.Picky | undefined, Picky.Picky | undefined] = [{ _0: rt.u8Rem(c, 3) }, { _0: rt.u8Rem(d, 3) }]; + const g: Picky.Picky | undefined = _202[0]; + const h: Picky.Picky | undefined = _202[1]; + const _213: [[Picky.Picky | undefined, rt.u8], [Picky.Picky | undefined, rt.u8]] = [[{ _0: rt.u8Rem(c, 3) }, rt.u8Rem(c, 2)] as [Picky.Picky | undefined, rt.u8], [{ _0: rt.u8Rem(d, 3) }, rt.u8Rem(d, 2)] as [Picky.Picky | undefined, rt.u8]]; + const j: [Picky.Picky | undefined, rt.u8] = _213[0]; + const k: [Picky.Picky | undefined, rt.u8] = _213[1]; + const _230: [rt.Arc, rt.Arc] = [new rt.Arc({ _0: rt.u8Rem(c, 3) }), new rt.Arc({ _0: rt.u8Rem(d, 3) })]; + const r: rt.Arc = _230[0]; + const s2: rt.Arc = _230[1]; + rt.byteVecPush(out, (!rt.eqOption(Picky.eq$cmp_PartialEq)(g, h) ? 1 : 0) | (((!rt.eqTuple([rt.eqOption(Picky.eq$cmp_PartialEq), rt.same])(j, k) ? 1 : 0) << 1) & 0xff) | (((!rt.eqArc(rt.eqOption(Picky.eq$cmp_PartialEq))(r, s2) ? 1 : 0) << 2) & 0xff)); const key: [rt.u8, Horizon.Horizon] = [rt.u8Rem(c, 3), { exclude: a, local: rt.u8Rem(d, 2) === 0 }]; rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.hashInsert(hashed, copy$tuple2_u8_keys_Horizon(key), i & 0xff), 204)); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeInsert(sorted, copy$tuple2_u8_keys_Horizon(key), i & 0xff), 204)); @@ -1664,24 +1664,24 @@ export function keyed$Option_u8_2_keys_arrays_closure5(data: rt.ByteSlice, make: const i: rt.usize = _13[0]; const b: rt.u8 = _13[1]; const i2: rt.u8 = i & 0xff; - const _23: Array = copy$array_Option_u8(make(b)); + const _23: Array = make(b); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.hashInsert(map, _23, i2), 204)); - const _30: Array = copy$array_Option_u8(make(b)); + const _30: Array = make(b); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeInsert(tree, _30, i2), 204)); - const _38: Array = copy$array_Option_u8(make(b)); + const _38: Array = make(b); const _35: rt.u8 = rt.hashAdd(set, _38) ? 1 : 0; - const _44: Array = copy$array_Option_u8(make(b)); + const _44: Array = make(b); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_35, rt.btreeAdd(ordered, _44) ? 1 : 0)), undefined, true); const _51: rt.u8 = rt.u8Rem(b, 4); - const _53: Array = copy$array_Option_u8(make(b)); + const _53: Array = make(b); rt.byteVecPush(out, option_mapOr$1bumeih(rt.hashInsert(values, _51, _53), 204, (old: Array): rt.u8 => { const _6: Array = make(b); return rt.eqSlice(rt.same)(old, _6) ? 1 : 0; })); - const _62: Array = copy$array_Option_u8(make(rt.u8Div(b, 2))); + const _62: Array = make(rt.u8Div(b, 2)); const _59: rt.Place = rt.entryOrInsertMut(rt.entry(map, _62), i2); _59.v = _59.v ^ 64; - const _69: Array = copy$array_Option_u8(make(rt.u8Div(b, 2))); + const _69: Array = make(rt.u8Div(b, 2)); const _67: rt.Entry, rt.u8> = rt.entry(tree, _69); if (!rt.entryOccupied(_67)) { const v: rt.Entry, rt.u8> = _67; @@ -1723,7 +1723,7 @@ export function keyed$Option_u8_2_keys_arrays_closure5(data: rt.ByteSlice, make: }), option_mapOr$1bumeih(rt.hashGet(values, b2), 221, (v2: Array): rt.u8 => { return rt.eqSlice(rt.same)(v2, key) ? 1 : 0; }))), undefined, true); - const _162: { end: Array } = { end: copy$array_Option_u8(copy$array_Option_u8(key)) }; + const _162: { end: Array } = { end: key }; rt.byteVecPush(out, rt.iterCount(rt.btreeRange(tree, _162)) & 0xff); const _170: [rt.RangeBound>, rt.RangeBound>] = [{ tag: "Excluded", _0: rt.sliceRange(key, 0) } as rt.RangeBound>, { tag: "Unbounded" } as rt.RangeBound>]; rt.byteVecPush(out, rt.iterCount(rt.btreeRange(tree, _170)) & 0xff); @@ -1805,7 +1805,7 @@ export function keyed$Option_u8_2_keys_arrays_closure5(data: rt.ByteSlice, make: return make(rt.u8Div(_29, 3)); }); const made: rt.BTreeSet> = rt.btreeExtendKeys(rt.btreeNew(rt.cmpSlice(rt.cmpOption(rt.cmp))) as rt.BTreeSet>, _330, true, undefined, undefined, 4, true); - const _335: [Array, rt.u8][] = [[copy$array_Option_u8(make(0)), 1] as [Array, rt.u8], [copy$array_Option_u8(make(1)), 2] as [Array, rt.u8]]; + const _335: [Array, rt.u8][] = [[make(0), 1] as [Array, rt.u8], [make(1), 2] as [Array, rt.u8]]; const counts: rt.HashMap, rt.u8> = rt.hashExtend(rt.hashNew(rt.hashing(rt.hashSlice(rt.hashOption(rt.hash8)), rt.eqSlice(rt.same))) as rt.HashMap, rt.u8>, rt.iterSlice(_335), undefined, undefined, undefined, 234881024); for (const b3 of rt.byteSliceView(data)) { const _354: Array = rt.sliceRange(make(b3), 0); @@ -1813,7 +1813,7 @@ export function keyed$Option_u8_2_keys_arrays_closure5(data: rt.ByteSlice, make: const _361: Array = rt.sliceRange(make(b3), 0); const _359: rt.Place | undefined = rt.hashGetMut(counts, _361); if (_359 === undefined) { - const _373: Array = copy$array_Option_u8(make(b3)); + const _373: Array = make(b3); const _370: rt.Place = rt.entryOrInsertWithMut(rt.entry(counts, _373), (): rt.u8 => { return 0; }); @@ -1831,7 +1831,7 @@ export function keyed$Option_u8_2_keys_arrays_closure5(data: rt.ByteSlice, make: }), undefined, true); rt.byteVecPush(out, rt.iterCount(rt.btreeIntersection(made, ordered)) & 0xff); rt.byteVecPush(out, rt.btreeIsSubset(made, ordered) ? 1 : 0); - const upper: rt.BTreeSet> = rt.btreeClone(made, copy$array_Option_u8, undefined); + const upper: rt.BTreeSet> = rt.btreeClone(made, undefined, undefined); const _405: Array = rt.sliceRange(probe, 0); const lower: rt.BTreeSet> = rt.btreeSplitOff(upper, _405); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(rt.btreeLen(upper) & 0xff, rt.btreeLen(lower) & 0xff)), undefined, true); @@ -1853,16 +1853,16 @@ export function keyed$Option_u8_2_keys_arrays_closure5(data: rt.ByteSlice, make: } const i3: rt.usize = _431[0]; const b4: rt.u8 = _431[1]; - const pair: [rt.u8, Array] = [rt.u8Rem(b4, 2), copy$array_Option_u8(make(b4))]; + const pair: [rt.u8, Array] = [rt.u8Rem(b4, 2), make(b4)]; const _452: [rt.u8, Array] = [1, make(2)]; const _444: rt.u8 = ((rt.cmpTuple<[rt.u8, Array], rt.Ordering | undefined>([rt.cmp, rt.cmpSlice(rt.cmpOption(rt.cmp))])(pair, _452) === -1 ? 1 : 0) << 1) & 0xff; const _462: [rt.u8, Array] = [0, make(3)]; const order4 = rt.cmpTuple<[rt.u8, Array], rt.Ordering | undefined>([rt.cmp, rt.cmpSlice(rt.cmpOption(rt.cmp))])(pair, _462); rt.byteVecPush(out, _444 | (order4 !== undefined && order4 <= 0 ? 1 : 0)); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeInsert(pairs, pair, i3 & 0xff), 204)); - const _476: Array | undefined = copy$Option_array2_Option_u8(then$0b2eeh4(rt.u8Rem(b4, 3) !== 0, (): Array => { + const _476: Array | undefined = then$0b2eeh4(rt.u8Rem(b4, 3) !== 0, (): Array => { return make(b4); - })); + }); rt.byteVecPush(out, rt.hashAdd(options, _476) ? 1 : 0); const _487: Array = rt.vecExact(make(b4).slice(), 2); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.hashInsert(vecs, _487, i3 & 0xff), 204)); @@ -1874,8 +1874,7 @@ export function keyed$Option_u8_2_keys_arrays_closure5(data: rt.ByteSlice, make: const iterEnd2: rt.u8 = 8; while ((_513 = iterStart2++) < iterEnd2) { const key2: Array = make(_513); - const _526: Array | undefined = copy$array_Option_u8(key2); - const _522: rt.u8 = rt.hashContains(options, _526) ? 1 : 0; + const _522: rt.u8 = rt.hashContains(options, key2) ? 1 : 0; const _533: Array = rt.sliceRange(key2, 0); const _529: rt.u8 = option_unwrapOr$0r2bmpr(rt.hashGet(vecs, _533), 221); const _538: Array = rt.sliceRange(key2, 0); @@ -2175,24 +2174,24 @@ export function keyed$char_2_keys_arrays_closure3(data: rt.ByteSlice, make: (a0: const i: rt.usize = _13[0]; const b: rt.u8 = _13[1]; const i2: rt.u8 = i & 0xff; - const _23: rt.char[] = copy$array_char(make(b)); + const _23: rt.char[] = make(b); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.hashInsert(map, _23, i2), 204)); - const _30: rt.char[] = copy$array_char(make(b)); + const _30: rt.char[] = make(b); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeInsert(tree, _30, i2), 204)); - const _38: rt.char[] = copy$array_char(make(b)); + const _38: rt.char[] = make(b); const _35: rt.u8 = rt.hashAdd(set, _38) ? 1 : 0; - const _44: rt.char[] = copy$array_char(make(b)); + const _44: rt.char[] = make(b); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_35, rt.btreeAdd(ordered, _44) ? 1 : 0)), undefined, true); const _51: rt.u8 = rt.u8Rem(b, 4); - const _53: rt.char[] = copy$array_char(make(b)); + const _53: rt.char[] = make(b); rt.byteVecPush(out, option_mapOr$141aobk(rt.hashInsert(values, _51, _53), 204, (old: rt.char[]): rt.u8 => { const _6: rt.char[] = make(b); return rt.eqSlice(rt.same)(old, _6) ? 1 : 0; })); - const _62: rt.char[] = copy$array_char(make(rt.u8Div(b, 2))); + const _62: rt.char[] = make(rt.u8Div(b, 2)); const _59: rt.Place = rt.entryOrInsertMut(rt.entry(map, _62), i2); _59.v = _59.v ^ 64; - const _69: rt.char[] = copy$array_char(make(rt.u8Div(b, 2))); + const _69: rt.char[] = make(rt.u8Div(b, 2)); const _67: rt.Entry = rt.entry(tree, _69); if (!rt.entryOccupied(_67)) { const v: rt.Entry = _67; @@ -2234,7 +2233,7 @@ export function keyed$char_2_keys_arrays_closure3(data: rt.ByteSlice, make: (a0: }), option_mapOr$141aobk(rt.hashGet(values, b2), 221, (v2: rt.char[]): rt.u8 => { return rt.eqSlice(rt.same)(v2, key) ? 1 : 0; }))), undefined, true); - const _162: { end: rt.char[] } = { end: copy$array_char(copy$array_char(key)) }; + const _162: { end: rt.char[] } = { end: key }; rt.byteVecPush(out, rt.iterCount(rt.btreeRange(tree, _162)) & 0xff); const _170: [rt.RangeBound, rt.RangeBound] = [{ tag: "Excluded", _0: rt.sliceRange(key, 0) } as rt.RangeBound, { tag: "Unbounded" } as rt.RangeBound]; rt.byteVecPush(out, rt.iterCount(rt.btreeRange(tree, _170)) & 0xff); @@ -2316,7 +2315,7 @@ export function keyed$char_2_keys_arrays_closure3(data: rt.ByteSlice, make: (a0: return make(rt.u8Div(_29, 3)); }); const made: rt.BTreeSet = rt.btreeExtendKeys(rt.btreeNew(rt.cmpSlice(rt.cmp)) as rt.BTreeSet, _330, true, undefined, undefined, 8, true); - const _335: [rt.char[], rt.u8][] = [[copy$array_char(make(0)), 1] as [rt.char[], rt.u8], [copy$array_char(make(1)), 2] as [rt.char[], rt.u8]]; + const _335: [rt.char[], rt.u8][] = [[make(0), 1] as [rt.char[], rt.u8], [make(1), 2] as [rt.char[], rt.u8]]; const counts: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(rt.hashSlice(rt.hash32), rt.eqSlice(rt.same))) as rt.HashMap, rt.iterSlice(_335), undefined, undefined, undefined, 117440512); for (const b3 of rt.byteSliceView(data)) { const _354: rt.char[] = rt.sliceRange(make(b3), 0); @@ -2324,7 +2323,7 @@ export function keyed$char_2_keys_arrays_closure3(data: rt.ByteSlice, make: (a0: const _361: rt.char[] = rt.sliceRange(make(b3), 0); const _359: rt.Place | undefined = rt.hashGetMut(counts, _361); if (_359 === undefined) { - const _373: rt.char[] = copy$array_char(make(b3)); + const _373: rt.char[] = make(b3); const _370: rt.Place = rt.entryOrInsertWithMut(rt.entry(counts, _373), (): rt.u8 => { return 0; }); @@ -2342,7 +2341,7 @@ export function keyed$char_2_keys_arrays_closure3(data: rt.ByteSlice, make: (a0: }), undefined, true); rt.byteVecPush(out, rt.iterCount(rt.btreeIntersection(made, ordered)) & 0xff); rt.byteVecPush(out, rt.btreeIsSubset(made, ordered) ? 1 : 0); - const upper: rt.BTreeSet = rt.btreeClone(made, copy$array_char, undefined); + const upper: rt.BTreeSet = rt.btreeClone(made, undefined, undefined); const _405: rt.char[] = rt.sliceRange(probe, 0); const lower: rt.BTreeSet = rt.btreeSplitOff(upper, _405); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(rt.btreeLen(upper) & 0xff, rt.btreeLen(lower) & 0xff)), undefined, true); @@ -2364,16 +2363,16 @@ export function keyed$char_2_keys_arrays_closure3(data: rt.ByteSlice, make: (a0: } const i3: rt.usize = _431[0]; const b4: rt.u8 = _431[1]; - const pair: [rt.u8, rt.char[]] = [rt.u8Rem(b4, 2), copy$array_char(make(b4))]; + const pair: [rt.u8, rt.char[]] = [rt.u8Rem(b4, 2), make(b4)]; const _452: [rt.u8, rt.char[]] = [1, make(2)]; const _444: rt.u8 = ((rt.cmpTuple<[rt.u8, rt.char[]], rt.Ordering | undefined>([rt.cmp, rt.cmpSlice(rt.cmp)])(pair, _452) === -1 ? 1 : 0) << 1) & 0xff; const _462: [rt.u8, rt.char[]] = [0, make(3)]; const order4 = rt.cmpTuple<[rt.u8, rt.char[]], rt.Ordering | undefined>([rt.cmp, rt.cmpSlice(rt.cmp)])(pair, _462); rt.byteVecPush(out, _444 | (order4 !== undefined && order4 <= 0 ? 1 : 0)); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeInsert(pairs, pair, i3 & 0xff), 204)); - const _476: rt.char[] | undefined = copy$Option_array2_char(then$1dhbcvy(rt.u8Rem(b4, 3) !== 0, (): rt.char[] => { + const _476: rt.char[] | undefined = then$1dhbcvy(rt.u8Rem(b4, 3) !== 0, (): rt.char[] => { return make(b4); - })); + }); rt.byteVecPush(out, rt.hashAdd(options, _476) ? 1 : 0); const _487: rt.char[] = rt.vecExact(make(b4).slice(), 4); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.hashInsert(vecs, _487, i3 & 0xff), 204)); @@ -2385,8 +2384,7 @@ export function keyed$char_2_keys_arrays_closure3(data: rt.ByteSlice, make: (a0: const iterEnd2: rt.u8 = 8; while ((_513 = iterStart2++) < iterEnd2) { const key2: rt.char[] = make(_513); - const _526: rt.char[] | undefined = copy$array_char(key2); - const _522: rt.u8 = rt.hashContains(options, _526) ? 1 : 0; + const _522: rt.u8 = rt.hashContains(options, key2) ? 1 : 0; const _533: rt.char[] = rt.sliceRange(key2, 0); const _529: rt.u8 = option_unwrapOr$0r2bmpr(rt.hashGet(vecs, _533), 221); const _538: rt.char[] = rt.sliceRange(key2, 0); @@ -2942,24 +2940,24 @@ export function keyed$u16_2_keys_arrays_closure0(data: rt.ByteSlice, make: (a0: const i: rt.usize = _13[0]; const b: rt.u8 = _13[1]; const i2: rt.u8 = i & 0xff; - const _23: rt.u16[] = copy$array_u16(make(b)); + const _23: rt.u16[] = make(b); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.hashInsert(map, _23, i2), 204)); - const _30: rt.u16[] = copy$array_u16(make(b)); + const _30: rt.u16[] = make(b); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeInsert(tree, _30, i2), 204)); - const _38: rt.u16[] = copy$array_u16(make(b)); + const _38: rt.u16[] = make(b); const _35: rt.u8 = rt.hashAdd(set, _38) ? 1 : 0; - const _44: rt.u16[] = copy$array_u16(make(b)); + const _44: rt.u16[] = make(b); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_35, rt.btreeAdd(ordered, _44) ? 1 : 0)), undefined, true); const _51: rt.u8 = rt.u8Rem(b, 4); - const _53: rt.u16[] = copy$array_u16(make(b)); + const _53: rt.u16[] = make(b); rt.byteVecPush(out, option_mapOr$1kiffmd(rt.hashInsert(values, _51, _53), 204, (old: rt.u16[]): rt.u8 => { const _6: rt.u16[] = make(b); return rt.eqSlice(rt.same)(old, _6) ? 1 : 0; })); - const _62: rt.u16[] = copy$array_u16(make(rt.u8Div(b, 2))); + const _62: rt.u16[] = make(rt.u8Div(b, 2)); const _59: rt.Place = rt.entryOrInsertMut(rt.entry(map, _62), i2); _59.v = _59.v ^ 64; - const _69: rt.u16[] = copy$array_u16(make(rt.u8Div(b, 2))); + const _69: rt.u16[] = make(rt.u8Div(b, 2)); const _67: rt.Entry = rt.entry(tree, _69); if (!rt.entryOccupied(_67)) { const v: rt.Entry = _67; @@ -3001,7 +2999,7 @@ export function keyed$u16_2_keys_arrays_closure0(data: rt.ByteSlice, make: (a0: }), option_mapOr$1kiffmd(rt.hashGet(values, b2), 221, (v2: rt.u16[]): rt.u8 => { return rt.eqSlice(rt.same)(v2, key) ? 1 : 0; }))), undefined, true); - const _162: { end: rt.u16[] } = { end: copy$array_u16(copy$array_u16(key)) }; + const _162: { end: rt.u16[] } = { end: key }; rt.byteVecPush(out, rt.iterCount(rt.btreeRange(tree, _162)) & 0xff); const _170: [rt.RangeBound, rt.RangeBound] = [{ tag: "Excluded", _0: rt.sliceRange(key, 0) } as rt.RangeBound, { tag: "Unbounded" } as rt.RangeBound]; rt.byteVecPush(out, rt.iterCount(rt.btreeRange(tree, _170)) & 0xff); @@ -3083,7 +3081,7 @@ export function keyed$u16_2_keys_arrays_closure0(data: rt.ByteSlice, make: (a0: return make(rt.u8Div(_29, 3)); }); const made: rt.BTreeSet = rt.btreeExtendKeys(rt.btreeNew(rt.cmpSlice(rt.cmp)) as rt.BTreeSet, _330, true, undefined, undefined, 4, true); - const _335: [rt.u16[], rt.u8][] = [[copy$array_u16(make(0)), 1] as [rt.u16[], rt.u8], [copy$array_u16(make(1)), 2] as [rt.u16[], rt.u8]]; + const _335: [rt.u16[], rt.u8][] = [[make(0), 1] as [rt.u16[], rt.u8], [make(1), 2] as [rt.u16[], rt.u8]]; const counts: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(rt.hashInts(2), rt.eqSlice(rt.same))) as rt.HashMap, rt.iterSlice(_335), undefined, undefined, undefined, 234881024); for (const b3 of rt.byteSliceView(data)) { const _354: rt.u16[] = rt.sliceRange(make(b3), 0); @@ -3091,7 +3089,7 @@ export function keyed$u16_2_keys_arrays_closure0(data: rt.ByteSlice, make: (a0: const _361: rt.u16[] = rt.sliceRange(make(b3), 0); const _359: rt.Place | undefined = rt.hashGetMut(counts, _361); if (_359 === undefined) { - const _373: rt.u16[] = copy$array_u16(make(b3)); + const _373: rt.u16[] = make(b3); const _370: rt.Place = rt.entryOrInsertWithMut(rt.entry(counts, _373), (): rt.u8 => { return 0; }); @@ -3109,7 +3107,7 @@ export function keyed$u16_2_keys_arrays_closure0(data: rt.ByteSlice, make: (a0: }), undefined, true); rt.byteVecPush(out, rt.iterCount(rt.btreeIntersection(made, ordered)) & 0xff); rt.byteVecPush(out, rt.btreeIsSubset(made, ordered) ? 1 : 0); - const upper: rt.BTreeSet = rt.btreeClone(made, copy$array_u16, undefined); + const upper: rt.BTreeSet = rt.btreeClone(made, undefined, undefined); const _405: rt.u16[] = rt.sliceRange(probe, 0); const lower: rt.BTreeSet = rt.btreeSplitOff(upper, _405); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(rt.btreeLen(upper) & 0xff, rt.btreeLen(lower) & 0xff)), undefined, true); @@ -3131,16 +3129,16 @@ export function keyed$u16_2_keys_arrays_closure0(data: rt.ByteSlice, make: (a0: } const i3: rt.usize = _431[0]; const b4: rt.u8 = _431[1]; - const pair: [rt.u8, rt.u16[]] = [rt.u8Rem(b4, 2), copy$array_u16(make(b4))]; + const pair: [rt.u8, rt.u16[]] = [rt.u8Rem(b4, 2), make(b4)]; const _452: [rt.u8, rt.u16[]] = [1, make(2)]; const _444: rt.u8 = ((rt.cmpTuple<[rt.u8, rt.u16[]], rt.Ordering | undefined>([rt.cmp, rt.cmpSlice(rt.cmp)])(pair, _452) === -1 ? 1 : 0) << 1) & 0xff; const _462: [rt.u8, rt.u16[]] = [0, make(3)]; const order4 = rt.cmpTuple<[rt.u8, rt.u16[]], rt.Ordering | undefined>([rt.cmp, rt.cmpSlice(rt.cmp)])(pair, _462); rt.byteVecPush(out, _444 | (order4 !== undefined && order4 <= 0 ? 1 : 0)); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeInsert(pairs, pair, i3 & 0xff), 204)); - const _476: rt.u16[] | undefined = copy$Option_array2_u16(then$0l07w38(rt.u8Rem(b4, 3) !== 0, (): rt.u16[] => { + const _476: rt.u16[] | undefined = then$0l07w38(rt.u8Rem(b4, 3) !== 0, (): rt.u16[] => { return make(b4); - })); + }); rt.byteVecPush(out, rt.hashAdd(options, _476) ? 1 : 0); const _487: rt.u16[] = rt.vecExact(make(b4).slice(), 2); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.hashInsert(vecs, _487, i3 & 0xff), 204)); @@ -3152,8 +3150,7 @@ export function keyed$u16_2_keys_arrays_closure0(data: rt.ByteSlice, make: (a0: const iterEnd2: rt.u8 = 8; while ((_513 = iterStart2++) < iterEnd2) { const key2: rt.u16[] = make(_513); - const _526: rt.u16[] | undefined = copy$array_u16(key2); - const _522: rt.u8 = rt.hashContains(options, _526) ? 1 : 0; + const _522: rt.u8 = rt.hashContains(options, key2) ? 1 : 0; const _533: rt.u16[] = rt.sliceRange(key2, 0); const _529: rt.u8 = option_unwrapOr$0r2bmpr(rt.hashGet(vecs, _533), 221); const _538: rt.u16[] = rt.sliceRange(key2, 0); @@ -3198,24 +3195,24 @@ export function keyed$u32_0_keys_arrays_closure7(data: rt.ByteSlice, make: (a0: const i: rt.usize = _13[0]; const b: rt.u8 = _13[1]; const i2: rt.u8 = i & 0xff; - const _23: rt.u32[] = copy$array_u32(make(b)); + const _23: rt.u32[] = make(b); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.hashInsert(map, _23, i2), 204)); - const _30: rt.u32[] = copy$array_u32(make(b)); + const _30: rt.u32[] = make(b); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeInsert(tree, _30, i2), 204)); - const _38: rt.u32[] = copy$array_u32(make(b)); + const _38: rt.u32[] = make(b); const _35: rt.u8 = rt.hashAdd(set, _38) ? 1 : 0; - const _44: rt.u32[] = copy$array_u32(make(b)); + const _44: rt.u32[] = make(b); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_35, rt.btreeAdd(ordered, _44) ? 1 : 0)), undefined, true); const _51: rt.u8 = rt.u8Rem(b, 4); - const _53: rt.u32[] = copy$array_u32(make(b)); + const _53: rt.u32[] = make(b); rt.byteVecPush(out, option_mapOr$1h1mlmc(rt.hashInsert(values, _51, _53), 204, (old: rt.u32[]): rt.u8 => { const _6: rt.u32[] = make(b); return rt.eqSlice(rt.same)(old, _6) ? 1 : 0; })); - const _62: rt.u32[] = copy$array_u32(make(rt.u8Div(b, 2))); + const _62: rt.u32[] = make(rt.u8Div(b, 2)); const _59: rt.Place = rt.entryOrInsertMut(rt.entry(map, _62), i2); _59.v = _59.v ^ 64; - const _69: rt.u32[] = copy$array_u32(make(rt.u8Div(b, 2))); + const _69: rt.u32[] = make(rt.u8Div(b, 2)); const _67: rt.Entry = rt.entry(tree, _69); if (!rt.entryOccupied(_67)) { const v: rt.Entry = _67; @@ -3257,7 +3254,7 @@ export function keyed$u32_0_keys_arrays_closure7(data: rt.ByteSlice, make: (a0: }), option_mapOr$1h1mlmc(rt.hashGet(values, b2), 221, (v2: rt.u32[]): rt.u8 => { return rt.eqSlice(rt.same)(v2, key) ? 1 : 0; }))), undefined, true); - const _162: { end: rt.u32[] } = { end: copy$array_u32(copy$array_u32(key)) }; + const _162: { end: rt.u32[] } = { end: key }; rt.byteVecPush(out, rt.iterCount(rt.btreeRange(tree, _162)) & 0xff); const _170: [rt.RangeBound, rt.RangeBound] = [{ tag: "Excluded", _0: rt.sliceRange(key, 0) } as rt.RangeBound, { tag: "Unbounded" } as rt.RangeBound]; rt.byteVecPush(out, rt.iterCount(rt.btreeRange(tree, _170)) & 0xff); @@ -3339,7 +3336,7 @@ export function keyed$u32_0_keys_arrays_closure7(data: rt.ByteSlice, make: (a0: return make(rt.u8Div(_29, 3)); }); const made: rt.BTreeSet = rt.btreeExtendKeys(rt.btreeNew(rt.cmpSlice(rt.cmp)) as rt.BTreeSet, _330, true, undefined, undefined, 0, true); - const _335: [rt.u32[], rt.u8][] = [[copy$array_u32(make(0)), 1] as [rt.u32[], rt.u8], [copy$array_u32(make(1)), 2] as [rt.u32[], rt.u8]]; + const _335: [rt.u32[], rt.u8][] = [[make(0), 1] as [rt.u32[], rt.u8], [make(1), 2] as [rt.u32[], rt.u8]]; const counts: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(rt.hashInts(4), rt.eqSlice(rt.same))) as rt.HashMap, rt.iterSlice(_335), undefined, undefined, undefined, 234881024); for (const b3 of rt.byteSliceView(data)) { const _354: rt.u32[] = rt.sliceRange(make(b3), 0); @@ -3347,7 +3344,7 @@ export function keyed$u32_0_keys_arrays_closure7(data: rt.ByteSlice, make: (a0: const _361: rt.u32[] = rt.sliceRange(make(b3), 0); const _359: rt.Place | undefined = rt.hashGetMut(counts, _361); if (_359 === undefined) { - const _373: rt.u32[] = copy$array_u32(make(b3)); + const _373: rt.u32[] = make(b3); const _370: rt.Place = rt.entryOrInsertWithMut(rt.entry(counts, _373), (): rt.u8 => { return 0; }); @@ -3365,7 +3362,7 @@ export function keyed$u32_0_keys_arrays_closure7(data: rt.ByteSlice, make: (a0: }), undefined, true); rt.byteVecPush(out, rt.iterCount(rt.btreeIntersection(made, ordered)) & 0xff); rt.byteVecPush(out, rt.btreeIsSubset(made, ordered) ? 1 : 0); - const upper: rt.BTreeSet = rt.btreeClone(made, copy$array_u32, undefined); + const upper: rt.BTreeSet = rt.btreeClone(made, undefined, undefined); const _405: rt.u32[] = rt.sliceRange(probe, 0); const lower: rt.BTreeSet = rt.btreeSplitOff(upper, _405); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(rt.btreeLen(upper) & 0xff, rt.btreeLen(lower) & 0xff)), undefined, true); @@ -3387,16 +3384,16 @@ export function keyed$u32_0_keys_arrays_closure7(data: rt.ByteSlice, make: (a0: } const i3: rt.usize = _431[0]; const b4: rt.u8 = _431[1]; - const pair: [rt.u8, rt.u32[]] = [rt.u8Rem(b4, 2), copy$array_u32(make(b4))]; + const pair: [rt.u8, rt.u32[]] = [rt.u8Rem(b4, 2), make(b4)]; const _452: [rt.u8, rt.u32[]] = [1, make(2)]; const _444: rt.u8 = ((rt.cmpTuple<[rt.u8, rt.u32[]], rt.Ordering | undefined>([rt.cmp, rt.cmpSlice(rt.cmp)])(pair, _452) === -1 ? 1 : 0) << 1) & 0xff; const _462: [rt.u8, rt.u32[]] = [0, make(3)]; const order4 = rt.cmpTuple<[rt.u8, rt.u32[]], rt.Ordering | undefined>([rt.cmp, rt.cmpSlice(rt.cmp)])(pair, _462); rt.byteVecPush(out, _444 | (order4 !== undefined && order4 <= 0 ? 1 : 0)); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeInsert(pairs, pair, i3 & 0xff), 204)); - const _476: rt.u32[] | undefined = copy$Option_array0_u32(then$0l8o6jo(rt.u8Rem(b4, 3) !== 0, (): rt.u32[] => { + const _476: rt.u32[] | undefined = then$0l8o6jo(rt.u8Rem(b4, 3) !== 0, (): rt.u32[] => { return make(b4); - })); + }); rt.byteVecPush(out, rt.hashAdd(options, _476) ? 1 : 0); const _487: rt.u32[] = rt.vecExact(make(b4).slice(), 4); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.hashInsert(vecs, _487, i3 & 0xff), 204)); @@ -3408,8 +3405,7 @@ export function keyed$u32_0_keys_arrays_closure7(data: rt.ByteSlice, make: (a0: const iterEnd2: rt.u8 = 8; while ((_513 = iterStart2++) < iterEnd2) { const key2: rt.u32[] = make(_513); - const _526: rt.u32[] | undefined = copy$array_u32(key2); - const _522: rt.u8 = rt.hashContains(options, _526) ? 1 : 0; + const _522: rt.u8 = rt.hashContains(options, key2) ? 1 : 0; const _533: rt.u32[] = rt.sliceRange(key2, 0); const _529: rt.u8 = option_unwrapOr$0r2bmpr(rt.hashGet(vecs, _533), 221); const _538: rt.u32[] = rt.sliceRange(key2, 0); @@ -3454,24 +3450,24 @@ export function keyed$u32_275_keys_arrays_closure8(data: rt.ByteSlice, make: (a0 const i: rt.usize = _13[0]; const b: rt.u8 = _13[1]; const i2: rt.u8 = i & 0xff; - const _23: rt.u32[] = copy$array_u32(make(b)); + const _23: rt.u32[] = make(b); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.hashInsert(map, _23, i2), 204)); - const _30: rt.u32[] = copy$array_u32(make(b)); + const _30: rt.u32[] = make(b); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeInsert(tree, _30, i2), 204)); - const _38: rt.u32[] = copy$array_u32(make(b)); + const _38: rt.u32[] = make(b); const _35: rt.u8 = rt.hashAdd(set, _38) ? 1 : 0; - const _44: rt.u32[] = copy$array_u32(make(b)); + const _44: rt.u32[] = make(b); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_35, rt.btreeAdd(ordered, _44) ? 1 : 0)), undefined, true); const _51: rt.u8 = rt.u8Rem(b, 4); - const _53: rt.u32[] = copy$array_u32(make(b)); + const _53: rt.u32[] = make(b); rt.byteVecPush(out, option_mapOr$1h1mlmc(rt.hashInsert(values, _51, _53), 204, (old: rt.u32[]): rt.u8 => { const _6: rt.u32[] = make(b); return rt.eqSlice(rt.same)(old, _6) ? 1 : 0; })); - const _62: rt.u32[] = copy$array_u32(make(rt.u8Div(b, 2))); + const _62: rt.u32[] = make(rt.u8Div(b, 2)); const _59: rt.Place = rt.entryOrInsertMut(rt.entry(map, _62), i2); _59.v = _59.v ^ 64; - const _69: rt.u32[] = copy$array_u32(make(rt.u8Div(b, 2))); + const _69: rt.u32[] = make(rt.u8Div(b, 2)); const _67: rt.Entry = rt.entry(tree, _69); if (!rt.entryOccupied(_67)) { const v: rt.Entry = _67; @@ -3513,7 +3509,7 @@ export function keyed$u32_275_keys_arrays_closure8(data: rt.ByteSlice, make: (a0 }), option_mapOr$1h1mlmc(rt.hashGet(values, b2), 221, (v2: rt.u32[]): rt.u8 => { return rt.eqSlice(rt.same)(v2, key) ? 1 : 0; }))), undefined, true); - const _162: { end: rt.u32[] } = { end: copy$array_u32(copy$array_u32(key)) }; + const _162: { end: rt.u32[] } = { end: key }; rt.byteVecPush(out, rt.iterCount(rt.btreeRange(tree, _162)) & 0xff); const _170: [rt.RangeBound, rt.RangeBound] = [{ tag: "Excluded", _0: rt.sliceRange(key, 0) } as rt.RangeBound, { tag: "Unbounded" } as rt.RangeBound]; rt.byteVecPush(out, rt.iterCount(rt.btreeRange(tree, _170)) & 0xff); @@ -3595,7 +3591,7 @@ export function keyed$u32_275_keys_arrays_closure8(data: rt.ByteSlice, make: (a0 return make(rt.u8Div(_29, 3)); }); const made: rt.BTreeSet = rt.btreeExtendKeys(rt.btreeNew(rt.cmpSlice(rt.cmp)) as rt.BTreeSet, _330, true, undefined, undefined, 1100, true); - const _335: [rt.u32[], rt.u8][] = [[copy$array_u32(make(0)), 1] as [rt.u32[], rt.u8], [copy$array_u32(make(1)), 2] as [rt.u32[], rt.u8]]; + const _335: [rt.u32[], rt.u8][] = [[make(0), 1] as [rt.u32[], rt.u8], [make(1), 2] as [rt.u32[], rt.u8]]; const counts: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(rt.hashInts(4), rt.eqSlice(rt.same))) as rt.HashMap, rt.iterSlice(_335), undefined, undefined, undefined, 917504); for (const b3 of rt.byteSliceView(data)) { const _354: rt.u32[] = rt.sliceRange(make(b3), 0); @@ -3603,7 +3599,7 @@ export function keyed$u32_275_keys_arrays_closure8(data: rt.ByteSlice, make: (a0 const _361: rt.u32[] = rt.sliceRange(make(b3), 0); const _359: rt.Place | undefined = rt.hashGetMut(counts, _361); if (_359 === undefined) { - const _373: rt.u32[] = copy$array_u32(make(b3)); + const _373: rt.u32[] = make(b3); const _370: rt.Place = rt.entryOrInsertWithMut(rt.entry(counts, _373), (): rt.u8 => { return 0; }); @@ -3621,7 +3617,7 @@ export function keyed$u32_275_keys_arrays_closure8(data: rt.ByteSlice, make: (a0 }), undefined, true); rt.byteVecPush(out, rt.iterCount(rt.btreeIntersection(made, ordered)) & 0xff); rt.byteVecPush(out, rt.btreeIsSubset(made, ordered) ? 1 : 0); - const upper: rt.BTreeSet = rt.btreeClone(made, copy$array_u32, undefined); + const upper: rt.BTreeSet = rt.btreeClone(made, undefined, undefined); const _405: rt.u32[] = rt.sliceRange(probe, 0); const lower: rt.BTreeSet = rt.btreeSplitOff(upper, _405); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(rt.btreeLen(upper) & 0xff, rt.btreeLen(lower) & 0xff)), undefined, true); @@ -3643,16 +3639,16 @@ export function keyed$u32_275_keys_arrays_closure8(data: rt.ByteSlice, make: (a0 } const i3: rt.usize = _431[0]; const b4: rt.u8 = _431[1]; - const pair: [rt.u8, rt.u32[]] = [rt.u8Rem(b4, 2), copy$array_u32(make(b4))]; + const pair: [rt.u8, rt.u32[]] = [rt.u8Rem(b4, 2), make(b4)]; const _452: [rt.u8, rt.u32[]] = [1, make(2)]; const _444: rt.u8 = ((rt.cmpTuple<[rt.u8, rt.u32[]], rt.Ordering | undefined>([rt.cmp, rt.cmpSlice(rt.cmp)])(pair, _452) === -1 ? 1 : 0) << 1) & 0xff; const _462: [rt.u8, rt.u32[]] = [0, make(3)]; const order4 = rt.cmpTuple<[rt.u8, rt.u32[]], rt.Ordering | undefined>([rt.cmp, rt.cmpSlice(rt.cmp)])(pair, _462); rt.byteVecPush(out, _444 | (order4 !== undefined && order4 <= 0 ? 1 : 0)); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeInsert(pairs, pair, i3 & 0xff), 204)); - const _476: rt.u32[] | undefined = copy$Option_array275_u32(then$0l8o6jo(rt.u8Rem(b4, 3) !== 0, (): rt.u32[] => { + const _476: rt.u32[] | undefined = then$0l8o6jo(rt.u8Rem(b4, 3) !== 0, (): rt.u32[] => { return make(b4); - })); + }); rt.byteVecPush(out, rt.hashAdd(options, _476) ? 1 : 0); const _487: rt.u32[] = rt.vecExact(make(b4).slice(), 4); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.hashInsert(vecs, _487, i3 & 0xff), 204)); @@ -3664,8 +3660,7 @@ export function keyed$u32_275_keys_arrays_closure8(data: rt.ByteSlice, make: (a0 const iterEnd2: rt.u8 = 8; while ((_513 = iterStart2++) < iterEnd2) { const key2: rt.u32[] = make(_513); - const _526: rt.u32[] | undefined = copy$array_u32(key2); - const _522: rt.u8 = rt.hashContains(options, _526) ? 1 : 0; + const _522: rt.u8 = rt.hashContains(options, key2) ? 1 : 0; const _533: rt.u32[] = rt.sliceRange(key2, 0); const _529: rt.u8 = option_unwrapOr$0r2bmpr(rt.hashGet(vecs, _533), 221); const _538: rt.u32[] = rt.sliceRange(key2, 0); @@ -3710,24 +3705,24 @@ export function keyed$u64_2_keys_arrays_closure1(data: rt.ByteSlice, make: (a0: const i: rt.usize = _13[0]; const b: rt.u8 = _13[1]; const i2: rt.u8 = i & 0xff; - const _23: rt.u64[] = copy$array_u64(make(b)); + const _23: rt.u64[] = make(b); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.hashInsert(map, _23, i2), 204)); - const _30: rt.u64[] = copy$array_u64(make(b)); + const _30: rt.u64[] = make(b); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeInsert(tree, _30, i2), 204)); - const _38: rt.u64[] = copy$array_u64(make(b)); + const _38: rt.u64[] = make(b); const _35: rt.u8 = rt.hashAdd(set, _38) ? 1 : 0; - const _44: rt.u64[] = copy$array_u64(make(b)); + const _44: rt.u64[] = make(b); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_35, rt.btreeAdd(ordered, _44) ? 1 : 0)), undefined, true); const _51: rt.u8 = rt.u8Rem(b, 4); - const _53: rt.u64[] = copy$array_u64(make(b)); + const _53: rt.u64[] = make(b); rt.byteVecPush(out, option_mapOr$0nlcxqx(rt.hashInsert(values, _51, _53), 204, (old: rt.u64[]): rt.u8 => { const _6: rt.u64[] = make(b); return rt.eqSlice(rt.u64Eq)(old, _6) ? 1 : 0; })); - const _62: rt.u64[] = copy$array_u64(make(rt.u8Div(b, 2))); + const _62: rt.u64[] = make(rt.u8Div(b, 2)); const _59: rt.Place = rt.entryOrInsertMut(rt.entry(map, _62), i2); _59.v = _59.v ^ 64; - const _69: rt.u64[] = copy$array_u64(make(rt.u8Div(b, 2))); + const _69: rt.u64[] = make(rt.u8Div(b, 2)); const _67: rt.Entry = rt.entry(tree, _69); if (!rt.entryOccupied(_67)) { const v: rt.Entry = _67; @@ -3769,7 +3764,7 @@ export function keyed$u64_2_keys_arrays_closure1(data: rt.ByteSlice, make: (a0: }), option_mapOr$0nlcxqx(rt.hashGet(values, b2), 221, (v2: rt.u64[]): rt.u8 => { return rt.eqSlice(rt.u64Eq)(v2, key) ? 1 : 0; }))), undefined, true); - const _162: { end: rt.u64[] } = { end: copy$array_u64(copy$array_u64(key)) }; + const _162: { end: rt.u64[] } = { end: key }; rt.byteVecPush(out, rt.iterCount(rt.btreeRange(tree, _162)) & 0xff); const _170: [rt.RangeBound, rt.RangeBound] = [{ tag: "Excluded", _0: rt.sliceRange(key, 0) } as rt.RangeBound, { tag: "Unbounded" } as rt.RangeBound]; rt.byteVecPush(out, rt.iterCount(rt.btreeRange(tree, _170)) & 0xff); @@ -3851,7 +3846,7 @@ export function keyed$u64_2_keys_arrays_closure1(data: rt.ByteSlice, make: (a0: return make(rt.u8Div(_29, 3)); }); const made: rt.BTreeSet = rt.btreeExtendKeys(rt.btreeNew(rt.cmpSlice(rt.cmp)) as rt.BTreeSet, _330, true, undefined, undefined, 16, true); - const _335: [rt.u64[], rt.u8][] = [[copy$array_u64(make(0)), 1] as [rt.u64[], rt.u8], [copy$array_u64(make(1)), 2] as [rt.u64[], rt.u8]]; + const _335: [rt.u64[], rt.u8][] = [[make(0), 1] as [rt.u64[], rt.u8], [make(1), 2] as [rt.u64[], rt.u8]]; const counts: rt.HashMap = rt.hashExtend(rt.hashNew(rt.hashing(rt.hashInts(8), rt.eqSlice(rt.u64Eq))) as rt.HashMap, rt.iterSlice(_335), undefined, undefined, undefined, 58720256); for (const b3 of rt.byteSliceView(data)) { const _354: rt.u64[] = rt.sliceRange(make(b3), 0); @@ -3859,7 +3854,7 @@ export function keyed$u64_2_keys_arrays_closure1(data: rt.ByteSlice, make: (a0: const _361: rt.u64[] = rt.sliceRange(make(b3), 0); const _359: rt.Place | undefined = rt.hashGetMut(counts, _361); if (_359 === undefined) { - const _373: rt.u64[] = copy$array_u64(make(b3)); + const _373: rt.u64[] = make(b3); const _370: rt.Place = rt.entryOrInsertWithMut(rt.entry(counts, _373), (): rt.u8 => { return 0; }); @@ -3877,7 +3872,7 @@ export function keyed$u64_2_keys_arrays_closure1(data: rt.ByteSlice, make: (a0: }), undefined, true); rt.byteVecPush(out, rt.iterCount(rt.btreeIntersection(made, ordered)) & 0xff); rt.byteVecPush(out, rt.btreeIsSubset(made, ordered) ? 1 : 0); - const upper: rt.BTreeSet = rt.btreeClone(made, copy$array_u64, undefined); + const upper: rt.BTreeSet = rt.btreeClone(made, undefined, undefined); const _405: rt.u64[] = rt.sliceRange(probe, 0); const lower: rt.BTreeSet = rt.btreeSplitOff(upper, _405); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(rt.btreeLen(upper) & 0xff, rt.btreeLen(lower) & 0xff)), undefined, true); @@ -3899,16 +3894,16 @@ export function keyed$u64_2_keys_arrays_closure1(data: rt.ByteSlice, make: (a0: } const i3: rt.usize = _431[0]; const b4: rt.u8 = _431[1]; - const pair: [rt.u8, rt.u64[]] = [rt.u8Rem(b4, 2), copy$array_u64(make(b4))]; + const pair: [rt.u8, rt.u64[]] = [rt.u8Rem(b4, 2), make(b4)]; const _452: [rt.u8, rt.u64[]] = [1, make(2)]; const _444: rt.u8 = ((rt.cmpTuple<[rt.u8, rt.u64[]], rt.Ordering | undefined>([rt.cmp, rt.cmpSlice(rt.cmp)])(pair, _452) === -1 ? 1 : 0) << 1) & 0xff; const _462: [rt.u8, rt.u64[]] = [0, make(3)]; const order4 = rt.cmpTuple<[rt.u8, rt.u64[]], rt.Ordering | undefined>([rt.cmp, rt.cmpSlice(rt.cmp)])(pair, _462); rt.byteVecPush(out, _444 | (order4 !== undefined && order4 <= 0 ? 1 : 0)); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.btreeInsert(pairs, pair, i3 & 0xff), 204)); - const _476: rt.u64[] | undefined = copy$Option_array2_u64(then$0uovwq9(rt.u8Rem(b4, 3) !== 0, (): rt.u64[] => { + const _476: rt.u64[] | undefined = then$0uovwq9(rt.u8Rem(b4, 3) !== 0, (): rt.u64[] => { return make(b4); - })); + }); rt.byteVecPush(out, rt.hashAdd(options, _476) ? 1 : 0); const _487: rt.u64[] = rt.vecExact(make(b4).slice(), 8); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(rt.hashInsert(vecs, _487, i3 & 0xff), 204)); @@ -3920,8 +3915,7 @@ export function keyed$u64_2_keys_arrays_closure1(data: rt.ByteSlice, make: (a0: const iterEnd2: rt.u8 = 8; while ((_513 = iterStart2++) < iterEnd2) { const key2: rt.u64[] = make(_513); - const _526: rt.u64[] | undefined = copy$array_u64(key2); - const _522: rt.u8 = rt.hashContains(options, _526) ? 1 : 0; + const _522: rt.u8 = rt.hashContains(options, key2) ? 1 : 0; const _533: rt.u64[] = rt.sliceRange(key2, 0); const _529: rt.u8 = option_unwrapOr$0r2bmpr(rt.hashGet(vecs, _533), 221); const _538: rt.u64[] = rt.sliceRange(key2, 0); diff --git a/ts/fixtures/lang/keys/expected/lib.ts b/ts/fixtures/lang/keys/expected/lib.ts new file mode 100644 index 000000000..32ed9ce7b --- /dev/null +++ b/ts/fixtures/lang/keys/expected/lib.ts @@ -0,0 +1,53 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { keys, overrides, bytes, lentKeys, lentValues, arrays, byteRefs } from "./keys.ts"; +import type * as Hop from "./keys.Hop.ts"; +import type * as Horizon from "./keys.Horizon.ts"; +import type * as Lopsided from "./keys.Lopsided.ts"; + +export function copy$Option_array2_keys_Hop(v: Hop.Hop[] | undefined): Hop.Hop[] | undefined { + return v === undefined ? v : copy$array_keys_Hop(v); +} + +export function copy$Option_array2_u8(v: Uint8Array | undefined): Uint8Array | undefined { + return v === undefined ? v : copy$array_u8(v); +} + +export function copy$Option_keys_Hop(v: Hop.Hop | undefined): Hop.Hop | undefined { + return v === undefined ? v : copy$keys_Hop(v); +} + +export function copy$array_keys_Hop(v: Hop.Hop[]): Hop.Hop[] { + return v.map(copy$keys_Hop); +} + +export function copy$array_u8(v: Uint8Array): Uint8Array { + return v.slice(); +} + +export function copy$keys_Hop(v: Hop.Hop): Hop.Hop { + return { _0: v._0 }; +} + +export function copy$keys_Horizon(v: Horizon.Horizon): Horizon.Horizon { + return { exclude: copy$Option_keys_Hop(v.exclude), local: v.local }; +} + +export function copy$tuple2_u8_keys_Horizon(v: [rt.u8, Horizon.Horizon]): [rt.u8, Horizon.Horizon] { + return [v[0], copy$keys_Horizon(v[1])]; +} + +export function drop$tuple2_u8_cmp_Reverse_sync_Arc_keys_Lopsided(_1: [rt.u8, rt.Arc]): void { + _1[1][Symbol.dispose](); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["keys::keys", keys as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["keys::overrides", overrides as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["keys::bytes", bytes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["keys::lent_keys", lentKeys as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["keys::lent_values", lentValues as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["keys::arrays", arrays as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["keys::byte_refs", byteRefs as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/keys.rs b/ts/fixtures/lang/keys/src/keys.rs similarity index 100% rename from ts/fixtures/lang/src/keys.rs rename to ts/fixtures/lang/keys/src/keys.rs diff --git a/ts/fixtures/lang/keys/src/lib.rs b/ts/fixtures/lang/keys/src/lib.rs new file mode 100644 index 000000000..404b67150 --- /dev/null +++ b/ts/fixtures/lang/keys/src/lib.rs @@ -0,0 +1,27 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod keys; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("keys::keys", keys::keys), + ("keys::overrides", keys::overrides), + ("keys::bytes", keys::bytes), + ("keys::lent_keys", keys::lent_keys), + ("keys::lent_values", keys::lent_values), + ("keys::arrays", keys::arrays), + ("keys::byte_refs", keys::byte_refs), + ] +} diff --git a/ts/fixtures/lang/keys/ts.toml b/ts/fixtures/lang/keys/ts.toml new file mode 100644 index 000000000..c441392d8 --- /dev/null +++ b/ts/fixtures/lang/keys/ts.toml @@ -0,0 +1,2 @@ +package = "lang-keys-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/lang.ts b/ts/fixtures/lang/lang.ts new file mode 100644 index 000000000..44828259f --- /dev/null +++ b/ts/fixtures/lang/lang.ts @@ -0,0 +1,106 @@ +// A hand-written caller of a fixture's translation, as moq's TypeScript is: it runs the +// harness, which picks each case by its first two bytes. `differential.ts` runs it beside +// native Rust's, from the output directory, as it does a fixture's own `caller.ts`, which +// adds the inputs its cases name from what this module shares. + +import { op as pick, run } from "./harness.ts"; +import { cases } from "./lib.ts"; + +export { run }; + +/** The first two bytes, which pick the case named `name`. */ +export function op(name: string): number[] { + const at = pick(name); + return [at >> 8, at & 0xff]; +} + +/** The bytes that pick each case, through `op`, which panics for one past what two bytes pick. */ +export const ops: Uint8Array[] = cases().map(([name]) => Uint8Array.from(op(name))); + +/** Which case the first two bytes of `input` pick. */ +export function picked(input: Uint8Array): number { + return ((input[0] << 8) | input[1]) % ops.length; +} + +/** A double's bits, big-endian, as `floats` takes them. */ +export function double(x: number | bigint): number[] { + const bytes = new Uint8Array(8); + const view = new DataView(bytes.buffer); + if (typeof x === "bigint") view.setBigUint64(0, x); + else view.setFloat64(0, x); + return [...bytes]; +} + +/** Integers whose `f64` rounds, as `floats`' kind 2 takes them: 16 bytes of a `u128`. */ +export const wides = [0n, 1n, (1n << 53n) + 1n, (1n << 53n) + 3n, (1n << 54n) + 2n, (1n << 63n) + 1025n, (1n << 64n) - 1n, (1n << 64n) - 1025n, (1n << 64n) + (1n << 11n) + 1n, (1n << 127n) + 1n, (1n << 128n) - 1n, (1n << 128n) - (1n << 74n), -(1n << 100n) - 1n]; + +/** + * `mul_adds`' operands at each width: signed zeros, a product that underflows to either + * zero, infinities and NaN, a product past the type's range whose sum is in it, subnormal + * sums and ties, products whose error alone survives, which rounding twice loses, and a + * product of half `c`'s last place, which only its error moves off a tie; then + * seeds for its sweeps. + */ +export const mulAdds = (max: number, tiny: number, eps: number, op: number[], bytes: (x: number) => number[]) => [ + ...[ + [0, 1, -0], [-0, 1, -0], [0, -1, 0], [-0, -0, -0], [-0, 0, -0], [1, -1, 1], [-1, 1, 1], + [tiny, -(2 ** -30), 0], [tiny, 2 ** -30, -0], [-tiny, 2 ** -30, -0], [tiny, 0.5, 0], [tiny, 0.5, -0], [-tiny, 0.5, 0], + [tiny, 1.5, 0], [tiny, 0.5, tiny], [tiny, -0.5, tiny], [tiny, 2 ** 52, tiny], + [Infinity, 0, 1], [0, -Infinity, 1], [Infinity, 1, -Infinity], [Infinity, -1, -Infinity], [1, 1, Infinity], [max, 2, -Infinity], [max, -2, Infinity], + [NaN, 1, 1], [1, NaN, 1], [1, 1, NaN], [Infinity, 1, NaN], + [max, 2, -max], [max, -2, max], [max, 1 + eps, -max], [max, 1 + eps, 0], [max * 0.5, 2, max * eps * 0.25], + [1 + 2 ** -27, 1 - 2 ** -27, -1], [1 + eps, 1 + eps, -1], [1 + eps, 1 - eps, -1], [0.1, 10, -1], [3, 1 / 3, -1], [1 + eps, 1 + eps, -(1 + 2 * eps)], + [1 + 2 ** -12, 1 + 2 ** -12, tiny], [1 + 2 ** -12, 1 + 2 ** -12, -tiny], [1 + eps, 1 + eps / 2, 0], [eps / 2 + eps * eps / 2, 1 - eps / 2, 1], [eps / 2 + eps * eps / 2, 1 - eps / 2, -1], + ].map((xs) => Uint8Array.of(...op, 0, ...xs.flatMap(bytes))), + ...Array.from({ length: 400 }, (_, i) => Uint8Array.of(...op, 1, ...double(BigInt(i + 1) * 0x9e3779b97f4a7c15n & 0xffff_ffff_ffff_ffffn))), +]; + +/** How many ULPs from native Rust's each float of `floats`' and `singles`' kind 7 may be, which Rust leaves to libm. */ +const ULPS = 2n; + +/** Whether each float of `width` bytes in two outputs is within `ULPS` of the other's. */ +export function ulpsWithin(width: number, native: Uint8Array, translated: Uint8Array): boolean { + if (native.length !== translated.length) return false; + const [a, b] = [native, translated].map((v) => new DataView(v.buffer, v.byteOffset, v.length)); + const read = (v: DataView, i: number) => (width === 8 ? v.getBigInt64(i) : BigInt(v.getInt32(i))); + // Bits as a line through zero, so the distance between two is how many floats apart they are. + const magnitude = (1n << BigInt(width * 8 - 1)) - 1n; + const line = (v: bigint) => (v < 0n ? -(v & magnitude) : v); + for (let i = 0; i < native.length; i += width) { + const d = line(read(a, i)) - line(read(b, i)); + if (d > ULPS || d < -ULPS) return false; + } + return true; +} + +/** + * 64-bit operands that random bytes rarely make: 2^k - 1, 2^k, and 2^k + 1 for each k + * where a limb, a safe number, or a sign ends, and values without that structure, whose + * quotients and remainders are not round. + */ +export function edges(): bigint[] { + const edges = new Set([ + 1_000_000n, + 0x9e3779b97f4a7c15n, + 0x0123456789abcdefn, + 0xfedcba9876543210n, + // Safe integers whose halves carry when multiplied, and a negative one. + 0x1d3c5b7a9f8e6dn, + -0x1b2a3c4d5e6f71n & 0xffffffffffffffffn, + ]); + for (const k of [0n, 1n, 16n, 21n, 31n, 32n, 33n, 52n, 53n, 54n, 63n, 64n]) { + for (const delta of [-1n, 0n, 1n]) edges.add(((1n << k) + delta) & 0xffffffffffffffffn); + } + // Small negative numbers, -2^32, and where negative safe numbers end, as signed values. + for (const k of [1n, 32n, 53n]) { + for (const delta of [-1n, 0n, 1n]) edges.add((-(1n << k) + delta) & 0xffffffffffffffffn); + } + return [...edges]; +} + +/** A `u64`'s bytes, big-endian. */ +export function be(v: bigint): number[] { + const bytes = new Uint8Array(8); + new DataView(bytes.buffer).setBigUint64(0, v); + return [...bytes]; +} diff --git a/ts/fixtures/lang/lengths/Cargo.toml b/ts/fixtures/lang/lengths/Cargo.toml new file mode 100644 index 000000000..84b14efb4 --- /dev/null +++ b/ts/fixtures/lang/lengths/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-lengths-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/lengths/expected/core/option.ts b/ts/fixtures/lang/lengths/expected/core/option.ts new file mode 100644 index 000000000..0fb1b6278 --- /dev/null +++ b/ts/fixtures/lang/lengths/expected/core/option.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/lengths/expected/harness.ts b/ts/fixtures/lang/lengths/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/lengths/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/expected/lengths.Tagged.ts b/ts/fixtures/lang/lengths/expected/lengths.Tagged.ts similarity index 100% rename from ts/fixtures/lang/expected/lengths.Tagged.ts rename to ts/fixtures/lang/lengths/expected/lengths.Tagged.ts diff --git a/ts/fixtures/lang/expected/lengths.ts b/ts/fixtures/lang/lengths/expected/lengths.ts similarity index 88% rename from ts/fixtures/lang/expected/lengths.ts rename to ts/fixtures/lang/lengths/expected/lengths.ts index 65468f8d1..c09db3302 100644 --- a/ts/fixtures/lang/expected/lengths.ts +++ b/ts/fixtures/lang/lengths/expected/lengths.ts @@ -3,7 +3,7 @@ import * as rt from "./rt.ts"; import { copy$Option_lengths_Tagged_array0_u32, copy$Option_lengths_Tagged_array0_u8, copy$Option_lengths_Tagged_array17_u32, copy$Option_lengths_Tagged_array17_u8, copy$Option_lengths_Tagged_array1_u32, copy$Option_lengths_Tagged_array1_u8, copy$Option_lengths_Tagged_array3_u32, copy$Option_lengths_Tagged_array3_u8, copy$array_array0_u8, copy$array_array17_u8, copy$array_array1_u8, copy$array_array3_u8, copy$array_lengths_Tagged_u32, copy$array_u32, copy$array_u8, copy$mem_MaybeUninit_tuple2_array0_array0_u8_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array0_lengths_Tagged_u32_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array0_u32_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array0_u8_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array17_array17_u8_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array17_lengths_Tagged_u32_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array17_u32_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array17_u8_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array1_array1_u8_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array1_lengths_Tagged_u32_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array1_u32_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array1_u8_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array3_array3_u8_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array3_lengths_Tagged_u32_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array3_u32_tuple2_u8_u8, copy$mem_MaybeUninit_tuple2_array3_u8_tuple2_u8_u8 } from "./lib.ts"; import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr } from "./core/option.ts"; -import * as lengths_Tagged from "./lengths.Tagged.ts"; +import * as Tagged from "./lengths.Tagged.ts"; /** Each case at the length `kind` picks. */ export function lengths(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { @@ -47,8 +47,8 @@ export function each$0(data: rt.ByteSlice, out: rt.ByteVec): void { return rt.usizeAdd(rt.usizeMul(i5, 0), j) & 0xff; }); }), out); - filled$lengths_Tagged_u32_0(data, rt.arrayFromFn(0, (i6: rt.usize): lengths_Tagged.Tagged => { - return new lengths_Tagged.Tagged(rt.u32Mul(i6 as rt.u32, 257), ~(i6 & 0xff) & 0xff); + filled$lengths_Tagged_u32_0(data, rt.arrayFromFn(0, (i6: rt.usize): Tagged.Tagged => { + return new Tagged.Tagged(rt.u32Mul(i6 as rt.u32, 257), ~(i6 & 0xff) & 0xff); }), out); swapped$u8_0(data, rows, out); swapped$u32_0(data, wide, out); @@ -82,8 +82,8 @@ export function each$1(data: rt.ByteSlice, out: rt.ByteVec): void { return rt.usizeAdd(rt.usizeMul(i5, 1), j) & 0xff; }); }), out); - filled$lengths_Tagged_u32_1(data, rt.arrayFromFn(1, (i6: rt.usize): lengths_Tagged.Tagged => { - return new lengths_Tagged.Tagged(rt.u32Mul(i6 as rt.u32, 257), ~(i6 & 0xff) & 0xff); + filled$lengths_Tagged_u32_1(data, rt.arrayFromFn(1, (i6: rt.usize): Tagged.Tagged => { + return new Tagged.Tagged(rt.u32Mul(i6 as rt.u32, 257), ~(i6 & 0xff) & 0xff); }), out); swapped$u8_1(data, rows, out); swapped$u32_1(data, wide, out); @@ -117,8 +117,8 @@ export function each$17(data: rt.ByteSlice, out: rt.ByteVec): void { return rt.usizeAdd(rt.usizeMul(i5, 17), j) & 0xff; }); }), out); - filled$lengths_Tagged_u32_17(data, rt.arrayFromFn(17, (i6: rt.usize): lengths_Tagged.Tagged => { - return new lengths_Tagged.Tagged(rt.u32Mul(i6 as rt.u32, 257), ~(i6 & 0xff) & 0xff); + filled$lengths_Tagged_u32_17(data, rt.arrayFromFn(17, (i6: rt.usize): Tagged.Tagged => { + return new Tagged.Tagged(rt.u32Mul(i6 as rt.u32, 257), ~(i6 & 0xff) & 0xff); }), out); swapped$u8_17(data, rows, out); swapped$u32_17(data, wide, out); @@ -152,8 +152,8 @@ export function each$3(data: rt.ByteSlice, out: rt.ByteVec): void { return rt.usizeAdd(rt.usizeMul(i5, 3), j) & 0xff; }); }), out); - filled$lengths_Tagged_u32_3(data, rt.arrayFromFn(3, (i6: rt.usize): lengths_Tagged.Tagged => { - return new lengths_Tagged.Tagged(rt.u32Mul(i6 as rt.u32, 257), ~(i6 & 0xff) & 0xff); + filled$lengths_Tagged_u32_3(data, rt.arrayFromFn(3, (i6: rt.usize): Tagged.Tagged => { + return new Tagged.Tagged(rt.u32Mul(i6 as rt.u32, 257), ~(i6 & 0xff) & 0xff); }), out); swapped$u8_3(data, rows, out); swapped$u32_3(data, wide, out); @@ -191,8 +191,8 @@ export function retagged$0(rows: Uint8Array[], out: rt.ByteVec): void { break; } const at: rt.usize = _7[0]; - const pair: [lengths_Tagged.Tagged | undefined, rt.u8] = [new lengths_Tagged.Tagged(copy$array_u8(rt.byteSliceToArray(_7[1])), at & 0xff), 0]; - let copy: lengths_Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array0_u8(copy$Option_lengths_Tagged_array0_u8(pair[0])); + const pair: [Tagged.Tagged | undefined, rt.u8] = [new Tagged.Tagged(copy$array_u8(rt.byteSliceToArray(_7[1])), at & 0xff), 0]; + let copy: Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array0_u8(copy$Option_lengths_Tagged_array0_u8(pair[0])); pair[0] = copy$Option_lengths_Tagged_array0_u8(copy); const part = rt.place(() => pair[0], (value) => pair[0] = value); const part2 = rt.place(() => copy, (value2) => copy = value2); @@ -221,8 +221,8 @@ export function retagged$1(rows: Uint8Array[], out: rt.ByteVec): void { break; } const at: rt.usize = _7[0]; - const pair: [lengths_Tagged.Tagged | undefined, rt.u8] = [new lengths_Tagged.Tagged(copy$array_u8(rt.byteSliceToArray(_7[1])), at & 0xff), 0]; - let copy: lengths_Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array1_u8(copy$Option_lengths_Tagged_array1_u8(pair[0])); + const pair: [Tagged.Tagged | undefined, rt.u8] = [new Tagged.Tagged(copy$array_u8(rt.byteSliceToArray(_7[1])), at & 0xff), 0]; + let copy: Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array1_u8(copy$Option_lengths_Tagged_array1_u8(pair[0])); pair[0] = copy$Option_lengths_Tagged_array1_u8(copy); const part = rt.place(() => pair[0], (value) => pair[0] = value); const part2 = rt.place(() => copy, (value2) => copy = value2); @@ -251,8 +251,8 @@ export function retagged$17(rows: Uint8Array[], out: rt.ByteVec): void { break; } const at: rt.usize = _7[0]; - const pair: [lengths_Tagged.Tagged | undefined, rt.u8] = [new lengths_Tagged.Tagged(copy$array_u8(rt.byteSliceToArray(_7[1])), at & 0xff), 0]; - let copy: lengths_Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array17_u8(copy$Option_lengths_Tagged_array17_u8(pair[0])); + const pair: [Tagged.Tagged | undefined, rt.u8] = [new Tagged.Tagged(copy$array_u8(rt.byteSliceToArray(_7[1])), at & 0xff), 0]; + let copy: Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array17_u8(copy$Option_lengths_Tagged_array17_u8(pair[0])); pair[0] = copy$Option_lengths_Tagged_array17_u8(copy); const part = rt.place(() => pair[0], (value) => pair[0] = value); const part2 = rt.place(() => copy, (value2) => copy = value2); @@ -281,8 +281,8 @@ export function retagged$3(rows: Uint8Array[], out: rt.ByteVec): void { break; } const at: rt.usize = _7[0]; - const pair: [lengths_Tagged.Tagged | undefined, rt.u8] = [new lengths_Tagged.Tagged(copy$array_u8(rt.byteSliceToArray(_7[1])), at & 0xff), 0]; - let copy: lengths_Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array3_u8(copy$Option_lengths_Tagged_array3_u8(pair[0])); + const pair: [Tagged.Tagged | undefined, rt.u8] = [new Tagged.Tagged(copy$array_u8(rt.byteSliceToArray(_7[1])), at & 0xff), 0]; + let copy: Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array3_u8(copy$Option_lengths_Tagged_array3_u8(pair[0])); pair[0] = copy$Option_lengths_Tagged_array3_u8(copy); const part = rt.place(() => pair[0], (value) => pair[0] = value); const part2 = rt.place(() => copy, (value2) => copy = value2); @@ -308,8 +308,8 @@ export function recloned$u32_0(rows: rt.u32[][], out: rt.ByteVec): void { break; } const at: rt.usize = _7[0]; - const pair: [lengths_Tagged.Tagged | undefined, rt.u8] = [new lengths_Tagged.Tagged(copy$array_u32(copy$array_u32(_7[1])), at & 0xff), 0]; - let copy: lengths_Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array0_u32(copy$Option_lengths_Tagged_array0_u32(pair[0])); + const pair: [Tagged.Tagged | undefined, rt.u8] = [new Tagged.Tagged(copy$array_u32(copy$array_u32(_7[1])), at & 0xff), 0]; + let copy: Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array0_u32(copy$Option_lengths_Tagged_array0_u32(pair[0])); pair[0] = copy$Option_lengths_Tagged_array0_u32(copy); const part = rt.place(() => pair[0], (value) => pair[0] = value); const part2 = rt.place(() => copy, (value2) => copy = value2); @@ -335,8 +335,8 @@ export function recloned$u32_1(rows: rt.u32[][], out: rt.ByteVec): void { break; } const at: rt.usize = _7[0]; - const pair: [lengths_Tagged.Tagged | undefined, rt.u8] = [new lengths_Tagged.Tagged(copy$array_u32(copy$array_u32(_7[1])), at & 0xff), 0]; - let copy: lengths_Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array1_u32(copy$Option_lengths_Tagged_array1_u32(pair[0])); + const pair: [Tagged.Tagged | undefined, rt.u8] = [new Tagged.Tagged(copy$array_u32(copy$array_u32(_7[1])), at & 0xff), 0]; + let copy: Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array1_u32(copy$Option_lengths_Tagged_array1_u32(pair[0])); pair[0] = copy$Option_lengths_Tagged_array1_u32(copy); const part = rt.place(() => pair[0], (value) => pair[0] = value); const part2 = rt.place(() => copy, (value2) => copy = value2); @@ -362,8 +362,8 @@ export function recloned$u32_17(rows: rt.u32[][], out: rt.ByteVec): void { break; } const at: rt.usize = _7[0]; - const pair: [lengths_Tagged.Tagged | undefined, rt.u8] = [new lengths_Tagged.Tagged(copy$array_u32(copy$array_u32(_7[1])), at & 0xff), 0]; - let copy: lengths_Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array17_u32(copy$Option_lengths_Tagged_array17_u32(pair[0])); + const pair: [Tagged.Tagged | undefined, rt.u8] = [new Tagged.Tagged(copy$array_u32(copy$array_u32(_7[1])), at & 0xff), 0]; + let copy: Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array17_u32(copy$Option_lengths_Tagged_array17_u32(pair[0])); pair[0] = copy$Option_lengths_Tagged_array17_u32(copy); const part = rt.place(() => pair[0], (value) => pair[0] = value); const part2 = rt.place(() => copy, (value2) => copy = value2); @@ -389,8 +389,8 @@ export function recloned$u32_3(rows: rt.u32[][], out: rt.ByteVec): void { break; } const at: rt.usize = _7[0]; - const pair: [lengths_Tagged.Tagged | undefined, rt.u8] = [new lengths_Tagged.Tagged(copy$array_u32(copy$array_u32(_7[1])), at & 0xff), 0]; - let copy: lengths_Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array3_u32(copy$Option_lengths_Tagged_array3_u32(pair[0])); + const pair: [Tagged.Tagged | undefined, rt.u8] = [new Tagged.Tagged(copy$array_u32(copy$array_u32(_7[1])), at & 0xff), 0]; + let copy: Tagged.Tagged | undefined = copy$Option_lengths_Tagged_array3_u32(copy$Option_lengths_Tagged_array3_u32(pair[0])); pair[0] = copy$Option_lengths_Tagged_array3_u32(copy); const part = rt.place(() => pair[0], (value) => pair[0] = value); const part2 = rt.place(() => copy, (value2) => copy = value2); @@ -664,36 +664,36 @@ export function filled$array3_u8_3(data: rt.ByteSlice, fill: Uint8Array[], out: * nothing points into them, the last two again beside a vector's iterator, which std * drops, then changed in place, a pair of tags through a pointer to it, and read back. */ -export function filled$lengths_Tagged_u32_0(data: rt.ByteSlice, fill: lengths_Tagged.Tagged[], out: rt.ByteVec): void { - const item = ([Array.from({ length: 0 }, (): lengths_Tagged.Tagged => { - return (new lengths_Tagged.Tagged((undefined as unknown) as rt.u32, (undefined as unknown) as rt.u8) as unknown) as lengths_Tagged.Tagged; - }), [undefined, undefined]] as unknown) as [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]; - const slots: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]][] = Array.from({ length: 3 }, (): [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] => { +export function filled$lengths_Tagged_u32_0(data: rt.ByteSlice, fill: Tagged.Tagged[], out: rt.ByteVec): void { + const item = ([Array.from({ length: 0 }, (): Tagged.Tagged => { + return (new Tagged.Tagged((undefined as unknown) as rt.u32, (undefined as unknown) as rt.u8) as unknown) as Tagged.Tagged; + }), [undefined, undefined]] as unknown) as [Tagged.Tagged[], [rt.u8, rt.u8]]; + const slots: [Tagged.Tagged[], [rt.u8, rt.u8]][] = Array.from({ length: 3 }, (): [Tagged.Tagged[], [rt.u8, rt.u8]] => { return copy$mem_MaybeUninit_tuple2_array0_lengths_Tagged_u32_tuple2_u8_u8(item); }); - const iter: rt.Iter<[[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8]> = rt.iterZip(rt.iterSlice(slots), new rt.RangeFrom(0, rt.u8Step), "len"); + const iter: rt.Iter<[[Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8]> = rt.iterZip(rt.iterSlice(slots), new rt.RangeFrom(0, rt.u8Step), "len"); while (true) { - const _12: [[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8] | rt.Done = iter.next(); + const _12: [[Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8] | rt.Done = iter.next(); if (_12 === rt.DONE) { break; } const at: rt.u8 = _12[1]; const uninit = _12[0]; - rt.ptrWrite(uninit, [copy$array_lengths_Tagged_u32(fill), [at, ~at & 0xff] as [rt.u8, rt.u8]] as [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]); + rt.ptrWrite(uninit, [copy$array_lengths_Tagged_u32(fill), [at, ~at & 0xff] as [rt.u8, rt.u8]] as [Tagged.Tagged[], [rt.u8, rt.u8]]); uninit; } - const picks: Array | undefined> = []; + const picks: Array | undefined> = []; for (const _26 of fill) { picks.push(_26); } - const iter3: rt.Iter<[[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], lengths_Tagged.Tagged | undefined]> = rt.iterZip(rt.iterSkip(rt.iterSlice(slots), 1), rt.iterSlice(picks), "index"); + const iter3: rt.Iter<[[Tagged.Tagged[], [rt.u8, rt.u8]], Tagged.Tagged | undefined]> = rt.iterZip(rt.iterSkip(rt.iterSlice(slots), 1), rt.iterSlice(picks), "index"); while (true) { - const _41: [[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], lengths_Tagged.Tagged | undefined] | rt.Done = iter3.next(); + const _41: [[Tagged.Tagged[], [rt.u8, rt.u8]], Tagged.Tagged | undefined] | rt.Done = iter3.next(); if (_41 === rt.DONE) { break; } const uninit2 = _41[0]; - rt.ptrWrite(uninit2, [copy$array_lengths_Tagged_u32(fill), [0, 90] as [rt.u8, rt.u8]] as [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]); + rt.ptrWrite(uninit2, [copy$array_lengths_Tagged_u32(fill), [0, 90] as [rt.u8, rt.u8]] as [Tagged.Tagged[], [rt.u8, rt.u8]]); uninit2; } for (const byte of rt.byteSliceView(data)) { @@ -701,7 +701,7 @@ export function filled$lengths_Tagged_u32_0(data: rt.ByteSlice, fill: lengths_Ta if (!(_58 < 3)) { rt.panic("index out of bounds: the len is " + 3 + " but the index is " + _58); } - const slot: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] = slots[_58]; + const slot: [Tagged.Tagged[], [rt.u8, rt.u8]] = slots[_58]; rt.sliceRotateLeft(slot[0], rt.usizeRem(byte as rt.usize, rt.max(0, 1))); const tags: [rt.u8, rt.u8] = slot[1]; tags[0] = tags[0] ^ byte; @@ -709,9 +709,9 @@ export function filled$lengths_Tagged_u32_0(data: rt.ByteSlice, fill: lengths_Ta rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(tags[0], tags[1])), undefined, true); } for (const _79 of slots) { - const _86: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] = _79; - rt.iterForEach(rt.iterSlice(_86[0]), (v2: lengths_Tagged.Tagged): undefined => { - lengths_Tagged.put$lengths_Put_u32(v2, out); + const _86: [Tagged.Tagged[], [rt.u8, rt.u8]] = _79; + rt.iterForEach(rt.iterSlice(_86[0]), (v2: Tagged.Tagged): undefined => { + Tagged.put$lengths_Put_u32(v2, out); }); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_86[1][0], _86[1][1])), undefined, true); } @@ -722,36 +722,36 @@ export function filled$lengths_Tagged_u32_0(data: rt.ByteSlice, fill: lengths_Ta * nothing points into them, the last two again beside a vector's iterator, which std * drops, then changed in place, a pair of tags through a pointer to it, and read back. */ -export function filled$lengths_Tagged_u32_1(data: rt.ByteSlice, fill: lengths_Tagged.Tagged[], out: rt.ByteVec): void { - const item = ([Array.from({ length: 1 }, (): lengths_Tagged.Tagged => { - return (new lengths_Tagged.Tagged((undefined as unknown) as rt.u32, (undefined as unknown) as rt.u8) as unknown) as lengths_Tagged.Tagged; - }), [undefined, undefined]] as unknown) as [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]; - const slots: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]][] = Array.from({ length: 3 }, (): [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] => { +export function filled$lengths_Tagged_u32_1(data: rt.ByteSlice, fill: Tagged.Tagged[], out: rt.ByteVec): void { + const item = ([Array.from({ length: 1 }, (): Tagged.Tagged => { + return (new Tagged.Tagged((undefined as unknown) as rt.u32, (undefined as unknown) as rt.u8) as unknown) as Tagged.Tagged; + }), [undefined, undefined]] as unknown) as [Tagged.Tagged[], [rt.u8, rt.u8]]; + const slots: [Tagged.Tagged[], [rt.u8, rt.u8]][] = Array.from({ length: 3 }, (): [Tagged.Tagged[], [rt.u8, rt.u8]] => { return copy$mem_MaybeUninit_tuple2_array1_lengths_Tagged_u32_tuple2_u8_u8(item); }); - const iter: rt.Iter<[[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8]> = rt.iterZip(rt.iterSlice(slots), new rt.RangeFrom(0, rt.u8Step), "len"); + const iter: rt.Iter<[[Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8]> = rt.iterZip(rt.iterSlice(slots), new rt.RangeFrom(0, rt.u8Step), "len"); while (true) { - const _12: [[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8] | rt.Done = iter.next(); + const _12: [[Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8] | rt.Done = iter.next(); if (_12 === rt.DONE) { break; } const at: rt.u8 = _12[1]; const uninit = _12[0]; - rt.ptrWrite(uninit, [copy$array_lengths_Tagged_u32(fill), [at, ~at & 0xff] as [rt.u8, rt.u8]] as [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]); + rt.ptrWrite(uninit, [copy$array_lengths_Tagged_u32(fill), [at, ~at & 0xff] as [rt.u8, rt.u8]] as [Tagged.Tagged[], [rt.u8, rt.u8]]); uninit; } - const picks: Array | undefined> = []; + const picks: Array | undefined> = []; for (const _26 of fill) { picks.push(_26); } - const iter3: rt.Iter<[[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], lengths_Tagged.Tagged | undefined]> = rt.iterZip(rt.iterSkip(rt.iterSlice(slots), 1), rt.iterSlice(picks), "index"); + const iter3: rt.Iter<[[Tagged.Tagged[], [rt.u8, rt.u8]], Tagged.Tagged | undefined]> = rt.iterZip(rt.iterSkip(rt.iterSlice(slots), 1), rt.iterSlice(picks), "index"); while (true) { - const _41: [[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], lengths_Tagged.Tagged | undefined] | rt.Done = iter3.next(); + const _41: [[Tagged.Tagged[], [rt.u8, rt.u8]], Tagged.Tagged | undefined] | rt.Done = iter3.next(); if (_41 === rt.DONE) { break; } const uninit2 = _41[0]; - rt.ptrWrite(uninit2, [copy$array_lengths_Tagged_u32(fill), [1, 90] as [rt.u8, rt.u8]] as [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]); + rt.ptrWrite(uninit2, [copy$array_lengths_Tagged_u32(fill), [1, 90] as [rt.u8, rt.u8]] as [Tagged.Tagged[], [rt.u8, rt.u8]]); uninit2; } for (const byte of rt.byteSliceView(data)) { @@ -759,7 +759,7 @@ export function filled$lengths_Tagged_u32_1(data: rt.ByteSlice, fill: lengths_Ta if (!(_58 < 3)) { rt.panic("index out of bounds: the len is " + 3 + " but the index is " + _58); } - const slot: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] = slots[_58]; + const slot: [Tagged.Tagged[], [rt.u8, rt.u8]] = slots[_58]; rt.sliceRotateLeft(slot[0], rt.usizeRem(byte as rt.usize, rt.max(1, 1))); const tags: [rt.u8, rt.u8] = slot[1]; tags[0] = tags[0] ^ byte; @@ -767,9 +767,9 @@ export function filled$lengths_Tagged_u32_1(data: rt.ByteSlice, fill: lengths_Ta rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(tags[0], tags[1])), undefined, true); } for (const _79 of slots) { - const _86: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] = _79; - rt.iterForEach(rt.iterSlice(_86[0]), (v2: lengths_Tagged.Tagged): undefined => { - lengths_Tagged.put$lengths_Put_u32(v2, out); + const _86: [Tagged.Tagged[], [rt.u8, rt.u8]] = _79; + rt.iterForEach(rt.iterSlice(_86[0]), (v2: Tagged.Tagged): undefined => { + Tagged.put$lengths_Put_u32(v2, out); }); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_86[1][0], _86[1][1])), undefined, true); } @@ -780,36 +780,36 @@ export function filled$lengths_Tagged_u32_1(data: rt.ByteSlice, fill: lengths_Ta * nothing points into them, the last two again beside a vector's iterator, which std * drops, then changed in place, a pair of tags through a pointer to it, and read back. */ -export function filled$lengths_Tagged_u32_17(data: rt.ByteSlice, fill: lengths_Tagged.Tagged[], out: rt.ByteVec): void { - const item = ([Array.from({ length: 17 }, (): lengths_Tagged.Tagged => { - return (new lengths_Tagged.Tagged((undefined as unknown) as rt.u32, (undefined as unknown) as rt.u8) as unknown) as lengths_Tagged.Tagged; - }), [undefined, undefined]] as unknown) as [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]; - const slots: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]][] = Array.from({ length: 3 }, (): [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] => { +export function filled$lengths_Tagged_u32_17(data: rt.ByteSlice, fill: Tagged.Tagged[], out: rt.ByteVec): void { + const item = ([Array.from({ length: 17 }, (): Tagged.Tagged => { + return (new Tagged.Tagged((undefined as unknown) as rt.u32, (undefined as unknown) as rt.u8) as unknown) as Tagged.Tagged; + }), [undefined, undefined]] as unknown) as [Tagged.Tagged[], [rt.u8, rt.u8]]; + const slots: [Tagged.Tagged[], [rt.u8, rt.u8]][] = Array.from({ length: 3 }, (): [Tagged.Tagged[], [rt.u8, rt.u8]] => { return copy$mem_MaybeUninit_tuple2_array17_lengths_Tagged_u32_tuple2_u8_u8(item); }); - const iter: rt.Iter<[[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8]> = rt.iterZip(rt.iterSlice(slots), new rt.RangeFrom(0, rt.u8Step), "len"); + const iter: rt.Iter<[[Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8]> = rt.iterZip(rt.iterSlice(slots), new rt.RangeFrom(0, rt.u8Step), "len"); while (true) { - const _12: [[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8] | rt.Done = iter.next(); + const _12: [[Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8] | rt.Done = iter.next(); if (_12 === rt.DONE) { break; } const at: rt.u8 = _12[1]; const uninit = _12[0]; - rt.ptrWrite(uninit, [copy$array_lengths_Tagged_u32(fill), [at, ~at & 0xff] as [rt.u8, rt.u8]] as [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]); + rt.ptrWrite(uninit, [copy$array_lengths_Tagged_u32(fill), [at, ~at & 0xff] as [rt.u8, rt.u8]] as [Tagged.Tagged[], [rt.u8, rt.u8]]); uninit; } - const picks: Array | undefined> = []; + const picks: Array | undefined> = []; for (const _26 of fill) { picks.push(_26); } - const iter3: rt.Iter<[[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], lengths_Tagged.Tagged | undefined]> = rt.iterZip(rt.iterSkip(rt.iterSlice(slots), 1), rt.iterSlice(picks), "index"); + const iter3: rt.Iter<[[Tagged.Tagged[], [rt.u8, rt.u8]], Tagged.Tagged | undefined]> = rt.iterZip(rt.iterSkip(rt.iterSlice(slots), 1), rt.iterSlice(picks), "index"); while (true) { - const _41: [[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], lengths_Tagged.Tagged | undefined] | rt.Done = iter3.next(); + const _41: [[Tagged.Tagged[], [rt.u8, rt.u8]], Tagged.Tagged | undefined] | rt.Done = iter3.next(); if (_41 === rt.DONE) { break; } const uninit2 = _41[0]; - rt.ptrWrite(uninit2, [copy$array_lengths_Tagged_u32(fill), [17, 90] as [rt.u8, rt.u8]] as [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]); + rt.ptrWrite(uninit2, [copy$array_lengths_Tagged_u32(fill), [17, 90] as [rt.u8, rt.u8]] as [Tagged.Tagged[], [rt.u8, rt.u8]]); uninit2; } for (const byte of rt.byteSliceView(data)) { @@ -817,7 +817,7 @@ export function filled$lengths_Tagged_u32_17(data: rt.ByteSlice, fill: lengths_T if (!(_58 < 3)) { rt.panic("index out of bounds: the len is " + 3 + " but the index is " + _58); } - const slot: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] = slots[_58]; + const slot: [Tagged.Tagged[], [rt.u8, rt.u8]] = slots[_58]; rt.sliceRotateLeft(slot[0], rt.usizeRem(byte as rt.usize, rt.max(17, 1))); const tags: [rt.u8, rt.u8] = slot[1]; tags[0] = tags[0] ^ byte; @@ -825,9 +825,9 @@ export function filled$lengths_Tagged_u32_17(data: rt.ByteSlice, fill: lengths_T rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(tags[0], tags[1])), undefined, true); } for (const _79 of slots) { - const _86: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] = _79; - rt.iterForEach(rt.iterSlice(_86[0]), (v2: lengths_Tagged.Tagged): undefined => { - lengths_Tagged.put$lengths_Put_u32(v2, out); + const _86: [Tagged.Tagged[], [rt.u8, rt.u8]] = _79; + rt.iterForEach(rt.iterSlice(_86[0]), (v2: Tagged.Tagged): undefined => { + Tagged.put$lengths_Put_u32(v2, out); }); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_86[1][0], _86[1][1])), undefined, true); } @@ -838,36 +838,36 @@ export function filled$lengths_Tagged_u32_17(data: rt.ByteSlice, fill: lengths_T * nothing points into them, the last two again beside a vector's iterator, which std * drops, then changed in place, a pair of tags through a pointer to it, and read back. */ -export function filled$lengths_Tagged_u32_3(data: rt.ByteSlice, fill: lengths_Tagged.Tagged[], out: rt.ByteVec): void { - const item = ([Array.from({ length: 3 }, (): lengths_Tagged.Tagged => { - return (new lengths_Tagged.Tagged((undefined as unknown) as rt.u32, (undefined as unknown) as rt.u8) as unknown) as lengths_Tagged.Tagged; - }), [undefined, undefined]] as unknown) as [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]; - const slots: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]][] = Array.from({ length: 3 }, (): [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] => { +export function filled$lengths_Tagged_u32_3(data: rt.ByteSlice, fill: Tagged.Tagged[], out: rt.ByteVec): void { + const item = ([Array.from({ length: 3 }, (): Tagged.Tagged => { + return (new Tagged.Tagged((undefined as unknown) as rt.u32, (undefined as unknown) as rt.u8) as unknown) as Tagged.Tagged; + }), [undefined, undefined]] as unknown) as [Tagged.Tagged[], [rt.u8, rt.u8]]; + const slots: [Tagged.Tagged[], [rt.u8, rt.u8]][] = Array.from({ length: 3 }, (): [Tagged.Tagged[], [rt.u8, rt.u8]] => { return copy$mem_MaybeUninit_tuple2_array3_lengths_Tagged_u32_tuple2_u8_u8(item); }); - const iter: rt.Iter<[[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8]> = rt.iterZip(rt.iterSlice(slots), new rt.RangeFrom(0, rt.u8Step), "len"); + const iter: rt.Iter<[[Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8]> = rt.iterZip(rt.iterSlice(slots), new rt.RangeFrom(0, rt.u8Step), "len"); while (true) { - const _12: [[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8] | rt.Done = iter.next(); + const _12: [[Tagged.Tagged[], [rt.u8, rt.u8]], rt.u8] | rt.Done = iter.next(); if (_12 === rt.DONE) { break; } const at: rt.u8 = _12[1]; const uninit = _12[0]; - rt.ptrWrite(uninit, [copy$array_lengths_Tagged_u32(fill), [at, ~at & 0xff] as [rt.u8, rt.u8]] as [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]); + rt.ptrWrite(uninit, [copy$array_lengths_Tagged_u32(fill), [at, ~at & 0xff] as [rt.u8, rt.u8]] as [Tagged.Tagged[], [rt.u8, rt.u8]]); uninit; } - const picks: Array | undefined> = []; + const picks: Array | undefined> = []; for (const _26 of fill) { picks.push(_26); } - const iter3: rt.Iter<[[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], lengths_Tagged.Tagged | undefined]> = rt.iterZip(rt.iterSkip(rt.iterSlice(slots), 1), rt.iterSlice(picks), "index"); + const iter3: rt.Iter<[[Tagged.Tagged[], [rt.u8, rt.u8]], Tagged.Tagged | undefined]> = rt.iterZip(rt.iterSkip(rt.iterSlice(slots), 1), rt.iterSlice(picks), "index"); while (true) { - const _41: [[lengths_Tagged.Tagged[], [rt.u8, rt.u8]], lengths_Tagged.Tagged | undefined] | rt.Done = iter3.next(); + const _41: [[Tagged.Tagged[], [rt.u8, rt.u8]], Tagged.Tagged | undefined] | rt.Done = iter3.next(); if (_41 === rt.DONE) { break; } const uninit2 = _41[0]; - rt.ptrWrite(uninit2, [copy$array_lengths_Tagged_u32(fill), [3, 90] as [rt.u8, rt.u8]] as [lengths_Tagged.Tagged[], [rt.u8, rt.u8]]); + rt.ptrWrite(uninit2, [copy$array_lengths_Tagged_u32(fill), [3, 90] as [rt.u8, rt.u8]] as [Tagged.Tagged[], [rt.u8, rt.u8]]); uninit2; } for (const byte of rt.byteSliceView(data)) { @@ -875,7 +875,7 @@ export function filled$lengths_Tagged_u32_3(data: rt.ByteSlice, fill: lengths_Ta if (!(_58 < 3)) { rt.panic("index out of bounds: the len is " + 3 + " but the index is " + _58); } - const slot: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] = slots[_58]; + const slot: [Tagged.Tagged[], [rt.u8, rt.u8]] = slots[_58]; rt.sliceRotateLeft(slot[0], rt.usizeRem(byte as rt.usize, rt.max(3, 1))); const tags: [rt.u8, rt.u8] = slot[1]; tags[0] = tags[0] ^ byte; @@ -883,9 +883,9 @@ export function filled$lengths_Tagged_u32_3(data: rt.ByteSlice, fill: lengths_Ta rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(tags[0], tags[1])), undefined, true); } for (const _79 of slots) { - const _86: [lengths_Tagged.Tagged[], [rt.u8, rt.u8]] = _79; - rt.iterForEach(rt.iterSlice(_86[0]), (v2: lengths_Tagged.Tagged): undefined => { - lengths_Tagged.put$lengths_Put_u32(v2, out); + const _86: [Tagged.Tagged[], [rt.u8, rt.u8]] = _79; + rt.iterForEach(rt.iterSlice(_86[0]), (v2: Tagged.Tagged): undefined => { + Tagged.put$lengths_Put_u32(v2, out); }); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_86[1][0], _86[1][1])), undefined, true); } diff --git a/ts/fixtures/lang/lengths/expected/lib.ts b/ts/fixtures/lang/lengths/expected/lib.ts new file mode 100644 index 000000000..83a0ea0d3 --- /dev/null +++ b/ts/fixtures/lang/lengths/expected/lib.ts @@ -0,0 +1,275 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { lengths } from "./lengths.ts"; +import * as Tagged from "./lengths.Tagged.ts"; + +export function copy$Option_lengths_Tagged_array0_u32(v: Tagged.Tagged | undefined): Tagged.Tagged | undefined { + return v === undefined ? v : copy$lengths_Tagged_array0_u32(v); +} + +export function copy$Option_lengths_Tagged_array0_u8(v: Tagged.Tagged | undefined): Tagged.Tagged | undefined { + return v === undefined ? v : copy$lengths_Tagged_array0_u8(v); +} + +export function copy$Option_lengths_Tagged_array17_u32(v: Tagged.Tagged | undefined): Tagged.Tagged | undefined { + return v === undefined ? v : copy$lengths_Tagged_array17_u32(v); +} + +export function copy$Option_lengths_Tagged_array17_u8(v: Tagged.Tagged | undefined): Tagged.Tagged | undefined { + return v === undefined ? v : copy$lengths_Tagged_array17_u8(v); +} + +export function copy$Option_lengths_Tagged_array1_u32(v: Tagged.Tagged | undefined): Tagged.Tagged | undefined { + return v === undefined ? v : copy$lengths_Tagged_array1_u32(v); +} + +export function copy$Option_lengths_Tagged_array1_u8(v: Tagged.Tagged | undefined): Tagged.Tagged | undefined { + return v === undefined ? v : copy$lengths_Tagged_array1_u8(v); +} + +export function copy$Option_lengths_Tagged_array3_u32(v: Tagged.Tagged | undefined): Tagged.Tagged | undefined { + return v === undefined ? v : copy$lengths_Tagged_array3_u32(v); +} + +export function copy$Option_lengths_Tagged_array3_u8(v: Tagged.Tagged | undefined): Tagged.Tagged | undefined { + return v === undefined ? v : copy$lengths_Tagged_array3_u8(v); +} + +export function copy$array_array0_u8(v: Uint8Array[]): Uint8Array[] { + return v.map(copy$array_u8); +} + +export function copy$array_array17_u8(v: Uint8Array[]): Uint8Array[] { + return v.map(copy$array_u8); +} + +export function copy$array_array1_u8(v: Uint8Array[]): Uint8Array[] { + return v.map(copy$array_u8); +} + +export function copy$array_array3_u8(v: Uint8Array[]): Uint8Array[] { + return v.map(copy$array_u8); +} + +export function copy$array_lengths_Tagged_u32(v: Tagged.Tagged[]): Tagged.Tagged[] { + return v.slice(); +} + +export function copy$array_u32(v: rt.u32[]): rt.u32[] { + return v.slice(); +} + +export function copy$array_u8(v: Uint8Array): Uint8Array { + return v.slice(); +} + +export function copy$lengths_Tagged_array0_u32(v: Tagged.Tagged): Tagged.Tagged { + return new Tagged.Tagged(copy$array_u32(v._0), v._1); +} + +export function copy$lengths_Tagged_array0_u8(v: Tagged.Tagged): Tagged.Tagged { + return new Tagged.Tagged(copy$array_u8(v._0), v._1); +} + +export function copy$lengths_Tagged_array17_u32(v: Tagged.Tagged): Tagged.Tagged { + return new Tagged.Tagged(copy$array_u32(v._0), v._1); +} + +export function copy$lengths_Tagged_array17_u8(v: Tagged.Tagged): Tagged.Tagged { + return new Tagged.Tagged(copy$array_u8(v._0), v._1); +} + +export function copy$lengths_Tagged_array1_u32(v: Tagged.Tagged): Tagged.Tagged { + return new Tagged.Tagged(copy$array_u32(v._0), v._1); +} + +export function copy$lengths_Tagged_array1_u8(v: Tagged.Tagged): Tagged.Tagged { + return new Tagged.Tagged(copy$array_u8(v._0), v._1); +} + +export function copy$lengths_Tagged_array3_u32(v: Tagged.Tagged): Tagged.Tagged { + return new Tagged.Tagged(copy$array_u32(v._0), v._1); +} + +export function copy$lengths_Tagged_array3_u8(v: Tagged.Tagged): Tagged.Tagged { + return new Tagged.Tagged(copy$array_u8(v._0), v._1); +} + +export function copy$mem_MaybeUninit_array_array0_u8(v: Uint8Array[]): Uint8Array[] { + if (v === undefined) { + return v; + } + return v.map(copy$mem_MaybeUninit_array_u8); +} + +export function copy$mem_MaybeUninit_array_array17_u8(v: Uint8Array[]): Uint8Array[] { + if (v === undefined) { + return v; + } + return v.map(copy$mem_MaybeUninit_array_u8); +} + +export function copy$mem_MaybeUninit_array_array1_u8(v: Uint8Array[]): Uint8Array[] { + if (v === undefined) { + return v; + } + return v.map(copy$mem_MaybeUninit_array_u8); +} + +export function copy$mem_MaybeUninit_array_array3_u8(v: Uint8Array[]): Uint8Array[] { + if (v === undefined) { + return v; + } + return v.map(copy$mem_MaybeUninit_array_u8); +} + +export function copy$mem_MaybeUninit_array_lengths_Tagged_u32(v: Tagged.Tagged[]): Tagged.Tagged[] { + if (v === undefined) { + return v; + } + return v.slice(); +} + +export function copy$mem_MaybeUninit_array_u32(v: rt.u32[]): rt.u32[] { + if (v === undefined) { + return v; + } + return v.slice(); +} + +export function copy$mem_MaybeUninit_array_u8(v: Uint8Array): Uint8Array { + if (v === undefined) { + return v; + } + return v.slice(); +} + +export function copy$mem_MaybeUninit_tuple2_array0_array0_u8_tuple2_u8_u8(v: [Uint8Array[], [rt.u8, rt.u8]]): [Uint8Array[], [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_array0_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array0_lengths_Tagged_u32_tuple2_u8_u8(v: [Tagged.Tagged[], [rt.u8, rt.u8]]): [Tagged.Tagged[], [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_lengths_Tagged_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array0_u32_tuple2_u8_u8(v: [rt.u32[], [rt.u8, rt.u8]]): [rt.u32[], [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array0_u8_tuple2_u8_u8(v: [Uint8Array, [rt.u8, rt.u8]]): [Uint8Array, [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array17_array17_u8_tuple2_u8_u8(v: [Uint8Array[], [rt.u8, rt.u8]]): [Uint8Array[], [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_array17_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array17_lengths_Tagged_u32_tuple2_u8_u8(v: [Tagged.Tagged[], [rt.u8, rt.u8]]): [Tagged.Tagged[], [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_lengths_Tagged_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array17_u32_tuple2_u8_u8(v: [rt.u32[], [rt.u8, rt.u8]]): [rt.u32[], [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array17_u8_tuple2_u8_u8(v: [Uint8Array, [rt.u8, rt.u8]]): [Uint8Array, [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array1_array1_u8_tuple2_u8_u8(v: [Uint8Array[], [rt.u8, rt.u8]]): [Uint8Array[], [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_array1_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array1_lengths_Tagged_u32_tuple2_u8_u8(v: [Tagged.Tagged[], [rt.u8, rt.u8]]): [Tagged.Tagged[], [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_lengths_Tagged_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array1_u32_tuple2_u8_u8(v: [rt.u32[], [rt.u8, rt.u8]]): [rt.u32[], [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array1_u8_tuple2_u8_u8(v: [Uint8Array, [rt.u8, rt.u8]]): [Uint8Array, [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array3_array3_u8_tuple2_u8_u8(v: [Uint8Array[], [rt.u8, rt.u8]]): [Uint8Array[], [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_array3_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array3_lengths_Tagged_u32_tuple2_u8_u8(v: [Tagged.Tagged[], [rt.u8, rt.u8]]): [Tagged.Tagged[], [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_lengths_Tagged_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array3_u32_tuple2_u8_u8(v: [rt.u32[], [rt.u8, rt.u8]]): [rt.u32[], [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_u32(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_array3_u8_tuple2_u8_u8(v: [Uint8Array, [rt.u8, rt.u8]]): [Uint8Array, [rt.u8, rt.u8]] { + if (v === undefined) { + return v; + } + return [copy$mem_MaybeUninit_array_u8(v[0]), copy$mem_MaybeUninit_tuple2_u8_u8(v[1])]; +} + +export function copy$mem_MaybeUninit_tuple2_u8_u8(v: [rt.u8, rt.u8]): [rt.u8, rt.u8] { + if (v === undefined) { + return v; + } + return [v[0], v[1]]; +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["lengths::lengths", lengths as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/src/lengths.rs b/ts/fixtures/lang/lengths/src/lengths.rs similarity index 100% rename from ts/fixtures/lang/src/lengths.rs rename to ts/fixtures/lang/lengths/src/lengths.rs diff --git a/ts/fixtures/lang/lengths/src/lib.rs b/ts/fixtures/lang/lengths/src/lib.rs new file mode 100644 index 000000000..62c6d2191 --- /dev/null +++ b/ts/fixtures/lang/lengths/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod lengths; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("lengths::lengths", lengths::lengths)] +} diff --git a/ts/fixtures/lang/lengths/ts.toml b/ts/fixtures/lang/lengths/ts.toml new file mode 100644 index 000000000..8e1aa4d7f --- /dev/null +++ b/ts/fixtures/lang/lengths/ts.toml @@ -0,0 +1,2 @@ +package = "lang-lengths-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/lists/Cargo.toml b/ts/fixtures/lang/lists/Cargo.toml new file mode 100644 index 000000000..1bbfd03fc --- /dev/null +++ b/ts/fixtures/lang/lists/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-lists-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/lists/expected/core/option.ts b/ts/fixtures/lang/lists/expected/core/option.ts new file mode 100644 index 000000000..a43f18933 --- /dev/null +++ b/ts/fixtures/lang/lists/expected/core/option.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function mapOr$1e4a1e0(self: rt.Ordering | undefined, default_: rt.u8, f: (a0: rt.Ordering) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/lists/expected/harness.ts b/ts/fixtures/lang/lists/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/lists/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/lists/expected/lib.ts b/ts/fixtures/lang/lists/expected/lib.ts new file mode 100644 index 000000000..9b0221e45 --- /dev/null +++ b/ts/fixtures/lang/lists/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { lists } from "./lists.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["lists::lists", lists as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/lists.Tally.ts b/ts/fixtures/lang/lists/expected/lists.Tally.ts similarity index 100% rename from ts/fixtures/lang/expected/lists.Tally.ts rename to ts/fixtures/lang/lists/expected/lists.Tally.ts diff --git a/ts/fixtures/lang/expected/lists.ts b/ts/fixtures/lang/lists/expected/lists.ts similarity index 86% rename from ts/fixtures/lang/expected/lists.ts rename to ts/fixtures/lang/lists/expected/lists.ts index 33a583b7e..8df59b124 100644 --- a/ts/fixtures/lang/expected/lists.ts +++ b/ts/fixtures/lang/lists/expected/lists.ts @@ -2,11 +2,11 @@ import * as rt from "./rt.ts"; import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, mapOr$1e4a1e0 as option_mapOr$1e4a1e0 } from "./core/option.ts"; -import * as lists_Tally from "./lists.Tally.ts"; +import * as Tally from "./lists.Tally.ts"; -export function hashOf$collections_LinkedList_lists_Tally(value: rt.LinkedList): rt.u64 { +export function hashOf$collections_LinkedList_lists_Tally(value: rt.LinkedList): rt.u64 { const h: rt.Hasher = rt.hasher(); - rt.hashList(lists_Tally.hash$Hash_hash_DefaultHasher as (a0: lists_Tally.Tally, a1: rt.Hasher) => undefined)(value, h); + rt.hashList(Tally.hash$Hash_hash_DefaultHasher as (a0: Tally.Tally, a1: rt.Hasher) => undefined)(value, h); return rt.hashFinish(h); } @@ -248,57 +248,57 @@ export function printed(l: rt.LinkedList, m: rt.LinkedList, out: r /** A list of `Tally`s, which JS changes in place rather than through places. */ export function tallies(data: rt.ByteSlice, out: rt.ByteVec): void { - const _4: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): lists_Tally.Tally => { + const _4: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): Tally.Tally => { return { n: _2 as rt.u16 }; }); - const l: rt.LinkedList = rt.listExtend(rt.listNew() as rt.LinkedList, _4); - const copy: rt.LinkedList = rt.listClone(l, lists_Tally.clone$Clone); - const _8: lists_Tally.Tally | undefined = rt.listEnd(l); + const l: rt.LinkedList = rt.listExtend(rt.listNew() as rt.LinkedList, _4); + const copy: rt.LinkedList = rt.listClone(l, Tally.clone$Clone); + const _8: Tally.Tally | undefined = rt.listEnd(l); if (_8 !== undefined) { _8.n = _8.n ^ 255; } - const _12: lists_Tally.Tally | undefined = rt.listEnd(l, true); + const _12: Tally.Tally | undefined = rt.listEnd(l, true); if (_12 !== undefined) { _12.n = rt.u16Add(_12.n, 1); } - const _19: lists_Tally.Tally = lists_Tally.default$Default(); + const _19: Tally.Tally = Tally.default$Default(); rt.listPushBack(l, _19).v.n = 119; - const _20: lists_Tally.Tally = rt.listPushFront(l, { n: 3 }).v; + const _20: Tally.Tally = rt.listPushFront(l, { n: 3 }).v; _20.n = rt.u16Mul(_20.n, 5); - const iter: rt.Iter<[rt.usize, lists_Tally.Tally]> = rt.iterEnumerate(rt.listIter(l)); + const iter: rt.Iter<[rt.usize, Tally.Tally]> = rt.iterEnumerate(rt.listIter(l)); while (true) { - const _29: [rt.usize, lists_Tally.Tally] | rt.Done = iter.next(); + const _29: [rt.usize, Tally.Tally] | rt.Done = iter.next(); if (_29 === rt.DONE) { break; } _29[1].n = rt.u16WrappingAdd(_29[1].n, _29[0] & 0xffff); } - const _38: rt.Iter = rt.listExtractIf(l, (t: lists_Tally.Tally): boolean => { + const _38: rt.Iter = rt.listExtractIf(l, (t: Tally.Tally): boolean => { t.n = rt.u16Add(t.n, 1); return rt.u16Rem(t.n, 4) === 0; }); - const taken: rt.LinkedList = rt.listExtend(rt.listNew() as rt.LinkedList, _38); - const rest: rt.LinkedList = rt.listClone(l, lists_Tally.clone$Clone); - rt.listCloneFrom(rest, taken, lists_Tally.clone$Clone); - const iter2: rt.Iter> = rt.iterSlice([l, copy, taken, rest]); + const taken: rt.LinkedList = rt.listExtend(rt.listNew() as rt.LinkedList, _38); + const rest: rt.LinkedList = rt.listClone(l, Tally.clone$Clone); + rt.listCloneFrom(rest, taken, Tally.clone$Clone); + const iter2: rt.Iter> = rt.iterSlice([l, copy, taken, rest]); while (true) { - const _52: rt.LinkedList | rt.Done = iter2.next(); + const _52: rt.LinkedList | rt.Done = iter2.next(); if (_52 === rt.DONE) { break; } rt.byteVecPush(out, _52.n & 0xff); - rt.iterExtendBytes(out, rt.iterMap(rt.listIter(_52), (t2: lists_Tally.Tally): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.listIter(_52), (t2: Tally.Tally): rt.u8 => { return t2.n & 0xff; }), undefined, true); } - rt.byteVecPush(out, rt.listContains(l, { n: 120 }, lists_Tally.eq$cmp_PartialEq) ? 1 : 0); - rt.byteVecPush(out, rt.cmpList(lists_Tally.cmp$cmp_Ord)(l, copy) & 0xff); + rt.byteVecPush(out, rt.listContains(l, { n: 120 }, Tally.eq$cmp_PartialEq) ? 1 : 0); + rt.byteVecPush(out, rt.cmpList(Tally.cmp$cmp_Ord)(l, copy) & 0xff); rt.byteVecPush(out, rt.u64Eq(hashOf$collections_LinkedList_lists_Tally(taken), hashOf$collections_LinkedList_lists_Tally(rest)) ? 1 : 0); let text: string = ""; const part = rt.iterToArray(rt.iterTake(rt.iterRev(rt.listIter(rest)), 2), undefined, 4, true); - const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(part, f, (value: lists_Tally.Tally, f: rt.Formatter) => lists_Tally.fmt$fmt_Debug(value, f))]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(part, f, (value: Tally.Tally, f: rt.Formatter) => Tally.fmt$fmt_Debug(value, f))]; text = rt.fmtWriteString(text, [args2[0]]).s; - const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.listIter(taken), f, (value: lists_Tally.Tally, f: rt.Formatter) => lists_Tally.fmt$fmt_Debug(value, f))]; + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.listIter(taken), f, (value: Tally.Tally, f: rt.Formatter) => Tally.fmt$fmt_Debug(value, f))]; text = rt.fmtWriteString(text, [rt.fmtSpec({ alternate: true }, args4[0])]).s; rt.iterExtendBytes(out, rt.iterSlice(rt.byteSliceView(rt.stringAsBytes(text))), undefined, true); } diff --git a/ts/fixtures/lang/lists/src/lib.rs b/ts/fixtures/lang/lists/src/lib.rs new file mode 100644 index 000000000..ff4c99315 --- /dev/null +++ b/ts/fixtures/lang/lists/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod lists; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("lists::lists", lists::lists)] +} diff --git a/ts/fixtures/lang/src/lists.rs b/ts/fixtures/lang/lists/src/lists.rs similarity index 100% rename from ts/fixtures/lang/src/lists.rs rename to ts/fixtures/lang/lists/src/lists.rs diff --git a/ts/fixtures/lang/lists/ts.toml b/ts/fixtures/lang/lists/ts.toml new file mode 100644 index 000000000..6023b41fd --- /dev/null +++ b/ts/fixtures/lang/lists/ts.toml @@ -0,0 +1,2 @@ +package = "lang-lists-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/locals/Cargo.toml b/ts/fixtures/lang/locals/Cargo.toml new file mode 100644 index 000000000..10725c93c --- /dev/null +++ b/ts/fixtures/lang/locals/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-locals-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/locals/expected/core/bool.ts b/ts/fixtures/lang/locals/expected/core/bool.ts new file mode 100644 index 000000000..ffe6ebaab --- /dev/null +++ b/ts/fixtures/lang/locals/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$1d6toqn(self: boolean, t: undefined): undefined | rt.None { + if (!self) { + return rt.None; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/locals/expected/core/option.ts b/ts/fixtures/lang/locals/expected/core/option.ts new file mode 100644 index 000000000..a52512ee5 --- /dev/null +++ b/ts/fixtures/lang/locals/expected/core/option.ts @@ -0,0 +1,27 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Noisy from "../locals.Noisy.ts"; + +export function mapOr$0cqaybi(self: Noisy.Noisy | undefined, default_: rt.u8, f: (a0: Noisy.Noisy) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1w5qtj7(self: undefined | rt.None, default_: rt.u8, f: (a0: undefined) => rt.u8): rt.u8 { + if (self === rt.None) { + return default_; + } + return f(self); +} + +export function mapOr$0ucbp7g(self: [rt.u64, rt.u64] | undefined, default_: rt.u8, f: (a0: [rt.u64, rt.u64]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/locals/expected/core/result.ts b/ts/fixtures/lang/locals/expected/core/result.ts new file mode 100644 index 000000000..d3a181cf1 --- /dev/null +++ b/ts/fixtures/lang/locals/expected/core/result.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function mapOr$18ipla0(self: rt.Result, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { + if (self.ok) { + return f(self.value); + } + return default_; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/locals/expected/harness.ts b/ts/fixtures/lang/locals/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/locals/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/locals/expected/lib.ts b/ts/fixtures/lang/locals/expected/lib.ts new file mode 100644 index 000000000..811fe4e36 --- /dev/null +++ b/ts/fixtures/lang/locals/expected/lib.ts @@ -0,0 +1,25 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { locals } from "./locals.ts"; +import type * as Twin from "./locals.Twin.ts"; + +export function copy$locals_Twin(v: Twin.Twin): Twin.Twin { + return { _0: v._0, _1: v._1 }; +} + +export function copy$tuple2_locals_Twin_locals_Twin(v: [Twin.Twin, Twin.Twin]): [Twin.Twin, Twin.Twin] { + return [copy$locals_Twin(v[0]), copy$locals_Twin(v[1])]; +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["locals::locals", (_22: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + locals(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/locals.Noisy.ts b/ts/fixtures/lang/locals/expected/locals.Noisy.ts similarity index 100% rename from ts/fixtures/lang/expected/locals.Noisy.ts rename to ts/fixtures/lang/locals/expected/locals.Noisy.ts diff --git a/ts/fixtures/lang/expected/locals.Polling.ts b/ts/fixtures/lang/locals/expected/locals.Polling.ts similarity index 100% rename from ts/fixtures/lang/expected/locals.Polling.ts rename to ts/fixtures/lang/locals/expected/locals.Polling.ts diff --git a/ts/fixtures/lang/expected/locals.Twin.ts b/ts/fixtures/lang/locals/expected/locals.Twin.ts similarity index 100% rename from ts/fixtures/lang/expected/locals.Twin.ts rename to ts/fixtures/lang/locals/expected/locals.Twin.ts diff --git a/ts/fixtures/lang/expected/locals.ts b/ts/fixtures/lang/locals/expected/locals.ts similarity index 69% rename from ts/fixtures/lang/expected/locals.ts rename to ts/fixtures/lang/locals/expected/locals.ts index 93a7811eb..1b617e66f 100644 --- a/ts/fixtures/lang/expected/locals.ts +++ b/ts/fixtures/lang/locals/expected/locals.ts @@ -1,14 +1,14 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { copy$Option_tuple2_u64_u64, copy$locals_Twin, copy$tuple2_u8_u8 } from "./lib.ts"; +import { copy$locals_Twin } from "./lib.ts"; import { thenSome$1d6toqn } from "./core/bool.ts"; import { mapOr$0cqaybi as option_mapOr$0cqaybi, mapOr$1w5qtj7 as option_mapOr$1w5qtj7, mapOr$0ucbp7g as option_mapOr$0ucbp7g } from "./core/option.ts"; import { mapOr$18ipla0 as result_mapOr$18ipla0 } from "./core/result.ts"; -import * as locals_Noisy from "./locals.Noisy.ts"; -import type * as locals_Polling from "./locals.Polling.ts"; -import type * as locals_Twin from "./locals.Twin.ts"; -import { set$0st49po as local_set$0st49po, get$0x8wyln as local_get$0x8wyln, get$1ei2eoj as local_get$1ei2eoj, take$09yi5f2 as local_take$09yi5f2, replace$0kxb7te, withBorrow$1qygtee, withBorrow$1k8k9m1, withBorrow$0r4ucls, withBorrow$1t1sbub, withBorrow$15ql9sa, take$1x34chv as local_take$1x34chv, take$122f15k as local_take$122f15k, replace$0bb3zeq, replace$1xk72wn } from "./std/thread/local.ts"; +import * as Noisy from "./locals.Noisy.ts"; +import type * as Polling from "./locals.Polling.ts"; +import type * as Twin from "./locals.Twin.ts"; +import { set$0st49po, get$0x8wyln, get$1ei2eoj, take$09yi5f2, replace$0kxb7te, withBorrow$1qygtee, withBorrow$1k8k9m1, withBorrow$0r4ucls, withBorrow$1t1sbub, withBorrow$15ql9sa, take$1x34chv, take$122f15k, replace$0bb3zeq, replace$1xk72wn } from "./std/thread/local.ts"; export const COUNT: rt.LocalKey> = /* @__PURE__ */ new rt.LocalKey(COUNT$init, false); @@ -16,10 +16,10 @@ export function COUNT$init(): rt.Cell { return new rt.Cell(7); } -export const HELD: rt.LocalKey> = /* @__PURE__ */ new rt.LocalKey(HELD$init, false); +export const HELD: rt.LocalKey> = /* @__PURE__ */ new rt.LocalKey(HELD$init, false); -export function HELD$init(): rt.RefCell { - return new rt.RefCell(undefined as locals_Noisy.Noisy | undefined); +export function HELD$init(): rt.RefCell { + return new rt.RefCell(undefined as Noisy.Noisy | undefined); } export const LOG: rt.LocalKey> = /* @__PURE__ */ new rt.LocalKey((): rt.RefCell => { @@ -30,18 +30,18 @@ export function LOG$init(_1: undefined): rt.RefCell { return new rt.RefCell(rt.byteVecFrom(Uint8Array.of(1, 2, 3))); } -export const PAIRS: rt.LocalKey> = /* @__PURE__ */ new rt.LocalKey(PAIRS$init, false); +export const PAIRS: rt.LocalKey> = /* @__PURE__ */ new rt.LocalKey(PAIRS$init, false); -export function PAIRS$init(): rt.Cell<[locals_Twin.Twin, locals_Twin.Twin]> { - const x: locals_Twin.Twin = { _0: 1, _1: 2 }; - const y: locals_Twin.Twin = copy$locals_Twin(x); +export function PAIRS$init(): rt.Cell<[Twin.Twin, Twin.Twin]> { + const x: Twin.Twin = { _0: 1, _1: 2 }; + const y: Twin.Twin = copy$locals_Twin(x); x._0 = 3; - return new rt.Cell([copy$locals_Twin(x), copy$locals_Twin(y)] as [locals_Twin.Twin, locals_Twin.Twin]); + return new rt.Cell([copy$locals_Twin(x), copy$locals_Twin(y)] as [Twin.Twin, Twin.Twin]); } -export const POLLING: rt.LocalKey = /* @__PURE__ */ new rt.LocalKey(POLLING$init, false); +export const POLLING: rt.LocalKey = /* @__PURE__ */ new rt.LocalKey(POLLING$init, false); -export function POLLING$init(): locals_Polling.Polling { +export function POLLING$init(): Polling.Polling { return { current: new rt.Cell(undefined as [rt.u64, rt.u64] | undefined), held: new rt.RefCell(new rt.ByteVec()) }; } @@ -64,26 +64,26 @@ export function locals(data: rt.ByteSlice, out: rt.ByteVec): void { rt.iterExtendBytes(out, rt.byteVecIntoIter(withBorrow$1k8k9m1(LOG, (log2: rt.ByteVec): rt.ByteVec => { return rt.byteVecFrom(rt.byteVecView(log2)); })), undefined, true); - rt.byteVecPush(out, ((p: locals_Polling.Polling): rt.u8 => { - return option_mapOr$0ucbp7g(copy$Option_tuple2_u64_u64(p.current.v), 253, (_2: [rt.u64, rt.u64]): rt.u8 => { + rt.byteVecPush(out, ((p: Polling.Polling): rt.u8 => { + return option_mapOr$0ucbp7g(p.current.v, 253, (_2: [rt.u64, rt.u64]): rt.u8 => { return rt.u64Low(_2[0]) & 0xff; }); })(POLLING.get())); - rt.byteVecPush(out, ((p2: locals_Polling.Polling): rt.u8 => { + rt.byteVecPush(out, ((p2: Polling.Polling): rt.u8 => { const _64: rt.RefCell = rt.refCellBorrow(p2.held); const _05: rt.u8 = _64.value.length & 0xff; rt.refRelease(_64); return _05; })(POLLING.get())); - rt.byteVecPush(out, withBorrow$1qygtee(HELD, (held: locals_Noisy.Noisy | undefined): rt.u8 => { - return option_mapOr$0cqaybi(held, 253, (n: locals_Noisy.Noisy): rt.u8 => { + rt.byteVecPush(out, withBorrow$1qygtee(HELD, (held: Noisy.Noisy | undefined): rt.u8 => { + return option_mapOr$0cqaybi(held, 253, (n: Noisy.Noisy): rt.u8 => { return n.id; }); })); rt.byteVecPush(out, withBorrow$1t1sbub(TALLY, (tally: rt.u32): rt.u8 => { return tally & 0xff; })); - const _26: [locals_Twin.Twin, locals_Twin.Twin] = local_get$0x8wyln(PAIRS); + const _26: [Twin.Twin, Twin.Twin] = get$0x8wyln(PAIRS); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_26[0]._0 & 0xff, _26[0]._1 & 0xff, _26[1]._0 & 0xff, _26[1]._1 & 0xff)), undefined, true); rt.byteVecPush(out, serial(false)); const log: rt.Arc> = new rt.Arc(new rt.Mutex(new rt.ByteVec())); @@ -123,11 +123,11 @@ export function locals(data: rt.ByteSlice, out: rt.ByteVec): void { })(LOG.get()); })(COUNT.get())); } else if (_46 === 4) { - const outer: [rt.u64, rt.u64] | undefined = ((p3: locals_Polling.Polling): [rt.u64, rt.u64] | undefined => { + const outer: [rt.u64, rt.u64] | undefined = ((p3: Polling.Polling): [rt.u64, rt.u64] | undefined => { const _45: [rt.u64, rt.u64] | undefined = [op as rt.u64, 1]; return rt.cellReplace(p3.current, _45); })(POLLING.get()); - const len: rt.usize = ((p4: locals_Polling.Polling): rt.usize => { + const len: rt.usize = ((p4: Polling.Polling): rt.usize => { const _611: rt.RefCell = rt.refCellBorrowMut(p4.held); rt.byteVecPush(_611.value, op); rt.refMutRelease(_611); @@ -141,19 +141,19 @@ export function locals(data: rt.ByteSlice, out: rt.ByteVec): void { })); rt.byteVecPush(out, len & 0xff); } else if (_46 === 5) { - ((held3: rt.RefCell): undefined => { - const _316: locals_Noisy.Noisy | undefined = new locals_Noisy.Noisy(op, rt.arcClone(log)); - const _94: rt.RefCell = rt.refCellBorrowMut(held3); + ((held3: rt.RefCell): undefined => { + const _316: Noisy.Noisy | undefined = new Noisy.Noisy(op, rt.arcClone(log)); + const _94: rt.RefCell = rt.refCellBorrowMut(held3); rt.drop(_94.value); _94.value = _316; rt.refMutRelease(_94); })(HELD.get()); } else if (_46 === 6) { - local_set$0st49po(COUNT, rt.u32WrappingMul(local_get$1ei2eoj(COUNT), 3)); + set$0st49po(COUNT, rt.u32WrappingMul(get$1ei2eoj(COUNT), 3)); rt.byteVecPush(out, replace$0kxb7te(COUNT, op as rt.u32) & 0xff); - rt.byteVecPush(out, local_take$09yi5f2(COUNT) & 0xff); - local_set$0st49po(COUNT, rt.u32Add(op as rt.u32, 1)); - const _103: [locals_Twin.Twin, locals_Twin.Twin] = local_get$0x8wyln(PAIRS); + rt.byteVecPush(out, take$09yi5f2(COUNT) & 0xff); + set$0st49po(COUNT, rt.u32Add(op as rt.u32, 1)); + const _103: [Twin.Twin, Twin.Twin] = get$0x8wyln(PAIRS); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_103[0]._0 & 0xff, _103[0]._1 & 0xff, _103[1]._0 & 0xff, _103[1]._1 & 0xff)), undefined, true); rt.byteVecPush(out, option_mapOr$1w5qtj7(thenSome$1d6toqn(rt.u8Rem(op, 2) === 0, undefined), 253, (_22: undefined): rt.u8 => { return 1; @@ -167,21 +167,21 @@ export function locals(data: rt.ByteSlice, out: rt.ByteVec): void { })); rt.iterExtendBytes(out, rt.byteVecIntoIter(replace$1xk72wn(LOG, rt.byteVecFrom(Uint8Array.of(op)))), undefined, true); rt.localKeyRefCellSet(LOG, rt.byteVecFrom(Uint8Array.of(op, op))); - rt.iterExtendBytes(out, rt.byteVecIntoIter(local_take$122f15k(LOG)), undefined, true); + rt.iterExtendBytes(out, rt.byteVecIntoIter(take$122f15k(LOG)), undefined, true); rt.localKeyRefCellSet(LOG, rt.byteVecFrom(Uint8Array.of(1, 2, 3))); - const _141: rt.LocalKey> = HELD; + const _141: rt.LocalKey> = HELD; const _144: rt.Arc> = rt.arcClone(log); - rt.localKeyRefCellSet(_141, new locals_Noisy.Noisy(op, _144), rt.drop); - rt.localKeyWithBorrowMutPlace(HELD, (held2: rt.Place): undefined => { + rt.localKeyRefCellSet(_141, new Noisy.Noisy(op, _144), rt.drop); + rt.localKeyWithBorrowMutPlace(HELD, (held2: rt.Place): undefined => { rt.drop(held2.v); held2.v = undefined; }); - const old: locals_Noisy.Noisy | undefined = replace$0bb3zeq(HELD, new locals_Noisy.Noisy(rt.u8WrappingAdd(op, 1), rt.arcClone(log))); - rt.byteVecPush(out, option_mapOr$0cqaybi(old, 253, (n2: locals_Noisy.Noisy): rt.u8 => { + const old: Noisy.Noisy | undefined = replace$0bb3zeq(HELD, new Noisy.Noisy(rt.u8WrappingAdd(op, 1), rt.arcClone(log))); + rt.byteVecPush(out, option_mapOr$0cqaybi(old, 253, (n2: Noisy.Noisy): rt.u8 => { return n2.id; })); rt.drop(old); - rt.byteVecPush(out, option_mapOr$0cqaybi(local_take$1x34chv(HELD), 253, (n3: locals_Noisy.Noisy): rt.u8 => { + rt.byteVecPush(out, option_mapOr$0cqaybi(take$1x34chv(HELD), 253, (n3: Noisy.Noisy): rt.u8 => { const _012: rt.u8 = n3.id; n3[Symbol.dispose](); return _012; @@ -218,17 +218,17 @@ export function locals(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecTruncate(_516.value, 3); rt.refMutRelease(_516); })(LOG.get()); - ((p5: locals_Polling.Polling): undefined => { + ((p5: Polling.Polling): undefined => { rt.cellSet(p5.current, undefined as [rt.u64, rt.u64] | undefined); const _911: rt.RefCell = rt.refCellBorrowMut(p5.held); rt.byteVecClear(_911.value); rt.refMutRelease(_911); })(POLLING.get()); - rt.drop(((held4: rt.RefCell): locals_Noisy.Noisy | undefined => { - const _518: rt.RefCell = rt.refCellBorrowMut(held4); + rt.drop(((held4: rt.RefCell): Noisy.Noisy | undefined => { + const _518: rt.RefCell = rt.refCellBorrowMut(held4); const taken = _518.value; _518.value = undefined; - const _022: locals_Noisy.Noisy | undefined = taken; + const _022: Noisy.Noisy | undefined = taken; rt.refMutRelease(_518); return _022; })(HELD.get())); @@ -244,7 +244,7 @@ export function serial(reset: boolean): rt.u8 { return ((next: rt.Cell<[rt.u8, rt.u8]>): rt.u8 => { let _4!: [rt.u8, rt.u8]; if (!reset) { - _4 = copy$tuple2_u8_u8(next.v); + _4 = next.v; } else { _4 = [0, 4] as [rt.u8, rt.u8]; } diff --git a/ts/fixtures/lang/expected/std/thread/local.ts b/ts/fixtures/lang/locals/expected/std/thread/local.ts similarity index 68% rename from ts/fixtures/lang/expected/std/thread/local.ts rename to ts/fixtures/lang/locals/expected/std/thread/local.ts index 9a7af7e33..26c85b860 100644 --- a/ts/fixtures/lang/expected/std/thread/local.ts +++ b/ts/fixtures/lang/locals/expected/std/thread/local.ts @@ -2,8 +2,8 @@ import * as rt from "../../rt.ts"; import { copy$tuple2_locals_Twin_locals_Twin } from "../../lib.ts"; -import type * as locals_Noisy from "../../locals.Noisy.ts"; -import type * as locals_Twin from "../../locals.Twin.ts"; +import type * as Noisy from "../../locals.Noisy.ts"; +import type * as Twin from "../../locals.Twin.ts"; export function set$0st49po(self: rt.LocalKey>, value: rt.u32): void { rt.localKeyInitializeWith(self, new rt.Cell(value), (value2: rt.Cell | undefined, cell: rt.Cell): undefined => { @@ -13,16 +13,8 @@ export function set$0st49po(self: rt.LocalKey>, value: rt.u32): }); } -export function set$0xuu1fw(self: rt.LocalKey>, value: rt.u8): void { - rt.localKeyInitializeWith(self, new rt.Cell(value), (value2: rt.Cell | undefined, cell: rt.Cell): undefined => { - if (value2 !== undefined) { - rt.cellSet(cell, value2.v); - } - }); -} - -export function get$0x8wyln(self: rt.LocalKey>): [locals_Twin.Twin, locals_Twin.Twin] { - return ((a0: rt.Cell<[locals_Twin.Twin, locals_Twin.Twin]>): [locals_Twin.Twin, locals_Twin.Twin] => { +export function get$0x8wyln(self: rt.LocalKey>): [Twin.Twin, Twin.Twin] { + return ((a0: rt.Cell<[Twin.Twin, Twin.Twin]>): [Twin.Twin, Twin.Twin] => { return copy$tuple2_locals_Twin_locals_Twin(a0.v); })(self.get()); } @@ -33,12 +25,6 @@ export function get$1ei2eoj(self: rt.LocalKey>): rt.u32 { })(self.get()); } -export function get$18ignl5(self: rt.LocalKey>): rt.u8 { - return ((a0: rt.Cell): rt.u8 => { - return a0.v; - })(self.get()); -} - export function take$09yi5f2(self: rt.LocalKey>): rt.u32 { return ((a0: rt.Cell): rt.u32 => { return rt.cellReplace(a0, 0); @@ -52,11 +38,11 @@ export function replace$0kxb7te(self: rt.LocalKey>, value: rt.u3 })(self.get()); } -export function withBorrow$1qygtee(self: rt.LocalKey>, f: (a0: locals_Noisy.Noisy | undefined) => rt.u8): rt.u8 { +export function withBorrow$1qygtee(self: rt.LocalKey>, f: (a0: Noisy.Noisy | undefined) => rt.u8): rt.u8 { const captured = f; - return ((cell: rt.RefCell): rt.u8 => { - const _32: (a0: locals_Noisy.Noisy | undefined) => rt.u8 = captured; - const _7: rt.RefCell = rt.refCellBorrow(cell); + return ((cell: rt.RefCell): rt.u8 => { + const _32: (a0: Noisy.Noisy | undefined) => rt.u8 = captured; + const _7: rt.RefCell = rt.refCellBorrow(cell); const _02: rt.u8 = _32(_7.value); rt.refRelease(_7); return _02; @@ -107,8 +93,8 @@ export function withBorrow$15ql9sa(self: rt.LocalKey>, f: (a0 })(self.get()); } -export function take$1x34chv(self: rt.LocalKey>): locals_Noisy.Noisy | undefined { - return ((a0: rt.RefCell): locals_Noisy.Noisy | undefined => { +export function take$1x34chv(self: rt.LocalKey>): Noisy.Noisy | undefined { + return ((a0: rt.RefCell): Noisy.Noisy | undefined => { return rt.refCellReplace(a0, undefined); })(self.get()); } @@ -119,9 +105,9 @@ export function take$122f15k(self: rt.LocalKey>): rt.Byte })(self.get()); } -export function replace$0bb3zeq(self: rt.LocalKey>, value: locals_Noisy.Noisy | undefined): locals_Noisy.Noisy | undefined { +export function replace$0bb3zeq(self: rt.LocalKey>, value: Noisy.Noisy | undefined): Noisy.Noisy | undefined { const captured = value; - return rt.closure((cell: rt.RefCell): locals_Noisy.Noisy | undefined => { + return rt.closure((cell: rt.RefCell): Noisy.Noisy | undefined => { return rt.refCellReplace(cell, captured); }, (): void => { rt.drop(captured); diff --git a/ts/fixtures/lang/locals/src/lib.rs b/ts/fixtures/lang/locals/src/lib.rs new file mode 100644 index 000000000..91d91dd71 --- /dev/null +++ b/ts/fixtures/lang/locals/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod locals; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("locals::locals", |_, data, out| locals::locals(data, out))] +} diff --git a/ts/fixtures/lang/src/locals.rs b/ts/fixtures/lang/locals/src/locals.rs similarity index 100% rename from ts/fixtures/lang/src/locals.rs rename to ts/fixtures/lang/locals/src/locals.rs diff --git a/ts/fixtures/lang/locals/ts.toml b/ts/fixtures/lang/locals/ts.toml new file mode 100644 index 000000000..972650b2f --- /dev/null +++ b/ts/fixtures/lang/locals/ts.toml @@ -0,0 +1,2 @@ +package = "lang-locals-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/locks/Cargo.toml b/ts/fixtures/lang/locks/Cargo.toml new file mode 100644 index 000000000..2b76ccc0c --- /dev/null +++ b/ts/fixtures/lang/locks/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-locks-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/locks/caller.ts b/ts/fixtures/lang/locks/caller.ts new file mode 100644 index 000000000..83bd9fb63 --- /dev/null +++ b/ts/fixtures/lang/locks/caller.ts @@ -0,0 +1,42 @@ +// The inputs `locks`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `locks` scripts: writes through guards and reads, `get_mut`, and a lock matched. + */ +const locks = [[0, 1, 5, 6, 2, 7, 3, 8, 3, 0, 1], [4, 0, 4, 1], [2, 9, 2, 10, 4, 1], [3, 3, 4, 0]].map( + (bytes) => Uint8Array.of(...op("locks::locks"), 0, ...bytes), +); + +/** `locks::mapped` scripts: writes and reads through mapped and filtered guards. */ +const mappedLocks = [[0x04, 0x01, 0x02, 0x86, 0x05, 0x0a, 0x03, 0x02, 0x80, 0x01, 0x03]].map((bytes) => + Uint8Array.of(...op("locks::mapped"), 0, ...bytes), +); + +/** + * `locks::relock` with each pick: a mutex locked again while a guard holds it, which + * panics, and a read-write lock read or written again while a guard, mapped or not, holds + * it, which aborts but for a read under a read. + */ +const relocks = Array.from({ length: 16 }, (_, pick) => Uint8Array.of(...op("locks::relock"), 0, pick)); + +/** `locks::mutex_mapped` scripts: writes and reads through mapped and filtered mutex guards. */ +const mutexMaps = [[0x04, 0x01, 0x02, 0x86, 0xf5, 0x0a, 0x03, 0x02, 0xe1, 0x80, 0x07, 0x02]].map((bytes) => + Uint8Array.of(...op("locks::mutex_mapped"), 0, ...bytes), +); + +/** `locks::printed` scripts: each lock's guards printed, empty and not. */ +const printed = [[], [0, 1, 25, 200]].map((bytes) => Uint8Array.of(...op("locks::printed"), 0, ...bytes)); + +/** `locks::downgraded` scripts: write guards downgraded, each lock's released in either order, and whole byte arrays mapped. */ +const downgrades = [[0x00, 0x01, 0x11, 0x02, 0xf2, 0xe2, 0x03, 0x04, 0x13, 0x05]].map((bytes) => + Uint8Array.of(...op("locks::downgraded"), 0, ...bytes), +); + +/** `locks::rwlocks` scripts: `get_mut` and `into_inner` among writes and reads. */ +const rwlocks = [[6, 7, 0, 6, 2, 14, 15, 1]].map((bytes) => Uint8Array.of(...op("locks::rwlocks"), 0, ...bytes)); + +export const cases: Uint8Array[] = [...locks, ...mappedLocks, ...relocks, ...mutexMaps, ...printed, ...downgrades, ...rwlocks]; diff --git a/ts/fixtures/lang/locks/expected/core/bool.ts b/ts/fixtures/lang/locks/expected/core/bool.ts new file mode 100644 index 000000000..586643586 --- /dev/null +++ b/ts/fixtures/lang/locks/expected/core/bool.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0sf2w1i(self: boolean, t: rt.Place): rt.Place | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function thenSome$0d5am30(self: boolean, t: rt.u8): rt.u8 | undefined { + if (!self) { + return undefined; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/locks/expected/core/option.ts b/ts/fixtures/lang/locks/expected/core/option.ts new file mode 100644 index 000000000..d13e15db8 --- /dev/null +++ b/ts/fixtures/lang/locks/expected/core/option.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$1iemzn8(self: string | undefined, default_: string): string { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/locks/expected/core/result.ts b/ts/fixtures/lang/locks/expected/core/result.ts new file mode 100644 index 000000000..dcc16c732 --- /dev/null +++ b/ts/fixtures/lang/locks/expected/core/result.ts @@ -0,0 +1,49 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import { drop$Result_sync_MutexGuard_locks_Tally_sync_TryLockError_sync_MutexGuard_locks_Tally, drop$Result_sync_RwLockReadGuard_locks_Tally_sync_TryLockError_sync_RwLockReadGuard_locks_Tally } from "../lib.ts"; +import type * as Tally from "../locks.Tally.ts"; + +export function map$02txiwz(self: rt.Result, rt.Mutex>, op: (a0: rt.Mutex) => rt.Result, rt.Mutex>): rt.Result, rt.Mutex>, rt.Mutex> { + if (self.ok) { + return rt.Ok(op(self.value)); + } + return self as rt.Result, rt.Mutex>, rt.Mutex>; +} + +export function map$1g6jln5(self: rt.Result, rt.RefCell>, op: (a0: rt.RefCell) => rt.Result, rt.RefCell>): rt.Result, rt.RefCell>, rt.RefCell> { + if (self.ok) { + return rt.Ok(op(self.value)); + } + return self as rt.Result, rt.RefCell>, rt.RefCell>; +} + +export function mapOr$0666x4n(self: rt.Result, rt.TryLockError>>, default_: rt.u8, f: (a0: rt.Mutex) => rt.u8): rt.u8 { + let _0!: rt.u8; + if (self.ok) { + _0 = f(self.value); + } else { + _0 = default_; + } + if (!self.ok) { + drop$Result_sync_MutexGuard_locks_Tally_sync_TryLockError_sync_MutexGuard_locks_Tally(self); + return _0; + } + return _0; +} + +export function mapOr$1qkf3ab(self: rt.Result, rt.TryLockError>>, default_: rt.u8, f: (a0: rt.RefCell) => rt.u8): rt.u8 { + let _0!: rt.u8; + if (self.ok) { + _0 = f(self.value); + } else { + _0 = default_; + } + if (!self.ok) { + drop$Result_sync_RwLockReadGuard_locks_Tally_sync_TryLockError_sync_RwLockReadGuard_locks_Tally(self); + return _0; + } + return _0; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/locks/expected/harness.ts b/ts/fixtures/lang/locks/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/locks/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/locks/expected/lib.ts b/ts/fixtures/lang/locks/expected/lib.ts new file mode 100644 index 000000000..766f22c7a --- /dev/null +++ b/ts/fixtures/lang/locks/expected/lib.ts @@ -0,0 +1,209 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { locks, relock, rwlocks, mapped, mutexMapped, printed, downgraded } from "./locks.ts"; +import type * as Tally from "./locks.Tally.ts"; + +export function drop$Result_Result_sync_MappedMutexGuard_u64_sync_MappedMutexGuard_u64_sync_MutexGuard_locks_Tally(_1: rt.Result, rt.Mutex>, rt.Mutex>): void { + if (_1.ok) { + drop$Result_sync_MappedMutexGuard_u64_sync_MappedMutexGuard_u64(_1.value); + } else { + rt.mutexUnlock(_1.error); + } +} + +export function drop$Result_Result_sync_MappedRwLockWriteGuard_u64_sync_MappedRwLockWriteGuard_u64_sync_RwLockWriteGuard_locks_Tally(_1: rt.Result, rt.RefCell>, rt.RefCell>): void { + if (_1.ok) { + drop$Result_sync_MappedRwLockWriteGuard_u64_sync_MappedRwLockWriteGuard_u64(_1.value); + } else { + rt.refMutRelease(_1.error); + } +} + +export function drop$Result_sync_MappedMutexGuard_u64_sync_MappedMutexGuard_u64(_1: rt.Result, rt.Mutex>): void { + if (_1.ok) { + rt.mutexUnlock(_1.value); + } else { + rt.mutexUnlock(_1.error); + } +} + +export function drop$Result_sync_MappedRwLockReadGuard_u8_sync_RwLockReadGuard_locks_Tally(_1: rt.Result, rt.RefCell>): void { + if (_1.ok) { + rt.refRelease(_1.value); + } else { + rt.refRelease(_1.error); + } +} + +export function drop$Result_sync_MappedRwLockWriteGuard_u64_sync_MappedRwLockWriteGuard_u64(_1: rt.Result, rt.RefCell>): void { + if (_1.ok) { + rt.refMutRelease(_1.value); + } else { + rt.refMutRelease(_1.error); + } +} + +export function drop$Result_sync_MutexGuard_array4_u8_sync_TryLockError_sync_MutexGuard_array4_u8(_1: rt.Result, rt.TryLockError>>): void { + if (_1.ok) { + rt.mutexUnlock(_1.value); + } else { + drop$sync_TryLockError_sync_MutexGuard_array4_u8(_1.error); + } +} + +export function drop$Result_sync_MutexGuard_locks_Tally_sync_TryLockError_sync_MutexGuard_locks_Tally(_1: rt.Result, rt.TryLockError>>): void { + if (_1.ok) { + rt.mutexUnlock(_1.value); + } else { + drop$sync_TryLockError_sync_MutexGuard_locks_Tally(_1.error); + } +} + +export function drop$Result_sync_MutexGuard_u32_sync_TryLockError_sync_MutexGuard_u32(_1: rt.Result, rt.TryLockError>>): void { + if (_1.ok) { + rt.mutexUnlock(_1.value); + } else { + drop$sync_TryLockError_sync_MutexGuard_u32(_1.error); + } +} + +export function drop$Result_sync_MutexGuard_u8_sync_TryLockError_sync_MutexGuard_u8(_1: rt.Result, rt.TryLockError>>): void { + if (_1.ok) { + rt.mutexUnlock(_1.value); + } else { + drop$sync_TryLockError_sync_MutexGuard_u8(_1.error); + } +} + +export function drop$Result_sync_RwLockReadGuard_array4_u8_sync_TryLockError_sync_RwLockReadGuard_array4_u8(_1: rt.Result, rt.TryLockError>>): void { + if (_1.ok) { + rt.refRelease(_1.value); + } else { + drop$sync_TryLockError_sync_RwLockReadGuard_array4_u8(_1.error); + } +} + +export function drop$Result_sync_RwLockReadGuard_locks_Tally_sync_TryLockError_sync_RwLockReadGuard_locks_Tally(_1: rt.Result, rt.TryLockError>>): void { + if (_1.ok) { + rt.refRelease(_1.value); + } else { + drop$sync_TryLockError_sync_RwLockReadGuard_locks_Tally(_1.error); + } +} + +export function drop$Result_sync_RwLockReadGuard_u32_sync_TryLockError_sync_RwLockReadGuard_u32(_1: rt.Result, rt.TryLockError>>): void { + if (_1.ok) { + rt.refRelease(_1.value); + } else { + drop$sync_TryLockError_sync_RwLockReadGuard_u32(_1.error); + } +} + +export function drop$Result_sync_RwLockWriteGuard_array4_u8_sync_TryLockError_sync_RwLockWriteGuard_array4_u8(_1: rt.Result, rt.TryLockError>>): void { + if (_1.ok) { + rt.refMutRelease(_1.value); + } else { + drop$sync_TryLockError_sync_RwLockWriteGuard_array4_u8(_1.error); + } +} + +export function drop$Result_sync_RwLockWriteGuard_locks_Tally_sync_TryLockError_sync_RwLockWriteGuard_locks_Tally(_1: rt.Result, rt.TryLockError>>): void { + if (_1.ok) { + rt.refMutRelease(_1.value); + } else { + drop$sync_TryLockError_sync_RwLockWriteGuard_locks_Tally(_1.error); + } +} + +export function drop$Result_sync_RwLockWriteGuard_u32_sync_TryLockError_sync_RwLockWriteGuard_u32(_1: rt.Result, rt.TryLockError>>): void { + if (_1.ok) { + rt.refMutRelease(_1.value); + } else { + drop$sync_TryLockError_sync_RwLockWriteGuard_u32(_1.error); + } +} + +export function drop$sync_TryLockError_sync_MutexGuard_array4_u8(_1: rt.TryLockError>): void { + if (_1.tag === "Poisoned") { + rt.mutexUnlock((_1 as { tag: "Poisoned"; _0: rt.Mutex })._0); + } +} + +export function drop$sync_TryLockError_sync_MutexGuard_locks_Tally(_1: rt.TryLockError>): void { + if (_1.tag === "Poisoned") { + rt.mutexUnlock((_1 as { tag: "Poisoned"; _0: rt.Mutex })._0); + } +} + +export function drop$sync_TryLockError_sync_MutexGuard_u32(_1: rt.TryLockError>): void { + if (_1.tag === "Poisoned") { + rt.mutexUnlock((_1 as { tag: "Poisoned"; _0: rt.Mutex })._0); + } +} + +export function drop$sync_TryLockError_sync_MutexGuard_u8(_1: rt.TryLockError>): void { + if (_1.tag === "Poisoned") { + rt.mutexUnlock((_1 as { tag: "Poisoned"; _0: rt.Mutex })._0); + } +} + +export function drop$sync_TryLockError_sync_RwLockReadGuard_array4_u8(_1: rt.TryLockError>): void { + if (_1.tag === "Poisoned") { + rt.refRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell })._0); + } +} + +export function drop$sync_TryLockError_sync_RwLockReadGuard_locks_Tally(_1: rt.TryLockError>): void { + if (_1.tag === "Poisoned") { + rt.refRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell })._0); + } +} + +export function drop$sync_TryLockError_sync_RwLockReadGuard_u32(_1: rt.TryLockError>): void { + if (_1.tag === "Poisoned") { + rt.refRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell })._0); + } +} + +export function drop$sync_TryLockError_sync_RwLockWriteGuard_array4_u8(_1: rt.TryLockError>): void { + if (_1.tag === "Poisoned") { + rt.refMutRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell })._0); + } +} + +export function drop$sync_TryLockError_sync_RwLockWriteGuard_locks_Tally(_1: rt.TryLockError>): void { + if (_1.tag === "Poisoned") { + rt.refMutRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell })._0); + } +} + +export function drop$sync_TryLockError_sync_RwLockWriteGuard_u32(_1: rt.TryLockError>): void { + if (_1.tag === "Poisoned") { + rt.refMutRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell })._0); + } +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["locks::locks", (_24: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + locks(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::relock", (_25: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + relock(data2, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::rwlocks", (_26: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + rwlocks(data3, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::mapped", (_27: rt.u8, data4: rt.ByteSlice, out4: rt.ByteVec): undefined => { + mapped(data4, out4); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::mutex_mapped", (_28: rt.u8, data5: rt.ByteSlice, out5: rt.ByteVec): undefined => { + mutexMapped(data5, out5); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::printed", (_29: rt.u8, data6: rt.ByteSlice, out6: rt.ByteVec): undefined => { + printed(data6, out6); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::downgraded", (_210: rt.u8, data7: rt.ByteSlice, out7: rt.ByteVec): undefined => { + downgraded(data7, out7); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/locks.Lock.ts b/ts/fixtures/lang/locks/expected/locks.Lock.ts similarity index 100% rename from ts/fixtures/lang/expected/locks.Lock.ts rename to ts/fixtures/lang/locks/expected/locks.Lock.ts diff --git a/ts/fixtures/lang/expected/locks.Tally.ts b/ts/fixtures/lang/locks/expected/locks.Tally.ts similarity index 100% rename from ts/fixtures/lang/expected/locks.Tally.ts rename to ts/fixtures/lang/locks/expected/locks.Tally.ts diff --git a/ts/fixtures/lang/expected/locks.ts b/ts/fixtures/lang/locks/expected/locks.ts similarity index 79% rename from ts/fixtures/lang/expected/locks.ts rename to ts/fixtures/lang/locks/expected/locks.ts index d57d6e49a..f2a2bf8c8 100644 --- a/ts/fixtures/lang/expected/locks.ts +++ b/ts/fixtures/lang/locks/expected/locks.ts @@ -5,27 +5,27 @@ import { drop$Result_Result_sync_MappedMutexGuard_u64_sync_MappedMutexGuard_u64_ import { thenSome$0sf2w1i, thenSome$0d5am30 } from "./core/bool.ts"; import { unwrapOr$1iemzn8 as option_unwrapOr$1iemzn8, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr } from "./core/option.ts"; import { map$02txiwz as result_map$02txiwz, map$1g6jln5 as result_map$1g6jln5, mapOr$0666x4n as result_mapOr$0666x4n, mapOr$1qkf3ab as result_mapOr$1qkf3ab } from "./core/result.ts"; -import * as locks_Lock from "./locks.Lock.ts"; -import * as locks_Tally from "./locks.Tally.ts"; +import * as Lock from "./locks.Lock.ts"; +import * as Tally from "./locks.Tally.ts"; /** Each byte an operation on the mutexes, its value the operand; each puts what it read. */ export function locks(data: rt.ByteSlice, out: rt.ByteVec): void { let _85!: boolean; - const shared: rt.Arc> = new rt.Arc(new rt.Mutex(locks_Tally.default$Default())); - const other: rt.Arc> = rt.arcClone(shared); + const shared: rt.Arc> = new rt.Arc(new rt.Mutex(Tally.default$Default())); + const other: rt.Arc> = rt.arcClone(shared); const own: rt.Mutex = new rt.Mutex(new rt.ByteVec()); const number: rt.Mutex = new rt.Mutex(0); const slot: rt.Mutex = new rt.Mutex(undefined); - const lock: locks_Lock.Lock = { _0: new rt.Mutex(7) }; + const lock: Lock.Lock = { _0: new rt.Mutex(7) }; for (const op of rt.byteSliceView(data)) { const _18: rt.u8 = rt.u8Rem(op, 8); if (_18 === 0) { - const tally: rt.Mutex = rt.mutexLock(shared.value); + const tally: rt.Mutex = rt.mutexLock(shared.value); tally.value.n = rt.u64Add(tally.value.n, op as rt.u64); rt.byteVecPush(tally.value.seen, op); rt.mutexUnlock(tally); } else if (_18 === 1) { - const tally2: rt.Mutex = rt.mutexLock(other.value); + const tally2: rt.Mutex = rt.mutexLock(other.value); rt.byteVecPush(out, rt.u64Low(tally2.value.n) & 0xff); rt.byteVecPush(out, tally2.value.seen.length & 0xff); rt.mutexUnlock(tally2); @@ -48,8 +48,8 @@ export function locks(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _76.value & 0xff); rt.mutexUnlock(_76); } else if (_18 === 4) { - const held2: rt.Mutex = rt.mutexLock(shared.value); - const _86: rt.Result, rt.TryLockError>> = rt.mutexTryLock(other.value); + const held2: rt.Mutex = rt.mutexLock(shared.value); + const _86: rt.Result, rt.TryLockError>> = rt.mutexTryLock(other.value); if (!_86.ok) { _85 = true; } else { @@ -58,9 +58,9 @@ export function locks(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _85 ? 1 : 0); drop$Result_sync_MutexGuard_locks_Tally_sync_TryLockError_sync_MutexGuard_locks_Tally(_86); rt.mutexUnlock(held2); - const _92: rt.Result, rt.TryLockError>> = rt.mutexTryLock(other.value); + const _92: rt.Result, rt.TryLockError>> = rt.mutexTryLock(other.value); if (_92.ok) { - const tally3: rt.Mutex = _92.value; + const tally3: rt.Mutex = _92.value; rt.byteVecPush(out, tally3.value.seen.length & 0xff); rt.mutexUnlock(tally3); } else { @@ -71,10 +71,10 @@ export function locks(data: rt.ByteSlice, out: rt.ByteVec): void { const _107: rt.Mutex = rt.mutexLock(lock._0); _107.value = rt.u32Add(_107.value, _104); rt.mutexUnlock(_107); - const args2: rt.Fmt[] = [(f: rt.Formatter) => locks_Lock.fmt$fmt_Debug(lock, f)]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => Lock.fmt$fmt_Debug(lock, f)]; const free: string = rt.fmtFormat([args2[0]]); const guard: rt.Result, rt.TryLockError>> = rt.mutexTryLock(lock._0); - const args4: rt.Fmt[] = [(f: rt.Formatter) => locks_Lock.fmt$fmt_Debug(lock, f)]; + const args4: rt.Fmt[] = [(f: rt.Formatter) => Lock.fmt$fmt_Debug(lock, f)]; const held3: string = rt.fmtFormat([args4[0]]); const _139: boolean = guard.ok; const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, free), (f: rt.Formatter) => rt.fmtPad(f, held3), (f: rt.Formatter) => rt.fmtBool(_139, f)]; @@ -83,7 +83,7 @@ export function locks(data: rt.ByteSlice, out: rt.ByteVec): void { } else if (_18 === 6) { rt.byteVecPush(out, false ? 1 : 0); } else { - const tally4: rt.Mutex = rt.mutexLock(shared.value); + const tally4: rt.Mutex = rt.mutexLock(shared.value); rt.byteVecPush(out, tally4.value.seen.length & 0xff); rt.mutexUnlock(tally4); } @@ -107,14 +107,14 @@ export function relock(data: rt.ByteSlice, out: rt.ByteVec): void { if (_4 !== undefined) { const pick: rt.u8 = _4; const mutex: rt.Mutex = new rt.Mutex(pick); - const lock: rt.RefCell = new rt.RefCell({ n: pick as rt.u64, seen: rt.byteVecFrom(Uint8Array.of(pick)) }); + const lock: rt.RefCell = new rt.RefCell({ n: pick as rt.u64, seen: rt.byteVecFrom(Uint8Array.of(pick)) }); const again: (a0: rt.ByteVec) => undefined = (out2: rt.ByteVec): undefined => { if ((pick & 1) === 0) { - const _93: rt.RefCell = rt.rwLockRead(lock); + const _93: rt.RefCell = rt.rwLockRead(lock); rt.byteVecPush(out2, rt.u64Low(_93.value.n) & 0xff); rt.refRelease(_93); } else { - const _162: rt.RefCell = rt.rwLockWrite(lock); + const _162: rt.RefCell = rt.rwLockWrite(lock); rt.byteVecPush(out2, _162.value.seen.length & 0xff); rt.refMutRelease(_162); } @@ -141,34 +141,34 @@ export function relock(data: rt.ByteSlice, out: rt.ByteVec): void { rt.panicFmt(["internal error: entered unreachable code: nothing holds the mutex"]); } } else if (_15 === 2) { - const read: rt.RefCell = rt.rwLockRead(lock); + const read: rt.RefCell = rt.rwLockRead(lock); rt.byteVecPush(out, rt.u64Low(read.value.n) & 0xff); again(out); rt.refRelease(read); } else if (_15 === 3) { - const write: rt.RefCell = rt.rwLockWrite(lock); + const write: rt.RefCell = rt.rwLockWrite(lock); rt.byteVecPush(out, rt.u64Low(write.value.n) & 0xff); again(out); rt.refMutRelease(write); } else if (_15 === 4) { - const _74: rt.RefCell = rt.rwLockRead(lock); - const seen: rt.RefCell = rt.refMap(_74, ((t4: locks_Tally.Tally): rt.ByteVec => { + const _74: rt.RefCell = rt.rwLockRead(lock); + const seen: rt.RefCell = rt.refMap(_74, ((t4: Tally.Tally): rt.ByteVec => { return t4.seen; })(_74.value)); rt.byteVecPush(out, seen.value.length & 0xff); again(out); rt.refRelease(seen); } else if (_15 === 5) { - const _86: rt.RefCell = rt.rwLockWrite(lock); - const n: rt.RefCell = rt.refMutMap(_86, ((t3: locks_Tally.Tally): rt.Place => { + const _86: rt.RefCell = rt.rwLockWrite(lock); + const n: rt.RefCell = rt.refMutMap(_86, ((t3: Tally.Tally): rt.Place => { return rt.place(() => t3.n, (value2) => t3.n = value2); })(_86.value)); rt.byteVecPush(out, rt.u64Low(n.value) & 0xff); again(out); rt.refMutRelease(n); } else if (_15 === 6) { - const _101: rt.RefCell = rt.rwLockRead(lock); - const _100: rt.Result, rt.RefCell> = rt.refFilterMap(_101, ((t2: locks_Tally.Tally): rt.u8 | undefined => { + const _101: rt.RefCell = rt.rwLockRead(lock); + const _100: rt.Result, rt.RefCell> = rt.refFilterMap(_101, ((t2: Tally.Tally): rt.u8 | undefined => { return rt.byteSliceFirst(rt.byteVecSlice(t2.seen)); })(_101.value)); if (_100.ok) { @@ -184,8 +184,8 @@ export function relock(data: rt.ByteSlice, out: rt.ByteVec): void { rt.panicFmt(["internal error: entered unreachable code: seen holds the pick"]); } } else { - const _114: rt.RefCell = rt.rwLockWrite(lock); - const n2: rt.RefCell = rt.refMutMap(_114, ((t: locks_Tally.Tally): rt.Place => { + const _114: rt.RefCell = rt.rwLockWrite(lock); + const n2: rt.RefCell = rt.refMutMap(_114, ((t: Tally.Tally): rt.Place => { return rt.place(() => t.n, (value) => t.n = value); })(_114.value)); const n3: rt.RefCell = rt.refMutMap(n2, ((n4: rt.Place): rt.Place => { @@ -209,19 +209,19 @@ export function relock(data: rt.ByteSlice, out: rt.ByteVec): void { export function rwlocks(data: rt.ByteSlice, out: rt.ByteVec): void { let _75!: boolean; let _91!: boolean; - const lock: rt.Arc> = new rt.Arc(new rt.RefCell(locks_Tally.default$Default())); + const lock: rt.Arc> = new rt.Arc(new rt.RefCell(Tally.default$Default())); const number: rt.RefCell = new rt.RefCell(0); const owned: rt.RefCell = new rt.RefCell(new rt.ByteVec()); for (const op of rt.byteSliceView(data)) { const _13: rt.u8 = rt.u8Rem(op, 8); if (_13 === 0) { - const tally: rt.RefCell = rt.rwLockWrite(lock.value); + const tally: rt.RefCell = rt.rwLockWrite(lock.value); tally.value.n = rt.u64Add(tally.value.n, op as rt.u64); rt.byteVecPush(tally.value.seen, op); rt.refMutRelease(tally); } else if (_13 === 1) { - const a: rt.RefCell = rt.rwLockRead(lock.value); - const b: rt.RefCell = rt.rwLockRead(lock.value); + const a: rt.RefCell = rt.rwLockRead(lock.value); + const b: rt.RefCell = rt.rwLockRead(lock.value); rt.byteVecPush(out, a.value.seen.length & 0xff); rt.byteVecPush(out, rt.u64Low(b.value.n) & 0xff); rt.refRelease(b); @@ -235,11 +235,11 @@ export function rwlocks(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _59.value & 0xff); rt.refRelease(_59); } else if (_13 === 3) { - const read: rt.RefCell = rt.rwLockRead(lock.value); - const _70: rt.Result, rt.TryLockError>> = rt.rwLockTryRead(lock.value); + const read: rt.RefCell = rt.rwLockRead(lock.value); + const _70: rt.Result, rt.TryLockError>> = rt.rwLockTryRead(lock.value); rt.byteVecPush(out, _70.ok ? 1 : 0); drop$Result_sync_RwLockReadGuard_locks_Tally_sync_TryLockError_sync_RwLockReadGuard_locks_Tally(_70); - const _76: rt.Result, rt.TryLockError>> = rt.rwLockTryWrite(lock.value); + const _76: rt.Result, rt.TryLockError>> = rt.rwLockTryWrite(lock.value); if (!_76.ok) { _75 = true; } else { @@ -248,9 +248,9 @@ export function rwlocks(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _75 ? 1 : 0); drop$Result_sync_RwLockWriteGuard_locks_Tally_sync_TryLockError_sync_RwLockWriteGuard_locks_Tally(_76); rt.refRelease(read); - const write: rt.Result, rt.TryLockError>> = rt.rwLockTryWrite(lock.value); + const write: rt.Result, rt.TryLockError>> = rt.rwLockTryWrite(lock.value); rt.byteVecPush(out, write.ok ? 1 : 0); - const _92: rt.Result, rt.TryLockError>> = rt.rwLockTryRead(lock.value); + const _92: rt.Result, rt.TryLockError>> = rt.rwLockTryRead(lock.value); if (!_92.ok) { _91 = true; } else { @@ -260,9 +260,9 @@ export function rwlocks(data: rt.ByteSlice, out: rt.ByteVec): void { drop$Result_sync_RwLockReadGuard_locks_Tally_sync_TryLockError_sync_RwLockReadGuard_locks_Tally(_92); drop$Result_sync_RwLockWriteGuard_locks_Tally_sync_TryLockError_sync_RwLockWriteGuard_locks_Tally(write); } else if (_13 === 4) { - const _97: rt.Result, rt.TryLockError>> = rt.rwLockTryWrite(lock.value); + const _97: rt.Result, rt.TryLockError>> = rt.rwLockTryWrite(lock.value); if (_97.ok) { - const tally2: rt.RefCell = _97.value; + const tally2: rt.RefCell = _97.value; rt.byteVecPush(out, tally2.value.seen.length & 0xff); rt.refMutRelease(tally2); } else { @@ -285,12 +285,12 @@ export function rwlocks(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _137.value & 0xff); rt.refRelease(_137); } else { - const tally3: locks_Tally.Tally = new rt.RefCell({ n: op as rt.u64, seen: rt.byteVecFrom(Uint8Array.of(op)) }).value; + const tally3: Tally.Tally = new rt.RefCell({ n: op as rt.u64, seen: rt.byteVecFrom(Uint8Array.of(op)) }).value; rt.byteVecPush(out, rt.u64Low(tally3.n) & 0xff); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(tally3.seen)); } } - const _158: rt.RefCell = rt.rwLockRead(lock.value); + const _158: rt.RefCell = rt.rwLockRead(lock.value); rt.byteVecPush(out, rt.u64Low(_158.value.n) & 0xff); rt.refRelease(_158); rt.byteVecPush(out, number.value & 0xff); @@ -304,18 +304,18 @@ export function rwlocks(data: rt.ByteSlice, out: rt.ByteVec): void { * after they drop, and whether it is still locked. */ export function mapped(data: rt.ByteSlice, out: rt.ByteVec): void { - const lock: rt.RefCell = new rt.RefCell(locks_Tally.default$Default()); + const lock: rt.RefCell = new rt.RefCell(Tally.default$Default()); const locked: (a0: rt.ByteVec) => undefined = (out2: rt.ByteVec): undefined => { let read!: boolean; let write!: boolean; - const _43: rt.Result, rt.TryLockError>> = rt.rwLockTryRead(lock); + const _43: rt.Result, rt.TryLockError>> = rt.rwLockTryRead(lock); if (!_43.ok) { read = true; } else { read = false; } drop$Result_sync_RwLockReadGuard_locks_Tally_sync_TryLockError_sync_RwLockReadGuard_locks_Tally(_43); - const _8: rt.Result, rt.TryLockError>> = rt.rwLockTryWrite(lock); + const _8: rt.Result, rt.TryLockError>> = rt.rwLockTryWrite(lock); if (!_8.ok) { write = true; } else { @@ -327,8 +327,8 @@ export function mapped(data: rt.ByteSlice, out: rt.ByteVec): void { for (const op of rt.byteSliceView(data)) { const _13: rt.u8 = rt.u8Rem(op, 4); if (_13 === 0) { - const _16: rt.RefCell = rt.rwLockWrite(lock); - const n: rt.RefCell = rt.refMutMap(_16, ((t7: locks_Tally.Tally): rt.Place => { + const _16: rt.RefCell = rt.rwLockWrite(lock); + const n: rt.RefCell = rt.refMutMap(_16, ((t7: Tally.Tally): rt.Place => { return rt.place(() => t7.n, (value3) => t7.n = value3); })(_16.value)); n.value = rt.u64Add(n.value, op as rt.u64); @@ -341,12 +341,12 @@ export function mapped(data: rt.ByteSlice, out: rt.ByteVec): void { again.value = _28; rt.refMutRelease(again); locked(out); - const _44: rt.RefCell = rt.rwLockRead(lock); + const _44: rt.RefCell = rt.rwLockRead(lock); rt.byteVecPush(out, rt.u64Low(_44.value.n) & 0xff); rt.refRelease(_44); } else if (_13 === 1) { - const _48: rt.RefCell = rt.rwLockRead(lock); - const seen: rt.RefCell = rt.refMap(_48, ((t6: locks_Tally.Tally): rt.ByteVec => { + const _48: rt.RefCell = rt.rwLockRead(lock); + const seen: rt.RefCell = rt.refMap(_48, ((t6: Tally.Tally): rt.ByteVec => { return t6.seen; })(_48.value)); rt.byteVecPush(out, seen.value.length & 0xff); @@ -358,8 +358,8 @@ export function mapped(data: rt.ByteSlice, out: rt.ByteVec): void { rt.refRelease(last); locked(out); } else if (_13 === 2) { - const _70: rt.RefCell = rt.rwLockWrite(lock); - const _69: rt.Result, rt.RefCell> = rt.refMutFilterMap(_70, ((t3: locks_Tally.Tally): rt.Place | undefined => { + const _70: rt.RefCell = rt.rwLockWrite(lock); + const _69: rt.Result, rt.RefCell> = rt.refMutFilterMap(_70, ((t3: Tally.Tally): rt.Place | undefined => { return rt.sliceLastMut(rt.byteSliceView(rt.byteVecSlice(t3.seen))); })(_70.value)); if (_69.ok) { @@ -368,13 +368,13 @@ export function mapped(data: rt.ByteSlice, out: rt.ByteVec): void { last2.value = _75; rt.refMutRelease(last2); } else { - const whole: rt.RefCell = _69.error; + const whole: rt.RefCell = _69.error; rt.byteVecPush(whole.value.seen, op); rt.refMutRelease(whole); } locked(out); - const _90: rt.RefCell = rt.rwLockRead(lock); - const _89: rt.Result, rt.RefCell> = rt.refFilterMap(_90, ((t4: locks_Tally.Tally): rt.u8 | undefined => { + const _90: rt.RefCell = rt.rwLockRead(lock); + const _89: rt.Result, rt.RefCell> = rt.refFilterMap(_90, ((t4: Tally.Tally): rt.u8 | undefined => { return rt.byteSliceFirst(rt.byteVecSlice(t4.seen)); })(_90.value)); if (_89.ok) { @@ -392,13 +392,13 @@ export function mapped(data: rt.ByteSlice, out: rt.ByteVec): void { rt.refRelease(first2); } } else { - const whole2: rt.RefCell = _89.error; + const whole2: rt.RefCell = _89.error; rt.byteVecPush(out, 240 | (whole2.value.seen.length & 0xff)); rt.refRelease(whole2); } locked(out); - const _117: rt.RefCell = rt.rwLockWrite(lock); - const _121: rt.Result, rt.RefCell>, rt.RefCell> = result_map$1g6jln5(rt.refMutFilterMap(_117, ((t5: locks_Tally.Tally): rt.Place | undefined => { + const _117: rt.RefCell = rt.rwLockWrite(lock); + const _121: rt.Result, rt.RefCell>, rt.RefCell> = result_map$1g6jln5(rt.refMutFilterMap(_117, ((t5: Tally.Tally): rt.Place | undefined => { return rt.place(() => t5.n, (value2) => t5.n = value2); })(_117.value)), (n7: rt.RefCell): rt.Result, rt.RefCell> => { return rt.refMutFilterMap(n7, ((n8: rt.Place): rt.Place | undefined => { @@ -421,21 +421,21 @@ export function mapped(data: rt.ByteSlice, out: rt.ByteVec): void { if (!_121.ok) { drop$Result_Result_sync_MappedRwLockWriteGuard_u64_sync_MappedRwLockWriteGuard_u64_sync_RwLockWriteGuard_locks_Tally(_121); } - const _137: rt.RefCell = rt.rwLockRead(lock); + const _137: rt.RefCell = rt.rwLockRead(lock); rt.byteVecPush(out, rt.u64Low(_137.value.n) & 0xff); rt.refRelease(_137); - const _145: rt.RefCell = rt.rwLockRead(lock); + const _145: rt.RefCell = rt.rwLockRead(lock); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(_145.value.seen)); rt.refRelease(_145); } else { - const _149: rt.RefCell = rt.rwLockWrite(lock); - const n5: rt.RefCell = rt.refMutMap(_149, ((t: locks_Tally.Tally): rt.Place => { + const _149: rt.RefCell = rt.rwLockWrite(lock); + const n5: rt.RefCell = rt.refMutMap(_149, ((t: Tally.Tally): rt.Place => { return rt.place(() => t.n, (value) => t.n = value); })(_149.value)); locked(out); rt.refMutRelease(n5); - const _157: rt.RefCell = rt.rwLockRead(lock); - const n6: rt.RefCell = rt.refMap(_157, ((t2: locks_Tally.Tally): rt.u64 => { + const _157: rt.RefCell = rt.rwLockRead(lock); + const n6: rt.RefCell = rt.refMap(_157, ((t2: Tally.Tally): rt.u64 => { return t2.n; })(_157.value)); locked(out); @@ -443,7 +443,7 @@ export function mapped(data: rt.ByteSlice, out: rt.ByteVec): void { rt.refRelease(n6); } } - const last3: locks_Tally.Tally = lock.value; + const last3: Tally.Tally = lock.value; rt.byteVecPush(out, rt.u64Low(last3.n) & 0xff); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(last3.seen)); } @@ -454,12 +454,12 @@ export function mapped(data: rt.ByteSlice, out: rt.ByteVec): void { * holds after they drop, and whether it is still locked. */ export function mutexMapped(data: rt.ByteSlice, out: rt.ByteVec): void { - const mutex: rt.Mutex = new rt.Mutex(locks_Tally.default$Default()); + const mutex: rt.Mutex = new rt.Mutex(Tally.default$Default()); const number: rt.Mutex = new rt.Mutex(0); const locked: (a0: rt.ByteVec) => undefined = (out2: rt.ByteVec): undefined => { let tally!: boolean; let number2!: boolean; - const _45: rt.Result, rt.TryLockError>> = rt.mutexTryLock(mutex); + const _45: rt.Result, rt.TryLockError>> = rt.mutexTryLock(mutex); if (!_45.ok) { tally = true; } else { @@ -478,8 +478,8 @@ export function mutexMapped(data: rt.ByteSlice, out: rt.ByteVec): void { for (const op of rt.byteSliceView(data)) { const _15: rt.u8 = rt.u8Rem(op, 4); if (_15 === 0) { - const _18: rt.Mutex = rt.mutexLock(mutex); - const n: rt.Mutex = rt.mutexMap(_18, ((t7: locks_Tally.Tally): rt.Place => { + const _18: rt.Mutex = rt.mutexLock(mutex); + const n: rt.Mutex = rt.mutexMap(_18, ((t7: Tally.Tally): rt.Place => { return rt.place(() => t7.n, (value3) => t7.n = value3); })(_18.value)); n.value = rt.u64Add(n.value, op as rt.u64); @@ -492,7 +492,7 @@ export function mutexMapped(data: rt.ByteSlice, out: rt.ByteVec): void { again.value = _30; rt.mutexUnlock(again); locked(out); - const _46: rt.Mutex = rt.mutexLock(mutex); + const _46: rt.Mutex = rt.mutexLock(mutex); rt.byteVecPush(out, rt.u64Low(_46.value.n) & 0xff); rt.mutexUnlock(_46); const _50: rt.Mutex = rt.mutexLock(number); @@ -507,8 +507,8 @@ export function mutexMapped(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _71.value & 0xff); rt.mutexUnlock(_71); } else if (_15 === 1) { - const _75: rt.Mutex = rt.mutexLock(mutex); - const seen: rt.Mutex = rt.mutexMap(_75, rt.partPlace(((t5: locks_Tally.Tally): rt.ByteVec => { + const _75: rt.Mutex = rt.mutexLock(mutex); + const seen: rt.Mutex = rt.mutexMap(_75, rt.partPlace(((t5: Tally.Tally): rt.ByteVec => { return t5.seen; })(_75.value))); rt.byteVecPush(seen.value, op); @@ -518,24 +518,24 @@ export function mutexMapped(data: rt.ByteSlice, out: rt.ByteVec): void { } locked(out); rt.mutexUnlock(seen); - const _99: rt.Mutex = rt.mutexLock(mutex); + const _99: rt.Mutex = rt.mutexLock(mutex); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(_99.value.seen)); rt.mutexUnlock(_99); if ((op >> 4) === 14) { - const _107: rt.Mutex = rt.mutexLock(mutex); - const whole2: rt.Mutex = rt.mutexMap(_107, rt.partPlace(((t6: locks_Tally.Tally): locks_Tally.Tally => { + const _107: rt.Mutex = rt.mutexLock(mutex); + const whole2: rt.Mutex = rt.mutexMap(_107, rt.partPlace(((t6: Tally.Tally): Tally.Tally => { return t6; })(_107.value))); - const _110: locks_Tally.Tally = { n: op as rt.u64, seen: rt.byteVecFrom(Uint8Array.of(op)) }; + const _110: Tally.Tally = { n: op as rt.u64, seen: rt.byteVecFrom(Uint8Array.of(op)) }; whole2.value = _110; rt.mutexUnlock(whole2); - const _123: rt.Mutex = rt.mutexLock(mutex); + const _123: rt.Mutex = rt.mutexLock(mutex); rt.byteVecPush(out, rt.u64Low(_123.value.n) & 0xff); rt.mutexUnlock(_123); } } else if (_15 === 2) { - const _128: rt.Mutex = rt.mutexLock(mutex); - const _127: rt.Result, rt.Mutex> = rt.mutexFilterMap(_128, ((t3: locks_Tally.Tally): rt.Place | undefined => { + const _128: rt.Mutex = rt.mutexLock(mutex); + const _127: rt.Result, rt.Mutex> = rt.mutexFilterMap(_128, ((t3: Tally.Tally): rt.Place | undefined => { return rt.sliceLastMut(rt.byteSliceView(rt.byteVecSlice(t3.seen))); })(_128.value)); if (_127.ok) { @@ -544,13 +544,13 @@ export function mutexMapped(data: rt.ByteSlice, out: rt.ByteVec): void { last.value = _133; rt.mutexUnlock(last); } else { - const whole3: rt.Mutex = _127.error; + const whole3: rt.Mutex = _127.error; rt.byteVecPush(whole3.value.seen, op); rt.mutexUnlock(whole3); } locked(out); - const _147: rt.Mutex = rt.mutexLock(mutex); - const _151: rt.Result, rt.Mutex>, rt.Mutex> = result_map$02txiwz(rt.mutexFilterMap(_147, ((t4: locks_Tally.Tally): rt.Place | undefined => { + const _147: rt.Mutex = rt.mutexLock(mutex); + const _151: rt.Result, rt.Mutex>, rt.Mutex> = result_map$02txiwz(rt.mutexFilterMap(_147, ((t4: Tally.Tally): rt.Place | undefined => { return rt.place(() => t4.n, (value2) => t4.n = value2); })(_147.value)), (n6: rt.Mutex): rt.Result, rt.Mutex> => { return rt.mutexFilterMap(n6, ((n7: rt.Place): rt.Place | undefined => { @@ -575,23 +575,23 @@ export function mutexMapped(data: rt.ByteSlice, out: rt.ByteVec): void { drop$Result_Result_sync_MappedMutexGuard_u64_sync_MappedMutexGuard_u64_sync_MutexGuard_locks_Tally(_151); } locked(out); - const _173: rt.Mutex = rt.mutexLock(mutex); + const _173: rt.Mutex = rt.mutexLock(mutex); rt.byteVecPush(out, rt.u64Low(_173.value.n) & 0xff); rt.mutexUnlock(_173); - const _181: rt.Mutex = rt.mutexLock(mutex); + const _181: rt.Mutex = rt.mutexLock(mutex); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(_181.value.seen)); rt.mutexUnlock(_181); } else { - const _185: rt.Mutex = rt.mutexLock(mutex); - const n5: rt.Mutex = rt.mutexMap(_185, ((t: locks_Tally.Tally): rt.Place => { + const _185: rt.Mutex = rt.mutexLock(mutex); + const n5: rt.Mutex = rt.mutexMap(_185, ((t: Tally.Tally): rt.Place => { return rt.place(() => t.n, (value) => t.n = value); })(_185.value)); locked(out); - const _195: rt.Result, rt.TryLockError>> = rt.mutexTryLock(mutex); + const _195: rt.Result, rt.TryLockError>> = rt.mutexTryLock(mutex); rt.byteVecPush(out, !_195.ok ? 1 : 0); drop$Result_sync_MutexGuard_locks_Tally_sync_TryLockError_sync_MutexGuard_locks_Tally(_195); rt.mutexUnlock(n5); - rt.byteVecPush(out, result_mapOr$0666x4n(rt.mutexTryLock(mutex), 254, (t2: rt.Mutex): rt.u8 => { + rt.byteVecPush(out, result_mapOr$0666x4n(rt.mutexTryLock(mutex), 254, (t2: rt.Mutex): rt.u8 => { const _0: rt.u8 = t2.value.seen.length & 0xff; rt.mutexUnlock(t2); return _0; @@ -599,7 +599,7 @@ export function mutexMapped(data: rt.ByteSlice, out: rt.ByteVec): void { locked(out); } } - const last2: locks_Tally.Tally = mutex.value; + const last2: Tally.Tally = mutex.value; rt.byteVecPush(out, rt.u64Low(last2.n) & 0xff); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(last2.seen)); rt.byteVecPush(out, number.value & 0xff); @@ -679,19 +679,19 @@ export function printed(data: rt.ByteSlice, out: rt.ByteVec): void { * operand; each puts what it read through them and whether each lock is still held. */ export function downgraded(data: rt.ByteSlice, out: rt.ByteVec): void { - const lock: rt.RefCell = new rt.RefCell(locks_Tally.default$Default()); + const lock: rt.RefCell = new rt.RefCell(Tally.default$Default()); const number: rt.RefCell = new rt.RefCell(0); const quad: rt.RefCell = new rt.RefCell(Uint8Array.of(1, 2, 3, 4)); const mutex: rt.Mutex = new rt.Mutex(Uint8Array.of(5, 6, 7, 8)); for (const op of rt.byteSliceView(data)) { const _16: rt.u8 = rt.u8Rem(op, 4); if (_16 === 0) { - const write: rt.RefCell = rt.rwLockWrite(lock); + const write: rt.RefCell = rt.rwLockWrite(lock); write.value.n = rt.u64Add(write.value.n, op as rt.u64); rt.byteVecPush(write.value.seen, op); - const read: rt.RefCell = rt.rwLockDowngrade(write); + const read: rt.RefCell = rt.rwLockDowngrade(write); rt.byteVecPush(out, held$locks_Tally(lock)); - rt.byteVecPush(out, result_mapOr$1qkf3ab(rt.rwLockTryRead(lock), 254, (t2: rt.RefCell): rt.u8 => { + rt.byteVecPush(out, result_mapOr$1qkf3ab(rt.rwLockTryRead(lock), 254, (t2: rt.RefCell): rt.u8 => { const _0: rt.u8 = t2.value.seen.length & 0xff; rt.refRelease(t2); return _0; @@ -765,8 +765,8 @@ export function downgraded(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(_152.value)); rt.mutexUnlock(_152); } else { - const _159: rt.RefCell = rt.rwLockDowngrade(rt.rwLockWrite(lock)); - const seen: rt.RefCell = rt.refMap(_159, ((t: locks_Tally.Tally): rt.ByteVec => { + const _159: rt.RefCell = rt.rwLockDowngrade(rt.rwLockWrite(lock)); + const seen: rt.RefCell = rt.refMap(_159, ((t: Tally.Tally): rt.ByteVec => { return t.seen; })(_159.value)); rt.byteVecPush(out, held$locks_Tally(lock)); @@ -785,7 +785,7 @@ export function downgraded(data: rt.ByteSlice, out: rt.ByteVec): void { } } rt.byteVecPush(out, held$locks_Tally(lock)); - const last: locks_Tally.Tally = lock.value; + const last: Tally.Tally = lock.value; rt.byteVecPush(out, rt.u64Low(last.n) & 0xff); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(last.seen)); rt.byteVecPush(out, number.value & 0xff); @@ -815,17 +815,17 @@ export function held$array4_u8(lock: rt.RefCell): rt.u8 { } /** Whether a read of `lock` would block, as 2, and whether a write would, as 1. */ -export function held$locks_Tally(lock: rt.RefCell): rt.u8 { +export function held$locks_Tally(lock: rt.RefCell): rt.u8 { let read!: boolean; let write!: boolean; - const _3: rt.Result, rt.TryLockError>> = rt.rwLockTryRead(lock); + const _3: rt.Result, rt.TryLockError>> = rt.rwLockTryRead(lock); if (!_3.ok) { read = true; } else { read = false; } drop$Result_sync_RwLockReadGuard_locks_Tally_sync_TryLockError_sync_RwLockReadGuard_locks_Tally(_3); - const _7: rt.Result, rt.TryLockError>> = rt.rwLockTryWrite(lock); + const _7: rt.Result, rt.TryLockError>> = rt.rwLockTryWrite(lock); if (!_7.ok) { write = true; } else { diff --git a/ts/fixtures/lang/locks/src/lib.rs b/ts/fixtures/lang/locks/src/lib.rs new file mode 100644 index 000000000..9a3b45cd7 --- /dev/null +++ b/ts/fixtures/lang/locks/src/lib.rs @@ -0,0 +1,29 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#![feature(mapped_lock_guards)] + +#[path = "../../harness.rs"] +pub mod harness; +mod locks; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("locks::locks", |_, data, out| locks::locks(data, out)), + ("locks::relock", |_, data, out| locks::relock(data, out)), + ("locks::rwlocks", |_, data, out| locks::rwlocks(data, out)), + ("locks::mapped", |_, data, out| locks::mapped(data, out)), + ("locks::mutex_mapped", |_, data, out| locks::mutex_mapped(data, out)), + ("locks::printed", |_, data, out| locks::printed(data, out)), + ("locks::downgraded", |_, data, out| locks::downgraded(data, out)), + ] +} diff --git a/ts/fixtures/lang/src/locks.rs b/ts/fixtures/lang/locks/src/locks.rs similarity index 100% rename from ts/fixtures/lang/src/locks.rs rename to ts/fixtures/lang/locks/src/locks.rs diff --git a/ts/fixtures/lang/locks/ts.toml b/ts/fixtures/lang/locks/ts.toml new file mode 100644 index 000000000..020d9e2d2 --- /dev/null +++ b/ts/fixtures/lang/locks/ts.toml @@ -0,0 +1,2 @@ +package = "lang-locks-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/manual/Cargo.toml b/ts/fixtures/lang/manual/Cargo.toml new file mode 100644 index 000000000..48bb7e41c --- /dev/null +++ b/ts/fixtures/lang/manual/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-manual-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/manual/expected/harness.ts b/ts/fixtures/lang/manual/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/manual/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/manual/expected/lib.ts b/ts/fixtures/lang/manual/expected/lib.ts new file mode 100644 index 000000000..fa45cef6e --- /dev/null +++ b/ts/fixtures/lang/manual/expected/lib.ts @@ -0,0 +1,31 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { arcs } from "./manual.ts"; + +export function copy$array_u8(v: Uint8Array): Uint8Array { + return v.slice(); +} + +export function copy$mem_MaybeUninit_mem_ManuallyDrop_tuple2_u8_u16(v: [rt.u8, rt.u16]): [rt.u8, rt.u16] { + if (v === undefined) { + return v; + } + return [v[0], v[1]]; +} + +export function copy$tuple2_u8_u16(v: [rt.u8, rt.u16]): [rt.u8, rt.u16] { + return [v[0], v[1]]; +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["manual::arcs", (_22: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + arcs(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/manual.ByHand.ts b/ts/fixtures/lang/manual/expected/manual.ByHand.ts similarity index 100% rename from ts/fixtures/lang/expected/manual.ByHand.ts rename to ts/fixtures/lang/manual/expected/manual.ByHand.ts diff --git a/ts/fixtures/lang/expected/manual.ts b/ts/fixtures/lang/manual/expected/manual.ts similarity index 100% rename from ts/fixtures/lang/expected/manual.ts rename to ts/fixtures/lang/manual/expected/manual.ts diff --git a/ts/fixtures/lang/manual/src/lib.rs b/ts/fixtures/lang/manual/src/lib.rs new file mode 100644 index 000000000..b7fdb594e --- /dev/null +++ b/ts/fixtures/lang/manual/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod manual; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("manual::arcs", |_, data, out| manual::arcs(data, out))] +} diff --git a/ts/fixtures/lang/src/manual.rs b/ts/fixtures/lang/manual/src/manual.rs similarity index 100% rename from ts/fixtures/lang/src/manual.rs rename to ts/fixtures/lang/manual/src/manual.rs diff --git a/ts/fixtures/lang/manual/ts.toml b/ts/fixtures/lang/manual/ts.toml new file mode 100644 index 000000000..9b2348b10 --- /dev/null +++ b/ts/fixtures/lang/manual/ts.toml @@ -0,0 +1,2 @@ +package = "lang-manual-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/methods/Cargo.toml b/ts/fixtures/lang/methods/Cargo.toml new file mode 100644 index 000000000..e1295c6ca --- /dev/null +++ b/ts/fixtures/lang/methods/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-methods-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/methods/caller.ts b/ts/fixtures/lang/methods/caller.ts new file mode 100644 index 000000000..b6e237e9a --- /dev/null +++ b/ts/fixtures/lang/methods/caller.ts @@ -0,0 +1,48 @@ +// The inputs `methods`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `methods::*` of every kind at every width, over operands at the edges of its range: + * both ends and their neighbors, the sign bit's, small values, and where they reach, + * either side of 2^53 and 2^64 and their negations. Each meets 0, 1, -1, 2, 10, and + * either end, which make `MIN / -1`, `MIN % -1`, and a zero divisor or base, and + * exponents and shifts in, at, and past the width. + */ +function methods(): Uint8Array[] { + const widths: [string, number, boolean][] = [["u8s", 8, false], ["u16s", 16, false], ["u32s", 32, false], ["u64s", 64, false], ["u128s", 128, false], ["usizes", 32, false], ["i8s", 8, true], ["i16s", 16, true], ["i32s", 32, true], ["i64s", 64, true], ["i128s", 128, true], ["isizes", 32, true]]; + // The kinds that read the `u32`, and the others, which read `b`. + const exponents = new Set([3, 4, 7, 8, 21, 22, 23, 38, 39, 40]); + const cases: Uint8Array[] = []; + for (const [name, bits, signed] of widths) { + const o = op(`methods::${name}`); + const width = BigInt(bits); + const min = signed ? -(1n << (width - 1n)) : 0n; + const max = (1n << (signed ? width - 1n : width)) - 1n; + const sign = 1n << (width - 1n); + const values = [min, min + 1n, min + 2n, -2n, -1n, 0n, 1n, 2n, 3n, 10n, 99n, max - 1n, max, sign - 1n, sign, sign + 1n]; + for (const k of [53n, 64n]) { + if (k < width) values.push(...[-1n, 0n, 1n].flatMap((d) => [(1n << k) + d, -(1n << k) + d])); + } + const edges = [...new Set(values.filter((v) => v >= min && v <= max))]; + const others = [0n, 1n, -1n, 2n, 10n, min, max].filter((v) => v >= min && v <= max); + const shifts = [0, 1, 2, bits - 1, bits, bits + 1, 2 * bits, 3 * bits - 1, 0x80000000, 0xffffffff]; + const be = (v: bigint) => Array.from({ length: bits / 8 }, (_, i) => Number((v >> BigInt(bits - 8 - 8 * i)) & 0xffn)); + const u32 = (n: number) => [n >>> 24, (n >>> 16) & 0xff, (n >>> 8) & 0xff, n & 0xff]; + let i = 0; + for (let kind = 0; kind < 42; kind++) { + for (const a of edges) { + if (exponents.has(kind)) { + for (const n of shifts) cases.push(Uint8Array.of(...o, kind, ...be(a), ...be(others[i++ % others.length]), ...u32(n))); + } else { + for (const b of others) cases.push(Uint8Array.of(...o, kind, ...be(a), ...be(b), ...u32(shifts[i++ % shifts.length]))); + } + } + } + } + return cases; +} + +export const cases: Uint8Array[] = [...methods()]; diff --git a/ts/fixtures/lang/methods/expected/core/option.ts b/ts/fixtures/lang/methods/expected/core/option.ts new file mode 100644 index 000000000..f2d7fef3c --- /dev/null +++ b/ts/fixtures/lang/methods/expected/core/option.ts @@ -0,0 +1,96 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$18pd8cy(self: rt.i128 | undefined, _: (a0: rt.i128) => rt.i128): rt.i128 | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function map$0b7sac9(self: rt.i16 | undefined, _: (a0: rt.i16) => rt.i16): rt.i16 | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function map$0x0f126(self: rt.i32 | undefined, _: (a0: rt.i32) => rt.i32): rt.i32 | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function map$02fxff7(self: rt.i64 | undefined, _: (a0: rt.i64) => rt.i64): rt.i64 | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function map$1u19ipa(self: rt.i8 | undefined, _: (a0: rt.i8) => rt.i8): rt.i8 | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function map$1rlqf9d(self: rt.isize | undefined, _: (a0: rt.isize) => rt.isize): rt.isize | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function map$1fszu7p(self: rt.u128 | undefined, _: (a0: rt.u128) => rt.u128): rt.u128 | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function map$12xrbxt(self: rt.u16 | undefined, _: (a0: rt.u16) => rt.u16): rt.u16 | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function map$0xz4pvf(self: rt.u32 | undefined, _: (a0: rt.u32) => rt.u32): rt.u32 | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function map$1rxjg4m(self: rt.u64 | undefined, _: (a0: rt.u64) => rt.u64): rt.u64 | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function map$03bv7br(self: rt.u8 | undefined, _: (a0: rt.u8) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +export function map$08v2q5m(self: rt.usize | undefined, _: (a0: rt.usize) => rt.usize): rt.usize | undefined { + if (self === undefined) { + return undefined; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/methods/expected/harness.ts b/ts/fixtures/lang/methods/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/methods/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/methods/expected/lib.ts b/ts/fixtures/lang/methods/expected/lib.ts new file mode 100644 index 000000000..69752d746 --- /dev/null +++ b/ts/fixtures/lang/methods/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { u8s, u16s, u32s, u64s, u128s, usizes, i8s, i16s, i32s, i64s, i128s, isizes } from "./methods.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["methods::u8s", u8s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::u16s", u16s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::u32s", u32s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::u64s", u64s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::u128s", u128s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::usizes", usizes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::i8s", i8s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::i16s", i16s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::i32s", i32s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::i64s", i64s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::i128s", i128s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["methods::isizes", isizes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/methods.ts b/ts/fixtures/lang/methods/expected/methods.ts similarity index 100% rename from ts/fixtures/lang/expected/methods.ts rename to ts/fixtures/lang/methods/expected/methods.ts diff --git a/ts/fixtures/lang/methods/src/lib.rs b/ts/fixtures/lang/methods/src/lib.rs new file mode 100644 index 000000000..cbccdebc3 --- /dev/null +++ b/ts/fixtures/lang/methods/src/lib.rs @@ -0,0 +1,34 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#![feature(wrapping_int_impl, wrapping_next_power_of_two)] + +#[path = "../../harness.rs"] +pub mod harness; +mod methods; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("methods::u8s", methods::u8s), + ("methods::u16s", methods::u16s), + ("methods::u32s", methods::u32s), + ("methods::u64s", methods::u64s), + ("methods::u128s", methods::u128s), + ("methods::usizes", methods::usizes), + ("methods::i8s", methods::i8s), + ("methods::i16s", methods::i16s), + ("methods::i32s", methods::i32s), + ("methods::i64s", methods::i64s), + ("methods::i128s", methods::i128s), + ("methods::isizes", methods::isizes), + ] +} diff --git a/ts/fixtures/lang/src/methods.rs b/ts/fixtures/lang/methods/src/methods.rs similarity index 100% rename from ts/fixtures/lang/src/methods.rs rename to ts/fixtures/lang/methods/src/methods.rs diff --git a/ts/fixtures/lang/methods/ts.toml b/ts/fixtures/lang/methods/ts.toml new file mode 100644 index 000000000..55e06352f --- /dev/null +++ b/ts/fixtures/lang/methods/ts.toml @@ -0,0 +1,2 @@ +package = "lang-methods-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/nested/Cargo.toml b/ts/fixtures/lang/nested/Cargo.toml new file mode 100644 index 000000000..5451d304a --- /dev/null +++ b/ts/fixtures/lang/nested/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-nested-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/nested/caller.ts b/ts/fixtures/lang/nested/caller.ts new file mode 100644 index 000000000..430df38c0 --- /dev/null +++ b/ts/fixtures/lang/nested/caller.ts @@ -0,0 +1,29 @@ +// The inputs `nested`'s cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `nested::consumers`, whose first byte is also `nth`'s index: of no items, one `Some` or + * `None`, `None` before `Some`, `nth` past the end, only `None`s, keys all tied, and + * `find` stopping early. + */ +const consumers = [[], [6], [5], [1, 2], [7, 2], [1, 3, 5], [2, 6, 10, 14], [4, 3, 0x90, 0x92, 5]].map((bytes) => Uint8Array.of(...op("nested::nested"), 3, ...bytes)); + +/** + * `nested::closures`, whose bytes `pick` each `None` (0 mod 3), `Some(None)` (1), or + * `Some(Some(_))` (2): of no bytes, only `None`s, only `Some(None)`s, `Some(None)` before + * a `None` and after it, a seed of each, and a `successors` whose size hint reserves past + * `isize::MAX`. + */ +const closures = [[], [3], [0, 3], [1], [4, 7, 1], [1, 2, 0, 4, 5], [4, 0, 1, 3, 5], [2, 1, 4, 3, 8], [5, 4], [0, 1, 2], [0xf0], [0xf1]].map((bytes) => Uint8Array.of(...op("nested::nested"), 5, ...bytes)); + +/** + * `nested::elements`, whose first byte is also the index and whose odd bytes are each a + * `None` element: of no elements, one of each, only `None`s, and an index in range and + * past the end of each mix. + */ +const elements = [[], [1], [2], [1, 3], [3, 1, 5], [0, 1, 2], [2, 6, 1, 8], [5, 4, 3, 0x10, 7, 0x40], [7, 0x22, 9, 0x22, 1, 0x80, 3, 6]].map((bytes) => Uint8Array.of(...op("nested::nested"), 6, ...bytes)); + +export const cases: Uint8Array[] = [...consumers, ...closures, ...elements]; diff --git a/ts/fixtures/lang/nested/expected/core/bool.ts b/ts/fixtures/lang/nested/expected/core/bool.ts new file mode 100644 index 000000000..6f6d7192c --- /dev/null +++ b/ts/fixtures/lang/nested/expected/core/bool.ts @@ -0,0 +1,26 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0d5am30(self: boolean, t: rt.u8): rt.u8 | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function thenSome$1j8foe9(self: boolean, _: undefined): undefined | rt.None { + if (!self) { + return rt.None; + } + return undefined; +} + +export function then$16ew6vr(self: boolean, f: () => rt.u8 | undefined): rt.u8 | undefined | rt.None { + if (!self) { + return rt.None; + } + return f(); +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/nested/expected/core/option.ts b/ts/fixtures/lang/nested/expected/core/option.ts new file mode 100644 index 000000000..fe5056a1f --- /dev/null +++ b/ts/fixtures/lang/nested/expected/core/option.ts @@ -0,0 +1,215 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function isNoneOr$1s1o3ss(self: rt.u8 | undefined, f: (a0: rt.u8) => boolean): boolean { + if (self === undefined) { + return true; + } + return f(self); +} + +export function unwrapOr$1kxjsqb(self: rt.u8 | undefined | rt.None, default_: rt.u8 | undefined): rt.u8 | undefined { + if (self === rt.None) { + return default_; + } + return self; +} + +export function unwrapOr$1la41a6(self: Uint8Array | undefined, default_: Uint8Array): Uint8Array { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$0pkankm(self: rt.u8 | undefined | rt.None, f: (a0: rt.u8 | undefined) => rt.u8 | undefined): rt.u8 | undefined | rt.None { + if (self === rt.None) { + return rt.None; + } + return f(self); +} + +export function map$1diqi3e(self: rt.Place | undefined, f: (a0: rt.Place) => undefined): undefined | rt.None { + if (self === undefined) { + return rt.None; + } + f(self); + return undefined; +} + +export function map$0rbsrz6(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8 | undefined): rt.u8 | undefined | rt.None { + if (self === undefined) { + return rt.None; + } + return f(self); +} + +export function map$0p22lts(self: rt.u8 | undefined, f: (a0: rt.u8) => undefined): undefined | rt.None { + if (self === undefined) { + return rt.None; + } + f(self); + return undefined; +} + +export function map$0jcaaxx(self: [rt.u8 | undefined, rt.u8] | undefined, f: (a0: [rt.u8 | undefined, rt.u8]) => Uint8Array): Uint8Array | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0cs071d(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0at3a41(self: undefined | rt.None, f: (a0: undefined) => rt.u8 | undefined): rt.u8 | undefined | rt.None { + if (self === rt.None) { + return rt.None; + } + return f(undefined); +} + +export function mapOr$1t0muvr(self: rt.u8 | undefined, default_: rt.usize, f: (a0: rt.u8) => rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$06rr3sb(self: rt.u8 | undefined, default_: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8 | undefined): rt.u8 | undefined { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1surhce(self: rt.u8 | undefined, default_: rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$18ph0j9(self: undefined | rt.None, default_: rt.u8, f: (a0: undefined) => rt.u8): rt.u8 { + if (self === rt.None) { + return default_; + } + return f(undefined); +} + +export function okOr$1vxk0yk(self: rt.u8 | undefined, err: rt.u8): rt.Result { + if (self === undefined) { + return rt.Err(err); + } + return rt.Ok(self); +} + +export function okOr$0g9lvh7(self: rt.u8 | undefined, _: undefined): rt.Result { + if (self === undefined) { + return rt.ERR; + } + return rt.Ok(self); +} + +export function andThen$0qni7te(self: rt.u8 | undefined | rt.None, f: (a0: rt.u8 | undefined) => rt.u8 | undefined | rt.None): rt.u8 | undefined | rt.None { + if (self === rt.None) { + return rt.None; + } + return f(self); +} + +export function andThen$0ocv8av(self: Array | undefined, f: (a0: Array) => rt.u8 | undefined | rt.None): rt.u8 | undefined | rt.None { + if (self === undefined) { + return rt.None; + } + return f(self); +} + +export function andThen$1bd14ex(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8 | undefined | rt.None): rt.u8 | undefined | rt.None { + if (self === undefined) { + return rt.None; + } + return f(self); +} + +export function filter$19gtvc4(self: rt.u8 | undefined | rt.None, predicate: (a0: rt.u8 | undefined) => boolean): rt.u8 | undefined | rt.None { + if (self !== rt.None) { + const x: rt.u8 | undefined = self; + if (predicate(x)) { + return x; + } + } + return rt.None; +} + +export function filter$0v80fk8(self: rt.u8 | undefined, predicate: (a0: rt.u8) => boolean): rt.u8 | undefined { + if (self !== undefined) { + const x: rt.u8 = self; + if (predicate(x)) { + return x; + } + } + return undefined; +} + +export function or$0j02yk0(self: rt.u8 | undefined | rt.None, optb: rt.u8 | undefined | rt.None): rt.u8 | undefined | rt.None { + if (self === rt.None) { + return optb; + } + return self; +} + +export function xor$0pemq84(self: rt.u8 | undefined | rt.None, optb: rt.u8 | undefined | rt.None): rt.u8 | undefined | rt.None { + let _0!: rt.u8 | undefined | rt.None; + b0: { + if (self === rt.None) { + if (optb !== rt.None) { + _0 = optb; + break b0; + } + } else if (optb === rt.None) { + _0 = self; + break b0; + } + _0 = rt.None; + } + return _0; +} + +export function xor$0kctyix(self: rt.u8 | undefined, optb: rt.u8 | undefined): rt.u8 | undefined { + let _0!: rt.u8 | undefined; + b0: { + if (self === undefined) { + if (optb !== undefined) { + _0 = optb; + break b0; + } + } else if (optb === undefined) { + _0 = self; + break b0; + } + _0 = undefined; + } + return _0; +} + +export function flatten$1nwzx42(self: rt.u8 | undefined | rt.None): rt.u8 | undefined { + if (self === rt.None) { + return undefined; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/nested/expected/core/result.ts b/ts/fixtures/lang/nested/expected/core/result.ts new file mode 100644 index 000000000..3cbe333d9 --- /dev/null +++ b/ts/fixtures/lang/nested/expected/core/result.ts @@ -0,0 +1,21 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function map$03hz3l7(self: rt.Result, op: (a0: rt.u8) => undefined): rt.Result { + if (self.ok) { + op(self.value); + return rt.OK; + } + return self as rt.Result; +} + +export function mapErr$1whfgss(self: rt.Result, op: (a0: undefined) => undefined): rt.Result { + if (self.ok) { + return self; + } + op(undefined); + return rt.ERR; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/nested/expected/harness.ts b/ts/fixtures/lang/nested/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/nested/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/nested/expected/lib.ts b/ts/fixtures/lang/nested/expected/lib.ts new file mode 100644 index 000000000..46ce423ee --- /dev/null +++ b/ts/fixtures/lang/nested/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { nested } from "./nested.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["nested::nested", nested as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/nested.Halves.ts b/ts/fixtures/lang/nested/expected/nested.Halves.ts similarity index 81% rename from ts/fixtures/lang/expected/nested.Halves.ts rename to ts/fixtures/lang/nested/expected/nested.Halves.ts index 2d2a2bb2c..ace8bd939 100644 --- a/ts/fixtures/lang/expected/nested.Halves.ts +++ b/ts/fixtures/lang/nested/expected/nested.Halves.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { halve as nested_halve } from "./nested.ts"; +import { halve } from "./nested.ts"; /** Counts down to 0, yielding each count as an `Option`: `None` for each odd one. */ export interface Halves { @@ -13,7 +13,7 @@ export function next$iter_Iterator(self: Halves): rt.u8 | undefined | rt.Done { if (_2 !== undefined) { const n: rt.u8 = _2; self._0 = n; - return rt.iterFromOption(nested_halve(n), rt.None); + return rt.iterFromOption(halve(n), rt.None); } return rt.DONE; } diff --git a/ts/fixtures/lang/expected/nested.Slot.ts b/ts/fixtures/lang/nested/expected/nested.Slot.ts similarity index 100% rename from ts/fixtures/lang/expected/nested.Slot.ts rename to ts/fixtures/lang/nested/expected/nested.Slot.ts diff --git a/ts/fixtures/lang/expected/nested.Tagged.ts b/ts/fixtures/lang/nested/expected/nested.Tagged.ts similarity index 100% rename from ts/fixtures/lang/expected/nested.Tagged.ts rename to ts/fixtures/lang/nested/expected/nested.Tagged.ts diff --git a/ts/fixtures/lang/expected/nested.Unit.ts b/ts/fixtures/lang/nested/expected/nested.Unit.ts similarity index 100% rename from ts/fixtures/lang/expected/nested.Unit.ts rename to ts/fixtures/lang/nested/expected/nested.Unit.ts diff --git a/ts/fixtures/lang/expected/nested.ts b/ts/fixtures/lang/nested/expected/nested.ts similarity index 97% rename from ts/fixtures/lang/expected/nested.ts rename to ts/fixtures/lang/nested/expected/nested.ts index af5bdbae4..dca41a062 100644 --- a/ts/fixtures/lang/expected/nested.ts +++ b/ts/fixtures/lang/nested/expected/nested.ts @@ -2,12 +2,12 @@ import * as rt from "./rt.ts"; import { thenSome$0d5am30, thenSome$1j8foe9, then$16ew6vr } from "./core/bool.ts"; -import { isNoneOr$1s1o3ss, unwrapOr$1kxjsqb as option_unwrapOr$1kxjsqb, unwrapOr$1la41a6 as option_unwrapOr$1la41a6, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$0pkankm as option_map$0pkankm, map$1diqi3e as option_map$1diqi3e, map$0rbsrz6 as option_map$0rbsrz6, map$0p22lts as option_map$0p22lts, map$0jcaaxx as option_map$0jcaaxx, map$0cs071d as option_map$0cs071d, map$0at3a41 as option_map$0at3a41, mapOr$1surhce as option_mapOr$1surhce, mapOr$1t0muvr as option_mapOr$1t0muvr, mapOr$06rr3sb as option_mapOr$06rr3sb, mapOr$18ph0j9 as option_mapOr$18ph0j9, okOr$1vxk0yk as option_okOr$1vxk0yk, okOr$0g9lvh7 as option_okOr$0g9lvh7, andThen$0qni7te as option_andThen$0qni7te, andThen$0ocv8av as option_andThen$0ocv8av, andThen$1bd14ex as option_andThen$1bd14ex, filter$19gtvc4, filter$0v80fk8, or$0j02yk0 as option_or$0j02yk0, xor$0pemq84, xor$0kctyix, flatten$1nwzx42 as option_flatten$1nwzx42 } from "./core/option.ts"; +import { isNoneOr$1s1o3ss, unwrapOr$1kxjsqb as option_unwrapOr$1kxjsqb, unwrapOr$1la41a6 as option_unwrapOr$1la41a6, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$0pkankm as option_map$0pkankm, map$1diqi3e as option_map$1diqi3e, map$0rbsrz6 as option_map$0rbsrz6, map$0p22lts as option_map$0p22lts, map$0jcaaxx as option_map$0jcaaxx, map$0cs071d as option_map$0cs071d, map$0at3a41 as option_map$0at3a41, mapOr$1t0muvr as option_mapOr$1t0muvr, mapOr$06rr3sb as option_mapOr$06rr3sb, mapOr$1surhce as option_mapOr$1surhce, mapOr$18ph0j9 as option_mapOr$18ph0j9, okOr$1vxk0yk as option_okOr$1vxk0yk, okOr$0g9lvh7 as option_okOr$0g9lvh7, andThen$0qni7te as option_andThen$0qni7te, andThen$0ocv8av as option_andThen$0ocv8av, andThen$1bd14ex as option_andThen$1bd14ex, filter$19gtvc4, filter$0v80fk8, or$0j02yk0 as option_or$0j02yk0, xor$0pemq84, xor$0kctyix, flatten$1nwzx42 as option_flatten$1nwzx42 } from "./core/option.ts"; import { map$03hz3l7 as result_map$03hz3l7, mapErr$1whfgss as result_mapErr$1whfgss } from "./core/result.ts"; -import * as nested_Halves from "./nested.Halves.ts"; -import type * as nested_Slot from "./nested.Slot.ts"; -import * as nested_Tagged from "./nested.Tagged.ts"; -import * as nested_Unit from "./nested.Unit.ts"; +import * as Halves from "./nested.Halves.ts"; +import type * as Slot from "./nested.Slot.ts"; +import * as Tagged from "./nested.Tagged.ts"; +import * as Unit from "./nested.Unit.ts"; /** * Run case `kind % 8` over `data`, whose bytes pick each `None`, `Some(None)`, or @@ -106,7 +106,7 @@ export function made(data: rt.ByteSlice, out: rt.ByteVec): void { })); rt.byteVecPush(out, code(tried(u, o))); rt.byteVecPush(out, o === o ? 1 : 0); - const slot: nested_Slot.Slot = { held: o, flag: u }; + const slot: Slot.Slot = { held: o, flag: u }; const taken2: rt.u8 | undefined | rt.None = slot.held; slot.held = rt.None; const taken: rt.u8 | undefined | rt.None = taken2; @@ -120,7 +120,7 @@ export function made(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, code(old) ^ code(slot.held)); rt.byteVecPush(out, code(rt.None)); const _106: rt.Ordering = rt.cmp(b, 128); - const tagged: nested_Tagged.Tagged = new nested_Tagged.Tagged(u, _106); + const tagged: Tagged.Tagged = new Tagged.Tagged(u, _106); rt.byteVecPush(out, (tagged.value !== rt.None ? 1 : 0) | ((order(tagged.order) << 1) & 0xff)); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(o, f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug), rt.None), (f: rt.Formatter) => rt.fmtOption(u, f, rt.fmtUnit, rt.None)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1]]))); @@ -226,11 +226,11 @@ export function iters(data: rt.ByteSlice, out: rt.ByteVec): void { } rt.byteVecPush(out, option_unwrapOr$0r2bmpr(_46, 225)); } - const own: nested_Halves.Halves = { _0: rt.u8Rem(data.length & 0xff, 8) }; - rt.byteVecPush(out, code(rt.iterToOption(nested_Halves.next$iter_Iterator(own), rt.None))); - const iter2: nested_Halves.Halves = own; + const own: Halves.Halves = { _0: rt.u8Rem(data.length & 0xff, 8) }; + rt.byteVecPush(out, code(rt.iterToOption(Halves.next$iter_Iterator(own), rt.None))); + const iter2: Halves.Halves = own; while (true) { - const _64: rt.u8 | undefined | rt.Done = nested_Halves.next$iter_Iterator(iter2); + const _64: rt.u8 | undefined | rt.Done = Halves.next$iter_Iterator(iter2); if (_64 === rt.DONE) { break; } @@ -733,9 +733,9 @@ export function pointed(data: rt.ByteSlice, f: (a0: rt.u8) => undefined): undefi return rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), f), undefined, 0, true); } -export function madeAll$nested_Unit(m: nested_Unit.Unit, data: rt.ByteSlice): undefined[] { +export function madeAll$nested_Unit(m: Unit.Unit, data: rt.ByteSlice): undefined[] { return rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): undefined => { - nested_Unit.made$nested_Made(m, _2); + Unit.made$nested_Made(m, _2); }), undefined, 0, true); } diff --git a/ts/fixtures/lang/nested/src/lib.rs b/ts/fixtures/lang/nested/src/lib.rs new file mode 100644 index 000000000..9f0b792dd --- /dev/null +++ b/ts/fixtures/lang/nested/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod nested; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("nested::nested", nested::nested)] +} diff --git a/ts/fixtures/lang/src/nested.rs b/ts/fixtures/lang/nested/src/nested.rs similarity index 100% rename from ts/fixtures/lang/src/nested.rs rename to ts/fixtures/lang/nested/src/nested.rs diff --git a/ts/fixtures/lang/nested/ts.toml b/ts/fixtures/lang/nested/ts.toml new file mode 100644 index 000000000..d14803f23 --- /dev/null +++ b/ts/fixtures/lang/nested/ts.toml @@ -0,0 +1,2 @@ +package = "lang-nested-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/objects/Cargo.toml b/ts/fixtures/lang/objects/Cargo.toml new file mode 100644 index 000000000..d5544c50d --- /dev/null +++ b/ts/fixtures/lang/objects/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-objects-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/objects/expected/core/option.ts b/ts/fixtures/lang/objects/expected/core/option.ts new file mode 100644 index 000000000..6e8907ca4 --- /dev/null +++ b/ts/fixtures/lang/objects/expected/core/option.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function mapOr$1q3ff8g(self: rt.Arc | undefined, default_: rt.u8, f: (a0: rt.Arc) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/objects/expected/harness.ts b/ts/fixtures/lang/objects/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/objects/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/objects/expected/lib.ts b/ts/fixtures/lang/objects/expected/lib.ts new file mode 100644 index 000000000..ccecb59fa --- /dev/null +++ b/ts/fixtures/lang/objects/expected/lib.ts @@ -0,0 +1,16 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { objects } from "./objects.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["objects::objects", (_22: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + objects(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/objects.Wakes.ts b/ts/fixtures/lang/objects/expected/objects.Wakes.ts similarity index 100% rename from ts/fixtures/lang/expected/objects.Wakes.ts rename to ts/fixtures/lang/objects/expected/objects.Wakes.ts diff --git a/ts/fixtures/lang/expected/objects.Window.ts b/ts/fixtures/lang/objects/expected/objects.Window.ts similarity index 100% rename from ts/fixtures/lang/expected/objects.Window.ts rename to ts/fixtures/lang/objects/expected/objects.Window.ts diff --git a/ts/fixtures/lang/expected/objects.ts b/ts/fixtures/lang/objects/expected/objects.ts similarity index 96% rename from ts/fixtures/lang/expected/objects.ts rename to ts/fixtures/lang/objects/expected/objects.ts index 47897819a..39c0a43a8 100644 --- a/ts/fixtures/lang/expected/objects.ts +++ b/ts/fixtures/lang/objects/expected/objects.ts @@ -3,7 +3,7 @@ import * as rt from "./rt.ts"; import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, mapOr$1q3ff8g as option_mapOr$1q3ff8g } from "./core/option.ts"; import * as Wakes from "./objects.Wakes.ts"; -import * as objects_Window from "./objects.Window.ts"; +import * as Window from "./objects.Window.ts"; /** moq-net's growing buffer: the `Arc` behind a parameter, replaced by a bigger one. */ export function reserve(current: rt.Place>, needed: rt.usize): void { @@ -110,23 +110,23 @@ export function rebox(p: rt.Place>, to: rt.u8): void { p.v = _3; } -export function apply(w: objects_Window.Window, start: rt.u8): void { - const _3: objects_Window.Window = objects_Window.withStart(rt.replaceIn(w, objects_Window.default$Default()), start); +export function apply(w: Window.Window, start: rt.u8): void { + const _3: Window.Window = Window.withStart(rt.replaceIn(w, Window.default$Default()), start); w[Symbol.dispose](); Object.assign(w, _3); } /** What moq-net's tracks do: a new value made of the old one's parts, swapped in. */ -export function park(w: objects_Window.Window, start: rt.u8): rt.u8 { +export function park(w: Window.Window, start: rt.u8): rt.u8 { const taken = w.held; w.held = []; - const _6: objects_Window.Window = rt.replaceIn(w, new objects_Window.Window(start, taken)); + const _6: Window.Window = rt.replaceIn(w, new Window.Window(start, taken)); const _0: rt.u8 = _6.start; _6[Symbol.dispose](); return _0; } -export function swapWindows(a: objects_Window.Window, b: objects_Window.Window): void { +export function swapWindows(a: Window.Window, b: Window.Window): void { Object.assign(a, rt.replaceIn(b, a)); } @@ -397,7 +397,7 @@ export function objects(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(_394[0], _394[1]))); } const _404: rt.Arc[] = [rt.arcClone(one)]; - const w: objects_Window.Window = new objects_Window.Window(by, _404); + const w: Window.Window = new Window.Window(by, _404); const other: rt.Arc[] = [rt.arcClone(two), rt.arcClone(two)]; const bytes: rt.ByteVec = new rt.ByteVec(); for (const b4 of rt.byteSliceView(data)) { @@ -457,8 +457,8 @@ export function objects(data: rt.ByteSlice, out: rt.ByteVec): void { return _04; })); rt.byteVecPush(out, two.weak & 0xff); - const a: objects_Window.Window = objects_Window.withStart(objects_Window.default$Default(), by); - const b7: objects_Window.Window = new objects_Window.Window(rt.u8WrappingAdd(by, 2), [rt.arcClone(one)]); + const a: Window.Window = Window.withStart(Window.default$Default(), by); + const b7: Window.Window = new Window.Window(rt.u8WrappingAdd(by, 2), [rt.arcClone(one)]); const _555: rt.u16 = by as rt.u16; const array: rt.u16[] = Array.from({ length: 2 }, (): rt.u16 => { return _555; diff --git a/ts/fixtures/lang/objects/src/lib.rs b/ts/fixtures/lang/objects/src/lib.rs new file mode 100644 index 000000000..b97289fbc --- /dev/null +++ b/ts/fixtures/lang/objects/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod objects; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("objects::objects", |_, data, out| objects::objects(data, out))] +} diff --git a/ts/fixtures/lang/src/objects.rs b/ts/fixtures/lang/objects/src/objects.rs similarity index 100% rename from ts/fixtures/lang/src/objects.rs rename to ts/fixtures/lang/objects/src/objects.rs diff --git a/ts/fixtures/lang/objects/ts.toml b/ts/fixtures/lang/objects/ts.toml new file mode 100644 index 000000000..2a0fc95cc --- /dev/null +++ b/ts/fixtures/lang/objects/ts.toml @@ -0,0 +1,2 @@ +package = "lang-objects-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/orders/Cargo.toml b/ts/fixtures/lang/orders/Cargo.toml new file mode 100644 index 000000000..183ced9b2 --- /dev/null +++ b/ts/fixtures/lang/orders/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-orders-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/orders/expected/core/bool.ts b/ts/fixtures/lang/orders/expected/core/bool.ts new file mode 100644 index 000000000..ffe6ebaab --- /dev/null +++ b/ts/fixtures/lang/orders/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$1d6toqn(self: boolean, t: undefined): undefined | rt.None { + if (!self) { + return rt.None; + } + return t; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/expected/core/cmp.ts b/ts/fixtures/lang/orders/expected/core/cmp.ts similarity index 61% rename from ts/fixtures/lang/expected/core/cmp.ts rename to ts/fixtures/lang/orders/expected/core/cmp.ts index abfc529da..e9d2d0980 100644 --- a/ts/fixtures/lang/expected/core/cmp.ts +++ b/ts/fixtures/lang/orders/expected/core/cmp.ts @@ -1,26 +1,26 @@ // Generated by rust2-ts. Do not edit. import * as rt from "../rt.ts"; -import * as orders_Item from "../orders.Item.ts"; +import * as Item from "../orders.Item.ts"; export function min$1ljcpv9(v1: string, v2: string): string { return rt.ordMin(v1, v2, rt.cmpLt(rt.cmpStr)); } -export function min$1f8m2y1(v1: orders_Item.Item, v2: orders_Item.Item): orders_Item.Item { - return rt.ordMin(v1, v2, orders_Item.lt$cmp_PartialOrd, rt.drop); +export function min$1f8m2y1(v1: Item.Item, v2: Item.Item): Item.Item { + return rt.ordMin(v1, v2, Item.lt$cmp_PartialOrd, rt.drop); } -export function min$0tn2vhs(v1: orders_Item.Item, v2: orders_Item.Item): orders_Item.Item { - return rt.ordMin(v1, v2, orders_Item.lt$cmp_PartialOrd); +export function min$0tn2vhs(v1: Item.Item, v2: Item.Item): Item.Item { + return rt.ordMin(v1, v2, Item.lt$cmp_PartialOrd); } export function min$1mtc1eg(v1: rt.u8, v2: rt.u8): rt.u8 { return rt.min(v1, v2); } -export function minBy$0f4msyz(v1: orders_Item.Item, v2: orders_Item.Item, compare: (a0: orders_Item.Item, a1: orders_Item.Item) => rt.Ordering): orders_Item.Item { - let _0!: orders_Item.Item; +export function minBy$0f4msyz(v1: Item.Item, v2: Item.Item, compare: (a0: Item.Item, a1: Item.Item) => rt.Ordering): Item.Item { + let _0!: Item.Item; let _10: boolean = false; let _9: boolean = false; _10 = true; @@ -49,8 +49,8 @@ export function minBy$0wmhcb1(v1: [rt.f64, rt.u8], v2: [rt.f64, rt.u8], compare: return v1; } -export function minByKey$04nvnd5(v1: orders_Item.Item, v2: orders_Item.Item, f: (a0: orders_Item.Item) => rt.u8): orders_Item.Item { - let _0!: orders_Item.Item; +export function minByKey$04nvnd5(v1: Item.Item, v2: Item.Item, f: (a0: Item.Item) => rt.u8): Item.Item { + let _0!: Item.Item; let _16: boolean = false; let _15: boolean = false; _16 = true; @@ -86,20 +86,20 @@ export function max$0i3ups8(v1: rt.i8, v2: rt.i8): rt.i8 { return rt.max(v1, v2); } -export function max$1tkcqvz(v1: orders_Item.Item, v2: orders_Item.Item): orders_Item.Item { - return rt.ordMax(v1, v2, orders_Item.lt$cmp_PartialOrd, rt.drop); +export function max$1tkcqvz(v1: Item.Item, v2: Item.Item): Item.Item { + return rt.ordMax(v1, v2, Item.lt$cmp_PartialOrd, rt.drop); } -export function max$0bn3iky(v1: orders_Item.Item, v2: orders_Item.Item): orders_Item.Item { - return rt.ordMax(v1, v2, orders_Item.lt$cmp_PartialOrd); +export function max$0bn3iky(v1: Item.Item, v2: Item.Item): Item.Item { + return rt.ordMax(v1, v2, Item.lt$cmp_PartialOrd); } export function max$0g5g0ks(v1: rt.u8, v2: rt.u8): rt.u8 { return rt.max(v1, v2); } -export function maxBy$04pyy5s(v1: orders_Item.Item, v2: orders_Item.Item, compare: (a0: orders_Item.Item, a1: orders_Item.Item) => rt.Ordering): orders_Item.Item { - let _0!: orders_Item.Item; +export function maxBy$04pyy5s(v1: Item.Item, v2: Item.Item, compare: (a0: Item.Item, a1: Item.Item) => rt.Ordering): Item.Item { + let _0!: Item.Item; let _10: boolean = false; let _9: boolean = false; _10 = true; @@ -128,15 +128,15 @@ export function maxBy$0yuzdd4(v1: [rt.f64, rt.u8], v2: [rt.f64, rt.u8], compare: return v1; } -export function maxByKey$1a9sf4b(v1: orders_Item.Item, v2: orders_Item.Item, f: (a0: orders_Item.Item) => orders_Item.Item): orders_Item.Item { - let _0!: orders_Item.Item; +export function maxByKey$1a9sf4b(v1: Item.Item, v2: Item.Item, f: (a0: Item.Item) => Item.Item): Item.Item { + let _0!: Item.Item; let _16: boolean = false; let _15: boolean = false; _16 = true; _15 = true; - const _6: orders_Item.Item = f(v2); - const _11: orders_Item.Item = f(v1); - if (!orders_Item.lt$cmp_PartialOrd(_6, _11)) { + const _6: Item.Item = f(v2); + const _11: Item.Item = f(v1); + if (!Item.lt$cmp_PartialOrd(_6, _11)) { _11[Symbol.dispose](); _6[Symbol.dispose](); _15 = false; diff --git a/ts/fixtures/lang/orders/expected/core/option.ts b/ts/fixtures/lang/orders/expected/core/option.ts new file mode 100644 index 000000000..68fac34ed --- /dev/null +++ b/ts/fixtures/lang/orders/expected/core/option.ts @@ -0,0 +1,62 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Item from "../orders.Item.ts"; + +export function unwrapOr$0l1fs14(self: rt.Ordering | undefined, default_: rt.Ordering): rt.Ordering { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$0isl2bb(self: rt.Result | undefined, f: (a0: rt.Result) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$05nbzug(self: rt.usize | undefined, f: (a0: rt.usize) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function mapOr$1e4a1e0(self: rt.Ordering | undefined, default_: rt.u8, f: (a0: rt.Ordering) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$14aggam(self: Item.Item | undefined, default_: rt.u8, f: (a0: Item.Item) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0z7fb2w(self: rt.ByteSlice | undefined, default_: Uint8Array, f: (a0: rt.ByteSlice) => Uint8Array): Uint8Array { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1surhce(self: rt.u8 | undefined, default_: rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$06gg5x7(self: [rt.usize, rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.usize, rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/orders/expected/core/result.ts b/ts/fixtures/lang/orders/expected/core/result.ts new file mode 100644 index 000000000..756da4648 --- /dev/null +++ b/ts/fixtures/lang/orders/expected/core/result.ts @@ -0,0 +1,115 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import { cmp$175ka5q as poll_cmp$175ka5q } from "../core/task/poll.ts"; +import * as Part from "../orders.Part.ts"; + +export function eq$15zrpyn(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return self.value === (other as { ok: true; value: rt.f64 }).value; + } + return self.error === (other as { ok: false; error: rt.f64 }).error; +} + +export function eq$1faqxpo(self: rt.Result, other: rt.Result): boolean { + if (!((self.ok ? 0 : 1) === (other.ok ? 0 : 1))) { + return false; + } + if (self.ok) { + return Part.eq$cmp_PartialEq(self.value, (other as { ok: true; value: Part.Part }).value); + } + return Part.eq$cmp_PartialEq(self.error, (other as { ok: false; error: Part.Part }).error); +} + +export function partialCmp$08on5x6(self: rt.Result, rt.u8>, other: rt.Result, rt.u8>): rt.Ordering | undefined { + if (self.ok) { + if (other.ok) { + return rt.cmpDeque(Part.partialCmp$cmp_PartialOrd)(self.value, other.value); + } + } else if (!other.ok) { + return rt.cmp(self.error, other.error); + } + return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); +} + +export function partialCmp$0v2kxbo(self: rt.Result, other: rt.Result): rt.Ordering | undefined { + if (self.ok) { + if (other.ok) { + return rt.f64PartialCmp(self.value, other.value); + } + } else if (!other.ok) { + return rt.f64PartialCmp(self.error, other.error); + } + return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); +} + +export function partialCmp$0spmpix(self: rt.Result, other: rt.Result): rt.Ordering | undefined { + if (self.ok) { + if (other.ok) { + return Part.partialCmp$cmp_PartialOrd(self.value, other.value); + } + } else if (!other.ok) { + return Part.partialCmp$cmp_PartialOrd(self.error, other.error); + } + return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); +} + +export function partialCmp$0hea5es(self: rt.Result, other: rt.Result): rt.Ordering | undefined { + if (self.ok) { + if (other.ok) { + return rt.cmp(self.value, other.value); + } + } else if (!other.ok) { + return rt.cmp(self.error, other.error); + } + return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); +} + +export function cmp$0nb553d(self: rt.Result, rt.Poll>, other: rt.Result, rt.Poll>): rt.Ordering { + if (self.ok) { + if (other.ok) { + return rt.cmpDeque(rt.cmp)(self.value, other.value); + } + } else if (!other.ok) { + return poll_cmp$175ka5q(self.error, other.error); + } + return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); +} + +export function cmp$0h5rzdg(self: rt.Result, other: rt.Result): rt.Ordering { + if (self.ok) { + if (other.ok) { + return Part.cmp$cmp_Ord(self.value, other.value); + } + } else if (!other.ok) { + return Part.cmp$cmp_Ord(self.error, other.error); + } + return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); +} + +export function cmp$0qsbu3y(self: rt.Result<[Part.Part], rt.u8>, other: rt.Result<[Part.Part], rt.u8>): rt.Ordering { + if (self.ok) { + if (other.ok) { + return rt.cmpTuple<[Part.Part], rt.Ordering>([Part.cmp$cmp_Ord])(self.value, other.value); + } + } else if (!other.ok) { + return rt.cmp(self.error, other.error); + } + return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); +} + +export function cmp$06akmd5(self: rt.Result, other: rt.Result): rt.Ordering { + if (self.ok) { + if (other.ok) { + return rt.cmp(self.value, other.value); + } + } else if (!other.ok) { + return rt.cmp(self.error, other.error); + } + return rt.cmp(self.ok ? 0 : 1, other.ok ? 0 : 1); +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/expected/core/task/poll.ts b/ts/fixtures/lang/orders/expected/core/task/poll.ts similarity index 100% rename from ts/fixtures/lang/expected/core/task/poll.ts rename to ts/fixtures/lang/orders/expected/core/task/poll.ts diff --git a/ts/fixtures/lang/orders/expected/harness.ts b/ts/fixtures/lang/orders/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/orders/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/orders/expected/lib.ts b/ts/fixtures/lang/orders/expected/lib.ts new file mode 100644 index 000000000..9dd96a562 --- /dev/null +++ b/ts/fixtures/lang/orders/expected/lib.ts @@ -0,0 +1,24 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { orders, bytes, tuples, held, btrees } from "./orders.ts"; + +export function copy$tuple2_u8_u8(v: [rt.u8, rt.u8]): [rt.u8, rt.u8] { + return [v[0], v[1]]; +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["orders::orders", orders as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["orders::bytes", (_22: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + bytes(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["orders::held", (_23: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + held(data2, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["orders::tuples", (_24: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + tuples(data3, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["orders::btrees", btrees as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/orders.Apart.ts b/ts/fixtures/lang/orders/expected/orders.Apart.ts similarity index 74% rename from ts/fixtures/lang/expected/orders.Apart.ts rename to ts/fixtures/lang/orders/expected/orders.Apart.ts index 8312ace52..2d16e8e7a 100644 --- a/ts/fixtures/lang/expected/orders.Apart.ts +++ b/ts/fixtures/lang/orders/expected/orders.Apart.ts @@ -1,19 +1,19 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { log as orders_log } from "./orders.ts"; +import { log } from "./orders.ts"; /** Zero-sized, equal by `cmp` and never by `==`. */ export interface Apart { } export function eq$cmp_PartialEq(_self: Apart, _2: Apart): boolean { - orders_log(Uint8Array.of(61, 0, 0)); + log(Uint8Array.of(61, 0, 0)); return false; } export function cmp$cmp_Ord(_self: Apart, _2: Apart): rt.Ordering { - orders_log(Uint8Array.of(99, 0, 0)); + log(Uint8Array.of(99, 0, 0)); return 0; } diff --git a/ts/fixtures/lang/expected/orders.Item.ts b/ts/fixtures/lang/orders/expected/orders.Item.ts similarity index 75% rename from ts/fixtures/lang/expected/orders.Item.ts rename to ts/fixtures/lang/orders/expected/orders.Item.ts index 42b88abe8..861234d12 100644 --- a/ts/fixtures/lang/expected/orders.Item.ts +++ b/ts/fixtures/lang/orders/expected/orders.Item.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { log as orders_log } from "./orders.ts"; +import { log } from "./orders.ts"; /** * Ordered by `key` alone, so `tag` tells equal ones apart. Each comparison logs which it @@ -22,21 +22,21 @@ export class Item { } export function drop$ops_Drop(self: Item): void { - orders_log(Uint8Array.of(100, self.tag, 0)); + log(Uint8Array.of(100, self.tag, 0)); } export function lt$cmp_PartialOrd(self: Item, other: Item): boolean { - orders_log(Uint8Array.of(60, self.tag, other.tag)); + log(Uint8Array.of(60, self.tag, other.tag)); return self.key < other.key; } export function le$cmp_PartialOrd(self: Item, other: Item): boolean { - orders_log(Uint8Array.of(108, self.tag, other.tag)); + log(Uint8Array.of(108, self.tag, other.tag)); return self.key <= other.key; } export function ge$cmp_PartialOrd(self: Item, other: Item): boolean { - orders_log(Uint8Array.of(103, self.tag, other.tag)); + log(Uint8Array.of(103, self.tag, other.tag)); return self.key >= other.key; } diff --git a/ts/fixtures/lang/expected/orders.Part.ts b/ts/fixtures/lang/orders/expected/orders.Part.ts similarity index 80% rename from ts/fixtures/lang/expected/orders.Part.ts rename to ts/fixtures/lang/orders/expected/orders.Part.ts index 0a51d66fd..870fa0802 100644 --- a/ts/fixtures/lang/expected/orders.Part.ts +++ b/ts/fixtures/lang/orders/expected/orders.Part.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { log as orders_log } from "./orders.ts"; +import { log } from "./orders.ts"; /** * Ordered by `PartialOrd` by its key, but not at all where either key is 7, and by `Ord` @@ -14,13 +14,13 @@ export interface Part { } export function eq$cmp_PartialEq(self: Part, other: Part): boolean { - orders_log(Uint8Array.of(61, self.tag, other.tag)); + log(Uint8Array.of(61, self.tag, other.tag)); return self.key === other.key; } export function partialCmp$cmp_PartialOrd(self: Part, other: Part): rt.Ordering | undefined { let _7!: boolean; - orders_log(Uint8Array.of(112, self.tag, other.tag)); + log(Uint8Array.of(112, self.tag, other.tag)); if (!(self.key === 7)) { _7 = other.key === 7; } else { @@ -33,7 +33,7 @@ export function partialCmp$cmp_PartialOrd(self: Part, other: Part): rt.Ordering } export function cmp$cmp_Ord(self: Part, other: Part): rt.Ordering { - orders_log(Uint8Array.of(99, self.tag, other.tag)); + log(Uint8Array.of(99, self.tag, other.tag)); return rt.cmp(other.key, self.key); } diff --git a/ts/fixtures/lang/expected/orders.Torn.ts b/ts/fixtures/lang/orders/expected/orders.Torn.ts similarity index 85% rename from ts/fixtures/lang/expected/orders.Torn.ts rename to ts/fixtures/lang/orders/expected/orders.Torn.ts index 298c96109..8275389a9 100644 --- a/ts/fixtures/lang/expected/orders.Torn.ts +++ b/ts/fixtures/lang/orders/expected/orders.Torn.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { log as orders_log } from "./orders.ts"; +import { log } from "./orders.ts"; /** * A key whose `Ord` orders by `key`, and whose `PartialOrd` and `PartialEq` judge by @@ -41,22 +41,22 @@ function class_(self: Torn): rt.u16 { } export function ne$cmp_PartialEq(self: Torn, other: Torn): boolean { - orders_log(Uint8Array.of(33, self.tag, other.tag)); + log(Uint8Array.of(33, self.tag, other.tag)); return class_(self) !== class_(other); } export function partialCmp$cmp_PartialOrd(self: Torn, other: Torn): rt.Ordering | undefined { - orders_log(Uint8Array.of(112, self.tag, other.tag)); + log(Uint8Array.of(112, self.tag, other.tag)); return rt.cmp(rank(self), rank(other)); } export function lt$cmp_PartialOrd(self: Torn, other: Torn): boolean { - orders_log(Uint8Array.of(60, self.tag, other.tag)); + log(Uint8Array.of(60, self.tag, other.tag)); return rank(self) < rank(other); } export function cmp$cmp_Ord(self: Torn, other: Torn): rt.Ordering { - orders_log(Uint8Array.of(99, self.tag, other.tag)); + log(Uint8Array.of(99, self.tag, other.tag)); return rt.cmp(self.key, other.key); } diff --git a/ts/fixtures/lang/expected/orders.ts b/ts/fixtures/lang/orders/expected/orders.ts similarity index 90% rename from ts/fixtures/lang/expected/orders.ts rename to ts/fixtures/lang/orders/expected/orders.ts index aa97efa72..aa7ba1c57 100644 --- a/ts/fixtures/lang/expected/orders.ts +++ b/ts/fixtures/lang/orders/expected/orders.ts @@ -8,7 +8,7 @@ import { unwrapOr$0l1fs14 as option_unwrapOr$0l1fs14, map$0isl2bb as option_map$ import { eq$15zrpyn as result_eq$15zrpyn, eq$1faqxpo as result_eq$1faqxpo, partialCmp$08on5x6 as result_partialCmp$08on5x6, partialCmp$0v2kxbo as result_partialCmp$0v2kxbo, partialCmp$0spmpix as result_partialCmp$0spmpix, partialCmp$0hea5es as result_partialCmp$0hea5es, cmp$0nb553d as result_cmp$0nb553d, cmp$0h5rzdg as result_cmp$0h5rzdg, cmp$0qsbu3y as result_cmp$0qsbu3y, cmp$06akmd5 as result_cmp$06akmd5 } from "./core/result.ts"; import { eq$1h9nnoh as poll_eq$1h9nnoh, cmp$175ka5q as poll_cmp$175ka5q, partialCmp$1fsj76o as poll_partialCmp$1fsj76o, partialCmp$1r9dhkr as poll_partialCmp$1r9dhkr } from "./core/task/poll.ts"; import * as Apart from "./orders.Apart.ts"; -import * as orders_Item from "./orders.Item.ts"; +import * as Item from "./orders.Item.ts"; import * as Part from "./orders.Part.ts"; import * as Torn from "./orders.Torn.ts"; @@ -33,8 +33,8 @@ export function flush(out: rt.ByteVec): void { }); } -export function item(tag: rt.usize, key: rt.u8): orders_Item.Item { - return new orders_Item.Item(rt.u8Rem(key, 8), tag & 0xff); +export function item(tag: rt.usize, key: rt.u8): Item.Item { + return new Item.Item(rt.u8Rem(key, 8), tag & 0xff); } /** Run one case. */ @@ -79,41 +79,41 @@ export function cmps(dataData: Uint8Array, dataStart: number, dataLen: number, o const s: string = _32[0]; const t: string = _32[1]; rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(rt.stringLen(max$17dwnpn(s, t)) & 0xff, rt.stringLen(min$1ljcpv9(s, t)) & 0xff)), undefined, true); - const _55: [orders_Item.Item, orders_Item.Item] = [item(rt.usizeMul(2, i), a), item(rt.usizeAdd(rt.usizeMul(2, i), 1), b)]; - const x: orders_Item.Item = _55[0]; - const y: orders_Item.Item = _55[1]; + const _55: [Item.Item, Item.Item] = [item(rt.usizeMul(2, i), a), item(rt.usizeAdd(rt.usizeMul(2, i), 1), b)]; + const x: Item.Item = _55[0]; + const y: Item.Item = _55[1]; rt.byteVecPush(out, max$0bn3iky(x, y).tag); rt.byteVecPush(out, min$0tn2vhs(x, y).tag); - const _76: orders_Item.Item = max$1tkcqvz(x, y); + const _76: Item.Item = max$1tkcqvz(x, y); rt.byteVecPush(out, _76.tag); _76[Symbol.dispose](); - const pair: () => [orders_Item.Item, orders_Item.Item] = (): [orders_Item.Item, orders_Item.Item] => { - return [item(rt.usizeMul(2, i), a), item(rt.usizeAdd(rt.usizeMul(2, i), 1), b)] as [orders_Item.Item, orders_Item.Item]; + const pair: () => [Item.Item, Item.Item] = (): [Item.Item, Item.Item] => { + return [item(rt.usizeMul(2, i), a), item(rt.usizeAdd(rt.usizeMul(2, i), 1), b)] as [Item.Item, Item.Item]; }; - const _83: [orders_Item.Item, orders_Item.Item] = pair(); - const _87: orders_Item.Item = min$1f8m2y1(_83[0], _83[1]); + const _83: [Item.Item, Item.Item] = pair(); + const _87: Item.Item = min$1f8m2y1(_83[0], _83[1]); rt.byteVecPush(out, _87.tag); _87[Symbol.dispose](); - const _90: [orders_Item.Item, orders_Item.Item] = pair(); - const _94: orders_Item.Item = maxBy$04pyy5s(_90[0], _90[1], (l: orders_Item.Item, r: orders_Item.Item): rt.Ordering => { + const _90: [Item.Item, Item.Item] = pair(); + const _94: Item.Item = maxBy$04pyy5s(_90[0], _90[1], (l: Item.Item, r: Item.Item): rt.Ordering => { return rt.orderingReverse(rt.cmp(l.key, r.key)); }); rt.byteVecPush(out, _94.tag); _94[Symbol.dispose](); - const _97: [orders_Item.Item, orders_Item.Item] = pair(); - const _101: orders_Item.Item = minBy$0f4msyz(_97[0], _97[1], (l2: orders_Item.Item, r2: orders_Item.Item): rt.Ordering => { + const _97: [Item.Item, Item.Item] = pair(); + const _101: Item.Item = minBy$0f4msyz(_97[0], _97[1], (l2: Item.Item, r2: Item.Item): rt.Ordering => { return rt.cmp(rt.u8Div(l2.key, 2), rt.u8Div(r2.key, 2)); }); rt.byteVecPush(out, _101.tag); _101[Symbol.dispose](); - const _104: [orders_Item.Item, orders_Item.Item] = pair(); - const _108: orders_Item.Item = maxByKey$1a9sf4b(_104[0], _104[1], (v: orders_Item.Item): orders_Item.Item => { + const _104: [Item.Item, Item.Item] = pair(); + const _108: Item.Item = maxByKey$1a9sf4b(_104[0], _104[1], (v: Item.Item): Item.Item => { return item(rt.usizeAdd(v.tag as rt.usize, 100), rt.u8Div(v.key, 2)); }); rt.byteVecPush(out, _108.tag); _108[Symbol.dispose](); - const _111: [orders_Item.Item, orders_Item.Item] = pair(); - const _115: orders_Item.Item = minByKey$04nvnd5(_111[0], _111[1], (v2: orders_Item.Item): rt.u8 => { + const _111: [Item.Item, Item.Item] = pair(); + const _115: Item.Item = minByKey$04nvnd5(_111[0], _111[1], (v2: Item.Item): rt.u8 => { return v2.key; }); rt.byteVecPush(out, _115.tag); @@ -127,7 +127,7 @@ export function cmps(dataData: Uint8Array, dataStart: number, dataLen: number, o * and sorted: each test std makes, and each item or key it drops. */ export function sorted(data: rt.ByteSlice, out: rt.ByteVec): void { - const _77: () => orders_Item.Item = (): orders_Item.Item => { + const _77: () => Item.Item = (): Item.Item => { return item(200, 0); }; const ascending: rt.ByteVec = rt.byteSliceToByteVec(data); @@ -140,47 +140,47 @@ export function sorted(data: rt.ByteSlice, out: rt.ByteVec): void { if (_12 === rt.DONE) { break; } - const items: () => rt.Iter = (): rt.Iter => { - return rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(_12))), (_24: [rt.usize, rt.u8]): orders_Item.Item => { + const items: () => rt.Iter = (): rt.Iter => { + return rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(_12))), (_24: [rt.usize, rt.u8]): Item.Item => { return item(_24[0], _24[1]); }); }; - const v: orders_Item.Item[] = rt.iterToArray(items(), undefined, 2, true); - rt.byteVecPush(out, rt.sliceIsSorted(v, orders_Item.le$cmp_PartialOrd) ? 1 : 0); - rt.byteVecPush(out, rt.iterIsSortedBy(rt.iterSlice(v), (a: orders_Item.Item, b3: orders_Item.Item): boolean => { + const v: Item.Item[] = rt.iterToArray(items(), undefined, 2, true); + rt.byteVecPush(out, rt.sliceIsSorted(v, Item.le$cmp_PartialOrd) ? 1 : 0); + rt.byteVecPush(out, rt.iterIsSortedBy(rt.iterSlice(v), (a: Item.Item, b3: Item.Item): boolean => { return a.key >= b3.key; }) ? 1 : 0); - rt.byteVecPush(out, rt.iterIsSortedBy(rt.iterMap(rt.iterSlice(v), (x: orders_Item.Item): orders_Item.Item => { + rt.byteVecPush(out, rt.iterIsSortedBy(rt.iterMap(rt.iterSlice(v), (x: Item.Item): Item.Item => { return item(rt.usizeAdd(x.tag as rt.usize, 100), rt.u8Div(x.key, 2)); - }), orders_Item.le$cmp_PartialOrd, undefined, rt.drop) ? 1 : 0); - rt.byteVecPush(out, rt.iterIsSortedBy(rt.iterSlice(v), orders_Item.le$cmp_PartialOrd) ? 1 : 0); - rt.byteVecPush(out, rt.iterIsSortedBy(rt.iterMap(rt.iterSlice(rt.sliceRange(v, 0, rt.usizeDiv(v.length, 2))), (x2: orders_Item.Item): rt.u8 => { + }), Item.le$cmp_PartialOrd, undefined, rt.drop) ? 1 : 0); + rt.byteVecPush(out, rt.iterIsSortedBy(rt.iterSlice(v), Item.le$cmp_PartialOrd) ? 1 : 0); + rt.byteVecPush(out, rt.iterIsSortedBy(rt.iterMap(rt.iterSlice(rt.sliceRange(v, 0, rt.usizeDiv(v.length, 2))), (x2: Item.Item): rt.u8 => { return x2.key; }), rt.le) ? 1 : 0); rt.dropAll(v); flush(out); - rt.byteVecPush(out, rt.iterIsSortedBy(items(), orders_Item.le$cmp_PartialOrd, undefined, rt.drop) ? 1 : 0); - rt.byteVecPush(out, rt.iterIsSortedBy(items(), (a2: orders_Item.Item, b4: orders_Item.Item): boolean => { + rt.byteVecPush(out, rt.iterIsSortedBy(items(), Item.le$cmp_PartialOrd, undefined, rt.drop) ? 1 : 0); + rt.byteVecPush(out, rt.iterIsSortedBy(items(), (a2: Item.Item, b4: Item.Item): boolean => { if (!(a2.tag > b4.tag)) { return a2.key <= b4.key; } return true; }, undefined, rt.drop) ? 1 : 0); - rt.byteVecPush(out, rt.iterIsSortedBy(rt.iterMap(items(), (x3: orders_Item.Item): rt.u8 => { + rt.byteVecPush(out, rt.iterIsSortedBy(rt.iterMap(items(), (x3: Item.Item): rt.u8 => { const _09: rt.u8 = x3.key; x3[Symbol.dispose](); return _09; }), rt.cmpLe(rt.cmpReverse(rt.cmp))) ? 1 : 0); - rt.byteVecPush(out, rt.iterIsSortedBy(rt.iterSlice(rt.iterToArray(items(), undefined, 2, true), rt.drop), orders_Item.le$cmp_PartialOrd, true, rt.drop) ? 1 : 0); + rt.byteVecPush(out, rt.iterIsSortedBy(rt.iterSlice(rt.iterToArray(items(), undefined, 2, true), rt.drop), Item.le$cmp_PartialOrd, true, rt.drop) ? 1 : 0); flush(out); - const _82: [orders_Item.Item, orders_Item.Item, orders_Item.Item, orders_Item.Item] = [_77(), _77(), _77(), _77()]; - const g: orders_Item.Item = _82[0]; - const h: orders_Item.Item = _82[1]; - const k: orders_Item.Item = _82[2]; - const l: orders_Item.Item = _82[3]; - const _94: rt.Iter = items(); + const _82: [Item.Item, Item.Item, Item.Item, Item.Item] = [_77(), _77(), _77(), _77()]; + const g: Item.Item = _82[0]; + const h: Item.Item = _82[1]; + const k: Item.Item = _82[2]; + const l: Item.Item = _82[3]; + const _94: rt.Iter = items(); const captured = g; - rt.byteVecPush(out, rt.iterIsSortedBy(_94, rt.closure((a3: orders_Item.Item, b5: orders_Item.Item): boolean => { + rt.byteVecPush(out, rt.iterIsSortedBy(_94, rt.closure((a3: Item.Item, b5: Item.Item): boolean => { if (!(captured.key <= a3.key)) { return false; } @@ -188,16 +188,16 @@ export function sorted(data: rt.ByteSlice, out: rt.ByteVec): void { }, (): void => { captured[Symbol.dispose](); }), undefined, rt.drop, rt.drop) ? 1 : 0); - const _103: rt.Iter = rt.iterSlice(rt.iterToArray(items(), undefined, 2, true), rt.drop); + const _103: rt.Iter = rt.iterSlice(rt.iterToArray(items(), undefined, 2, true), rt.drop); const captured2 = h; - rt.byteVecPush(out, rt.iterIsSortedBy(_103, rt.closure((a4: orders_Item.Item, b6: orders_Item.Item): boolean => { + rt.byteVecPush(out, rt.iterIsSortedBy(_103, rt.closure((a4: Item.Item, b6: Item.Item): boolean => { return a4.key <= rt.u8Add(b6.key, captured2.key); }, (): void => { captured2[Symbol.dispose](); }), true, rt.drop, rt.drop) ? 1 : 0); - const _108: rt.Iter = items(); + const _108: rt.Iter = items(); const captured3 = k; - rt.byteVecPush(out, rt.iterIsSortedBy(rt.iterMap(_108, rt.closure((x4: orders_Item.Item): rt.u8 => { + rt.byteVecPush(out, rt.iterIsSortedBy(rt.iterMap(_108, rt.closure((x4: Item.Item): rt.u8 => { const _012: rt.u8 = rt.u8Add(x4.key, captured3.key); x4[Symbol.dispose](); return _012; @@ -205,7 +205,7 @@ export function sorted(data: rt.ByteSlice, out: rt.ByteVec): void { captured3[Symbol.dispose](); })), rt.le, true) ? 1 : 0); const captured4 = l; - const key: (a0: orders_Item.Item) => rt.u8 = rt.closure((x5: orders_Item.Item): rt.u8 => { + const key: (a0: Item.Item) => rt.u8 = rt.closure((x5: Item.Item): rt.u8 => { const _013: rt.u8 = rt.u8Add(x5.key, captured4.key); x5[Symbol.dispose](); return _013; @@ -239,8 +239,8 @@ export function sorted(data: rt.ByteSlice, out: rt.ByteVec): void { export function heaps(data: rt.ByteSlice, out: rt.ByteVec): void { let _127: boolean = false; let _128: boolean = false; - let heap: rt.BinaryHeap = rt.heapNew() as rt.BinaryHeap; - const other: rt.BinaryHeap = rt.heapWithCapacity(4, 2) as rt.BinaryHeap; + let heap: rt.BinaryHeap = rt.heapNew() as rt.BinaryHeap; + const other: rt.BinaryHeap = rt.heapWithCapacity(4, 2) as rt.BinaryHeap; const ops: rt.Iter<[rt.usize, rt.u8]> = rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(data))); while (true) { const _8: [rt.usize, rt.u8] | rt.Done = ops.next(); @@ -254,21 +254,21 @@ export function heaps(data: rt.ByteSlice, out: rt.ByteVec): void { const _17: rt.u8 = rt.u8Rem(op, 12); if (0 <= _17) { if (_17 <= 2) { - rt.heapPush(heap, item(i, v), orders_Item.le$cmp_PartialOrd); + rt.heapPush(heap, item(i, v), Item.le$cmp_PartialOrd); break b2; } } if (_17 === 3) { - rt.byteVecPush(out, option_mapOr$14aggam(rt.heapPop(heap, orders_Item.le$cmp_PartialOrd), 255, (x5: orders_Item.Item): rt.u8 => { + rt.byteVecPush(out, option_mapOr$14aggam(rt.heapPop(heap, Item.le$cmp_PartialOrd), 255, (x5: Item.Item): rt.u8 => { const _06: rt.u8 = x5.tag; x5[Symbol.dispose](); return _06; })); } else if (_17 === 4) { - const _26: rt.PeekMut | undefined = rt.heapPeekMut(heap, orders_Item.le$cmp_PartialOrd, orders_Item.ge$cmp_PartialOrd, orders_Item.lt$cmp_PartialOrd); + const _26: rt.PeekMut | undefined = rt.heapPeekMut(heap, Item.le$cmp_PartialOrd, Item.ge$cmp_PartialOrd, Item.lt$cmp_PartialOrd); if (_26 !== undefined) { _127 = true; - const top: rt.PeekMut = _26; + const top: rt.PeekMut = _26; rt.peekMutDerefMut(top); top.v.key = rt.u8Rem(v, 8); if ((v & 16) !== 0) { @@ -280,25 +280,25 @@ export function heaps(data: rt.ByteSlice, out: rt.ByteVec): void { _127 = false; } } else if (_17 === 5) { - const _37: rt.PeekMut | undefined = rt.heapPeekMut(heap, orders_Item.le$cmp_PartialOrd, orders_Item.ge$cmp_PartialOrd, orders_Item.lt$cmp_PartialOrd); + const _37: rt.PeekMut | undefined = rt.heapPeekMut(heap, Item.le$cmp_PartialOrd, Item.ge$cmp_PartialOrd, Item.lt$cmp_PartialOrd); if (_37 !== undefined) { _128 = true; - const top2: rt.PeekMut = _37; + const top2: rt.PeekMut = _37; const _41: rt.u8 = rt.u8Rem(v, 3); if (_41 === 0) { _128 = false; - const _44: orders_Item.Item = rt.peekMutPop(top2); + const _44: Item.Item = rt.peekMutPop(top2); rt.byteVecPush(out, _44.tag); _44[Symbol.dispose](); } else if (_41 === 1) { rt.byteVecPush(out, top2.v.tag); } else { _128 = false; - const top3: rt.PeekMut = top2; + const top3: rt.PeekMut = top2; rt.peekMutDerefMut(top3); - const _50: orders_Item.Item = top3.v; + const _50: Item.Item = top3.v; _50.tag = _50.tag ^ 64; - const _54: orders_Item.Item = rt.peekMutPop(top3); + const _54: Item.Item = rt.peekMutPop(top3); rt.byteVecPush(out, _54.tag); _54[Symbol.dispose](); } @@ -308,32 +308,32 @@ export function heaps(data: rt.ByteSlice, out: rt.ByteVec): void { _128 = false; } } else if (_17 === 6) { - const _57: orders_Item.Item = item(i, v); - rt.heapPush(other, _57, orders_Item.le$cmp_PartialOrd); + const _57: Item.Item = item(i, v); + rt.heapPush(other, _57, Item.le$cmp_PartialOrd); } else if (_17 === 7) { - rt.heapAppend(heap, other, orders_Item.le$cmp_PartialOrd, orders_Item.ge$cmp_PartialOrd, orders_Item.lt$cmp_PartialOrd); + rt.heapAppend(heap, other, Item.le$cmp_PartialOrd, Item.ge$cmp_PartialOrd, Item.lt$cmp_PartialOrd); } else if (_17 === 8) { - rt.heapRetain(heap, (x4: orders_Item.Item): boolean => { + rt.heapRetain(heap, (x4: Item.Item): boolean => { return x4.key !== rt.u8Rem(v, 8); - }, orders_Item.le$cmp_PartialOrd, orders_Item.ge$cmp_PartialOrd, orders_Item.lt$cmp_PartialOrd, rt.drop); + }, Item.le$cmp_PartialOrd, Item.ge$cmp_PartialOrd, Item.lt$cmp_PartialOrd, rt.drop); } else if (_17 === 9) { - rt.heapExtend(heap, rt.iterMap(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), rt.usizeRem(v as rt.usize, 6)), (_28: rt.u8): orders_Item.Item => { + rt.heapExtend(heap, rt.iterMap(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), rt.usizeRem(v as rt.usize, 6)), (_28: rt.u8): Item.Item => { return item(rt.usizeAdd(i, 50), _28); - }), orders_Item.le$cmp_PartialOrd, orders_Item.ge$cmp_PartialOrd, orders_Item.lt$cmp_PartialOrd, undefined, 2, true); + }), Item.le$cmp_PartialOrd, Item.ge$cmp_PartialOrd, Item.lt$cmp_PartialOrd, undefined, 2, true); } else if (_17 === 10) { - const sorted: orders_Item.Item[] = rt.heapIntoSortedVec(rt.replaceIn(heap, rt.heapNew() as rt.BinaryHeap), orders_Item.le$cmp_PartialOrd, orders_Item.ge$cmp_PartialOrd, orders_Item.lt$cmp_PartialOrd); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(sorted), (x3: orders_Item.Item): rt.u8 => { + const sorted: Item.Item[] = rt.heapIntoSortedVec(rt.replaceIn(heap, rt.heapNew() as rt.BinaryHeap), Item.le$cmp_PartialOrd, Item.ge$cmp_PartialOrd, Item.lt$cmp_PartialOrd); + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(sorted), (x3: Item.Item): rt.u8 => { return x3.tag; }), undefined, true); flush(out); - const _81: rt.BinaryHeap = rt.heapFrom(sorted, orders_Item.le$cmp_PartialOrd, orders_Item.ge$cmp_PartialOrd, orders_Item.lt$cmp_PartialOrd); + const _81: rt.BinaryHeap = rt.heapFrom(sorted, Item.le$cmp_PartialOrd, Item.ge$cmp_PartialOrd, Item.lt$cmp_PartialOrd); rt.heapDrop(heap, rt.drop); heap = _81; } else { - rt.iterExtendBytes(out, rt.iterMap(rt.heapIter(heap), (x: orders_Item.Item): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.heapIter(heap), (x: Item.Item): rt.u8 => { return x.tag; }), "next"); - rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(option_mapOr$14aggam(heap.d[0], 255, (x2: orders_Item.Item): rt.u8 => { + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(option_mapOr$14aggam(heap.d[0], 255, (x2: Item.Item): rt.u8 => { return x2.tag; }), heap.d.length & 0xff, heap.d.length === 0 ? 1 : 0)), undefined, true); } @@ -343,24 +343,24 @@ export function heaps(data: rt.ByteSlice, out: rt.ByteVec): void { break; } } - const drain: rt.Iter = rt.heapDrain(heap, rt.drop); - rt.byteVecPush(out, option_mapOr$14aggam(rt.iterToOption(drain.next()), 255, (x6: orders_Item.Item): rt.u8 => { + const drain: rt.Iter = rt.heapDrain(heap, rt.drop); + rt.byteVecPush(out, option_mapOr$14aggam(rt.iterToOption(drain.next()), 255, (x6: Item.Item): rt.u8 => { const _07: rt.u8 = x6.tag; x6[Symbol.dispose](); return _07; })); rt.drop(drain); flush(out); - const collected: rt.BinaryHeap = rt.heapFrom(rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(data))), (_29: [rt.usize, rt.u8]): orders_Item.Item => { + const collected: rt.BinaryHeap = rt.heapFrom(rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(data))), (_29: [rt.usize, rt.u8]): Item.Item => { return item(_29[0], _29[1]); - }), undefined, 2, true), orders_Item.le$cmp_PartialOrd, orders_Item.ge$cmp_PartialOrd, orders_Item.lt$cmp_PartialOrd); - rt.byteVecPush(out, option_mapOr$14aggam(rt.heapPop(collected, orders_Item.le$cmp_PartialOrd), 255, (x7: orders_Item.Item): rt.u8 => { + }), undefined, 2, true), Item.le$cmp_PartialOrd, Item.ge$cmp_PartialOrd, Item.lt$cmp_PartialOrd); + rt.byteVecPush(out, option_mapOr$14aggam(rt.heapPop(collected, Item.le$cmp_PartialOrd), 255, (x7: Item.Item): rt.u8 => { const _09: rt.u8 = x7.tag; x7[Symbol.dispose](); return _09; })); - const rest: rt.Iter = rt.heapIter(collected, rt.drop); - rt.byteVecPush(out, option_mapOr$14aggam(rt.iterToOption(rest.next()), 255, (x8: orders_Item.Item): rt.u8 => { + const rest: rt.Iter = rt.heapIter(collected, rt.drop); + rt.byteVecPush(out, option_mapOr$14aggam(rt.iterToOption(rest.next()), 255, (x8: Item.Item): rt.u8 => { const _010: rt.u8 = x8.tag; x8[Symbol.dispose](); return _010; @@ -1244,13 +1244,13 @@ export function btrees(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(rt.btreeLen(set2) & 0xff, rt.btreeLen(units) & 0xff, rt.btreeLen(map2) & 0xff)), undefined, true); rt.iterExtendBytes(out, rt.btreeValues(map2), undefined, true); flush(out); - const _211: rt.Iter<[undefined | rt.None, orders_Item.Item]> = rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(data))), (_217: [rt.usize, rt.u8]): [undefined | rt.None, orders_Item.Item] => { + const _211: rt.Iter<[undefined | rt.None, Item.Item]> = rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(data))), (_217: [rt.usize, rt.u8]): [undefined | rt.None, Item.Item] => { const i4: rt.usize = _217[0]; const b14: rt.u8 = _217[1]; - return [thenSome$1d6toqn(rt.u8Rem(b14, 2) === 0, undefined), item(i4, b14)] as [undefined | rt.None, orders_Item.Item]; + return [thenSome$1d6toqn(rt.u8Rem(b14, 2) === 0, undefined), item(i4, b14)] as [undefined | rt.None, Item.Item]; }); - const phantoms: rt.BTreeMap = rt.btreeCollect(rt.btreeNew(rt.cmpOption(rt.cmpNothing, rt.None)) as rt.BTreeMap, rt.iterToArray(_211, undefined, 3, true), 3, true, undefined, undefined, rt.drop); - rt.iterExtendBytes(out, rt.iterMap(rt.btreeValues(phantoms), (x: orders_Item.Item): rt.u8 => { + const phantoms: rt.BTreeMap = rt.btreeCollect(rt.btreeNew(rt.cmpOption(rt.cmpNothing, rt.None)) as rt.BTreeMap, rt.iterToArray(_211, undefined, 3, true), 3, true, undefined, undefined, rt.drop); + rt.iterExtendBytes(out, rt.iterMap(rt.btreeValues(phantoms), (x: Item.Item): rt.u8 => { return x.tag; }), undefined, true); rt.btreeDrop(phantoms, undefined, rt.drop); diff --git a/ts/fixtures/lang/orders/src/lib.rs b/ts/fixtures/lang/orders/src/lib.rs new file mode 100644 index 000000000..20b7acd53 --- /dev/null +++ b/ts/fixtures/lang/orders/src/lib.rs @@ -0,0 +1,25 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod orders; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("orders::orders", orders::orders), + ("orders::bytes", |_, data, out| orders::bytes(data, out)), + ("orders::held", |_, data, out| orders::held(data, out)), + ("orders::tuples", |_, data, out| orders::tuples(data, out)), + ("orders::btrees", orders::btrees), + ] +} diff --git a/ts/fixtures/lang/src/orders.rs b/ts/fixtures/lang/orders/src/orders.rs similarity index 100% rename from ts/fixtures/lang/src/orders.rs rename to ts/fixtures/lang/orders/src/orders.rs diff --git a/ts/fixtures/lang/orders/ts.toml b/ts/fixtures/lang/orders/ts.toml new file mode 100644 index 000000000..ea8983186 --- /dev/null +++ b/ts/fixtures/lang/orders/ts.toml @@ -0,0 +1,2 @@ +package = "lang-orders-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/pointers/Cargo.toml b/ts/fixtures/lang/pointers/Cargo.toml new file mode 100644 index 000000000..e4bac57d6 --- /dev/null +++ b/ts/fixtures/lang/pointers/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-pointers-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/pointers/caller.ts b/ts/fixtures/lang/pointers/caller.ts new file mode 100644 index 000000000..3bf736228 --- /dev/null +++ b/ts/fixtures/lang/pointers/caller.ts @@ -0,0 +1,18 @@ +// The inputs `pointers`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `pointers::cells` scripts: each operation on every cell, a number wrapping past its top, a + * struct assigned through `get` and written over, and cells replaced or made and taken out. + */ +const unsafeCells = [ + [0, 248, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15], + [4, 12, 4, 5, 253, 7, 255, 0], + [3, 251, 6, 3, 2, 2, 254], + [], +].map((bytes) => Uint8Array.of(...op("pointers::cells"), 0, ...bytes)); + +export const cases: Uint8Array[] = [...unsafeCells]; diff --git a/ts/fixtures/lang/pointers/expected/core/option.ts b/ts/fixtures/lang/pointers/expected/core/option.ts new file mode 100644 index 000000000..cb29805c9 --- /dev/null +++ b/ts/fixtures/lang/pointers/expected/core/option.ts @@ -0,0 +1,52 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Loaded from "../pointers.Loaded.ts"; +import type * as Pair from "../pointers.Pair.ts"; + +export function unwrapOr$0mkoact(self: Loaded.Loaded | undefined, default_: Loaded.Loaded): Loaded.Loaded { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$1cfrse5(self: Loaded.Loaded | undefined, f: (a0: Loaded.Loaded) => Loaded.Loaded): Loaded.Loaded | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function mapOr$08xz81a(self: Pair.Pair | undefined, default_: rt.u8, f: (a0: Pair.Pair) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1wxcg5q(self: [rt.u8, rt.Arc] | undefined, default_: rt.u8, f: (a0: [rt.u8, rt.Arc]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function filter$0tnmmii(self: rt.u32 | undefined, predicate: (a0: rt.u32) => boolean): rt.u32 | undefined { + if (self !== undefined) { + const x: rt.u32 = self; + if (predicate(x)) { + return x; + } + } + return undefined; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/pointers/expected/harness.ts b/ts/fixtures/lang/pointers/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/pointers/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/pointers/expected/lib.ts b/ts/fixtures/lang/pointers/expected/lib.ts new file mode 100644 index 000000000..5f31eaff7 --- /dev/null +++ b/ts/fixtures/lang/pointers/expected/lib.ts @@ -0,0 +1,238 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { lists, shared, places, unchecked, nested, copies, sentinels, cells, rebound, lapsed, writers, made, segments, uninitRuns, iteratedRuns, besideWritten, waiters, taken, bytes, loaded, reattached, partWritten, aimed } from "./pointers.ts"; +import type * as Aimed from "./pointers.Aimed.ts"; +import type * as ByCall from "./pointers.ByCall.ts"; +import type * as ByClosure from "./pointers.ByClosure.ts"; +import type * as ByObject from "./pointers.ByObject.ts"; +import type * as Duo from "./pointers.Duo.ts"; +import type * as Halves from "./pointers.Halves.ts"; +import type * as Housed from "./pointers.Housed.ts"; +import type * as Inner from "./pointers.Inner.ts"; +import type * as Leaning from "./pointers.Leaning.ts"; +import * as List from "./pointers.List.ts"; +import type * as Outer from "./pointers.Outer.ts"; +import type * as Pair from "./pointers.Pair.ts"; +import type * as Paired from "./pointers.Paired.ts"; + +export function copy$Option_pointers_Pair(v: Pair.Pair | undefined): Pair.Pair | undefined { + return v === undefined ? v : copy$pointers_Pair(v); +} + +export function copy$array_ptr_array4_u8(v: rt.ByteSlice[]): rt.ByteSlice[] { + return v.slice(); +} + +export function copy$array_u16(v: rt.u16[]): rt.u16[] { + return v.slice(); +} + +export function copy$array_u32(v: rt.u32[]): rt.u32[] { + return v.slice(); +} + +export function copy$array_u8(v: Uint8Array): Uint8Array { + return v.slice(); +} + +export function copy$array_unit(v: undefined[]): undefined[] { + return v.slice(); +} + +export function copy$mem_MaybeUninit_array_u32(v: rt.u32[]): rt.u32[] { + if (v === undefined) { + return v; + } + return v.slice(); +} + +export function copy$mem_MaybeUninit_array_u8(v: Uint8Array): Uint8Array { + if (v === undefined) { + return v; + } + return v.slice(); +} + +export function copy$mem_MaybeUninit_tuple2_u8_u8(v: [rt.u8, rt.u8]): [rt.u8, rt.u8] { + if (v === undefined) { + return v; + } + return [v[0], v[1]]; +} + +export function copy$pointers_Aimed_Cell_u8(v: Aimed.Aimed>): Aimed.Aimed> { + return { at: v.at as rt.Place>, seen: v.seen as rt.Place>, held: v.held as rt.Place>, maybe: v.maybe as rt.Place> | undefined, tagged: copy$tuple2_mutPtr_Cell_u8_u8(v.tagged as [rt.Place>, rt.u8]), to: v.to, read: (v.read as (a0: rt.Place>) => rt.u8) as (a0: rt.Ptr>) => rt.u8 }; +} + +export function copy$pointers_Aimed_array2_u16(v: Aimed.Aimed): Aimed.Aimed { + return { at: v.at as rt.u16[], seen: v.seen as rt.u16[], held: v.held as rt.u16[], maybe: v.maybe as rt.u16[] | undefined, tagged: copy$tuple2_mutPtr_array2_u16_u8(v.tagged as [rt.u16[], rt.u8]), to: v.to, read: (v.read as (a0: rt.u16[]) => rt.u8) as (a0: rt.Ptr) => rt.u8 }; +} + +export function copy$pointers_Aimed_array4_u8(v: Aimed.Aimed): Aimed.Aimed { + return { at: v.at as rt.ByteSlice, seen: v.seen as rt.ByteSlice, held: v.held as rt.ByteSlice, maybe: v.maybe as rt.ByteSlice | undefined, tagged: copy$tuple2_mutPtr_array4_u8_u8(v.tagged as [rt.ByteSlice, rt.u8]), to: v.to, read: (v.read as (a0: rt.ByteSlice) => rt.u8) as (a0: rt.Ptr) => rt.u8 }; +} + +export function copy$pointers_Aimed_pointers_Housed_u8(v: Aimed.Aimed>): Aimed.Aimed> { + return { at: v.at as Housed.Housed, seen: v.seen as Housed.Housed, held: v.held as Housed.Housed, maybe: v.maybe as Housed.Housed | undefined, tagged: copy$tuple2_mutPtr_pointers_Housed_u8_u8(v.tagged as [Housed.Housed, rt.u8]), to: v.to, read: (v.read as (a0: Housed.Housed) => rt.u8) as (a0: rt.Ptr>) => rt.u8 }; +} + +export function copy$pointers_Aimed_pointers_Leaning(v: Aimed.Aimed): Aimed.Aimed { + return { at: v.at as rt.Place, seen: v.seen as rt.Place, held: v.held as rt.Place, maybe: v.maybe as rt.Place | undefined, tagged: copy$tuple2_mutPtr_pointers_Leaning_u8(v.tagged as [rt.Place, rt.u8]), to: v.to, read: (v.read as (a0: rt.Place) => rt.u8) as (a0: rt.Ptr) => rt.u8 }; +} + +export function copy$pointers_Aimed_pointers_Paired(v: Aimed.Aimed): Aimed.Aimed { + return { at: v.at as Paired.Paired, seen: v.seen as Paired.Paired, held: v.held as Paired.Paired, maybe: v.maybe as Paired.Paired | undefined, tagged: copy$tuple2_mutPtr_pointers_Paired_u8(v.tagged as [Paired.Paired, rt.u8]), to: v.to, read: (v.read as (a0: Paired.Paired) => rt.u8) as (a0: rt.Ptr) => rt.u8 }; +} + +export function copy$pointers_Aimed_u8(v: Aimed.Aimed): Aimed.Aimed { + return { at: v.at as rt.Place, seen: v.seen as rt.Place, held: v.held as rt.Place, maybe: v.maybe as rt.Place | undefined, tagged: copy$tuple2_mutPtr_u8_u8(v.tagged as [rt.Place, rt.u8]), to: v.to, read: (v.read as (a0: rt.Place) => rt.u8) as (a0: rt.Ptr) => rt.u8 }; +} + +export function copy$pointers_ByCall(v: ByCall.ByCall): ByCall.ByCall { + return { _0: v._0, _1: v._1 }; +} + +export function copy$pointers_ByClosure(v: ByClosure.ByClosure): ByClosure.ByClosure { + return { _0: v._0, _1: v._1 }; +} + +export function copy$pointers_ByObject(v: ByObject.ByObject): ByObject.ByObject { + return { _0: v._0, _1: v._1 }; +} + +export function copy$pointers_Duo(v: Duo.Duo): Duo.Duo { + return { _0: v._0, _1: v._1 }; +} + +export function copy$pointers_Halves(v: Halves.Halves): Halves.Halves { + return ({ at0: copy$mem_MaybeUninit_array_u32(v.at0) } as unknown) as Halves.Halves; +} + +export function copy$pointers_Inner(v: Inner.Inner): Inner.Inner { + return { a: v.a, b: v.b }; +} + +export function copy$pointers_Outer(v: Outer.Outer): Outer.Outer { + return { inner: copy$pointers_Inner(v.inner), pair: copy$tuple2_u32_u32(v.pair), n: v.n }; +} + +export function copy$pointers_Pair(v: Pair.Pair): Pair.Pair { + return { a: v.a, b: v.b }; +} + +export function copy$tuple2_array2_u32_u8(v: [rt.u32[], rt.u8]): [rt.u32[], rt.u8] { + return [copy$array_u32(v[0]), v[1]]; +} + +export function copy$tuple2_mutPtr_Cell_u8_u8(v: [rt.Place>, rt.u8]): [rt.Place>, rt.u8] { + return [v[0], v[1]]; +} + +export function copy$tuple2_mutPtr_array2_u16_u8(v: [rt.u16[], rt.u8]): [rt.u16[], rt.u8] { + return [v[0], v[1]]; +} + +export function copy$tuple2_mutPtr_array4_u8_u8(v: [rt.ByteSlice, rt.u8]): [rt.ByteSlice, rt.u8] { + return [v[0], v[1]]; +} + +export function copy$tuple2_mutPtr_pointers_Housed_u8_u8(v: [Housed.Housed, rt.u8]): [Housed.Housed, rt.u8] { + return [v[0], v[1]]; +} + +export function copy$tuple2_mutPtr_pointers_Leaning_u8(v: [rt.Place, rt.u8]): [rt.Place, rt.u8] { + return [v[0], v[1]]; +} + +export function copy$tuple2_mutPtr_pointers_Paired_u8(v: [Paired.Paired, rt.u8]): [Paired.Paired, rt.u8] { + return [v[0], v[1]]; +} + +export function copy$tuple2_mutPtr_u8_u8(v: [rt.Place, rt.u8]): [rt.Place, rt.u8] { + return [v[0], v[1]]; +} + +export function copy$tuple2_u32_u32(v: [rt.u32, rt.u32]): [rt.u32, rt.u32] { + return [v[0], v[1]]; +} + +export function copy$tuple2_u8_String(v: [rt.u8, string]): [rt.u8, string] { + return [v[0], v[1]]; +} + +export function copy$tuple2_u8_sync_Arc_u8(v: [rt.u8, rt.Arc]): [rt.u8, rt.Arc] { + return [v[0], v[1]]; +} + +export function copy$tuple2_u8_u8(v: [rt.u8, rt.u8]): [rt.u8, rt.u8] { + return [v[0], v[1]]; +} + +export function drop$pointers_List_String(_1: List.List): void { + List.drop$ops_Drop_String(_1); +} + +export function drop$pointers_List_sync_Arc_u8(_1: List.List>): void { + List.drop$ops_Drop_sync_Arc_u8(_1); +} + +export function drop$tuple2_u8_sync_Arc_u8(_1: [rt.u8, rt.Arc]): void { + _1[1][Symbol.dispose](); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["pointers::copies", (_210: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + copies(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::lists", (_211: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + lists(data2.data, data2.start, data2.length, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::nested", (_212: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + nested(data3, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::places", (_213: rt.u8, data4: rt.ByteSlice, out4: rt.ByteVec): undefined => { + places(data4, out4); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::sentinels", (_214: rt.u8, data5: rt.ByteSlice, out5: rt.ByteVec): undefined => { + sentinels(data5, out5); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::shared", (_215: rt.u8, data6: rt.ByteSlice, out6: rt.ByteVec): undefined => { + shared(data6.data, data6.start, data6.length, out6); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::unchecked", (_216: rt.u8, data7: rt.ByteSlice, out7: rt.ByteVec): undefined => { + unchecked(data7, out7); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::cells", (_217: rt.u8, data8: rt.ByteSlice, out8: rt.ByteVec): undefined => { + cells(data8, out8); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::rebound", (_218: rt.u8, data9: rt.ByteSlice, out9: rt.ByteVec): undefined => { + rebound(data9, out9); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::writers", (_219: rt.u8, data10: rt.ByteSlice, out10: rt.ByteVec): undefined => { + writers(data10, out10); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::made", (_220: rt.u8, data11: rt.ByteSlice, out11: rt.ByteVec): undefined => { + made(data11, out11); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::lapsed", (_221: rt.u8, data12: rt.ByteSlice, out12: rt.ByteVec): undefined => { + lapsed(data12, out12); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::segments", (_222: rt.u8, data13: rt.ByteSlice, out13: rt.ByteVec): undefined => { + segments(data13, out13); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::uninit_runs", (_223: rt.u8, data14: rt.ByteSlice, out14: rt.ByteVec): undefined => { + uninitRuns(data14, out14); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::beside_written", (_224: rt.u8, data15: rt.ByteSlice, out15: rt.ByteVec): undefined => { + besideWritten(data15, out15); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::iterated_runs", (_225: rt.u8, data16: rt.ByteSlice, out16: rt.ByteVec): undefined => { + iteratedRuns(data16, out16); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::waiters", (_226: rt.u8, data17: rt.ByteSlice, out17: rt.ByteVec): undefined => { + waiters(data17, out17); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::taken", (_227: rt.u8, data18: rt.ByteSlice, out18: rt.ByteVec): undefined => { + taken(data18, out18); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::bytes", (_228: rt.u8, data19: rt.ByteSlice, out19: rt.ByteVec): undefined => { + bytes(data19, out19); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::loaded", (_229: rt.u8, data20: rt.ByteSlice, out20: rt.ByteVec): undefined => { + loaded(data20, out20); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::reattached", (_230: rt.u8, data21: rt.ByteSlice, out21: rt.ByteVec): undefined => { + reattached(data21, out21); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::part_written", (_231: rt.u8, data22: rt.ByteSlice, out22: rt.ByteVec): undefined => { + partWritten(data22, out22); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["pointers::aimed", (_232: rt.u8, data23: rt.ByteSlice, out23: rt.ByteVec): undefined => { + aimed(data23, out23); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/pointers.Aimed.ts b/ts/fixtures/lang/pointers/expected/pointers.Aimed.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Aimed.ts rename to ts/fixtures/lang/pointers/expected/pointers.Aimed.ts diff --git a/ts/fixtures/lang/expected/pointers.Bin.ts b/ts/fixtures/lang/pointers/expected/pointers.Bin.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Bin.ts rename to ts/fixtures/lang/pointers/expected/pointers.Bin.ts diff --git a/ts/fixtures/lang/expected/pointers.Borrows.ts b/ts/fixtures/lang/pointers/expected/pointers.Borrows.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Borrows.ts rename to ts/fixtures/lang/pointers/expected/pointers.Borrows.ts diff --git a/ts/fixtures/lang/expected/pointers.ByCall.ts b/ts/fixtures/lang/pointers/expected/pointers.ByCall.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.ByCall.ts rename to ts/fixtures/lang/pointers/expected/pointers.ByCall.ts diff --git a/ts/fixtures/lang/expected/pointers.ByClosure.ts b/ts/fixtures/lang/pointers/expected/pointers.ByClosure.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.ByClosure.ts rename to ts/fixtures/lang/pointers/expected/pointers.ByClosure.ts diff --git a/ts/fixtures/lang/expected/pointers.ByObject.ts b/ts/fixtures/lang/pointers/expected/pointers.ByObject.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.ByObject.ts rename to ts/fixtures/lang/pointers/expected/pointers.ByObject.ts diff --git a/ts/fixtures/lang/expected/pointers.Duo.ts b/ts/fixtures/lang/pointers/expected/pointers.Duo.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Duo.ts rename to ts/fixtures/lang/pointers/expected/pointers.Duo.ts diff --git a/ts/fixtures/lang/expected/pointers.Enclosed.ts b/ts/fixtures/lang/pointers/expected/pointers.Enclosed.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Enclosed.ts rename to ts/fixtures/lang/pointers/expected/pointers.Enclosed.ts diff --git a/ts/fixtures/lang/expected/pointers.Free.ts b/ts/fixtures/lang/pointers/expected/pointers.Free.ts similarity index 53% rename from ts/fixtures/lang/expected/pointers.Free.ts rename to ts/fixtures/lang/pointers/expected/pointers.Free.ts index 2ac9dc0cf..d909c8985 100644 --- a/ts/fixtures/lang/expected/pointers.Free.ts +++ b/ts/fixtures/lang/pointers/expected/pointers.Free.ts @@ -1,9 +1,9 @@ // Generated by rust2-ts. Do not edit. -import type * as pointers_Node from "./pointers.Node.ts"; +import type * as Node from "./pointers.Node.ts"; export interface Free { - next: pointers_Node.Node | undefined; + next: Node.Node | undefined; } //# sourceMappingURL=pointers.Free.ts.map diff --git a/ts/fixtures/lang/expected/pointers.Gauge.ts b/ts/fixtures/lang/pointers/expected/pointers.Gauge.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Gauge.ts rename to ts/fixtures/lang/pointers/expected/pointers.Gauge.ts diff --git a/ts/fixtures/lang/expected/pointers.Halves.ts b/ts/fixtures/lang/pointers/expected/pointers.Halves.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Halves.ts rename to ts/fixtures/lang/pointers/expected/pointers.Halves.ts diff --git a/ts/fixtures/lang/expected/pointers.Held.ts b/ts/fixtures/lang/pointers/expected/pointers.Held.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Held.ts rename to ts/fixtures/lang/pointers/expected/pointers.Held.ts diff --git a/ts/fixtures/lang/expected/pointers.Housed.ts b/ts/fixtures/lang/pointers/expected/pointers.Housed.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Housed.ts rename to ts/fixtures/lang/pointers/expected/pointers.Housed.ts diff --git a/ts/fixtures/lang/expected/pointers.Inner.ts b/ts/fixtures/lang/pointers/expected/pointers.Inner.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Inner.ts rename to ts/fixtures/lang/pointers/expected/pointers.Inner.ts diff --git a/ts/fixtures/lang/expected/pointers.Leaning.ts b/ts/fixtures/lang/pointers/expected/pointers.Leaning.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Leaning.ts rename to ts/fixtures/lang/pointers/expected/pointers.Leaning.ts diff --git a/ts/fixtures/lang/expected/pointers.Lent.ts b/ts/fixtures/lang/pointers/expected/pointers.Lent.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Lent.ts rename to ts/fixtures/lang/pointers/expected/pointers.Lent.ts diff --git a/ts/fixtures/lang/expected/pointers.Link.ts b/ts/fixtures/lang/pointers/expected/pointers.Link.ts similarity index 50% rename from ts/fixtures/lang/expected/pointers.Link.ts rename to ts/fixtures/lang/pointers/expected/pointers.Link.ts index 1e6b17bca..fbbf5dec0 100644 --- a/ts/fixtures/lang/expected/pointers.Link.ts +++ b/ts/fixtures/lang/pointers/expected/pointers.Link.ts @@ -1,8 +1,8 @@ // Generated by rust2-ts. Do not edit. -import type * as pointers_Node from "./pointers.Node.ts"; +import type * as Node from "./pointers.Node.ts"; /** A node's links while it is in the list, or while it is free. */ -export type Link = { at0: pointers_Node.Node | undefined; at4: pointers_Node.Node }; +export type Link = { at0: Node.Node | undefined; at4: Node.Node }; //# sourceMappingURL=pointers.Link.ts.map diff --git a/ts/fixtures/lang/pointers/expected/pointers.Links.ts b/ts/fixtures/lang/pointers/expected/pointers.Links.ts new file mode 100644 index 000000000..03bee7790 --- /dev/null +++ b/ts/fixtures/lang/pointers/expected/pointers.Links.ts @@ -0,0 +1,10 @@ +// Generated by rust2-ts. Do not edit. + +import type * as Node from "./pointers.Node.ts"; + +export interface Links { + next: Node.Node; + prev: Node.Node; +} + +//# sourceMappingURL=pointers.Links.ts.map diff --git a/ts/fixtures/lang/expected/pointers.List.ts b/ts/fixtures/lang/pointers/expected/pointers.List.ts similarity index 56% rename from ts/fixtures/lang/expected/pointers.List.ts rename to ts/fixtures/lang/pointers/expected/pointers.List.ts index 252cb221c..0687bfcfa 100644 --- a/ts/fixtures/lang/expected/pointers.List.ts +++ b/ts/fixtures/lang/pointers/expected/pointers.List.ts @@ -5,16 +5,16 @@ import { copy$tuple2_u8_String, copy$tuple2_u8_sync_Arc_u8, drop$tuple2_u8_sync_ import { attachBefore$String, attachBefore$sync_Arc_u8, detach$String, detach$sync_Arc_u8 } from "./pointers.ts"; import type * as Free from "./pointers.Free.ts"; import type * as Links from "./pointers.Links.ts"; -import * as pointers_Node from "./pointers.Node.ts"; +import * as Node from "./pointers.Node.ts"; /** Entries in the order they were pushed, but for those moved to the front. */ export class List { /** The guard: `next` is the first entry and `prev` the last, or itself if none. */ - guard: pointers_Node.Node | undefined; - free: pointers_Node.Node | undefined; + guard: Node.Node | undefined; + free: Node.Node | undefined; len: rt.usize; - constructor(guard: pointers_Node.Node | undefined, free: pointers_Node.Node | undefined, len: rt.usize) { + constructor(guard: Node.Node | undefined, free: Node.Node | undefined, len: rt.usize) { this.guard = guard; this.free = free; this.len = len; @@ -29,74 +29,74 @@ export function new$sync_Arc_u8(): List> { return new List(undefined, undefined, 0); } -export function guard$String(self: List): pointers_Node.Node { +export function guard$String(self: List): Node.Node { if (self.guard !== undefined) { return self.guard; } - const guard2: pointers_Node.Node = pointers_Node.new$String(); + const guard2: Node.Node = Node.new$String(); const _8: Links.Links = { next: guard2, prev: guard2 }; - const _11: pointers_Node.Node = guard2; + const _11: Node.Node = guard2; _11.link.at0 = _8.next; _11.link.at4 = _8.prev; self.guard = guard2; return guard2; } -export function guard$sync_Arc_u8(self: List>): pointers_Node.Node> { +export function guard$sync_Arc_u8(self: List>): Node.Node> { if (self.guard !== undefined) { return self.guard; } - const guard2: pointers_Node.Node> = pointers_Node.new$sync_Arc_u8(); + const guard2: Node.Node> = Node.new$sync_Arc_u8(); const _8: Links.Links> = { next: guard2, prev: guard2 }; - const _11: pointers_Node.Node> = guard2; + const _11: Node.Node> = guard2; _11.link.at0 = _8.next; _11.link.at4 = _8.prev; self.guard = guard2; return guard2; } -export function alloc$String(self: List): pointers_Node.Node { +export function alloc$String(self: List): Node.Node { if (self.free === undefined) { - return pointers_Node.new$String(); + return Node.new$String(); } - const free: pointers_Node.Node = self.free; + const free: Node.Node = self.free; self.free = free.link.at0; return free; } -export function alloc$sync_Arc_u8(self: List>): pointers_Node.Node> { +export function alloc$sync_Arc_u8(self: List>): Node.Node> { if (self.free === undefined) { - return pointers_Node.new$sync_Arc_u8(); + return Node.new$sync_Arc_u8(); } - const free: pointers_Node.Node> = self.free; + const free: Node.Node> = self.free; self.free = free.link.at0; return free; } export function pushBack$String(self: List, key: rt.u8, value: string): void { - const guard: pointers_Node.Node = guard$String(self); - const node: pointers_Node.Node = alloc$String(self); + const guard: Node.Node = guard$String(self); + const node: Node.Node = alloc$String(self); rt.ptrWrite(node.entry, [key, value] as [rt.u8, string]); attachBefore$String(node, guard); self.len = rt.usizeAdd(self.len, 1); } export function pushBack$sync_Arc_u8(self: List>, key: rt.u8, value: rt.Arc): void { - const guard: pointers_Node.Node> = guard$sync_Arc_u8(self); - const node: pointers_Node.Node> = alloc$sync_Arc_u8(self); + const guard: Node.Node> = guard$sync_Arc_u8(self); + const node: Node.Node> = alloc$sync_Arc_u8(self); rt.ptrWrite(node.entry, [key, value] as [rt.u8, rt.Arc]); attachBefore$sync_Arc_u8(node, guard); self.len = rt.usizeAdd(self.len, 1); } -export function find$String(self: List, key: rt.u8): pointers_Node.Node | undefined { - const _4: pointers_Node.Node | undefined = self.guard; +export function find$String(self: List, key: rt.u8): Node.Node | undefined { + const _4: Node.Node | undefined = self.guard; if (_4 !== undefined) { - const guard: pointers_Node.Node = _4; - let at: pointers_Node.Node = guard.link.at0 as pointers_Node.Node; + const guard: Node.Node = _4; + let at: Node.Node = guard.link.at0 as Node.Node; while (at !== guard) { if (!(at.entry[0] === key)) { - at = at.link.at0 as pointers_Node.Node; + at = at.link.at0 as Node.Node; } else { return at; } @@ -106,14 +106,14 @@ export function find$String(self: List, key: rt.u8): pointers_Node.Node< return undefined; } -export function find$sync_Arc_u8(self: List>, key: rt.u8): pointers_Node.Node> | undefined { - const _4: pointers_Node.Node> | undefined = self.guard; +export function find$sync_Arc_u8(self: List>, key: rt.u8): Node.Node> | undefined { + const _4: Node.Node> | undefined = self.guard; if (_4 !== undefined) { - const guard: pointers_Node.Node> = _4; - let at: pointers_Node.Node> = guard.link.at0 as pointers_Node.Node>; + const guard: Node.Node> = _4; + let at: Node.Node> = guard.link.at0 as Node.Node>; while (at !== guard) { if (!(at.entry[0] === key)) { - at = at.link.at0 as pointers_Node.Node>; + at = at.link.at0 as Node.Node>; } else { return at; } @@ -124,9 +124,9 @@ export function find$sync_Arc_u8(self: List>, key: rt.u8): pointer } export function remove$String(self: List, key: rt.u8): [rt.u8, string] | undefined { - const _4: pointers_Node.Node | undefined = find$String(self, key); + const _4: Node.Node | undefined = find$String(self, key); if (_4 !== undefined) { - const node: pointers_Node.Node = _4; + const node: Node.Node = _4; detach$String(node); const entry: [rt.u8, string] = copy$tuple2_u8_String(node.entry); const _16: Free.Free = { next: self.free }; @@ -139,9 +139,9 @@ export function remove$String(self: List, key: rt.u8): [rt.u8, string] | } export function remove$sync_Arc_u8(self: List>, key: rt.u8): [rt.u8, rt.Arc] | undefined { - const _4: pointers_Node.Node> | undefined = find$sync_Arc_u8(self, key); + const _4: Node.Node> | undefined = find$sync_Arc_u8(self, key); if (_4 !== undefined) { - const node: pointers_Node.Node> = _4; + const node: Node.Node> = _4; detach$sync_Arc_u8(node); const entry: [rt.u8, rt.Arc] = copy$tuple2_u8_sync_Arc_u8(node.entry); const _16: Free.Free> = { next: self.free }; @@ -154,13 +154,13 @@ export function remove$sync_Arc_u8(self: List>, key: rt.u8): [rt.u } export function toFront$String(self: List, key: rt.u8): boolean { - const _4: pointers_Node.Node | undefined = find$String(self, key); + const _4: Node.Node | undefined = find$String(self, key); if (_4 !== undefined) { - const node: pointers_Node.Node = _4; + const node: Node.Node = _4; if (self.guard !== undefined) { - const guard: pointers_Node.Node = self.guard; + const guard: Node.Node = self.guard; detach$String(node); - attachBefore$String(node, guard.link.at0 as pointers_Node.Node); + attachBefore$String(node, guard.link.at0 as Node.Node); return true; } return false; @@ -169,13 +169,13 @@ export function toFront$String(self: List, key: rt.u8): boolean { } export function toFront$sync_Arc_u8(self: List>, key: rt.u8): boolean { - const _4: pointers_Node.Node> | undefined = find$sync_Arc_u8(self, key); + const _4: Node.Node> | undefined = find$sync_Arc_u8(self, key); if (_4 !== undefined) { - const node: pointers_Node.Node> = _4; + const node: Node.Node> = _4; if (self.guard !== undefined) { - const guard: pointers_Node.Node> = self.guard; + const guard: Node.Node> = self.guard; detach$sync_Arc_u8(node); - attachBefore$sync_Arc_u8(node, guard.link.at0 as pointers_Node.Node>); + attachBefore$sync_Arc_u8(node, guard.link.at0 as Node.Node>); return true; } return false; @@ -184,7 +184,7 @@ export function toFront$sync_Arc_u8(self: List>, key: rt.u8): bool } export function getMut$String(self: List, key: rt.u8): rt.Place | undefined { - const _3: pointers_Node.Node | undefined = find$String(self, key); + const _3: Node.Node | undefined = find$String(self, key); if (_3 !== undefined) { const _9: [rt.u8, string] = _3.entry; return rt.place(() => _9[1], (value) => _9[1] = value); @@ -195,8 +195,8 @@ export function getMut$String(self: List, key: rt.u8): rt.Place export function each$String(self: List, out: rt.ByteVec): void { b0: { if (self.guard !== undefined) { - const guard: pointers_Node.Node = self.guard; - let at: pointers_Node.Node = guard.link.at0 as pointers_Node.Node; + const guard: Node.Node = self.guard; + let at: Node.Node = guard.link.at0 as Node.Node; while (true) { if (!((at !== guard))) { break b0; @@ -204,7 +204,7 @@ export function each$String(self: List, out: rt.ByteVec): void { const _13: [rt.u8, string] = at.entry; rt.byteVecPush(out, _13[0]); rt.byteVecExtendFromSlice(out, rt.stringAsBytes(_13[1])); - at = at.link.at0 as pointers_Node.Node; + at = at.link.at0 as Node.Node; } } } @@ -212,10 +212,10 @@ export function each$String(self: List, out: rt.ByteVec): void { export function drop$ops_Drop_String(self: List): void { if (self.guard !== undefined) { - const guard: pointers_Node.Node = self.guard; - let at: pointers_Node.Node = guard.link.at0 as pointers_Node.Node; + const guard: Node.Node = self.guard; + let at: Node.Node = guard.link.at0 as Node.Node; while (at !== guard) { - at = at.link.at0 as pointers_Node.Node; + at = at.link.at0 as Node.Node; } } while (self.free !== undefined) { @@ -225,10 +225,10 @@ export function drop$ops_Drop_String(self: List): void { export function drop$ops_Drop_sync_Arc_u8(self: List>): void { if (self.guard !== undefined) { - const guard: pointers_Node.Node> = self.guard; - let at: pointers_Node.Node> = guard.link.at0 as pointers_Node.Node>; + const guard: Node.Node> = self.guard; + let at: Node.Node> = guard.link.at0 as Node.Node>; while (at !== guard) { - const next: pointers_Node.Node> = at.link.at0 as pointers_Node.Node>; + const next: Node.Node> = at.link.at0 as Node.Node>; drop$tuple2_u8_sync_Arc_u8(at.entry); at = next; } diff --git a/ts/fixtures/lang/expected/pointers.Loaded.ts b/ts/fixtures/lang/pointers/expected/pointers.Loaded.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Loaded.ts rename to ts/fixtures/lang/pointers/expected/pointers.Loaded.ts diff --git a/ts/fixtures/lang/expected/pointers.Log.ts b/ts/fixtures/lang/pointers/expected/pointers.Log.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Log.ts rename to ts/fixtures/lang/pointers/expected/pointers.Log.ts diff --git a/ts/fixtures/lang/expected/pointers.Node.ts b/ts/fixtures/lang/pointers/expected/pointers.Node.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Node.ts rename to ts/fixtures/lang/pointers/expected/pointers.Node.ts diff --git a/ts/fixtures/lang/expected/pointers.Outer.ts b/ts/fixtures/lang/pointers/expected/pointers.Outer.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Outer.ts rename to ts/fixtures/lang/pointers/expected/pointers.Outer.ts diff --git a/ts/fixtures/lang/expected/pointers.Pair.ts b/ts/fixtures/lang/pointers/expected/pointers.Pair.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Pair.ts rename to ts/fixtures/lang/pointers/expected/pointers.Pair.ts diff --git a/ts/fixtures/lang/expected/pointers.Paired.ts b/ts/fixtures/lang/pointers/expected/pointers.Paired.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Paired.ts rename to ts/fixtures/lang/pointers/expected/pointers.Paired.ts diff --git a/ts/fixtures/lang/expected/pointers.Pointing.ts b/ts/fixtures/lang/pointers/expected/pointers.Pointing.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Pointing.ts rename to ts/fixtures/lang/pointers/expected/pointers.Pointing.ts diff --git a/ts/fixtures/lang/expected/pointers.Reattached.ts b/ts/fixtures/lang/pointers/expected/pointers.Reattached.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Reattached.ts rename to ts/fixtures/lang/pointers/expected/pointers.Reattached.ts diff --git a/ts/fixtures/lang/expected/pointers.Refilled.ts b/ts/fixtures/lang/pointers/expected/pointers.Refilled.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Refilled.ts rename to ts/fixtures/lang/pointers/expected/pointers.Refilled.ts diff --git a/ts/fixtures/lang/expected/pointers.Reset.ts b/ts/fixtures/lang/pointers/expected/pointers.Reset.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Reset.ts rename to ts/fixtures/lang/pointers/expected/pointers.Reset.ts diff --git a/ts/fixtures/lang/expected/pointers.Run.ts b/ts/fixtures/lang/pointers/expected/pointers.Run.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Run.ts rename to ts/fixtures/lang/pointers/expected/pointers.Run.ts diff --git a/ts/fixtures/lang/expected/pointers.Segment.ts b/ts/fixtures/lang/pointers/expected/pointers.Segment.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Segment.ts rename to ts/fixtures/lang/pointers/expected/pointers.Segment.ts diff --git a/ts/fixtures/lang/expected/pointers.Span.ts b/ts/fixtures/lang/pointers/expected/pointers.Span.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Span.ts rename to ts/fixtures/lang/pointers/expected/pointers.Span.ts diff --git a/ts/fixtures/lang/expected/pointers.Stable.ts b/ts/fixtures/lang/pointers/expected/pointers.Stable.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Stable.ts rename to ts/fixtures/lang/pointers/expected/pointers.Stable.ts diff --git a/ts/fixtures/lang/expected/pointers.Swapped.ts b/ts/fixtures/lang/pointers/expected/pointers.Swapped.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Swapped.ts rename to ts/fixtures/lang/pointers/expected/pointers.Swapped.ts diff --git a/ts/fixtures/lang/expected/pointers.To.ts b/ts/fixtures/lang/pointers/expected/pointers.To.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.To.ts rename to ts/fixtures/lang/pointers/expected/pointers.To.ts diff --git a/ts/fixtures/lang/expected/pointers.Viewed.ts b/ts/fixtures/lang/pointers/expected/pointers.Viewed.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Viewed.ts rename to ts/fixtures/lang/pointers/expected/pointers.Viewed.ts diff --git a/ts/fixtures/lang/expected/pointers.Waiter.ts b/ts/fixtures/lang/pointers/expected/pointers.Waiter.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Waiter.ts rename to ts/fixtures/lang/pointers/expected/pointers.Waiter.ts diff --git a/ts/fixtures/lang/expected/pointers.Waiters.ts b/ts/fixtures/lang/pointers/expected/pointers.Waiters.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Waiters.ts rename to ts/fixtures/lang/pointers/expected/pointers.Waiters.ts diff --git a/ts/fixtures/lang/expected/pointers.Window.ts b/ts/fixtures/lang/pointers/expected/pointers.Window.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Window.ts rename to ts/fixtures/lang/pointers/expected/pointers.Window.ts diff --git a/ts/fixtures/lang/expected/pointers.Wrapped.ts b/ts/fixtures/lang/pointers/expected/pointers.Wrapped.ts similarity index 58% rename from ts/fixtures/lang/expected/pointers.Wrapped.ts rename to ts/fixtures/lang/pointers/expected/pointers.Wrapped.ts index 2b30e2287..7e89b7c28 100644 --- a/ts/fixtures/lang/expected/pointers.Wrapped.ts +++ b/ts/fixtures/lang/pointers/expected/pointers.Wrapped.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import type * as pointers_Held from "./pointers.Held.ts"; +import type * as Held from "./pointers.Held.ts"; /** crossbeam-epoch's own wrapper over `UnsafeCell`, which lends its pointer to a closure. */ export class Wrapped { @@ -16,31 +16,31 @@ export class Wrapped { } } -export function new$pointers_Held(value: pointers_Held.Held): Wrapped { +export function new$pointers_Held(value: Held.Held): Wrapped { return new Wrapped(new rt.Cell(value)); } -export function with$pointers_Held_u8_pointers_cells_closure2(self: Wrapped, f: (a0: pointers_Held.Held) => rt.u8): rt.u8 { +export function with$pointers_Held_u8_pointers_cells_closure2(self: Wrapped, f: (a0: Held.Held) => rt.u8): rt.u8 { return f(self._0.v); } -export function with$pointers_Held_u8_pointers_cells_closure4(self: Wrapped, f: (a0: pointers_Held.Held) => rt.u8): rt.u8 { +export function with$pointers_Held_u8_pointers_cells_closure4(self: Wrapped, f: (a0: Held.Held) => rt.u8): rt.u8 { return f(self._0.v); } -export function withMut$pointers_Held_unit_pointers_cells_closure0(self: Wrapped, f: (a0: pointers_Held.Held) => undefined): void { +export function withMut$pointers_Held_unit_pointers_cells_closure0(self: Wrapped, f: (a0: Held.Held) => undefined): void { f(self._0.v); } -export function withMut$pointers_Held_unit_pointers_cells_closure1(self: Wrapped, f: (a0: pointers_Held.Held) => undefined): void { +export function withMut$pointers_Held_unit_pointers_cells_closure1(self: Wrapped, f: (a0: Held.Held) => undefined): void { f(self._0.v); } -export function withMut$pointers_Held_unit_pointers_cells_closure3(self: Wrapped, f: (a0: pointers_Held.Held) => undefined): void { +export function withMut$pointers_Held_unit_pointers_cells_closure3(self: Wrapped, f: (a0: Held.Held) => undefined): void { f(self._0.v); } -export function withMut$pointers_Held_unit_pointers_cells_closure5(self: Wrapped, f: (a0: pointers_Held.Held) => undefined): void { +export function withMut$pointers_Held_unit_pointers_cells_closure5(self: Wrapped, f: (a0: Held.Held) => undefined): void { f(self._0.v); } diff --git a/ts/fixtures/lang/expected/pointers.Written.ts b/ts/fixtures/lang/pointers/expected/pointers.Written.ts similarity index 100% rename from ts/fixtures/lang/expected/pointers.Written.ts rename to ts/fixtures/lang/pointers/expected/pointers.Written.ts diff --git a/ts/fixtures/lang/expected/pointers.ts b/ts/fixtures/lang/pointers/expected/pointers.ts similarity index 94% rename from ts/fixtures/lang/expected/pointers.ts rename to ts/fixtures/lang/pointers/expected/pointers.ts index d4fd0509b..bf78056d8 100644 --- a/ts/fixtures/lang/expected/pointers.ts +++ b/ts/fixtures/lang/pointers/expected/pointers.ts @@ -10,9 +10,9 @@ import * as ByClosure from "./pointers.ByClosure.ts"; import type * as ByObject from "./pointers.ByObject.ts"; import type * as Duo from "./pointers.Duo.ts"; import type * as Enclosed from "./pointers.Enclosed.ts"; -import type * as pointers_Gauge from "./pointers.Gauge.ts"; -import type * as pointers_Halves from "./pointers.Halves.ts"; -import * as pointers_Held from "./pointers.Held.ts"; +import type * as Gauge from "./pointers.Gauge.ts"; +import type * as Halves from "./pointers.Halves.ts"; +import * as Held from "./pointers.Held.ts"; import * as Housed from "./pointers.Housed.ts"; import type * as Inner from "./pointers.Inner.ts"; import * as Leaning from "./pointers.Leaning.ts"; @@ -21,15 +21,15 @@ import type * as Links from "./pointers.Links.ts"; import * as List from "./pointers.List.ts"; import type * as Loaded from "./pointers.Loaded.ts"; import type * as Log from "./pointers.Log.ts"; -import type * as pointers_Node from "./pointers.Node.ts"; +import type * as Node from "./pointers.Node.ts"; import type * as Outer from "./pointers.Outer.ts"; -import type * as pointers_Pair from "./pointers.Pair.ts"; +import type * as Pair from "./pointers.Pair.ts"; import * as Paired from "./pointers.Paired.ts"; import * as Pointing from "./pointers.Pointing.ts"; import type * as Reattached from "./pointers.Reattached.ts"; import type * as Refilled from "./pointers.Refilled.ts"; import * as Reset from "./pointers.Reset.ts"; -import type * as pointers_Run from "./pointers.Run.ts"; +import type * as Run from "./pointers.Run.ts"; import * as Segment from "./pointers.Segment.ts"; import type * as Span from "./pointers.Span.ts"; import type * as Stable from "./pointers.Stable.ts"; @@ -38,38 +38,38 @@ import type * as To from "./pointers.To.ts"; import type * as Viewed from "./pointers.Viewed.ts"; import type * as Waiter from "./pointers.Waiter.ts"; import * as Waiters from "./pointers.Waiters.ts"; -import type * as pointers_Window from "./pointers.Window.ts"; -import * as pointers_Wrapped from "./pointers.Wrapped.ts"; +import type * as Window from "./pointers.Window.ts"; +import * as Wrapped from "./pointers.Wrapped.ts"; import type * as Written from "./pointers.Written.ts"; /** Put `node` in the list just before `at`. */ -export function attachBefore$String(node: pointers_Node.Node, at: pointers_Node.Node): void { +export function attachBefore$String(node: Node.Node, at: Node.Node): void { const _3: Links.Links = { next: at, prev: at.link.at4 }; - const _8: pointers_Node.Node = node; + const _8: Node.Node = node; _8.link.at0 = _3.next; _8.link.at4 = _3.prev; at.link.at4 = node; - (node.link.at4.link.at0 as pointers_Node.Node) = node; + (node.link.at4.link.at0 as Node.Node) = node; } /** Put `node` in the list just before `at`. */ -export function attachBefore$sync_Arc_u8(node: pointers_Node.Node>, at: pointers_Node.Node>): void { +export function attachBefore$sync_Arc_u8(node: Node.Node>, at: Node.Node>): void { const _3: Links.Links> = { next: at, prev: at.link.at4 }; - const _8: pointers_Node.Node> = node; + const _8: Node.Node> = node; _8.link.at0 = _3.next; _8.link.at4 = _3.prev; at.link.at4 = node; - (node.link.at4.link.at0 as pointers_Node.Node>) = node; + (node.link.at4.link.at0 as Node.Node>) = node; } -export function detach$String(node: pointers_Node.Node): void { - (node.link.at4.link.at0 as pointers_Node.Node) = node.link.at0 as pointers_Node.Node; - ((node.link.at0 as pointers_Node.Node)).link.at4 = node.link.at4; +export function detach$String(node: Node.Node): void { + (node.link.at4.link.at0 as Node.Node) = node.link.at0 as Node.Node; + ((node.link.at0 as Node.Node)).link.at4 = node.link.at4; } -export function detach$sync_Arc_u8(node: pointers_Node.Node>): void { - (node.link.at4.link.at0 as pointers_Node.Node>) = node.link.at0 as pointers_Node.Node>; - ((node.link.at0 as pointers_Node.Node>)).link.at4 = node.link.at4; +export function detach$sync_Arc_u8(node: Node.Node>): void { + (node.link.at4.link.at0 as Node.Node>) = node.link.at0 as Node.Node>; + ((node.link.at0 as Node.Node>)).link.at4 = node.link.at4; } /** @@ -178,11 +178,11 @@ export function places(data: rt.ByteSlice, out: rt.ByteVec): void { let _52!: rt.u8; let x: rt.u32 = 0; let y: rt.u32 = 1; - const pair: pointers_Pair.Pair = { a: 2, b: 3 }; + const pair: Pair.Pair = { a: 2, b: 3 }; const px: rt.Place = rt.place(() => x, (value) => x = value); const py: rt.Place = rt.place(() => y, (value2) => y = value2); const pa: rt.Place = rt.place(() => pair.a, (value3) => pair.a = value3); - const pp: pointers_Pair.Pair = pair; + const pp: Pair.Pair = pair; let held: rt.Place = rt.NULL; const bytes: Uint8Array = rt.bytes(2); const pb: rt.ByteSlice = rt.byteSliceFrom(bytes); @@ -207,7 +207,7 @@ export function places(data: rt.ByteSlice, out: rt.ByteVec): void { } else if (_21 === 4) { pp.b = v; } else if (_21 === 5) { - const old: pointers_Pair.Pair = copy$pointers_Pair(pp); + const old: Pair.Pair = copy$pointers_Pair(pp); rt.ptrWrite(pp, { a: old.b, b: old.a }); } else if (_21 === 6) { if (!((byte & 1) === 0)) { @@ -224,7 +224,7 @@ export function places(data: rt.ByteSlice, out: rt.ByteVec): void { pointer3.v = v; old4; } else if (_21 === 10) { - const _46: pointers_Pair.Pair = { a: v, b: rt.u32Add(v, 1) }; + const _46: Pair.Pair = { a: v, b: rt.u32Add(v, 1) }; const pointer2 = pp; const old3 = copy$pointers_Pair(pointer2); rt.ptrWrite(pointer2, _46); @@ -338,21 +338,21 @@ export function copies(data: rt.ByteSlice, out: rt.ByteVec): void { return _16; })); uninit; - const h: pointers_Halves.Halves = ({ at0: [v, rt.u32Add(v, 1)] } as unknown) as pointers_Halves.Halves; - const g: pointers_Halves.Halves = copy$pointers_Halves(h); + const h: Halves.Halves = ({ at0: [v, rt.u32Add(v, 1)] } as unknown) as Halves.Halves; + const g: Halves.Halves = copy$pointers_Halves(h); g.at0[0] = rt.u32Add(v, 2); - let held: pointers_Pair.Pair | undefined = { a: v, b: 0 }; - const p: rt.Place = rt.place(() => held, (value) => held = value); - const old: pointers_Pair.Pair | undefined = copy$Option_pointers_Pair(p.v); + let held: Pair.Pair | undefined = { a: v, b: 0 }; + const p: rt.Place = rt.place(() => held, (value) => held = value); + const old: Pair.Pair | undefined = copy$Option_pointers_Pair(p.v); if (p.v !== undefined) { p.v.a = rt.u32Add(v, 3); } const _35: [rt.u8, rt.u8] = snapshot(v); const before: rt.u8 = _35[0]; const after: rt.u8 = _35[1]; - rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(y[0] & 0xff, x[0] & 0xff, h.at0[0] & 0xff, g.at0[0] & 0xff, option_mapOr$08xz81a(old, 0, (o: pointers_Pair.Pair): rt.u8 => { + rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(y[0] & 0xff, x[0] & 0xff, h.at0[0] & 0xff, g.at0[0] & 0xff, option_mapOr$08xz81a(old, 0, (o: Pair.Pair): rt.u8 => { return o.a & 0xff; - }), option_mapOr$08xz81a(held, 0, (o2: pointers_Pair.Pair): rt.u8 => { + }), option_mapOr$08xz81a(held, 0, (o2: Pair.Pair): rt.u8 => { return o2.a & 0xff; }), before, after))); } @@ -412,7 +412,7 @@ export function cells(data: rt.ByteSlice, out: rt.ByteVec): void { let num: rt.Cell = new rt.Cell(4294967295 - 1); const pair: rt.Cell = new rt.Cell({ _0: 0, _1: 255 }); let text: rt.Cell = new rt.Cell(""); - const held: pointers_Wrapped.Wrapped = pointers_Wrapped.new$pointers_Held(new pointers_Held.Held(0, rt.arcClone(count))); + const held: Wrapped.Wrapped = Wrapped.new$pointers_Held(new Held.Held(0, rt.arcClone(count))); for (const op of rt.byteSliceView(data)) { const n: rt.u8 = rt.u8Div(op, 8); const _23: rt.u8 = rt.u8Rem(op, 8); @@ -444,11 +444,11 @@ export function cells(data: rt.ByteSlice, out: rt.ByteVec): void { rt.iterExtendBytes(out, rt.iterSlice(rt.byteSliceView(rt.stringAsBytes(text.v))), undefined, true); } else if (_23 === 4) { const _99: rt.Arc = rt.arcClone(count); - const fresh: pointers_Held.Held = new pointers_Held.Held(n, _99); + const fresh: Held.Held = new Held.Held(n, _99); if (rt.u8Rem(n, 2) === 0) { const captured2 = fresh; - pointers_Wrapped.withMut$pointers_Held_unit_pointers_cells_closure0(held, rt.closure((p6: pointers_Held.Held): undefined => { - const _311: pointers_Held.Held = captured2; + Wrapped.withMut$pointers_Held_unit_pointers_cells_closure0(held, rt.closure((p6: Held.Held): undefined => { + const _311: Held.Held = captured2; p6[Symbol.dispose](); rt.ptrWrite(p6, _311); }, (): void => { @@ -456,22 +456,22 @@ export function cells(data: rt.ByteSlice, out: rt.ByteVec): void { })); } else { const captured = fresh; - pointers_Wrapped.withMut$pointers_Held_unit_pointers_cells_closure1(held, rt.closure((p5: pointers_Held.Held): undefined => { + Wrapped.withMut$pointers_Held_unit_pointers_cells_closure1(held, rt.closure((p5: Held.Held): undefined => { rt.ptrWrite(p5, captured); }, (): void => { captured[Symbol.dispose](); })); } - rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(pointers_Wrapped.with$pointers_Held_u8_pointers_cells_closure2(held, (p7: pointers_Held.Held): rt.u8 => { + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(Wrapped.with$pointers_Held_u8_pointers_cells_closure2(held, (p7: Held.Held): rt.u8 => { return p7.n; }), count.strong & 0xff)), undefined, true); } else if (_23 === 5) { - pointers_Wrapped.withMut$pointers_Held_unit_pointers_cells_closure3(held, (p3: pointers_Held.Held): undefined => { + Wrapped.withMut$pointers_Held_unit_pointers_cells_closure3(held, (p3: Held.Held): undefined => { p3.n = rt.u8WrappingAdd(p3.n, n); }); - const _119: pointers_Held.Held = held._0.v; + const _119: Held.Held = held._0.v; _119.n = _119.n ^ 1; - rt.byteVecPush(out, pointers_Wrapped.with$pointers_Held_u8_pointers_cells_closure4(held, (p4: pointers_Held.Held): rt.u8 => { + rt.byteVecPush(out, Wrapped.with$pointers_Held_u8_pointers_cells_closure4(held, (p4: Held.Held): rt.u8 => { return p4.n; })); } else if (_23 === 6) { @@ -487,12 +487,12 @@ export function cells(data: rt.ByteSlice, out: rt.ByteVec): void { Object.assign(pair.v, _140); } else { const _146: rt.Arc = rt.arcClone(count); - const made: pointers_Wrapped.Wrapped = pointers_Wrapped.new$pointers_Held(new pointers_Held.Held(n, _146)); - pointers_Wrapped.withMut$pointers_Held_unit_pointers_cells_closure5(made, (p2: pointers_Held.Held): undefined => { + const made: Wrapped.Wrapped = Wrapped.new$pointers_Held(new Held.Held(n, _146)); + Wrapped.withMut$pointers_Held_unit_pointers_cells_closure5(made, (p2: Held.Held): undefined => { p2.n = p2.n ^ 85; }); rt.byteVecPush(out, count.strong & 0xff); - const made2: pointers_Held.Held = made._0.v; + const made2: Held.Held = made._0.v; rt.byteVecPush(out, made2.n); made2[Symbol.dispose](); rt.byteVecPush(out, count.strong & 0xff); @@ -753,7 +753,7 @@ export function byClosure(n: rt.u8): Uint8Array { } /** Each part of a `Gauge` written into, never given another object. */ -export function nudge(g: pointers_Gauge.Gauge, n: rt.u8): void { +export function nudge(g: Gauge.Gauge, n: rt.u8): void { g.range[0] = g.range[0] ^ n; const _3: [rt.u8, rt.u8] = g.slot; _3[1] = _3[1] ^ n; @@ -772,7 +772,7 @@ export function made(data: rt.ByteSlice, out: rt.ByteVec): void { } export function madeParts(n: rt.u8): Uint8Array { - const g: pointers_Gauge.Gauge = { range: [n, ~n & 0xff] as [rt.u8, rt.u8], slot: copy$mem_MaybeUninit_tuple2_u8_u8([~n & 0xff, n] as [rt.u8, rt.u8]) }; + const g: Gauge.Gauge = { range: [n, ~n & 0xff] as [rt.u8, rt.u8], slot: copy$mem_MaybeUninit_tuple2_u8_u8([~n & 0xff, n] as [rt.u8, rt.u8]) }; const p: [rt.u8, rt.u8] = g.range; const q: [rt.u8, rt.u8] = g.slot; nudge(g, n ^ 90); @@ -845,8 +845,8 @@ export function segments(data: rt.ByteSlice, out: rt.ByteVec): void { */ export function uninitRuns(data: rt.ByteSlice, out: rt.ByteVec): void { let _7!: rt.usize; - const runs: pointers_Run.Run[] = Array.from({ length: 3 }, (): pointers_Run.Run => { - return ({ span: [undefined, undefined], n: undefined } as unknown) as pointers_Run.Run; + const runs: Run.Run[] = Array.from({ length: 3 }, (): Run.Run => { + return ({ span: [undefined, undefined], n: undefined } as unknown) as Run.Run; }); let iterStart: rt.usize = 0; const iterEnd: rt.usize = 3; @@ -858,7 +858,7 @@ export function uninitRuns(data: rt.ByteSlice, out: rt.ByteVec): void { } rt.ptrWrite(runs[at], { span: [n, ~n & 0xff] as [rt.u8, rt.u8], n: at & 0xff }); } - const last: pointers_Run.Run = ({ span: [undefined, undefined], n: undefined } as unknown) as pointers_Run.Run; + const last: Run.Run = ({ span: [undefined, undefined], n: undefined } as unknown) as Run.Run; rt.ptrWrite(last, { span: [data.length & 0xff, 0] as [rt.u8, rt.u8], n: 3 }); const tail: [rt.u8, rt.u8] = last.span; for (const byte of rt.byteSliceView(data)) { @@ -866,7 +866,7 @@ export function uninitRuns(data: rt.ByteSlice, out: rt.ByteVec): void { if (!(_40 < 3)) { rt.panic("index out of bounds: the len is " + 3 + " but the index is " + _40); } - const run: pointers_Run.Run = runs[_40]; + const run: Run.Run = runs[_40]; const span: [rt.u8, rt.u8] = run.span; span[0] = span[0] ^ byte; span[1] = rt.u8WrappingAdd(span[1], run.n); @@ -874,10 +874,10 @@ export function uninitRuns(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, span[0]); } for (const _56 of runs) { - const run2: pointers_Run.Run = _56; + const run2: Run.Run = _56; rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(run2.span[0], run2.span[1], run2.n)), undefined, true); } - const last2: pointers_Run.Run = last; + const last2: Run.Run = last; rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(last2.span[0], last2.span[1], last2.n)), undefined, true); } @@ -891,12 +891,12 @@ export function iteratedRuns(data: rt.ByteSlice, out: rt.ByteVec): void { const byte: (a0: rt.usize) => rt.u8 = (at3: rt.usize): rt.u8 => { return option_unwrapOr$0r2bmpr(rt.byteSliceGet(data, at3), 0); }; - const runs: pointers_Run.Run[] = Array.from({ length: 3 }, (): pointers_Run.Run => { - return ({ span: [undefined, undefined], n: undefined } as unknown) as pointers_Run.Run; + const runs: Run.Run[] = Array.from({ length: 3 }, (): Run.Run => { + return ({ span: [undefined, undefined], n: undefined } as unknown) as Run.Run; }); - const iter: rt.Iter = rt.iterSlice(runs); + const iter: rt.Iter = rt.iterSlice(runs); while (true) { - const _10: pointers_Run.Run | rt.Done = iter.next(); + const _10: Run.Run | rt.Done = iter.next(); if (_10 === rt.DONE) { break; } @@ -904,12 +904,12 @@ export function iteratedRuns(data: rt.ByteSlice, out: rt.ByteVec): void { rt.ptrWrite(uninit, { span: [byte(0), ~byte(0) & 0xff] as [rt.u8, rt.u8], n: 0 }); uninit; } - const boxed: pointers_Run.Run[] = Array.from({ length: 4 }, (): pointers_Run.Run => { - return ({ span: [undefined, undefined], n: undefined } as unknown) as pointers_Run.Run; + const boxed: Run.Run[] = Array.from({ length: 4 }, (): Run.Run => { + return ({ span: [undefined, undefined], n: undefined } as unknown) as Run.Run; }); - const iter2: rt.Iter = rt.iterSlice(boxed); + const iter2: rt.Iter = rt.iterSlice(boxed); while (true) { - const _30: pointers_Run.Run | rt.Done = iter2.next(); + const _30: Run.Run | rt.Done = iter2.next(); if (_30 === rt.DONE) { break; } @@ -917,17 +917,17 @@ export function iteratedRuns(data: rt.ByteSlice, out: rt.ByteVec): void { rt.ptrWrite(uninit2, { span: [byte(1), 1] as [rt.u8, rt.u8], n: 1 }); uninit2; } - const iter3: rt.Iter<[pointers_Run.Run[], rt.u8]> = rt.iterZip(rt.sliceChunksExactMut(boxed, 2), new rt.RangeFrom(0, rt.u8Step), "len"); + const iter3: rt.Iter<[Run.Run[], rt.u8]> = rt.iterZip(rt.sliceChunksExactMut(boxed, 2), new rt.RangeFrom(0, rt.u8Step), "len"); l5: while (true) { - const _46: [pointers_Run.Run[], rt.u8] | rt.Done = iter3.next(); + const _46: [Run.Run[], rt.u8] | rt.Done = iter3.next(); if (_46 === rt.DONE) { break; } const at: rt.u8 = _46[1]; - const iterS: pointers_Run.Run[] = _46[0]; + const iterS: Run.Run[] = _46[0]; let iterI: number = 0; while (true) { - const _53: pointers_Run.Run | rt.Done = iterI < iterS.length ? iterS[iterI++] : rt.DONE; + const _53: Run.Run | rt.Done = iterI < iterS.length ? iterS[iterI++] : rt.DONE; if (_53 === rt.DONE) { continue l5; } @@ -936,9 +936,9 @@ export function iteratedRuns(data: rt.ByteSlice, out: rt.ByteVec): void { uninit3; } } - const iter5: rt.Iter<[pointers_Run.Run, rt.usize]> = rt.iterZip(rt.iterSlice(runs), new rt.RangeFrom(0, rt.usizeStep), "len"); + const iter5: rt.Iter<[Run.Run, rt.usize]> = rt.iterZip(rt.iterSlice(runs), new rt.RangeFrom(0, rt.usizeStep), "len"); while (true) { - const _74: [pointers_Run.Run, rt.usize] | rt.Done = iter5.next(); + const _74: [Run.Run, rt.usize] | rt.Done = iter5.next(); if (_74 === rt.DONE) { break; } @@ -952,7 +952,7 @@ export function iteratedRuns(data: rt.ByteSlice, out: rt.ByteVec): void { if (!(_95 < 3)) { rt.panic("index out of bounds: the len is " + 3 + " but the index is " + _95); } - const run: pointers_Run.Run = runs[_95]; + const run: Run.Run = runs[_95]; const span: [rt.u8, rt.u8] = run.span; span[0] = span[0] ^ byte2; span[1] = rt.u8WrappingAdd(span[1], run.n); @@ -963,13 +963,13 @@ export function iteratedRuns(data: rt.ByteSlice, out: rt.ByteVec): void { span2[1] = span2[1] ^ byte2; rt.byteVecPush(out, span2[1]); } - const iter7: rt.Iter = rt.iterChain(rt.iterSlice(runs), rt.iterSlice(boxed)); + const iter7: rt.Iter = rt.iterChain(rt.iterSlice(runs), rt.iterSlice(boxed)); while (true) { - const _123: pointers_Run.Run | rt.Done = iter7.next(); + const _123: Run.Run | rt.Done = iter7.next(); if (_123 === rt.DONE) { break; } - const run3: pointers_Run.Run = _123; + const run3: Run.Run = _123; rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(run3.span[0], run3.span[1], run3.n)), undefined, true); } } @@ -1331,11 +1331,11 @@ export function nextRead$pointers_Loaded(items: rt.Iter): Loaded. * into fields of one generic type: one into an array and one into a struct. */ export function reattached(data: rt.ByteSlice, out: rt.ByteVec): void { - const window: pointers_Window.Window = { at: rt.NULL }; + const window: Window.Window = { at: rt.NULL }; let buf: rt.u16[] = Array.from({ length: 4 }, (): rt.u16 => { return 0; }); - const slot: pointers_Window.Window = { at: rt.NULL }; + const slot: Window.Window = { at: rt.NULL }; let pair: Reattached.Reattached = { _0: 0, _1: 0 }; for (const n of rt.byteSliceView(data)) { const _17: rt.u16[] = buf; diff --git a/ts/fixtures/lang/pointers/src/lib.rs b/ts/fixtures/lang/pointers/src/lib.rs new file mode 100644 index 000000000..39e2cb23b --- /dev/null +++ b/ts/fixtures/lang/pointers/src/lib.rs @@ -0,0 +1,49 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod pointers; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("pointers::copies", |_, data, out| pointers::copies(data, out)), + ("pointers::lists", |_, data, out| pointers::lists(data, out)), + ("pointers::nested", |_, data, out| pointers::nested(data, out)), + ("pointers::places", |_, data, out| pointers::places(data, out)), + ("pointers::sentinels", |_, data, out| pointers::sentinels(data, out)), + ("pointers::shared", |_, data, out| pointers::shared(data, out)), + ("pointers::unchecked", |_, data, out| pointers::unchecked(data, out)), + ("pointers::cells", |_, data, out| pointers::cells(data, out)), + ("pointers::rebound", |_, data, out| pointers::rebound(data, out)), + ("pointers::writers", |_, data, out| pointers::writers(data, out)), + ("pointers::made", |_, data, out| pointers::made(data, out)), + ("pointers::lapsed", |_, data, out| pointers::lapsed(data, out)), + ("pointers::segments", |_, data, out| pointers::segments(data, out)), + ("pointers::uninit_runs", |_, data, out| pointers::uninit_runs(data, out)), + ("pointers::beside_written", |_, data, out| { + pointers::beside_written(data, out) + }), + ("pointers::iterated_runs", |_, data, out| { + pointers::iterated_runs(data, out) + }), + ("pointers::waiters", |_, data, out| pointers::waiters(data, out)), + ("pointers::taken", |_, data, out| pointers::taken(data, out)), + ("pointers::bytes", |_, data, out| pointers::bytes(data, out)), + ("pointers::loaded", |_, data, out| pointers::loaded(data, out)), + ("pointers::reattached", |_, data, out| pointers::reattached(data, out)), + ("pointers::part_written", |_, data, out| { + pointers::part_written(data, out) + }), + ("pointers::aimed", |_, data, out| pointers::aimed(data, out)), + ] +} diff --git a/ts/fixtures/lang/src/pointers.rs b/ts/fixtures/lang/pointers/src/pointers.rs similarity index 100% rename from ts/fixtures/lang/src/pointers.rs rename to ts/fixtures/lang/pointers/src/pointers.rs diff --git a/ts/fixtures/lang/pointers/ts.toml b/ts/fixtures/lang/pointers/ts.toml new file mode 100644 index 000000000..5cb50e220 --- /dev/null +++ b/ts/fixtures/lang/pointers/ts.toml @@ -0,0 +1,2 @@ +package = "lang-pointers-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/refs/Cargo.toml b/ts/fixtures/lang/refs/Cargo.toml new file mode 100644 index 000000000..d479ce1b9 --- /dev/null +++ b/ts/fixtures/lang/refs/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-refs-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/refs/caller.ts b/ts/fixtures/lang/refs/caller.ts new file mode 100644 index 000000000..0fef64077 --- /dev/null +++ b/ts/fixtures/lang/refs/caller.ts @@ -0,0 +1,25 @@ +// The inputs `refs`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `refs::compared` of a split and the bytes either side of it, whose remainders by 3 and 5 + * make the bytes and floats: sides that are equal, empty, or a prefix of the other, and + * floats with a NaN before, after, or where they differ, and a `-0.0` against `0.0`. + */ +const placeCompares = [ + [2, 1, 2, 1, 2], + [0], + [0, 1], + [1, 1, 1, 2], + [2, 1, 2, 1], + [2, 0, 3, 0, 3], + [2, 0, 3, 1, 3], + [1, 3, 3, 1], + [2, 3, 0, 3, 1], + [1, 4, 0], +].map(([split, ...data]) => Uint8Array.of(...op("refs::compared"), split, ...data)); + +export const cases: Uint8Array[] = [...placeCompares]; diff --git a/ts/fixtures/lang/refs/expected/core/bool.ts b/ts/fixtures/lang/refs/expected/core/bool.ts new file mode 100644 index 000000000..a829bc88b --- /dev/null +++ b/ts/fixtures/lang/refs/expected/core/bool.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$0xksuo2(self: boolean, t: rt.Place): rt.Place | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function then$0ozmvid(self: boolean, f: () => rt.ByteVec): rt.ByteVec | undefined { + if (!self) { + return undefined; + } + return f(); +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/refs/expected/core/option.ts b/ts/fixtures/lang/refs/expected/core/option.ts new file mode 100644 index 000000000..9fbe75b1e --- /dev/null +++ b/ts/fixtures/lang/refs/expected/core/option.ts @@ -0,0 +1,134 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0x6fy3l(self: [rt.u8, rt.u8] | undefined, default_: [rt.u8, rt.u8]): [rt.u8, rt.u8] { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$11c0we2(self: rt.u32 | undefined, default_: rt.u32): rt.u32 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOrDefault$165pyh5(self: string | undefined): string { + if (self === undefined) { + return ""; + } + return self; +} + +export function unwrapOrDefault$0wx44sw(self: rt.ByteVec | undefined): rt.ByteVec { + if (self === undefined) { + return new rt.ByteVec(); + } + return self; +} + +export function map$1k7m6zz(self: [rt.u8, rt.u8] | undefined, f: (a0: [rt.u8, rt.u8]) => [rt.u8, rt.u8]): [rt.u8, rt.u8] | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$1fmzefe(self: rt.u8 | undefined, f: (a0: rt.u8) => [rt.u8, rt.u8]): [rt.u8, rt.u8] | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0cs071d(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function mapOr$1xztl8h(self: rt.u8 | undefined | rt.None, default_: rt.u8, f: (a0: rt.u8 | undefined) => rt.u8): rt.u8 { + if (self === rt.None) { + return default_; + } + return f(self); +} + +export function mapOr$0lcrgk1(self: string | undefined, default_: rt.u8, f: (a0: string) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1e4a1e0(self: rt.Ordering | undefined, default_: rt.u8, f: (a0: rt.Ordering) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1giiemz(self: rt.Place | undefined, default_: rt.u32, f: (a0: rt.Place) => rt.u32): rt.u32 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0mmpeqx(self: [rt.u8, rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u8, rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1m2xzon(self: rt.u8 | undefined, default_: boolean, f: (a0: rt.u8) => boolean): boolean { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1surhce(self: rt.u8 | undefined, default_: rt.u8, f: (a0: rt.u8) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function andThen$101gy6h(self: rt.Place | undefined, f: (a0: rt.Place) => rt.Place | undefined): rt.Place | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function filter$033ccod(self: [rt.u8, rt.u8] | undefined, predicate: (a0: [rt.u8, rt.u8]) => boolean): [rt.u8, rt.u8] | undefined { + if (self !== undefined) { + const x: [rt.u8, rt.u8] = self; + if (predicate(x)) { + return x; + } + } + return undefined; +} + +export function or$1loyskh(self: rt.u8 | undefined, optb: rt.u8 | undefined): rt.u8 | undefined { + if (self === undefined) { + return optb; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/refs/expected/core/result.ts b/ts/fixtures/lang/refs/expected/core/result.ts new file mode 100644 index 000000000..4708e9536 --- /dev/null +++ b/ts/fixtures/lang/refs/expected/core/result.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function err$1nqzzwu(self: rt.Result): rt.u8 | undefined { + if (self.ok) { + return undefined; + } + return self.error; +} + +export function asRef$0ssaoss(self: rt.Result): rt.Result { + if (self.ok) { + return rt.Ok(self.value); + } + return rt.Err(self.error); +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/refs/expected/harness.ts b/ts/fixtures/lang/refs/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/refs/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/refs/expected/lib.ts b/ts/fixtures/lang/refs/expected/lib.ts new file mode 100644 index 000000000..af928bf7c --- /dev/null +++ b/ts/fixtures/lang/refs/expected/lib.ts @@ -0,0 +1,36 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { refs, toRefs, adapted, compared } from "./refs.ts"; + +export function copy$Option_tuple2_u8_u8(v: [rt.u8, rt.u8] | undefined): [rt.u8, rt.u8] | undefined { + return v === undefined ? v : copy$tuple2_u8_u8(v); +} + +export function copy$array_u32(v: rt.u32[]): rt.u32[] { + return v.slice(); +} + +export function copy$tuple2_u8_u8(v: [rt.u8, rt.u8]): [rt.u8, rt.u8] { + return [v[0], v[1]]; +} + +export const out$u8: { err: unknown } = { err: undefined }; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["refs::refs", (_22: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + refs(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["refs::to_refs", (_23: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + toRefs(data2, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["refs::adapted", (_24: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + adapted(data3, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["refs::compared", (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec): undefined => { + compared(a0, a1.data, a1.start, a1.length, a2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/refs.Counts.ts b/ts/fixtures/lang/refs/expected/refs.Counts.ts similarity index 100% rename from ts/fixtures/lang/expected/refs.Counts.ts rename to ts/fixtures/lang/refs/expected/refs.Counts.ts diff --git a/ts/fixtures/lang/expected/refs.Cursor.ts b/ts/fixtures/lang/refs/expected/refs.Cursor.ts similarity index 100% rename from ts/fixtures/lang/expected/refs.Cursor.ts rename to ts/fixtures/lang/refs/expected/refs.Cursor.ts diff --git a/ts/fixtures/lang/expected/refs.Fetch.ts b/ts/fixtures/lang/refs/expected/refs.Fetch.ts similarity index 100% rename from ts/fixtures/lang/expected/refs.Fetch.ts rename to ts/fixtures/lang/refs/expected/refs.Fetch.ts diff --git a/ts/fixtures/lang/expected/refs.Held.ts b/ts/fixtures/lang/refs/expected/refs.Held.ts similarity index 100% rename from ts/fixtures/lang/expected/refs.Held.ts rename to ts/fixtures/lang/refs/expected/refs.Held.ts diff --git a/ts/fixtures/lang/expected/refs.Listing.ts b/ts/fixtures/lang/refs/expected/refs.Listing.ts similarity index 100% rename from ts/fixtures/lang/expected/refs.Listing.ts rename to ts/fixtures/lang/refs/expected/refs.Listing.ts diff --git a/ts/fixtures/lang/expected/refs.Nest.ts b/ts/fixtures/lang/refs/expected/refs.Nest.ts similarity index 66% rename from ts/fixtures/lang/expected/refs.Nest.ts rename to ts/fixtures/lang/refs/expected/refs.Nest.ts index 8c2fc72cc..b9bfc788e 100644 --- a/ts/fixtures/lang/expected/refs.Nest.ts +++ b/ts/fixtures/lang/refs/expected/refs.Nest.ts @@ -1,10 +1,10 @@ // Generated by rust2-ts. Do not edit. -import type * as refs_Pair from "./refs.Pair.ts"; +import type * as Pair from "./refs.Pair.ts"; /** A struct a reference points into. */ export interface Nest { - pair: refs_Pair.Pair; + pair: Pair.Pair; } //# sourceMappingURL=refs.Nest.ts.map diff --git a/ts/fixtures/lang/expected/refs.Pair.ts b/ts/fixtures/lang/refs/expected/refs.Pair.ts similarity index 100% rename from ts/fixtures/lang/expected/refs.Pair.ts rename to ts/fixtures/lang/refs/expected/refs.Pair.ts diff --git a/ts/fixtures/lang/expected/refs.Pair2.ts b/ts/fixtures/lang/refs/expected/refs.Pair2.ts similarity index 100% rename from ts/fixtures/lang/expected/refs.Pair2.ts rename to ts/fixtures/lang/refs/expected/refs.Pair2.ts diff --git a/ts/fixtures/lang/expected/refs.Reader.ts b/ts/fixtures/lang/refs/expected/refs.Reader.ts similarity index 100% rename from ts/fixtures/lang/expected/refs.Reader.ts rename to ts/fixtures/lang/refs/expected/refs.Reader.ts diff --git a/ts/fixtures/lang/expected/refs.ts b/ts/fixtures/lang/refs/expected/refs.ts similarity index 97% rename from ts/fixtures/lang/expected/refs.ts rename to ts/fixtures/lang/refs/expected/refs.ts index 939f278f5..2a89ebc29 100644 --- a/ts/fixtures/lang/expected/refs.ts +++ b/ts/fixtures/lang/refs/expected/refs.ts @@ -3,15 +3,15 @@ import * as rt from "./rt.ts"; import { copy$Option_tuple2_u8_u8, copy$array_u32, out$u8 } from "./lib.ts"; import { thenSome$0xksuo2, then$0ozmvid } from "./core/bool.ts"; -import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOr$0x6fy3l as option_unwrapOr$0x6fy3l, unwrapOr$11c0we2 as option_unwrapOr$11c0we2, unwrapOrDefault$165pyh5 as option_unwrapOrDefault$165pyh5, unwrapOrDefault$0wx44sw as option_unwrapOrDefault$0wx44sw, map$1k7m6zz as option_map$1k7m6zz, map$1fmzefe as option_map$1fmzefe, map$0cs071d as option_map$0cs071d, mapOr$1xztl8h as option_mapOr$1xztl8h, mapOr$0lcrgk1 as option_mapOr$0lcrgk1, mapOr$1e4a1e0 as option_mapOr$1e4a1e0, mapOr$1giiemz as option_mapOr$1giiemz, mapOr$1surhce as option_mapOr$1surhce, mapOr$0mmpeqx as option_mapOr$0mmpeqx, mapOr$1m2xzon as option_mapOr$1m2xzon, andThen$101gy6h as option_andThen$101gy6h, filter$033ccod, or$1loyskh as option_or$1loyskh } from "./core/option.ts"; +import { unwrapOr$0x6fy3l as option_unwrapOr$0x6fy3l, unwrapOr$11c0we2 as option_unwrapOr$11c0we2, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOrDefault$165pyh5 as option_unwrapOrDefault$165pyh5, unwrapOrDefault$0wx44sw as option_unwrapOrDefault$0wx44sw, map$1k7m6zz as option_map$1k7m6zz, map$1fmzefe as option_map$1fmzefe, map$0cs071d as option_map$0cs071d, mapOr$1xztl8h as option_mapOr$1xztl8h, mapOr$0lcrgk1 as option_mapOr$0lcrgk1, mapOr$1e4a1e0 as option_mapOr$1e4a1e0, mapOr$1giiemz as option_mapOr$1giiemz, mapOr$0mmpeqx as option_mapOr$0mmpeqx, mapOr$1m2xzon as option_mapOr$1m2xzon, mapOr$1surhce as option_mapOr$1surhce, andThen$101gy6h as option_andThen$101gy6h, filter$033ccod, or$1loyskh as option_or$1loyskh } from "./core/option.ts"; import { err$1nqzzwu, asRef$0ssaoss } from "./core/result.ts"; import * as Counts from "./refs.Counts.ts"; import * as Cursor from "./refs.Cursor.ts"; import type * as Fetch from "./refs.Fetch.ts"; -import type * as refs_Held from "./refs.Held.ts"; +import type * as Held from "./refs.Held.ts"; import * as Listing from "./refs.Listing.ts"; import type * as Nest from "./refs.Nest.ts"; -import * as refs_Pair from "./refs.Pair.ts"; +import * as Pair from "./refs.Pair.ts"; import type * as Pair2 from "./refs.Pair2.ts"; import * as Reader from "./refs.Reader.ts"; @@ -74,7 +74,7 @@ export function largestOf(seen: rt.Place, items: rt.ByteSlice } /** moq-net's `&mut Box`: changed through, and replaced whole. */ -export function rebox(b: rt.Place, by: rt.u8): void { +export function rebox(b: rt.Place, by: rt.u8): void { const _3: rt.u8 = rt.u8WrappingAdd(b.v.n, by); b.v.n = _3; if (rt.u8Rem(by, 2) === 0) { @@ -247,7 +247,7 @@ export function refs(data: rt.ByteSlice, out: rt.ByteVec): void { nested = undefined as rt.u8 | undefined; rt.byteVecPush(out, _117(old3)); rt.byteVecPush(out, _117(nested)); - let boxed: refs_Pair.Pair = { n: by }; + let boxed: Pair.Pair = { n: by }; const pair: [rt.u8, rt.u8] = [by, rt.u8WrappingAdd(by, 1)]; let fetch = { tag: "Idle" } as Fetch.Fetch; let text: string = ""; @@ -292,10 +292,10 @@ export function refs(data: rt.ByteSlice, out: rt.ByteVec): void { let remaining: rt.usize = rt.u8Rem(by, 5) as rt.usize; rt.byteVecPush(out, skip(rt.place(() => remaining, (value16) => remaining = value16), data) & 0xff); rt.byteVecPush(out, remaining & 0xff); - const _214: [refs_Pair.Pair, refs_Pair.Pair] = [{ n: 1 }, { n: 2 }]; - const a: refs_Pair.Pair = _214[0]; - const b5: refs_Pair.Pair = _214[1]; - let p: refs_Pair.Pair = a; + const _214: [Pair.Pair, Pair.Pair] = [{ n: 1 }, { n: 2 }]; + const a: Pair.Pair = _214[0]; + const b5: Pair.Pair = _214[1]; + let p: Pair.Pair = a; const borrowed = p; const r: rt.Place = rt.place(() => borrowed.n, (value17) => borrowed.n = value17); p = b5; @@ -1070,13 +1070,13 @@ export function kept(data: rt.ByteSlice, out: rt.ByteVec): void { const y: Nest.Nest = _20[1]; let i: rt.usize = rt.usizeRem(by as rt.usize, rt.byteSliceFrom(v).length); let r: Nest.Nest = x; - const held: refs_Held.Held = { at: x }; + const held: Held.Held = { at: x }; const copied: Nest.Nest = r; const _42: rt.usize = i; if (!(_42 < 4)) { rt.panic("index out of bounds: the len is " + 4 + " but the index is " + _42); } - const _44: refs_Pair.Pair = r.pair; + const _44: Pair.Pair = r.pair; const _82: Nest.Nest = held.at; const _48: Nest.Nest = held.at; const part = v[_42]; @@ -1153,11 +1153,11 @@ export function tallyAll$mut_mut_u32(t: rt.Place>>, da return total$refs_Tally_mut_mut_mut_u32(t); } -export function tallyAll$mut_refs_Pair(t: rt.Place, data: rt.ByteSlice): rt.u32 { +export function tallyAll$mut_refs_Pair(t: rt.Place, data: rt.ByteSlice): rt.u32 { for (const _5 of rt.byteSliceView(data)) { - refs_Pair.tally$refs_Tally_mut(t, _5); + Pair.tally$refs_Tally_mut(t, _5); } - return refs_Pair.total$refs_Tally_mut_mut(t); + return Pair.total$refs_Tally_mut_mut(t); } export function tallyAll$mut_u32(t: rt.Place>, data: rt.ByteSlice): rt.u32 { @@ -1168,7 +1168,7 @@ export function tallyAll$mut_u32(t: rt.Place>, data: rt.ByteSli } /** The larger of two references, replacing the one a `&mut` points at. */ -export function keepLarger(r: rt.Place, other: refs_Pair.Pair): void { +export function keepLarger(r: rt.Place, other: Pair.Pair): void { if (other.n > r.v.n) { r.v = other; } @@ -1297,11 +1297,11 @@ export function toRefs(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, skip(rt.usizeRem(n, 3)) & 0xff); rt.byteVecPush(out, skip(1) & 0xff); rt.byteVecPush(out, left.length & 0xff); - const pairs: refs_Pair.Pair[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 1))), (_22: rt.u8): refs_Pair.Pair => { + const pairs: Pair.Pair[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 1))), (_22: rt.u8): Pair.Pair => { return { n: _22 }; }), undefined, 1, true); - const first: refs_Pair.Pair = { n: 0 }; - let largest: refs_Pair.Pair = first; + const first: Pair.Pair = { n: 0 }; + let largest: Pair.Pair = first; for (const _147 of pairs) { keepLarger(rt.place(() => largest, (value3) => largest = value3), _147); } @@ -1314,10 +1314,10 @@ export function toRefs(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u32ToBeBytes(x))); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u32ToBeBytes(y))); let count: rt.u32 = 0; - const pair: refs_Pair.Pair = { n: 1 }; + const pair: Pair.Pair = { n: 1 }; let _182: rt.Place = rt.place(() => count, (value7) => count = value7); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u32ToBeBytes(tallyAll$mut_u32(rt.place(() => _182, (value8) => _182 = value8), rt.byteSliceRange(data, 1))))); - let _189: refs_Pair.Pair = pair; + let _189: Pair.Pair = pair; rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u32ToBeBytes(tallyAll$mut_refs_Pair(rt.place(() => _189, (value9) => _189 = value9), rt.byteSliceRange(data, 1))))); let _197: rt.Place = rt.place(() => count, (value10) => count = value10); let _196: rt.Place> = rt.place(() => _197, (value11) => _197 = value11); diff --git a/ts/fixtures/lang/refs/src/lib.rs b/ts/fixtures/lang/refs/src/lib.rs new file mode 100644 index 000000000..a4d762dbe --- /dev/null +++ b/ts/fixtures/lang/refs/src/lib.rs @@ -0,0 +1,24 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod refs; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("refs::refs", |_, data, out| refs::refs(data, out)), + ("refs::to_refs", |_, data, out| refs::to_refs(data, out)), + ("refs::adapted", |_, data, out| refs::adapted(data, out)), + ("refs::compared", refs::compared), + ] +} diff --git a/ts/fixtures/lang/src/refs.rs b/ts/fixtures/lang/refs/src/refs.rs similarity index 100% rename from ts/fixtures/lang/src/refs.rs rename to ts/fixtures/lang/refs/src/refs.rs diff --git a/ts/fixtures/lang/refs/ts.toml b/ts/fixtures/lang/refs/ts.toml new file mode 100644 index 000000000..db549a232 --- /dev/null +++ b/ts/fixtures/lang/refs/ts.toml @@ -0,0 +1,2 @@ +package = "lang-refs-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/results/Cargo.toml b/ts/fixtures/lang/results/Cargo.toml new file mode 100644 index 000000000..d78ca82e1 --- /dev/null +++ b/ts/fixtures/lang/results/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-results-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/results/expected/core/option.ts b/ts/fixtures/lang/results/expected/core/option.ts new file mode 100644 index 000000000..abd6afb03 --- /dev/null +++ b/ts/fixtures/lang/results/expected/core/option.ts @@ -0,0 +1,33 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$17ntxfo(self: rt.Result | undefined, default_: rt.Result): rt.Result { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function mapOr$1w5qtj7(self: undefined | rt.None, default_: rt.u8, f: (a0: undefined) => rt.u8): rt.u8 { + if (self === rt.None) { + return default_; + } + return f(self); +} + +export function mapOr$02k4ito(self: rt.usize | undefined, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/results/expected/core/result.ts b/ts/fixtures/lang/results/expected/core/result.ts new file mode 100644 index 000000000..4dc0f1e99 --- /dev/null +++ b/ts/fixtures/lang/results/expected/core/result.ts @@ -0,0 +1,13 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function map$03hz3l7(self: rt.Result, op: (a0: rt.u8) => undefined): rt.Result { + if (self.ok) { + op(self.value); + return rt.OK; + } + return self as rt.Result; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/results/expected/harness.ts b/ts/fixtures/lang/results/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/results/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/results/expected/lib.ts b/ts/fixtures/lang/results/expected/lib.ts new file mode 100644 index 000000000..4e150e2cc --- /dev/null +++ b/ts/fixtures/lang/results/expected/lib.ts @@ -0,0 +1,41 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { results } from "./results.ts"; +import type * as Logged from "./results.Logged.ts"; + +export function copy$Result_array0_u8_u8(v: rt.Result): rt.Result { + return v.ok ? rt.Ok(copy$array_u8(v.value)) : rt.Err(v.error); +} + +export function copy$Result_array1_u8_u8(v: rt.Result): rt.Result { + return v.ok ? rt.Ok(copy$array_u8(v.value)) : rt.Err(v.error); +} + +export function copy$Result_array5_u8_u8(v: rt.Result): rt.Result { + return v.ok ? rt.Ok(copy$array_u8(v.value)) : rt.Err(v.error); +} + +export function copy$array_u8(v: Uint8Array): Uint8Array { + return v.slice(); +} + +export function drop$Result_results_Logged_results_Logged(_1: rt.Result): void { + if (_1.ok) { + _1.value[Symbol.dispose](); + } else { + _1.error[Symbol.dispose](); + } +} + +export const out$u8: { err: unknown } = { err: undefined }; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["results::results", results as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/results.Logged.ts b/ts/fixtures/lang/results/expected/results.Logged.ts similarity index 100% rename from ts/fixtures/lang/expected/results.Logged.ts rename to ts/fixtures/lang/results/expected/results.Logged.ts diff --git a/ts/fixtures/lang/expected/results.ts b/ts/fixtures/lang/results/expected/results.ts similarity index 90% rename from ts/fixtures/lang/expected/results.ts rename to ts/fixtures/lang/results/expected/results.ts index f83f4c610..3fe967d2b 100644 --- a/ts/fixtures/lang/expected/results.ts +++ b/ts/fixtures/lang/results/expected/results.ts @@ -4,7 +4,7 @@ import * as rt from "./rt.ts"; import { copy$Result_array0_u8_u8, copy$Result_array1_u8_u8, copy$Result_array5_u8_u8, drop$Result_results_Logged_results_Logged, out$u8 } from "./lib.ts"; import { unwrapOr$17ntxfo as option_unwrapOr$17ntxfo, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, mapOr$1w5qtj7 as option_mapOr$1w5qtj7, mapOr$02k4ito as option_mapOr$02k4ito } from "./core/option.ts"; import { map$03hz3l7 as result_map$03hz3l7 } from "./core/result.ts"; -import * as results_Logged from "./results.Logged.ts"; +import * as Logged from "./results.Logged.ts"; /** The iterators of `Result`s of each payload `kind` picks. */ export function results(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { @@ -145,85 +145,85 @@ export function flush(log: rt.RefCell, out: rt.ByteVec): void { */ export function owned(data: rt.ByteSlice, out: rt.ByteVec): void { const log: rt.Arc> = new rt.Arc(new rt.RefCell(new rt.ByteVec())); - const made: (a0: rt.u8) => rt.Result = (b2: rt.u8): rt.Result => { - const logged: results_Logged.Logged = new results_Logged.Logged(b2, rt.arcClone(log)); + const made: (a0: rt.u8) => rt.Result = (b2: rt.u8): rt.Result => { + const logged: Logged.Logged = new Logged.Logged(b2, rt.arcClone(log)); if (!(rt.u8Rem(b2, 3) === 0)) { return rt.Ok(logged); } return rt.Err(logged); }; for (const b of rt.byteSliceView(data)) { - const it: rt.Iter = rt.iterResult(made(b), rt.drop, rt.drop); + const it: rt.Iter = rt.iterResult(made(b), rt.drop, rt.drop); const _21: rt.RefCell = rt.refCellBorrowMut(log.value); rt.byteVecPush(_21.value, 254); rt.refMutRelease(_21); rt.drop(it); - const iter2: rt.Iter = rt.iterResult(made(b), rt.drop, rt.drop); + const iter2: rt.Iter = rt.iterResult(made(b), rt.drop, rt.drop); while (true) { - const _30: results_Logged.Logged | rt.Done = iter2.next(); + const _30: Logged.Logged | rt.Done = iter2.next(); if (_30 === rt.DONE) { break; } - const l: results_Logged.Logged = _30; + const l: Logged.Logged = _30; rt.byteVecPush(out, l.id); l[Symbol.dispose](); } rt.drop(iter2); flush(log.value, out); } - const results: rt.Result[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): rt.Result => { + const results: rt.Result[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): rt.Result => { return made(_2); }), undefined, 12, true); for (const _47 of results) { - rt.iterExtendBytes(out, rt.iterMap(rt.iterResult(_47), (l3: results_Logged.Logged): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterResult(_47), (l3: Logged.Logged): rt.u8 => { return l3.id; }), undefined, true); } - const iter4: rt.Iter>> = rt.iterSliceMut(results); + const iter4: rt.Iter>> = rt.iterSliceMut(results); l7: while (true) { - const _59: rt.Place> | rt.Done = iter4.next(); + const _59: rt.Place> | rt.Done = iter4.next(); if (_59 === rt.DONE) { break; } - const iter5: rt.Iter = rt.iterResult(_59.v); + const iter5: rt.Iter = rt.iterResult(_59.v); while (true) { - const _65: results_Logged.Logged | rt.Done = iter5.next(); + const _65: Logged.Logged | rt.Done = iter5.next(); if (_65 === rt.DONE) { continue l7; } _65.id = _65.id ^ 64; } } - const iter6: rt.Iter = rt.iterRev(rt.iterFlatten(rt.iterSliceMut(results), (value: rt.Place>) => rt.iterResult(value.v), false, undefined, true)); + const iter6: rt.Iter = rt.iterRev(rt.iterFlatten(rt.iterSliceMut(results), (value: rt.Place>) => rt.iterResult(value.v), false, undefined, true)); while (true) { - const _76: results_Logged.Logged | rt.Done = iter6.next(); + const _76: Logged.Logged | rt.Done = iter6.next(); if (_76 === rt.DONE) { break; } _76.id = rt.u8WrappingAdd(_76.id, 1); } - rt.iterExtendBytes(out, rt.iterMap(rt.iterFlatten(rt.iterSlice(results), (value: rt.Result) => rt.iterResult(value), false, undefined, true), (l4: results_Logged.Logged): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterFlatten(rt.iterSlice(results), (value: rt.Result) => rt.iterResult(value), false, undefined, true), (l4: Logged.Logged): rt.u8 => { return l4.id; }), "next"); flush(log.value, out); - const iter7: rt.Iter = rt.iterTake(rt.iterFlatten(rt.iterSlice(results, drop$Result_results_Logged_results_Logged), (value: rt.Result) => rt.iterResult(value, rt.drop, rt.drop), true, undefined, true), 2, rt.drop); + const iter7: rt.Iter = rt.iterTake(rt.iterFlatten(rt.iterSlice(results, drop$Result_results_Logged_results_Logged), (value: rt.Result) => rt.iterResult(value, rt.drop, rt.drop), true, undefined, true), 2, rt.drop); while (true) { - const _97: results_Logged.Logged | rt.Done = iter7.next(); + const _97: Logged.Logged | rt.Done = iter7.next(); if (_97 === rt.DONE) { break; } - const l2: results_Logged.Logged = _97; + const l2: Logged.Logged = _97; rt.byteVecPush(out, l2.id); flush(log.value, out); l2[Symbol.dispose](); } rt.drop(iter7); flush(log.value, out); - const rest: results_Logged.Logged[] = rt.iterToArray(rt.iterFlatten(rt.iterMap(rt.iterRev(rt.iterSlice(rt.byteSliceView(data))), (_23: rt.u8): rt.Result => { + const rest: Logged.Logged[] = rt.iterToArray(rt.iterFlatten(rt.iterMap(rt.iterRev(rt.iterSlice(rt.byteSliceView(data))), (_23: rt.u8): rt.Result => { return made(_23); - }), (value: rt.Result) => rt.iterResult(value, rt.drop, rt.drop), false, undefined, true), "next", 8); + }), (value: rt.Result) => rt.iterResult(value, rt.drop, rt.drop), false, undefined, true), "next", 8); flush(log.value, out); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(rest), (l5: results_Logged.Logged): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(rest), (l5: Logged.Logged): rt.u8 => { return l5.id; }), undefined, true); rt.dropAll(rest); diff --git a/ts/fixtures/lang/results/src/lib.rs b/ts/fixtures/lang/results/src/lib.rs new file mode 100644 index 000000000..4fa59f38d --- /dev/null +++ b/ts/fixtures/lang/results/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod results; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("results::results", results::results)] +} diff --git a/ts/fixtures/lang/src/results.rs b/ts/fixtures/lang/results/src/results.rs similarity index 100% rename from ts/fixtures/lang/src/results.rs rename to ts/fixtures/lang/results/src/results.rs diff --git a/ts/fixtures/lang/results/ts.toml b/ts/fixtures/lang/results/ts.toml new file mode 100644 index 000000000..10f900b5c --- /dev/null +++ b/ts/fixtures/lang/results/ts.toml @@ -0,0 +1,2 @@ +package = "lang-results-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/returns/Cargo.toml b/ts/fixtures/lang/returns/Cargo.toml new file mode 100644 index 000000000..fa59bea58 --- /dev/null +++ b/ts/fixtures/lang/returns/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-returns-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/returns/expected/core/bool.ts b/ts/fixtures/lang/returns/expected/core/bool.ts new file mode 100644 index 000000000..d3dfeb463 --- /dev/null +++ b/ts/fixtures/lang/returns/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function then$0w2ymju(self: boolean, f: () => rt.ByteSlice): rt.ByteSlice | undefined { + if (!self) { + return undefined; + } + return f(); +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/returns/expected/core/option.ts b/ts/fixtures/lang/returns/expected/core/option.ts new file mode 100644 index 000000000..01fe14751 --- /dev/null +++ b/ts/fixtures/lang/returns/expected/core/option.ts @@ -0,0 +1,55 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as returns_Error from "../returns.Error.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$0c2keyb(self: rt.ByteSlice | undefined, f: (a0: rt.ByteSlice) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$1yogfym(self: [rt.u8, rt.ByteSlice] | undefined, f: (a0: [rt.u8, rt.ByteSlice]) => rt.ByteSlice): rt.ByteSlice | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function okOr$1b6nkwr(self: rt.char | undefined, err: rt.u8): rt.Result { + if (self === undefined) { + return rt.Err(err); + } + return rt.Ok(self); +} + +export function okOr$0gtm15y(self: rt.ByteSlice | undefined, err: rt.u8 | undefined): rt.Result { + if (self === undefined) { + return rt.Err(err); + } + return rt.Ok(self); +} + +export function okOr$12p77jh(self: rt.ByteSlice | undefined, err: returns_Error.Error): rt.Result { + if (self === undefined) { + return rt.Err(err); + } + return rt.Ok(self); +} + +export function okOr$0tezn0w(self: rt.ByteSlice | undefined, _: undefined): rt.Result { + if (self === undefined) { + return rt.ERR; + } + return rt.Ok(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/returns/expected/core/result.ts b/ts/fixtures/lang/returns/expected/core/result.ts new file mode 100644 index 000000000..42c87b508 --- /dev/null +++ b/ts/fixtures/lang/returns/expected/core/result.ts @@ -0,0 +1,27 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as returns_Error from "../returns.Error.ts"; + +export function map$1rffkv6(self: rt.Result, _: (a0: rt.u32) => rt.u64): rt.Result { + if (self.ok) { + return rt.Ok(self.value as rt.u64); + } + return self as rt.Result; +} + +export function mapOr$0fbyajt(self: rt.Result, default_: rt.usize, _: (a0: rt.ByteSlice) => rt.usize): rt.usize { + if (self.ok) { + return self.value.length; + } + return default_; +} + +export function andThen$1yropo4(self: rt.Result<[rt.ByteSlice, rt.ByteSlice], returns_Error.Error>, op: (a0: [rt.ByteSlice, rt.ByteSlice]) => rt.Result): rt.Result { + if (self.ok) { + return op(self.value); + } + return self as rt.Result; +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/returns/expected/harness.ts b/ts/fixtures/lang/returns/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/returns/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/returns/expected/lib.ts b/ts/fixtures/lang/returns/expected/lib.ts new file mode 100644 index 000000000..30218957d --- /dev/null +++ b/ts/fixtures/lang/returns/expected/lib.ts @@ -0,0 +1,42 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { returns } from "./returns.ts"; + +export const out$bool: { p: boolean } = { p: undefined as never }; + +export const out$ref_slice_u8: { pData: Uint8Array; pStart: number; pLen: number } = { pData: undefined as never, pStart: undefined as never, pLen: undefined as never }; + +export const out$tuple2_f64_char: { err: unknown; p_1: rt.char } = { err: undefined, p_1: undefined as never }; + +export const out$tuple2_i64_u64: { err: unknown; p_1: rt.u64 } = { err: undefined, p_1: undefined as never }; + +export const out$tuple2_ref_slice_u8_ref_slice_u8: { p_0Data: Uint8Array; p_0Start: number; p_0Len: number; p_1Data: Uint8Array; p_1Start: number; p_1Len: number } = { p_0Data: undefined as never, p_0Start: undefined as never, p_0Len: undefined as never, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never }; + +export const out$tuple2_u16_ref_slice_u8: { err: unknown; p_1Data: Uint8Array; p_1Start: number; p_1Len: number } = { err: undefined, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never }; + +export const out$tuple2_u32_ref_slice_u8: { err: unknown; p_1Data: Uint8Array; p_1Start: number; p_1Len: number } = { err: undefined, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never }; + +export const out$tuple2_u64_ref_slice_u8: { err: unknown; p_1Data: Uint8Array; p_1Start: number; p_1Len: number } = { err: undefined, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never }; + +export const out$tuple2_u8_ref_slice_u8: { err: unknown; p_1Data: Uint8Array; p_1Start: number; p_1Len: number } = { err: undefined, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never }; + +export const out$tuple3_ref_slice_u8_ref_array2_u8_ref_slice_u8: { p_0Data: Uint8Array; p_0Start: number; p_0Len: number; p_1Data: Uint8Array; p_1Start: number; p_1Len: number; p_2Data: Uint8Array; p_2Start: number; p_2Len: number } = { p_0Data: undefined as never, p_0Start: undefined as never, p_0Len: undefined as never, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never, p_2Data: undefined as never, p_2Start: undefined as never, p_2Len: undefined as never }; + +export const out$tuple3_u64_u64_ref_slice_u8: { err: unknown; p_1: rt.u64; p_2Data: Uint8Array; p_2Start: number; p_2Len: number } = { err: undefined, p_1: undefined as never, p_2Data: undefined as never, p_2Start: undefined as never, p_2Len: undefined as never }; + +export const out$u32: { err: unknown } = { err: undefined }; + +export const out$u64: { err: unknown } = { err: undefined }; + +export const out$u8: { err: unknown } = { err: undefined }; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["returns::returns", returns as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/returns.At.ts b/ts/fixtures/lang/returns/expected/returns.At.ts similarity index 100% rename from ts/fixtures/lang/expected/returns.At.ts rename to ts/fixtures/lang/returns/expected/returns.At.ts diff --git a/ts/fixtures/lang/expected/returns.Error.ts b/ts/fixtures/lang/returns/expected/returns.Error.ts similarity index 100% rename from ts/fixtures/lang/expected/returns.Error.ts rename to ts/fixtures/lang/returns/expected/returns.Error.ts diff --git a/ts/fixtures/lang/expected/returns.Guard.ts b/ts/fixtures/lang/returns/expected/returns.Guard.ts similarity index 100% rename from ts/fixtures/lang/expected/returns.Guard.ts rename to ts/fixtures/lang/returns/expected/returns.Guard.ts diff --git a/ts/fixtures/lang/expected/returns.Late.ts b/ts/fixtures/lang/returns/expected/returns.Late.ts similarity index 100% rename from ts/fixtures/lang/expected/returns.Late.ts rename to ts/fixtures/lang/returns/expected/returns.Late.ts diff --git a/ts/fixtures/lang/expected/returns.Split.ts b/ts/fixtures/lang/returns/expected/returns.Split.ts similarity index 100% rename from ts/fixtures/lang/expected/returns.Split.ts rename to ts/fixtures/lang/returns/expected/returns.Split.ts diff --git a/ts/fixtures/lang/expected/returns.Wrapped.ts b/ts/fixtures/lang/returns/expected/returns.Wrapped.ts similarity index 100% rename from ts/fixtures/lang/expected/returns.Wrapped.ts rename to ts/fixtures/lang/returns/expected/returns.Wrapped.ts diff --git a/ts/fixtures/lang/expected/returns.ts b/ts/fixtures/lang/returns/expected/returns.ts similarity index 98% rename from ts/fixtures/lang/expected/returns.ts rename to ts/fixtures/lang/returns/expected/returns.ts index 29e2cce11..ed3915604 100644 --- a/ts/fixtures/lang/expected/returns.ts +++ b/ts/fixtures/lang/returns/expected/returns.ts @@ -10,7 +10,7 @@ import * as returns_Error from "./returns.Error.ts"; import * as Guard from "./returns.Guard.ts"; import * as Late from "./returns.Late.ts"; import * as Split from "./returns.Split.ts"; -import * as returns_Wrapped from "./returns.Wrapped.ts"; +import * as Wrapped from "./returns.Wrapped.ts"; /** A slice alone, with returns from several places. */ export function take(dataData: Uint8Array, dataStart: number, dataLen: number, n: rt.usize): returns_Error.Error | undefined { @@ -319,7 +319,7 @@ export function wrapped(dataData: Uint8Array, dataStart: number, dataLen: number out$tuple2_u8_ref_slice_u8.p_1Len = dataLen; return _19_0; } - out$tuple2_u8_ref_slice_u8.err = returns_Wrapped.from$convert_From_tuple2_ref_slice_u8_u8([new rt.ByteSlice(_15_0Data, _15_0Start, _15_0Len), _15_1]); + out$tuple2_u8_ref_slice_u8.err = Wrapped.from$convert_From_tuple2_ref_slice_u8_u8([new rt.ByteSlice(_15_0Data, _15_0Start, _15_0Len), _15_1]); return undefined; } @@ -739,12 +739,12 @@ export function returns(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void rt.byteVecPush(out, returns_Error.code(err5 as returns_Error.Error)); } const part20: rt.u8 | undefined = wrapped(data.data, data.start, data.length); - const err6: returns_Wrapped.Wrapped | undefined = part20 === undefined ? out$tuple2_u8_ref_slice_u8.err as returns_Wrapped.Wrapped : undefined; + const err6: Wrapped.Wrapped | undefined = part20 === undefined ? out$tuple2_u8_ref_slice_u8.err as Wrapped.Wrapped : undefined; const part23: number = out$tuple2_u8_ref_slice_u8.p_1Len; if (err6 === undefined) { rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(part20 as rt.u8, part23 & 0xff))); } else { - rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(238, (err6 as returns_Wrapped.Wrapped)._0, (err6 as returns_Wrapped.Wrapped)._1))); + rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(238, (err6 as Wrapped.Wrapped)._0, (err6 as Wrapped.Wrapped)._1))); } } else { const at: At.At = { _0: rt.usizeRem(kind as rt.usize, 5) }; diff --git a/ts/fixtures/lang/returns/src/lib.rs b/ts/fixtures/lang/returns/src/lib.rs new file mode 100644 index 000000000..6c6d828d3 --- /dev/null +++ b/ts/fixtures/lang/returns/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod returns; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("returns::returns", returns::returns)] +} diff --git a/ts/fixtures/lang/src/returns.rs b/ts/fixtures/lang/returns/src/returns.rs similarity index 100% rename from ts/fixtures/lang/src/returns.rs rename to ts/fixtures/lang/returns/src/returns.rs diff --git a/ts/fixtures/lang/returns/ts.toml b/ts/fixtures/lang/returns/ts.toml new file mode 100644 index 000000000..761c06930 --- /dev/null +++ b/ts/fixtures/lang/returns/ts.toml @@ -0,0 +1,2 @@ +package = "lang-returns-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/rings/Cargo.toml b/ts/fixtures/lang/rings/Cargo.toml new file mode 100644 index 000000000..679424b6e --- /dev/null +++ b/ts/fixtures/lang/rings/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-rings-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/rings/caller.ts b/ts/fixtures/lang/rings/caller.ts new file mode 100644 index 000000000..9e60cc638 --- /dev/null +++ b/ts/fixtures/lang/rings/caller.ts @@ -0,0 +1,32 @@ +// The inputs `rings`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `rings::slices` of each item type, from a deque made by `new`, `with_capacity` of 5, and + * from a `Vec` of 7: pushed at both ends and popped at the front to wrap it, past a few + * capacities, then each step by a few arguments, twice. + */ +const ringsCases = Array.from({ length: 5 * 3 * 4 * 24 * 3 }, (_, i) => { + const [kind, first, wraps, step, arg] = [i % 5, [0, 0x15, 0x1e][Math.floor(i / 5) % 3], [1, 3, 6, 10][Math.floor(i / 15) % 4], Math.floor(i / 60) % 24, [0, 0x5b, 0xe7][Math.floor(i / 1440)]]; + const wrap = Array.from({ length: wraps }, (_, j) => [j % 3 === 2 ? 4 : 0, j * 3, 6, 0, 4, j]).flat(); + return Uint8Array.of(...op("rings::slices"), kind, first, ...wrap, step, arg, step, arg ^ 0x25); +}); + +/** + * `rings::slices` remaking each wrapped deque each way and with a few skips: a clone, + * `clone_from`, `clone_into`, its `into_iter` read in part and by `nth`, from a `Vec` as it + * is and filtered in place, and a `Vec`'s `into_iter` read in part, collected as it is and + * cloned; then pushed at both ends. + */ +const remadeCases = [0, 5, 0x2d, 0x37, 0x64, 0x6e, 1, 0x10, 2, 0x11, 3, 0x21, 0x0e, 0x13, 0x45, 0x5f].flatMap((arg) => + Array.from({ length: 5 * 3 * 4 }, (_, i) => { + const [kind, first, wraps] = [i % 5, [0, 0x15, 0x1e][Math.floor(i / 5) % 3], [1, 3, 6, 10][Math.floor(i / 15)]]; + const wrap = Array.from({ length: wraps }, (_, j) => [j % 3 === 2 ? 4 : 0, j * 3, 6, 0, 4, j]).flat(); + return Uint8Array.of(...op("rings::slices"), kind, first, ...wrap, 22, arg, 0, 9, 4, 9); + }), +); + +export const cases: Uint8Array[] = [...ringsCases, ...remadeCases]; diff --git a/ts/fixtures/lang/rings/expected/core/option.ts b/ts/fixtures/lang/rings/expected/core/option.ts new file mode 100644 index 000000000..07f3e7865 --- /dev/null +++ b/ts/fixtures/lang/rings/expected/core/option.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function mapOr$1ttssgs(self: [rt.u8, rt.ByteSlice] | undefined, default_: [rt.u8, rt.ByteSlice], f: (a0: [rt.u8, rt.ByteSlice]) => [rt.u8, rt.ByteSlice]): [rt.u8, rt.ByteSlice] { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/rings/expected/harness.ts b/ts/fixtures/lang/rings/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/rings/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/rings/expected/lib.ts b/ts/fixtures/lang/rings/expected/lib.ts new file mode 100644 index 000000000..d9808ec33 --- /dev/null +++ b/ts/fixtures/lang/rings/expected/lib.ts @@ -0,0 +1,16 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { slices } from "./rings.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["rings::slices", (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec): undefined => { + slices(a0, a1.data, a1.start, a1.length, a2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/rings.Big.ts b/ts/fixtures/lang/rings/expected/rings.Big.ts similarity index 100% rename from ts/fixtures/lang/expected/rings.Big.ts rename to ts/fixtures/lang/rings/expected/rings.Big.ts diff --git a/ts/fixtures/lang/expected/rings.ts b/ts/fixtures/lang/rings/expected/rings.ts similarity index 100% rename from ts/fixtures/lang/expected/rings.ts rename to ts/fixtures/lang/rings/expected/rings.ts diff --git a/ts/fixtures/lang/rings/src/lib.rs b/ts/fixtures/lang/rings/src/lib.rs new file mode 100644 index 000000000..ebea938b3 --- /dev/null +++ b/ts/fixtures/lang/rings/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod rings; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("rings::slices", rings::slices)] +} diff --git a/ts/fixtures/lang/src/rings.rs b/ts/fixtures/lang/rings/src/rings.rs similarity index 100% rename from ts/fixtures/lang/src/rings.rs rename to ts/fixtures/lang/rings/src/rings.rs diff --git a/ts/fixtures/lang/rings/ts.toml b/ts/fixtures/lang/rings/ts.toml new file mode 100644 index 000000000..07ad1e78b --- /dev/null +++ b/ts/fixtures/lang/rings/ts.toml @@ -0,0 +1,2 @@ +package = "lang-rings-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/saturates/Cargo.toml b/ts/fixtures/lang/saturates/Cargo.toml new file mode 100644 index 000000000..7d3af6e80 --- /dev/null +++ b/ts/fixtures/lang/saturates/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-saturates-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/saturates/caller.ts b/ts/fixtures/lang/saturates/caller.ts new file mode 100644 index 000000000..810d9d3b4 --- /dev/null +++ b/ts/fixtures/lang/saturates/caller.ts @@ -0,0 +1,35 @@ +// The inputs `saturates`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `saturates::*` of every kind at every width, over operands at the edges of its range and + * across them: 0, 1, either end, the sign bit's neighbors, which make `MIN / -1` and + * `MIN % -1`, and at 128 bits values past 2^64. + */ +function saturates(): Uint8Array[] { + const widths: [string, number][] = [["u8s", 8], ["u16s", 16], ["u32s", 32], ["u64s", 64], ["u128s", 128], ["usizes", 32], ["i8s", 8], ["i16s", 16], ["i32s", 32], ["i64s", 64], ["i128s", 128], ["isizes", 32]]; + const cases: Uint8Array[] = []; + for (const [name, bits] of widths) { + const o = op(`saturates::${name}`); + const width = BigInt(bits); + const mask = (1n << width) - 1n; + const sign = 1n << (width - 1n); + const half = sign >> 1n; + const edges = [0n, 1n, 3n, mask, mask - 1n, sign, sign - 1n, sign + 1n, half, half + 1n, mask - half]; + if (bits === 128) edges.push(1n << 64n, (1n << 64n) + 3n, 0x9e3779b97f4a7c150123456789abcdefn); + const be = (v: bigint) => Array.from({ length: bits / 8 }, (_, i) => Number((v >> BigInt(bits - 8 - 8 * i)) & 0xffn)); + let i = 0; + for (const a of edges) { + for (const b of edges) { + const c = edges[(i++ * 5 + 3) % edges.length]; + for (let kind = 0; kind < 24; kind++) cases.push(Uint8Array.of(...o, kind, ...be(a), ...be(b), ...be(c))); + } + } + } + return cases; +} + +export const cases: Uint8Array[] = [...saturates()]; diff --git a/ts/fixtures/lang/saturates/expected/core/option.ts b/ts/fixtures/lang/saturates/expected/core/option.ts new file mode 100644 index 000000000..45fcd396d --- /dev/null +++ b/ts/fixtures/lang/saturates/expected/core/option.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function isSomeAnd$08u1px1(self: rt.Ordering | undefined, f: (a0: rt.Ordering) => boolean): boolean { + if (self === undefined) { + return false; + } + return f(self); +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/saturates/expected/harness.ts b/ts/fixtures/lang/saturates/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/saturates/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/saturates/expected/lib.ts b/ts/fixtures/lang/saturates/expected/lib.ts new file mode 100644 index 000000000..a04919eb3 --- /dev/null +++ b/ts/fixtures/lang/saturates/expected/lib.ts @@ -0,0 +1,63 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { u8s, u16s, u32s, u64s, u128s, usizes, i8s, i16s, i32s, i64s, i128s, isizes } from "./saturates.ts"; +import * as Gauge from "./saturates.Gauge.ts"; + +export function copy$saturates_Gauge_i128(v: Gauge.Gauge): Gauge.Gauge { + return new Gauge.Gauge(v._0); +} + +export function copy$saturates_Gauge_i16(v: Gauge.Gauge): Gauge.Gauge { + return new Gauge.Gauge(v._0); +} + +export function copy$saturates_Gauge_i32(v: Gauge.Gauge): Gauge.Gauge { + return new Gauge.Gauge(v._0); +} + +export function copy$saturates_Gauge_i64(v: Gauge.Gauge): Gauge.Gauge { + return new Gauge.Gauge(v._0); +} + +export function copy$saturates_Gauge_i8(v: Gauge.Gauge): Gauge.Gauge { + return new Gauge.Gauge(v._0); +} + +export function copy$saturates_Gauge_isize(v: Gauge.Gauge): Gauge.Gauge { + return new Gauge.Gauge(v._0); +} + +export function copy$saturates_Gauge_u128(v: Gauge.Gauge): Gauge.Gauge { + return new Gauge.Gauge(v._0); +} + +export function copy$saturates_Gauge_u16(v: Gauge.Gauge): Gauge.Gauge { + return new Gauge.Gauge(v._0); +} + +export function copy$saturates_Gauge_u32(v: Gauge.Gauge): Gauge.Gauge { + return new Gauge.Gauge(v._0); +} + +export function copy$saturates_Gauge_u64(v: Gauge.Gauge): Gauge.Gauge { + return new Gauge.Gauge(v._0); +} + +export function copy$saturates_Gauge_u8(v: Gauge.Gauge): Gauge.Gauge { + return new Gauge.Gauge(v._0); +} + +export function copy$saturates_Gauge_usize(v: Gauge.Gauge): Gauge.Gauge { + return new Gauge.Gauge(v._0); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["saturates::u8s", u8s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::u16s", u16s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::u32s", u32s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::u64s", u64s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::u128s", u128s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::usizes", usizes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::i8s", i8s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::i16s", i16s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::i32s", i32s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::i64s", i64s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::i128s", i128s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["saturates::isizes", isizes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/saturates.Gauge.ts b/ts/fixtures/lang/saturates/expected/saturates.Gauge.ts similarity index 100% rename from ts/fixtures/lang/expected/saturates.Gauge.ts rename to ts/fixtures/lang/saturates/expected/saturates.Gauge.ts diff --git a/ts/fixtures/lang/expected/saturates.ts b/ts/fixtures/lang/saturates/expected/saturates.ts similarity index 89% rename from ts/fixtures/lang/expected/saturates.ts rename to ts/fixtures/lang/saturates/expected/saturates.ts index 57df4d614..8e7adcc10 100644 --- a/ts/fixtures/lang/expected/saturates.ts +++ b/ts/fixtures/lang/saturates/expected/saturates.ts @@ -3,7 +3,7 @@ import * as rt from "./rt.ts"; import { copy$saturates_Gauge_i128, copy$saturates_Gauge_i16, copy$saturates_Gauge_i32, copy$saturates_Gauge_i64, copy$saturates_Gauge_i8, copy$saturates_Gauge_isize, copy$saturates_Gauge_u128, copy$saturates_Gauge_u16, copy$saturates_Gauge_u32, copy$saturates_Gauge_u64, copy$saturates_Gauge_u8, copy$saturates_Gauge_usize } from "./lib.ts"; import { isSomeAnd$08u1px1, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr } from "./core/option.ts"; -import * as saturates_Gauge from "./saturates.Gauge.ts"; +import * as Gauge from "./saturates.Gauge.ts"; export function hashed$i128(v: rt.i128): rt.u64 { const h: rt.Hasher = rt.hasher(); @@ -113,75 +113,75 @@ export function hashed$num_Saturating_usize(v: rt.usize): rt.u64 { return rt.hashFinish(h); } -export function hashed$saturates_Gauge_i128(v: saturates_Gauge.Gauge): rt.u64 { +export function hashed$saturates_Gauge_i128(v: Gauge.Gauge): rt.u64 { const h: rt.Hasher = rt.hasher(); - saturates_Gauge.hash$Hash_i128_hash_DefaultHasher(v, h); + Gauge.hash$Hash_i128_hash_DefaultHasher(v, h); return rt.hashFinish(h); } -export function hashed$saturates_Gauge_i16(v: saturates_Gauge.Gauge): rt.u64 { +export function hashed$saturates_Gauge_i16(v: Gauge.Gauge): rt.u64 { const h: rt.Hasher = rt.hasher(); - saturates_Gauge.hash$Hash_i16_hash_DefaultHasher(v, h); + Gauge.hash$Hash_i16_hash_DefaultHasher(v, h); return rt.hashFinish(h); } -export function hashed$saturates_Gauge_i32(v: saturates_Gauge.Gauge): rt.u64 { +export function hashed$saturates_Gauge_i32(v: Gauge.Gauge): rt.u64 { const h: rt.Hasher = rt.hasher(); - saturates_Gauge.hash$Hash_i32_hash_DefaultHasher(v, h); + Gauge.hash$Hash_i32_hash_DefaultHasher(v, h); return rt.hashFinish(h); } -export function hashed$saturates_Gauge_i64(v: saturates_Gauge.Gauge): rt.u64 { +export function hashed$saturates_Gauge_i64(v: Gauge.Gauge): rt.u64 { const h: rt.Hasher = rt.hasher(); - saturates_Gauge.hash$Hash_i64_hash_DefaultHasher(v, h); + Gauge.hash$Hash_i64_hash_DefaultHasher(v, h); return rt.hashFinish(h); } -export function hashed$saturates_Gauge_i8(v: saturates_Gauge.Gauge): rt.u64 { +export function hashed$saturates_Gauge_i8(v: Gauge.Gauge): rt.u64 { const h: rt.Hasher = rt.hasher(); - saturates_Gauge.hash$Hash_i8_hash_DefaultHasher(v, h); + Gauge.hash$Hash_i8_hash_DefaultHasher(v, h); return rt.hashFinish(h); } -export function hashed$saturates_Gauge_isize(v: saturates_Gauge.Gauge): rt.u64 { +export function hashed$saturates_Gauge_isize(v: Gauge.Gauge): rt.u64 { const h: rt.Hasher = rt.hasher(); - saturates_Gauge.hash$Hash_isize_hash_DefaultHasher(v, h); + Gauge.hash$Hash_isize_hash_DefaultHasher(v, h); return rt.hashFinish(h); } -export function hashed$saturates_Gauge_u128(v: saturates_Gauge.Gauge): rt.u64 { +export function hashed$saturates_Gauge_u128(v: Gauge.Gauge): rt.u64 { const h: rt.Hasher = rt.hasher(); - saturates_Gauge.hash$Hash_u128_hash_DefaultHasher(v, h); + Gauge.hash$Hash_u128_hash_DefaultHasher(v, h); return rt.hashFinish(h); } -export function hashed$saturates_Gauge_u16(v: saturates_Gauge.Gauge): rt.u64 { +export function hashed$saturates_Gauge_u16(v: Gauge.Gauge): rt.u64 { const h: rt.Hasher = rt.hasher(); - saturates_Gauge.hash$Hash_u16_hash_DefaultHasher(v, h); + Gauge.hash$Hash_u16_hash_DefaultHasher(v, h); return rt.hashFinish(h); } -export function hashed$saturates_Gauge_u32(v: saturates_Gauge.Gauge): rt.u64 { +export function hashed$saturates_Gauge_u32(v: Gauge.Gauge): rt.u64 { const h: rt.Hasher = rt.hasher(); - saturates_Gauge.hash$Hash_u32_hash_DefaultHasher(v, h); + Gauge.hash$Hash_u32_hash_DefaultHasher(v, h); return rt.hashFinish(h); } -export function hashed$saturates_Gauge_u64(v: saturates_Gauge.Gauge): rt.u64 { +export function hashed$saturates_Gauge_u64(v: Gauge.Gauge): rt.u64 { const h: rt.Hasher = rt.hasher(); - saturates_Gauge.hash$Hash_u64_hash_DefaultHasher(v, h); + Gauge.hash$Hash_u64_hash_DefaultHasher(v, h); return rt.hashFinish(h); } -export function hashed$saturates_Gauge_u8(v: saturates_Gauge.Gauge): rt.u64 { +export function hashed$saturates_Gauge_u8(v: Gauge.Gauge): rt.u64 { const h: rt.Hasher = rt.hasher(); - saturates_Gauge.hash$Hash_u8_hash_DefaultHasher(v, h); + Gauge.hash$Hash_u8_hash_DefaultHasher(v, h); return rt.hashFinish(h); } -export function hashed$saturates_Gauge_usize(v: saturates_Gauge.Gauge): rt.u64 { +export function hashed$saturates_Gauge_usize(v: Gauge.Gauge): rt.u64 { const h: rt.Hasher = rt.hasher(); - saturates_Gauge.hash$Hash_usize_hash_DefaultHasher(v, h); + Gauge.hash$Hash_usize_hash_DefaultHasher(v, h); return rt.hashFinish(h); } @@ -385,16 +385,16 @@ export function u8s(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _20(out, a); _20(out, a); } else if (_21 === 21) { - const _370: [saturates_Gauge.Gauge, saturates_Gauge.Gauge] = [new saturates_Gauge.Gauge(a), new saturates_Gauge.Gauge(b)]; - const x7: saturates_Gauge.Gauge = _370[0]; - const y: saturates_Gauge.Gauge = _370[1]; - const _378: saturates_Gauge.Gauge = saturates_Gauge.default$Default_u8(); - const args4: rt.Fmt[] = [(f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_u8(x7, f), (f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_u8(_378, f)]; + const _370: [Gauge.Gauge, Gauge.Gauge] = [new Gauge.Gauge(a), new Gauge.Gauge(b)]; + const x7: Gauge.Gauge = _370[0]; + const y: Gauge.Gauge = _370[1]; + const _378: Gauge.Gauge = Gauge.default$Default_u8(); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Gauge.fmt$fmt_Debug_u8(x7, f), (f: rt.Formatter) => Gauge.fmt$fmt_Debug_u8(_378, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args4[0], " ", args4[1]]))); - rt.byteVecPush(out, saturates_Gauge.eq$cmp_PartialEq_u8(x7, y) ? 1 : 0); - rt.byteVecPush(out, saturates_Gauge.cmp$cmp_Ord_u8(x7, y) & 0xff); + rt.byteVecPush(out, Gauge.eq$cmp_PartialEq_u8(x7, y) ? 1 : 0); + rt.byteVecPush(out, Gauge.cmp$cmp_Ord_u8(x7, y) & 0xff); rt.byteVecPush(out, rt.u64Eq(hashed$saturates_Gauge_u8(x7), hashed$num_Saturating_u8(a)) ? 1 : 0); - const z: saturates_Gauge.Gauge = copy$saturates_Gauge_u8(x7); + const z: Gauge.Gauge = copy$saturates_Gauge_u8(x7); z._0 = rt.u8SaturatingSub(z._0, y._0); _20(out, z._0); } else if (_21 === 22) { @@ -583,16 +583,16 @@ export function u16s(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _20(out, a); _20(out, a); } else if (_21 === 21) { - const _370: [saturates_Gauge.Gauge, saturates_Gauge.Gauge] = [new saturates_Gauge.Gauge(a), new saturates_Gauge.Gauge(b)]; - const x7: saturates_Gauge.Gauge = _370[0]; - const y: saturates_Gauge.Gauge = _370[1]; - const _378: saturates_Gauge.Gauge = saturates_Gauge.default$Default_u16(); - const args4: rt.Fmt[] = [(f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_u16(x7, f), (f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_u16(_378, f)]; + const _370: [Gauge.Gauge, Gauge.Gauge] = [new Gauge.Gauge(a), new Gauge.Gauge(b)]; + const x7: Gauge.Gauge = _370[0]; + const y: Gauge.Gauge = _370[1]; + const _378: Gauge.Gauge = Gauge.default$Default_u16(); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Gauge.fmt$fmt_Debug_u16(x7, f), (f: rt.Formatter) => Gauge.fmt$fmt_Debug_u16(_378, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args4[0], " ", args4[1]]))); - rt.byteVecPush(out, saturates_Gauge.eq$cmp_PartialEq_u16(x7, y) ? 1 : 0); - rt.byteVecPush(out, saturates_Gauge.cmp$cmp_Ord_u16(x7, y) & 0xff); + rt.byteVecPush(out, Gauge.eq$cmp_PartialEq_u16(x7, y) ? 1 : 0); + rt.byteVecPush(out, Gauge.cmp$cmp_Ord_u16(x7, y) & 0xff); rt.byteVecPush(out, rt.u64Eq(hashed$saturates_Gauge_u16(x7), hashed$num_Saturating_u16(a)) ? 1 : 0); - const z: saturates_Gauge.Gauge = copy$saturates_Gauge_u16(x7); + const z: Gauge.Gauge = copy$saturates_Gauge_u16(x7); z._0 = rt.u16SaturatingSub(z._0, y._0); _20(out, z._0); } else if (_21 === 22) { @@ -781,16 +781,16 @@ export function u32s(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _20(out, a); _20(out, a); } else if (_21 === 21) { - const _370: [saturates_Gauge.Gauge, saturates_Gauge.Gauge] = [new saturates_Gauge.Gauge(a), new saturates_Gauge.Gauge(b)]; - const x7: saturates_Gauge.Gauge = _370[0]; - const y: saturates_Gauge.Gauge = _370[1]; - const _378: saturates_Gauge.Gauge = saturates_Gauge.default$Default_u32(); - const args4: rt.Fmt[] = [(f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_u32(x7, f), (f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_u32(_378, f)]; + const _370: [Gauge.Gauge, Gauge.Gauge] = [new Gauge.Gauge(a), new Gauge.Gauge(b)]; + const x7: Gauge.Gauge = _370[0]; + const y: Gauge.Gauge = _370[1]; + const _378: Gauge.Gauge = Gauge.default$Default_u32(); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Gauge.fmt$fmt_Debug_u32(x7, f), (f: rt.Formatter) => Gauge.fmt$fmt_Debug_u32(_378, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args4[0], " ", args4[1]]))); - rt.byteVecPush(out, saturates_Gauge.eq$cmp_PartialEq_u32(x7, y) ? 1 : 0); - rt.byteVecPush(out, saturates_Gauge.cmp$cmp_Ord_u32(x7, y) & 0xff); + rt.byteVecPush(out, Gauge.eq$cmp_PartialEq_u32(x7, y) ? 1 : 0); + rt.byteVecPush(out, Gauge.cmp$cmp_Ord_u32(x7, y) & 0xff); rt.byteVecPush(out, rt.u64Eq(hashed$saturates_Gauge_u32(x7), hashed$num_Saturating_u32(a)) ? 1 : 0); - const z: saturates_Gauge.Gauge = copy$saturates_Gauge_u32(x7); + const z: Gauge.Gauge = copy$saturates_Gauge_u32(x7); z._0 = rt.u32SaturatingSub(z._0, y._0); _20(out, z._0); } else if (_21 === 22) { @@ -979,16 +979,16 @@ export function u64s(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _20(out, a); _20(out, a); } else if (_21 === 21) { - const _370: [saturates_Gauge.Gauge, saturates_Gauge.Gauge] = [new saturates_Gauge.Gauge(a), new saturates_Gauge.Gauge(b)]; - const x7: saturates_Gauge.Gauge = _370[0]; - const y: saturates_Gauge.Gauge = _370[1]; - const _378: saturates_Gauge.Gauge = saturates_Gauge.default$Default_u64(); - const args4: rt.Fmt[] = [(f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_u64(x7, f), (f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_u64(_378, f)]; + const _370: [Gauge.Gauge, Gauge.Gauge] = [new Gauge.Gauge(a), new Gauge.Gauge(b)]; + const x7: Gauge.Gauge = _370[0]; + const y: Gauge.Gauge = _370[1]; + const _378: Gauge.Gauge = Gauge.default$Default_u64(); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Gauge.fmt$fmt_Debug_u64(x7, f), (f: rt.Formatter) => Gauge.fmt$fmt_Debug_u64(_378, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args4[0], " ", args4[1]]))); - rt.byteVecPush(out, saturates_Gauge.eq$cmp_PartialEq_u64(x7, y) ? 1 : 0); - rt.byteVecPush(out, saturates_Gauge.cmp$cmp_Ord_u64(x7, y) & 0xff); + rt.byteVecPush(out, Gauge.eq$cmp_PartialEq_u64(x7, y) ? 1 : 0); + rt.byteVecPush(out, Gauge.cmp$cmp_Ord_u64(x7, y) & 0xff); rt.byteVecPush(out, rt.u64Eq(hashed$saturates_Gauge_u64(x7), hashed$num_Saturating_u64(a)) ? 1 : 0); - const z: saturates_Gauge.Gauge = copy$saturates_Gauge_u64(x7); + const z: Gauge.Gauge = copy$saturates_Gauge_u64(x7); z._0 = rt.u64SaturatingSub(z._0, y._0); _20(out, z._0); } else if (_21 === 22) { @@ -1177,16 +1177,16 @@ export function u128s(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _20(out, a); _20(out, a); } else if (_21 === 21) { - const _370: [saturates_Gauge.Gauge, saturates_Gauge.Gauge] = [new saturates_Gauge.Gauge(a), new saturates_Gauge.Gauge(b)]; - const x7: saturates_Gauge.Gauge = _370[0]; - const y: saturates_Gauge.Gauge = _370[1]; - const _378: saturates_Gauge.Gauge = saturates_Gauge.default$Default_u128(); - const args4: rt.Fmt[] = [(f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_u128(x7, f), (f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_u128(_378, f)]; + const _370: [Gauge.Gauge, Gauge.Gauge] = [new Gauge.Gauge(a), new Gauge.Gauge(b)]; + const x7: Gauge.Gauge = _370[0]; + const y: Gauge.Gauge = _370[1]; + const _378: Gauge.Gauge = Gauge.default$Default_u128(); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Gauge.fmt$fmt_Debug_u128(x7, f), (f: rt.Formatter) => Gauge.fmt$fmt_Debug_u128(_378, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args4[0], " ", args4[1]]))); - rt.byteVecPush(out, saturates_Gauge.eq$cmp_PartialEq_u128(x7, y) ? 1 : 0); - rt.byteVecPush(out, saturates_Gauge.cmp$cmp_Ord_u128(x7, y) & 0xff); + rt.byteVecPush(out, Gauge.eq$cmp_PartialEq_u128(x7, y) ? 1 : 0); + rt.byteVecPush(out, Gauge.cmp$cmp_Ord_u128(x7, y) & 0xff); rt.byteVecPush(out, rt.u64Eq(hashed$saturates_Gauge_u128(x7), hashed$num_Saturating_u128(a)) ? 1 : 0); - const z: saturates_Gauge.Gauge = copy$saturates_Gauge_u128(x7); + const z: Gauge.Gauge = copy$saturates_Gauge_u128(x7); z._0 = rt.u128SaturatingSub(z._0, y._0); _20(out, z._0); } else if (_21 === 22) { @@ -1375,16 +1375,16 @@ export function usizes(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _20(out, a); _20(out, a); } else if (_21 === 21) { - const _370: [saturates_Gauge.Gauge, saturates_Gauge.Gauge] = [new saturates_Gauge.Gauge(a), new saturates_Gauge.Gauge(b)]; - const x7: saturates_Gauge.Gauge = _370[0]; - const y: saturates_Gauge.Gauge = _370[1]; - const _378: saturates_Gauge.Gauge = saturates_Gauge.default$Default_usize(); - const args4: rt.Fmt[] = [(f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_usize(x7, f), (f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_usize(_378, f)]; + const _370: [Gauge.Gauge, Gauge.Gauge] = [new Gauge.Gauge(a), new Gauge.Gauge(b)]; + const x7: Gauge.Gauge = _370[0]; + const y: Gauge.Gauge = _370[1]; + const _378: Gauge.Gauge = Gauge.default$Default_usize(); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Gauge.fmt$fmt_Debug_usize(x7, f), (f: rt.Formatter) => Gauge.fmt$fmt_Debug_usize(_378, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args4[0], " ", args4[1]]))); - rt.byteVecPush(out, saturates_Gauge.eq$cmp_PartialEq_usize(x7, y) ? 1 : 0); - rt.byteVecPush(out, saturates_Gauge.cmp$cmp_Ord_usize(x7, y) & 0xff); + rt.byteVecPush(out, Gauge.eq$cmp_PartialEq_usize(x7, y) ? 1 : 0); + rt.byteVecPush(out, Gauge.cmp$cmp_Ord_usize(x7, y) & 0xff); rt.byteVecPush(out, rt.u64Eq(hashed$saturates_Gauge_usize(x7), hashed$num_Saturating_usize(a)) ? 1 : 0); - const z: saturates_Gauge.Gauge = copy$saturates_Gauge_usize(x7); + const z: Gauge.Gauge = copy$saturates_Gauge_usize(x7); z._0 = rt.usizeSaturatingSub(z._0, y._0); _20(out, z._0); } else if (_21 === 22) { @@ -1568,16 +1568,16 @@ export function i8s(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _20(out, a); _20(out, a); } else if (_21 === 21) { - const _344: [saturates_Gauge.Gauge, saturates_Gauge.Gauge] = [new saturates_Gauge.Gauge(a), new saturates_Gauge.Gauge(b)]; - const x7: saturates_Gauge.Gauge = _344[0]; - const y: saturates_Gauge.Gauge = _344[1]; - const _352: saturates_Gauge.Gauge = saturates_Gauge.default$Default_i8(); - const args4: rt.Fmt[] = [(f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_i8(x7, f), (f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_i8(_352, f)]; + const _344: [Gauge.Gauge, Gauge.Gauge] = [new Gauge.Gauge(a), new Gauge.Gauge(b)]; + const x7: Gauge.Gauge = _344[0]; + const y: Gauge.Gauge = _344[1]; + const _352: Gauge.Gauge = Gauge.default$Default_i8(); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Gauge.fmt$fmt_Debug_i8(x7, f), (f: rt.Formatter) => Gauge.fmt$fmt_Debug_i8(_352, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args4[0], " ", args4[1]]))); - rt.byteVecPush(out, saturates_Gauge.eq$cmp_PartialEq_i8(x7, y) ? 1 : 0); - rt.byteVecPush(out, saturates_Gauge.cmp$cmp_Ord_i8(x7, y) & 0xff); + rt.byteVecPush(out, Gauge.eq$cmp_PartialEq_i8(x7, y) ? 1 : 0); + rt.byteVecPush(out, Gauge.cmp$cmp_Ord_i8(x7, y) & 0xff); rt.byteVecPush(out, rt.u64Eq(hashed$saturates_Gauge_i8(x7), hashed$num_Saturating_i8(a)) ? 1 : 0); - const z: saturates_Gauge.Gauge = copy$saturates_Gauge_i8(x7); + const z: Gauge.Gauge = copy$saturates_Gauge_i8(x7); z._0 = rt.i8SaturatingSub(z._0, y._0); _20(out, z._0); } else if (_21 === 22) { @@ -1762,16 +1762,16 @@ export function i16s(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _20(out, a); _20(out, a); } else if (_21 === 21) { - const _344: [saturates_Gauge.Gauge, saturates_Gauge.Gauge] = [new saturates_Gauge.Gauge(a), new saturates_Gauge.Gauge(b)]; - const x7: saturates_Gauge.Gauge = _344[0]; - const y: saturates_Gauge.Gauge = _344[1]; - const _352: saturates_Gauge.Gauge = saturates_Gauge.default$Default_i16(); - const args4: rt.Fmt[] = [(f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_i16(x7, f), (f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_i16(_352, f)]; + const _344: [Gauge.Gauge, Gauge.Gauge] = [new Gauge.Gauge(a), new Gauge.Gauge(b)]; + const x7: Gauge.Gauge = _344[0]; + const y: Gauge.Gauge = _344[1]; + const _352: Gauge.Gauge = Gauge.default$Default_i16(); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Gauge.fmt$fmt_Debug_i16(x7, f), (f: rt.Formatter) => Gauge.fmt$fmt_Debug_i16(_352, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args4[0], " ", args4[1]]))); - rt.byteVecPush(out, saturates_Gauge.eq$cmp_PartialEq_i16(x7, y) ? 1 : 0); - rt.byteVecPush(out, saturates_Gauge.cmp$cmp_Ord_i16(x7, y) & 0xff); + rt.byteVecPush(out, Gauge.eq$cmp_PartialEq_i16(x7, y) ? 1 : 0); + rt.byteVecPush(out, Gauge.cmp$cmp_Ord_i16(x7, y) & 0xff); rt.byteVecPush(out, rt.u64Eq(hashed$saturates_Gauge_i16(x7), hashed$num_Saturating_i16(a)) ? 1 : 0); - const z: saturates_Gauge.Gauge = copy$saturates_Gauge_i16(x7); + const z: Gauge.Gauge = copy$saturates_Gauge_i16(x7); z._0 = rt.i16SaturatingSub(z._0, y._0); _20(out, z._0); } else if (_21 === 22) { @@ -1956,16 +1956,16 @@ export function i32s(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _20(out, a); _20(out, a); } else if (_21 === 21) { - const _344: [saturates_Gauge.Gauge, saturates_Gauge.Gauge] = [new saturates_Gauge.Gauge(a), new saturates_Gauge.Gauge(b)]; - const x7: saturates_Gauge.Gauge = _344[0]; - const y: saturates_Gauge.Gauge = _344[1]; - const _352: saturates_Gauge.Gauge = saturates_Gauge.default$Default_i32(); - const args4: rt.Fmt[] = [(f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_i32(x7, f), (f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_i32(_352, f)]; + const _344: [Gauge.Gauge, Gauge.Gauge] = [new Gauge.Gauge(a), new Gauge.Gauge(b)]; + const x7: Gauge.Gauge = _344[0]; + const y: Gauge.Gauge = _344[1]; + const _352: Gauge.Gauge = Gauge.default$Default_i32(); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Gauge.fmt$fmt_Debug_i32(x7, f), (f: rt.Formatter) => Gauge.fmt$fmt_Debug_i32(_352, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args4[0], " ", args4[1]]))); - rt.byteVecPush(out, saturates_Gauge.eq$cmp_PartialEq_i32(x7, y) ? 1 : 0); - rt.byteVecPush(out, saturates_Gauge.cmp$cmp_Ord_i32(x7, y) & 0xff); + rt.byteVecPush(out, Gauge.eq$cmp_PartialEq_i32(x7, y) ? 1 : 0); + rt.byteVecPush(out, Gauge.cmp$cmp_Ord_i32(x7, y) & 0xff); rt.byteVecPush(out, rt.u64Eq(hashed$saturates_Gauge_i32(x7), hashed$num_Saturating_i32(a)) ? 1 : 0); - const z: saturates_Gauge.Gauge = copy$saturates_Gauge_i32(x7); + const z: Gauge.Gauge = copy$saturates_Gauge_i32(x7); z._0 = rt.i32SaturatingSub(z._0, y._0); _20(out, z._0); } else if (_21 === 22) { @@ -2150,16 +2150,16 @@ export function i64s(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _20(out, a); _20(out, a); } else if (_21 === 21) { - const _344: [saturates_Gauge.Gauge, saturates_Gauge.Gauge] = [new saturates_Gauge.Gauge(a), new saturates_Gauge.Gauge(b)]; - const x7: saturates_Gauge.Gauge = _344[0]; - const y: saturates_Gauge.Gauge = _344[1]; - const _352: saturates_Gauge.Gauge = saturates_Gauge.default$Default_i64(); - const args4: rt.Fmt[] = [(f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_i64(x7, f), (f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_i64(_352, f)]; + const _344: [Gauge.Gauge, Gauge.Gauge] = [new Gauge.Gauge(a), new Gauge.Gauge(b)]; + const x7: Gauge.Gauge = _344[0]; + const y: Gauge.Gauge = _344[1]; + const _352: Gauge.Gauge = Gauge.default$Default_i64(); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Gauge.fmt$fmt_Debug_i64(x7, f), (f: rt.Formatter) => Gauge.fmt$fmt_Debug_i64(_352, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args4[0], " ", args4[1]]))); - rt.byteVecPush(out, saturates_Gauge.eq$cmp_PartialEq_i64(x7, y) ? 1 : 0); - rt.byteVecPush(out, saturates_Gauge.cmp$cmp_Ord_i64(x7, y) & 0xff); + rt.byteVecPush(out, Gauge.eq$cmp_PartialEq_i64(x7, y) ? 1 : 0); + rt.byteVecPush(out, Gauge.cmp$cmp_Ord_i64(x7, y) & 0xff); rt.byteVecPush(out, rt.u64Eq(hashed$saturates_Gauge_i64(x7), hashed$num_Saturating_i64(a)) ? 1 : 0); - const z: saturates_Gauge.Gauge = copy$saturates_Gauge_i64(x7); + const z: Gauge.Gauge = copy$saturates_Gauge_i64(x7); z._0 = rt.i64SaturatingSub(z._0, y._0); _20(out, z._0); } else if (_21 === 22) { @@ -2344,16 +2344,16 @@ export function i128s(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _20(out, a); _20(out, a); } else if (_21 === 21) { - const _344: [saturates_Gauge.Gauge, saturates_Gauge.Gauge] = [new saturates_Gauge.Gauge(a), new saturates_Gauge.Gauge(b)]; - const x7: saturates_Gauge.Gauge = _344[0]; - const y: saturates_Gauge.Gauge = _344[1]; - const _352: saturates_Gauge.Gauge = saturates_Gauge.default$Default_i128(); - const args4: rt.Fmt[] = [(f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_i128(x7, f), (f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_i128(_352, f)]; + const _344: [Gauge.Gauge, Gauge.Gauge] = [new Gauge.Gauge(a), new Gauge.Gauge(b)]; + const x7: Gauge.Gauge = _344[0]; + const y: Gauge.Gauge = _344[1]; + const _352: Gauge.Gauge = Gauge.default$Default_i128(); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Gauge.fmt$fmt_Debug_i128(x7, f), (f: rt.Formatter) => Gauge.fmt$fmt_Debug_i128(_352, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args4[0], " ", args4[1]]))); - rt.byteVecPush(out, saturates_Gauge.eq$cmp_PartialEq_i128(x7, y) ? 1 : 0); - rt.byteVecPush(out, saturates_Gauge.cmp$cmp_Ord_i128(x7, y) & 0xff); + rt.byteVecPush(out, Gauge.eq$cmp_PartialEq_i128(x7, y) ? 1 : 0); + rt.byteVecPush(out, Gauge.cmp$cmp_Ord_i128(x7, y) & 0xff); rt.byteVecPush(out, rt.u64Eq(hashed$saturates_Gauge_i128(x7), hashed$num_Saturating_i128(a)) ? 1 : 0); - const z: saturates_Gauge.Gauge = copy$saturates_Gauge_i128(x7); + const z: Gauge.Gauge = copy$saturates_Gauge_i128(x7); z._0 = rt.i128SaturatingSub(z._0, y._0); _20(out, z._0); } else if (_21 === 22) { @@ -2538,16 +2538,16 @@ export function isizes(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _20(out, a); _20(out, a); } else if (_21 === 21) { - const _344: [saturates_Gauge.Gauge, saturates_Gauge.Gauge] = [new saturates_Gauge.Gauge(a), new saturates_Gauge.Gauge(b)]; - const x7: saturates_Gauge.Gauge = _344[0]; - const y: saturates_Gauge.Gauge = _344[1]; - const _352: saturates_Gauge.Gauge = saturates_Gauge.default$Default_isize(); - const args4: rt.Fmt[] = [(f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_isize(x7, f), (f: rt.Formatter) => saturates_Gauge.fmt$fmt_Debug_isize(_352, f)]; + const _344: [Gauge.Gauge, Gauge.Gauge] = [new Gauge.Gauge(a), new Gauge.Gauge(b)]; + const x7: Gauge.Gauge = _344[0]; + const y: Gauge.Gauge = _344[1]; + const _352: Gauge.Gauge = Gauge.default$Default_isize(); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Gauge.fmt$fmt_Debug_isize(x7, f), (f: rt.Formatter) => Gauge.fmt$fmt_Debug_isize(_352, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args4[0], " ", args4[1]]))); - rt.byteVecPush(out, saturates_Gauge.eq$cmp_PartialEq_isize(x7, y) ? 1 : 0); - rt.byteVecPush(out, saturates_Gauge.cmp$cmp_Ord_isize(x7, y) & 0xff); + rt.byteVecPush(out, Gauge.eq$cmp_PartialEq_isize(x7, y) ? 1 : 0); + rt.byteVecPush(out, Gauge.cmp$cmp_Ord_isize(x7, y) & 0xff); rt.byteVecPush(out, rt.u64Eq(hashed$saturates_Gauge_isize(x7), hashed$num_Saturating_isize(a)) ? 1 : 0); - const z: saturates_Gauge.Gauge = copy$saturates_Gauge_isize(x7); + const z: Gauge.Gauge = copy$saturates_Gauge_isize(x7); z._0 = rt.isizeSaturatingSub(z._0, y._0); _20(out, z._0); } else if (_21 === 22) { diff --git a/ts/fixtures/lang/saturates/src/lib.rs b/ts/fixtures/lang/saturates/src/lib.rs new file mode 100644 index 000000000..678f06fec --- /dev/null +++ b/ts/fixtures/lang/saturates/src/lib.rs @@ -0,0 +1,32 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod saturates; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("saturates::u8s", saturates::u8s), + ("saturates::u16s", saturates::u16s), + ("saturates::u32s", saturates::u32s), + ("saturates::u64s", saturates::u64s), + ("saturates::u128s", saturates::u128s), + ("saturates::usizes", saturates::usizes), + ("saturates::i8s", saturates::i8s), + ("saturates::i16s", saturates::i16s), + ("saturates::i32s", saturates::i32s), + ("saturates::i64s", saturates::i64s), + ("saturates::i128s", saturates::i128s), + ("saturates::isizes", saturates::isizes), + ] +} diff --git a/ts/fixtures/lang/src/saturates.rs b/ts/fixtures/lang/saturates/src/saturates.rs similarity index 100% rename from ts/fixtures/lang/src/saturates.rs rename to ts/fixtures/lang/saturates/src/saturates.rs diff --git a/ts/fixtures/lang/saturates/ts.toml b/ts/fixtures/lang/saturates/ts.toml new file mode 100644 index 000000000..c8340b3e7 --- /dev/null +++ b/ts/fixtures/lang/saturates/ts.toml @@ -0,0 +1,2 @@ +package = "lang-saturates-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/searches/Cargo.toml b/ts/fixtures/lang/searches/Cargo.toml new file mode 100644 index 000000000..b3d2d3a49 --- /dev/null +++ b/ts/fixtures/lang/searches/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-searches-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/searches/caller.ts b/ts/fixtures/lang/searches/caller.ts new file mode 100644 index 000000000..aad0d8fcf --- /dev/null +++ b/ts/fixtures/lang/searches/caller.ts @@ -0,0 +1,30 @@ +// The inputs `searches`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `searches::searches` of each search and pattern, by chars, needles, and counts its first + * byte picks: an empty needle, one, two, and three chars, and counts from 0 to 4. Of no + * text, a separator alone, twice, and at either end, runs a two-char needle overlaps in, + * chars of each UTF-8 width, and digits the closure matches, read from either end. + */ +const searchesOp = op("searches::searches"); +const searchesCases = [0x00, 0x12, 0x22, 0x31, 0x4e, 0x57].flatMap((pick) => + [[], [0], [0, 0], [0, 2], [2, 0], [0, 2, 0], [2, 2, 2], [2, 2, 2, 2], [14, 7, 14], [0x80, 2, 0x80], [0x82, 0x8e, 0x07, 0x83]].flatMap((text) => + Array.from({ length: 85 }, (_, kind) => Uint8Array.of(...searchesOp, kind, pick, ...text)), + ), +); + +/** + * `searches::texts` of each iterator and the trims, of no text, a line end of each kind + * alone, between lines and doubled, a `\r` without a `\n`, and whitespace of each UTF-8 + * width between the chars JS's `\s` alone counts, read from either end. + */ +const textsOp = op("searches::texts"); +const textsCases = [[], [0], [1, 0], [2, 1, 0, 2], [2, 0, 0, 2], [0, 2], [2, 1], [1, 1, 0], [3, 2, 3], [6, 7, 8, 9, 2, 10, 2, 11, 12, 13, 2, 14, 15, 4, 5], [0x83, 2, 0x8d, 0x0a, 0x84]].flatMap( + (text) => Array.from({ length: 4 }, (_, kind) => Uint8Array.of(...textsOp, kind, ...text)), +); + +export const cases: Uint8Array[] = [...searchesCases, ...textsCases]; diff --git a/ts/fixtures/lang/searches/expected/core/option.ts b/ts/fixtures/lang/searches/expected/core/option.ts new file mode 100644 index 000000000..0596cf60a --- /dev/null +++ b/ts/fixtures/lang/searches/expected/core/option.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function mapOr$1ttssgs(self: [rt.u8, rt.ByteSlice] | undefined, default_: [rt.u8, rt.ByteSlice], f: (a0: [rt.u8, rt.ByteSlice]) => [rt.u8, rt.ByteSlice]): [rt.u8, rt.ByteSlice] { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/searches/expected/harness.ts b/ts/fixtures/lang/searches/expected/harness.ts new file mode 100644 index 000000000..7c19e53ff --- /dev/null +++ b/ts/fixtures/lang/searches/expected/harness.ts @@ -0,0 +1,64 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +/** A char of the alphabet for each byte, by its low bits. */ +export function text(data: rt.ByteSlice): string { + let s: string = ""; + const iterS: Uint8Array = rt.byteSliceView(data); + let iterI: number = 0; + while (true) { + const _5: rt.u8 | rt.Done = iterI < iterS.length ? iterS[iterI++] : rt.DONE; + if (_5 === rt.DONE) { + return s; + } + const _13: rt.usize = rt.u8Rem(_5, 16) as rt.usize; + if (!(_13 < 16)) { + rt.panic("index out of bounds: the len is " + 16 + " but the index is " + _13); + } + s = s + String.fromCodePoint([47, 92, 97, 48, 57, 127, 128, 233, 2047, 2048, 55295, 57344, 65535, 65536, 128512, 1114111][_13]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/searches/expected/lib.ts b/ts/fixtures/lang/searches/expected/lib.ts new file mode 100644 index 000000000..0a68ef21e --- /dev/null +++ b/ts/fixtures/lang/searches/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { searches, texts } from "./searches.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["searches::searches", searches as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["searches::texts", texts as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/searches.ts b/ts/fixtures/lang/searches/expected/searches.ts similarity index 98% rename from ts/fixtures/lang/expected/searches.ts rename to ts/fixtures/lang/searches/expected/searches.ts index 38131d108..588ba91c6 100644 --- a/ts/fixtures/lang/expected/searches.ts +++ b/ts/fixtures/lang/searches/expected/searches.ts @@ -2,16 +2,15 @@ import * as rt from "./rt.ts"; import { mapOr$1ttssgs as option_mapOr$1ttssgs } from "./core/option.ts"; -import { put as fmt_put } from "./fmt.ts"; -import { text as strs_text } from "./strs.ts"; +import { put as harness_put, text } from "./harness.ts"; export function put$searches_Item_ref_str(self: string, out: rt.ByteVec): void { - fmt_put(out, self); + harness_put(out, self); } export function put$searches_Item_tuple2_usize_ref_str(self: [rt.usize, string], out: rt.ByteVec): void { rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u32ToBeBytes(self[0] as rt.u32))); - fmt_put(out, self[1]); + harness_put(out, self[1]); } export function put$searches_Item_tuple2_usize_char(self: [rt.usize, rt.char], out: rt.ByteVec): void { @@ -3545,7 +3544,7 @@ export function putOption(out: rt.ByteVec, s: string | undefined): void { if (s === undefined) { rt.byteVecPush(out, 254); } else { - fmt_put(out, s); + harness_put(out, s); } } @@ -3568,8 +3567,8 @@ export function searches(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void return [_2[0], _2[1]] as [rt.u8, rt.ByteSlice]; }); const pick: rt.u8 = _6[0]; - const s: string = strs_text(_6[1]); - const alphabet: rt.char[] = rt.iterToArray(rt.strChars(strs_text(rt.byteSliceFrom(Uint8Array.of(rt.u8Rem(pick, 16), rt.u8Div(pick, 16))))), "next", 4); + const s: string = text(_6[1]); + const alphabet: rt.char[] = rt.iterToArray(rt.strChars(text(rt.byteSliceFrom(Uint8Array.of(rt.u8Rem(pick, 16), rt.u8Div(pick, 16))))), "next", 4); const _25: rt.char = alphabet[rt.idx(alphabet, 0)]; const _24: [rt.char, rt.char] = [_25, alphabet[rt.idx(alphabet, 1)]]; const c: rt.char = _25; @@ -3592,7 +3591,7 @@ export function searches(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const _50: string = s; const part4 = _6[1]; if (m === 9) { - fmt_put(out, rt.strTrimMatches(_50, String.fromCodePoint(c))); + harness_put(out, rt.strTrimMatches(_50, String.fromCodePoint(c))); } else if (m === 10) { both$ref_str_str_Split_char(rt.strSplit(_50, String.fromCodePoint(c)), part4, out); } else if (m === 11) { @@ -3616,8 +3615,8 @@ export function searches(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void putOption(out, rt.strStripPrefix(_50, String.fromCodePoint(c))); putOption(out, rt.strStripSuffix(_50, String.fromCodePoint(c))); } else if (m === 2) { - fmt_put(out, rt.strReplace(_50, String.fromCodePoint(c), "<>")); - fmt_put(out, rt.strReplace(_50, String.fromCodePoint(c), "é", n)); + harness_put(out, rt.strReplace(_50, String.fromCodePoint(c), "<>")); + harness_put(out, rt.strReplace(_50, String.fromCodePoint(c), "é", n)); } else if (m === 3) { front$ref_str_str_Split_char(rt.strSplit(_50, String.fromCodePoint(c)), out); front$ref_str_str_RSplit_char(rt.strRsplit(_50, String.fromCodePoint(c)), out); @@ -3646,8 +3645,8 @@ export function searches(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void putOption(out, rt.strStripPrefix(s, needle)); putOption(out, rt.strStripSuffix(s, needle)); } else if (_127 === 2) { - fmt_put(out, rt.strReplace(s, needle, "<>")); - fmt_put(out, rt.strReplace(s, needle, "é", n)); + harness_put(out, rt.strReplace(s, needle, "<>")); + harness_put(out, rt.strReplace(s, needle, "é", n)); } else if (_127 === 3) { front$ref_str_str_Split_ref_str(rt.strSplit(s, needle), out); front$ref_str_str_RSplit_ref_str(rt.strRsplit(s, needle), out); @@ -3671,7 +3670,7 @@ export function searches(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const part3 = _6[1]; if (m === 9) { const _211: rt.char[] = [c, d]; - fmt_put(out, rt.strTrimMatches(_206, rt.patternChars(rt.sliceRange(_211, 0)))); + harness_put(out, rt.strTrimMatches(_206, rt.patternChars(rt.sliceRange(_211, 0)))); } else if (m === 10) { const _215: rt.char[] = [c, d]; both$ref_str_str_Split_ref_slice_char(rt.strSplit(_206, rt.patternChars(rt.sliceRange(_215, 0))), part3, out); @@ -3709,9 +3708,9 @@ export function searches(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void putOption(out, rt.strStripSuffix(_206, rt.patternChars(rt.sliceRange(_274, 0)))); } else if (m === 2) { const _281: rt.char[] = [c, d]; - fmt_put(out, rt.strReplace(_206, rt.patternChars(rt.sliceRange(_281, 0)), "<>")); + harness_put(out, rt.strReplace(_206, rt.patternChars(rt.sliceRange(_281, 0)), "<>")); const _289: rt.char[] = [c, d]; - fmt_put(out, rt.strReplace(_206, rt.patternChars(rt.sliceRange(_289, 0)), "é", n)); + harness_put(out, rt.strReplace(_206, rt.patternChars(rt.sliceRange(_289, 0)), "é", n)); } else if (m === 3) { const _295: rt.char[] = [c, d]; front$ref_str_str_Split_ref_slice_char(rt.strSplit(_206, rt.patternChars(rt.sliceRange(_295, 0))), out); @@ -3745,7 +3744,7 @@ export function searches(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const _349: string = s; const part2 = _6[1]; if (m === 9) { - fmt_put(out, rt.strTrimMatches(_349, rt.patternChars([c, d]))); + harness_put(out, rt.strTrimMatches(_349, rt.patternChars([c, d]))); } else if (m === 10) { both$ref_str_str_Split_array2_char(rt.strSplit(_349, rt.patternChars([c, d])), part2, out); } else if (m === 11) { @@ -3769,8 +3768,8 @@ export function searches(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void putOption(out, rt.strStripPrefix(_349, rt.patternChars([c, d]))); putOption(out, rt.strStripSuffix(_349, rt.patternChars([c, d]))); } else if (m === 2) { - fmt_put(out, rt.strReplace(_349, rt.patternChars([c, d]), "<>")); - fmt_put(out, rt.strReplace(_349, rt.patternChars([c, d]), "é", n)); + harness_put(out, rt.strReplace(_349, rt.patternChars([c, d]), "<>")); + harness_put(out, rt.strReplace(_349, rt.patternChars([c, d]), "é", n)); } else if (m === 3) { front$ref_str_str_Split_array2_char(rt.strSplit(_349, rt.patternChars([c, d])), out); front$ref_str_str_RSplit_array2_char(rt.strRsplit(_349, rt.patternChars([c, d])), out); @@ -3793,7 +3792,7 @@ export function searches(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const _438: string = s; const part = _6[1]; if (m === 9) { - fmt_put(out, rt.strTrimMatches(_438, p)); + harness_put(out, rt.strTrimMatches(_438, p)); } else if (m === 10) { both$ref_str_str_Split_searches_searches_closure1(rt.strSplit(_438, p), part, out); } else if (m === 11) { @@ -3817,8 +3816,8 @@ export function searches(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void putOption(out, rt.strStripPrefix(_438, p)); putOption(out, rt.strStripSuffix(_438, p)); } else if (m === 2) { - fmt_put(out, rt.strReplace(_438, p, "<>")); - fmt_put(out, rt.strReplace(_438, p, "é", n)); + harness_put(out, rt.strReplace(_438, p, "<>")); + harness_put(out, rt.strReplace(_438, p, "é", n)); } else if (m === 3) { front$ref_str_str_Split_searches_searches_closure1(rt.strSplit(_438, p), out); front$ref_str_str_RSplit_searches_searches_closure1(rt.strRsplit(_438, p), out); @@ -3870,9 +3869,9 @@ export function texts(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } else if (_7 === 2) { both$ref_str_str_SplitWhitespace(rt.strSplitWhitespace(s), data, out); } else { - fmt_put(out, rt.strTrimMatches(s, rt.charIsWhitespace)); - fmt_put(out, rt.strTrimStartMatches(s, rt.charIsWhitespace)); - fmt_put(out, rt.strTrimEndMatches(s, rt.charIsWhitespace)); + harness_put(out, rt.strTrimMatches(s, rt.charIsWhitespace)); + harness_put(out, rt.strTrimStartMatches(s, rt.charIsWhitespace)); + harness_put(out, rt.strTrimEndMatches(s, rt.charIsWhitespace)); for (const _37 of rt.iterToArray(rt.iterMap(rt.strChars(s), (a0: rt.char): boolean => { return rt.charIsWhitespace(a0); }), "next", 1)) { diff --git a/ts/fixtures/lang/searches/src/lib.rs b/ts/fixtures/lang/searches/src/lib.rs new file mode 100644 index 000000000..c54cc428c --- /dev/null +++ b/ts/fixtures/lang/searches/src/lib.rs @@ -0,0 +1,22 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod searches; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("searches::searches", searches::searches), + ("searches::texts", searches::texts), + ] +} diff --git a/ts/fixtures/lang/src/searches.rs b/ts/fixtures/lang/searches/src/searches.rs similarity index 99% rename from ts/fixtures/lang/src/searches.rs rename to ts/fixtures/lang/searches/src/searches.rs index b82734e30..0254aeb81 100644 --- a/ts/fixtures/lang/src/searches.rs +++ b/ts/fixtures/lang/searches/src/searches.rs @@ -6,8 +6,7 @@ use std::cell::RefCell; -use crate::fmt::put; -use crate::strs::text; +use crate::harness::{put, text}; /// An item of a search, put in the output. trait Item { diff --git a/ts/fixtures/lang/searches/ts.toml b/ts/fixtures/lang/searches/ts.toml new file mode 100644 index 000000000..23b09dd21 --- /dev/null +++ b/ts/fixtures/lang/searches/ts.toml @@ -0,0 +1,2 @@ +package = "lang-searches-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/separated/Cargo.toml b/ts/fixtures/lang/separated/Cargo.toml new file mode 100644 index 000000000..931e5ad9d --- /dev/null +++ b/ts/fixtures/lang/separated/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-separated-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/separated/caller.ts b/ts/fixtures/lang/separated/caller.ts new file mode 100644 index 000000000..5819180e4 --- /dev/null +++ b/ts/fixtures/lang/separated/caller.ts @@ -0,0 +1,16 @@ +// The inputs `separated`'s cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `separated::separated` of every form and order of reads, over data whose bytes its bounds + * make separators of alone, in runs, and at either end, and over one element and none. + */ +const separatedOp = op("separated::separated"); +const separated = [[], [0], [0x90], [0, 0, 0], [5, 0x90, 0, 0x7f, 0, 0xff, 3], [0x80, 1, 2, 0], [0xff, 0x7f, 0x80, 0x81]].flatMap((data) => + Array.from({ length: 256 }, (_, kind) => Uint8Array.of(...separatedOp, kind, ...data)), +); + +export const cases: Uint8Array[] = [...separated]; diff --git a/ts/fixtures/lang/separated/expected/core/option.ts b/ts/fixtures/lang/separated/expected/core/option.ts new file mode 100644 index 000000000..803d48279 --- /dev/null +++ b/ts/fixtures/lang/separated/expected/core/option.ts @@ -0,0 +1,84 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import { sum, sumWords, sumPairs, sumTexts, sumTwos } from "../separated.ts"; +import type * as Pair from "../separated.Pair.ts"; + +export function map$1r7pvtd(self: string[] | undefined, _: (a0: string[]) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return sumTexts(self); +} + +export function map$14orwce(self: Uint8Array[] | undefined, _: (a0: Uint8Array[]) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return sumTwos(self); +} + +export function map$02o7iu2(self: Pair.Pair[] | undefined, _: (a0: Pair.Pair[]) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return sumPairs(self); +} + +export function map$0vryjg8(self: rt.u16[] | undefined, _: (a0: rt.u16[]) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return sumWords(self); +} + +export function map$1uuzv15(self: rt.ByteSlice | undefined, _: (a0: rt.ByteSlice) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return sum(self); +} + +export function mapOr$0j8cgo8(self: string[] | undefined, default_: rt.u8, _: (a0: string[]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return sumTexts(self); +} + +export function mapOr$0wkl4zm(self: Uint8Array[] | undefined, default_: rt.u8, _: (a0: Uint8Array[]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return sumTwos(self); +} + +export function mapOr$15c63lv(self: Pair.Pair[] | undefined, default_: rt.u8, _: (a0: Pair.Pair[]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return sumPairs(self); +} + +export function mapOr$1qu2moz(self: rt.u16[] | undefined, default_: rt.u8, _: (a0: rt.u16[]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return sumWords(self); +} + +export function mapOr$18m1ie6(self: rt.ByteSlice | undefined, default_: rt.u8, _: (a0: rt.ByteSlice) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return sum(self); +} + +export function mapOr$02k4ito(self: rt.usize | undefined, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/separated/expected/harness.ts b/ts/fixtures/lang/separated/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/separated/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/separated/expected/lib.ts b/ts/fixtures/lang/separated/expected/lib.ts new file mode 100644 index 000000000..03d070728 --- /dev/null +++ b/ts/fixtures/lang/separated/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { separated } from "./separated.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["separated::separated", separated as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/separated.Below.ts b/ts/fixtures/lang/separated/expected/separated.Below.ts similarity index 100% rename from ts/fixtures/lang/expected/separated.Below.ts rename to ts/fixtures/lang/separated/expected/separated.Below.ts diff --git a/ts/fixtures/lang/expected/separated.Pair.ts b/ts/fixtures/lang/separated/expected/separated.Pair.ts similarity index 100% rename from ts/fixtures/lang/expected/separated.Pair.ts rename to ts/fixtures/lang/separated/expected/separated.Pair.ts diff --git a/ts/fixtures/lang/expected/separated.ts b/ts/fixtures/lang/separated/expected/separated.ts similarity index 93% rename from ts/fixtures/lang/expected/separated.ts rename to ts/fixtures/lang/separated/expected/separated.ts index e6abc62b1..1c574f1ad 100644 --- a/ts/fixtures/lang/expected/separated.ts +++ b/ts/fixtures/lang/separated/expected/separated.ts @@ -3,7 +3,7 @@ import * as rt from "./rt.ts"; import { map$1r7pvtd as option_map$1r7pvtd, map$14orwce as option_map$14orwce, map$02o7iu2 as option_map$02o7iu2, map$0vryjg8 as option_map$0vryjg8, map$1uuzv15 as option_map$1uuzv15, mapOr$0j8cgo8 as option_mapOr$0j8cgo8, mapOr$0wkl4zm as option_mapOr$0wkl4zm, mapOr$15c63lv as option_mapOr$15c63lv, mapOr$1qu2moz as option_mapOr$1qu2moz, mapOr$18m1ie6 as option_mapOr$18m1ie6, mapOr$02k4ito as option_mapOr$02k4ito } from "./core/option.ts"; import * as Below from "./separated.Below.ts"; -import * as separated_Pair from "./separated.Pair.ts"; +import * as Pair from "./separated.Pair.ts"; /** Puts what was logged since the last flush, after a marker. */ export function flush(log: rt.RefCell, out: rt.ByteVec): void { @@ -35,8 +35,8 @@ export function sumWords(part: rt.u16[]): rt.u8 { }); } -export function sumPairs(part: separated_Pair.Pair[]): rt.u8 { - return rt.iterFold(rt.iterSlice(part), part.length & 0xff, (acc: rt.u8, p: separated_Pair.Pair): rt.u8 => { +export function sumPairs(part: Pair.Pair[]): rt.u8 { + return rt.iterFold(rt.iterSlice(part), part.length & 0xff, (acc: rt.u8, p: Pair.Pair): rt.u8 => { return rt.u8WrappingMul(acc, 31) ^ p.a ^ ((p.b >> 4) & 0xff); }); } @@ -93,25 +93,25 @@ export function scribbleWords(i: rt.usize, part: rt.u16[]): void { } } -export function scribblePairs(i: rt.usize, part: separated_Pair.Pair[]): void { - const _3: separated_Pair.Pair | undefined = rt.sliceFirst(part); +export function scribblePairs(i: rt.usize, part: Pair.Pair[]): void { + const _3: Pair.Pair | undefined = rt.sliceFirst(part); if (_3 !== undefined) { _3.a = rt.u8WrappingAdd(_3.a, rt.u8Add(i & 0xff, 1)); } - const _11: separated_Pair.Pair | undefined = rt.sliceLast(part); + const _11: Pair.Pair | undefined = rt.sliceLast(part); if (_11 !== undefined) { Object.assign(_11, { a: _11.b & 0xff, b: i & 0xffff }); } - rt.sliceSort(part, rt.cmpLt(separated_Pair.partialCmp$cmp_PartialOrd), 4, true); - const iter: rt.Iter = rt.sliceRsplitMut(part, (p: separated_Pair.Pair): boolean => { + rt.sliceSort(part, rt.cmpLt(Pair.partialCmp$cmp_PartialOrd), 4, true); + const iter: rt.Iter = rt.sliceRsplitMut(part, (p: Pair.Pair): boolean => { return rt.u8Rem(p.a, 2) === 0; }); while (true) { - const _22: separated_Pair.Pair[] | rt.Done = iter.next(); + const _22: Pair.Pair[] | rt.Done = iter.next(); if (_22 === rt.DONE) { break; } - const _26: separated_Pair.Pair | undefined = rt.sliceFirst(_22); + const _26: Pair.Pair | undefined = rt.sliceFirst(_22); if (_26 !== undefined) { _26.b = _26.b ^ 85; } @@ -137,9 +137,9 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi let _425!: rt.ByteSlice | undefined; let _456!: rt.i32; let p8!: rt.ByteSlice | undefined; - let _524!: separated_Pair.Pair[] | undefined; + let _524!: Pair.Pair[] | undefined; let _557!: rt.i32; - let p10!: separated_Pair.Pair[] | undefined; + let p10!: Pair.Pair[] | undefined; let _635!: string[] | undefined; let _668!: rt.i32; let p12!: string[] | undefined; @@ -155,9 +155,9 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi let _1070!: rt.u16[] | undefined; let _1103!: rt.i32; let p20!: rt.u16[] | undefined; - let _1181!: separated_Pair.Pair[] | undefined; + let _1181!: Pair.Pair[] | undefined; let _1214!: rt.i32; - let p22!: separated_Pair.Pair[] | undefined; + let p22!: Pair.Pair[] | undefined; let _1284!: rt.usize; let _1322!: rt.usize; let _1361!: rt.usize; @@ -168,13 +168,13 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi let _1665!: rt.usize; let p25!: rt.u16[] | undefined; let _1694!: rt.usize; - let p27!: separated_Pair.Pair[] | undefined; + let p27!: Pair.Pair[] | undefined; let _1870!: rt.usize; let p29!: rt.ByteSlice | undefined; let _1899!: rt.usize; let p31!: rt.u16[] | undefined; let _1928!: rt.usize; - let p33!: separated_Pair.Pair[] | undefined; + let p33!: Pair.Pair[] | undefined; const log: rt.RefCell = new rt.RefCell(new rt.ByteVec()); const steps: rt.u8 = kind >> 3; const iter: rt.Iter = rt.iterSlice([0, 1, 128, 256]); @@ -188,7 +188,7 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi const words: rt.u16[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): rt.u16 => { return rt.u16Mul(_2 as rt.u16, 257); }), undefined, 2, true); - const pairs: separated_Pair.Pair[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_24: rt.u8): separated_Pair.Pair => { + const pairs: Pair.Pair[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_24: rt.u8): Pair.Pair => { const b2: rt.u8 = _24; return { a: b2, b: rt.u16Mul(b2 as rt.u16, 3) }; }), undefined, 4, true); @@ -213,7 +213,7 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi rt.refMutRelease(_75); return (w >> 8) < bound; }; - const testPairs: (a0: separated_Pair.Pair) => boolean = (p35: separated_Pair.Pair): boolean => { + const testPairs: (a0: Pair.Pair) => boolean = (p35: Pair.Pair): boolean => { const _63: rt.RefCell = rt.refCellBorrowMut(log); rt.byteVecPush(_63.value, p35.a ^ 51); rt.refMutRelease(_63); @@ -398,7 +398,7 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi rt.byteVecPush(out, sum(rt.splitAsSlice(copy))); rt.byteVecPush(out, sum(rt.splitAsSlice(it7))); flush(log, out); - const it8: rt.Iter = rt.sliceSplit(pairs, testPairs); + const it8: rt.Iter = rt.sliceSplit(pairs, testPairs); rt.iterToOption(it8.nextBack()); rt.byteVecPush(out, sumPairs(rt.splitAsSlice(it8))); flush(log, out); @@ -460,7 +460,7 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi break; } const back5: boolean = _513; - const it11: rt.Iter = rt.sliceRsplit(pairs, testPairs); + const it11: rt.Iter = rt.sliceRsplit(pairs, testPairs); hint(it11.sizeHint(), out); flush(log, out); while (true) { @@ -480,7 +480,7 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi } } } - const it12: rt.Iter = rt.sliceRsplit(pairs, testPairs); + const it12: rt.Iter = rt.sliceRsplit(pairs, testPairs); let iterStart6: rt.i32 = 0; const iterEnd6: rt.i32 = 12; while ((_557 = iterStart6++) < iterEnd6) { @@ -773,7 +773,7 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi break; } const back11: boolean = _1170; - const it23: rt.Iter = rt.sliceSplitInclusive(pairs, testPairs); + const it23: rt.Iter = rt.sliceSplitInclusive(pairs, testPairs); hint(it23.sizeHint(), out); flush(log, out); while (true) { @@ -793,7 +793,7 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi } } } - const it24: rt.Iter = rt.sliceSplitInclusive(pairs, testPairs); + const it24: rt.Iter = rt.sliceSplitInclusive(pairs, testPairs); let iterStart12: rt.i32 = 0; const iterEnd12: rt.i32 = 12; while ((_1214 = iterStart12++) < iterEnd12) { @@ -886,10 +886,10 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi const iterEnd16: rt.usize = _1399; while ((_1404 = iterStart16++) < iterEnd16) { const n4: rt.usize = _1404; - const it28: rt.Iter = rt.sliceRsplitn(pairs, n4, testPairs); + const it28: rt.Iter = rt.sliceRsplitn(pairs, n4, testPairs); hint(it28.sizeHint(), out); while (true) { - const _1414: separated_Pair.Pair[] | rt.Done = it28.next(); + const _1414: Pair.Pair[] | rt.Done = it28.next(); if (_1414 !== rt.DONE) { rt.byteVecPush(out, sumPairs(_1414)); hint(it28.sizeHint(), out); @@ -976,9 +976,9 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi }), undefined, true); flush(log, out); rt.byteVecPush(out, sumWords(words)); - const iter34: rt.Iter<[rt.usize, separated_Pair.Pair[]]> = rt.iterEnumerate(rt.sliceSplitMut(pairs, testPairs)); + const iter34: rt.Iter<[rt.usize, Pair.Pair[]]> = rt.iterEnumerate(rt.sliceSplitMut(pairs, testPairs)); while (true) { - const _1587: [rt.usize, separated_Pair.Pair[]] | rt.Done = iter34.next(); + const _1587: [rt.usize, Pair.Pair[]] | rt.Done = iter34.next(); if (_1587 === rt.DONE) { break; } @@ -986,16 +986,16 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi } flush(log, out); rt.byteVecPush(out, sumPairs(pairs)); - const held3: separated_Pair.Pair[][] = rt.iterToArray(rt.sliceSplitMut(pairs, testPairs), "next", 8); - const iter35: rt.Iter<[rt.usize, rt.Place]> = rt.iterRev(rt.iterEnumerate(rt.iterSliceMut(held3))); + const held3: Pair.Pair[][] = rt.iterToArray(rt.sliceSplitMut(pairs, testPairs), "next", 8); + const iter35: rt.Iter<[rt.usize, rt.Place]> = rt.iterRev(rt.iterEnumerate(rt.iterSliceMut(held3))); while (true) { - const _1609: [rt.usize, rt.Place] | rt.Done = iter35.next(); + const _1609: [rt.usize, rt.Place] | rt.Done = iter35.next(); if (_1609 === rt.DONE) { break; } scribblePairs(rt.usizeAdd(_1609[0], 7), _1609[1].v); } - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held3), (p46: separated_Pair.Pair[]): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held3), (p46: Pair.Pair[]): rt.u8 => { return sumPairs(p46); }), undefined, true); flush(log, out); @@ -1036,7 +1036,7 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi flush(log, out); } rt.byteVecPush(out, sumWords(words)); - const it32: rt.Iter = rt.sliceRsplitMut(pairs, testPairs); + const it32: rt.Iter = rt.sliceRsplitMut(pairs, testPairs); let iterStart20: rt.usize = 0; const iterEnd20: rt.usize = 12; while ((_1694 = iterStart20++) < iterEnd20) { @@ -1103,9 +1103,9 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi }), undefined, true); flush(log, out); rt.byteVecPush(out, sumWords(words)); - const iter43: rt.Iter<[rt.usize, separated_Pair.Pair[]]> = rt.iterEnumerate(rt.sliceSplitInclusiveMut(pairs, testPairs)); + const iter43: rt.Iter<[rt.usize, Pair.Pair[]]> = rt.iterEnumerate(rt.sliceSplitInclusiveMut(pairs, testPairs)); while (true) { - const _1821: [rt.usize, separated_Pair.Pair[]] | rt.Done = iter43.next(); + const _1821: [rt.usize, Pair.Pair[]] | rt.Done = iter43.next(); if (_1821 === rt.DONE) { break; } @@ -1113,16 +1113,16 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi } flush(log, out); rt.byteVecPush(out, sumPairs(pairs)); - const held6: separated_Pair.Pair[][] = rt.iterToArray(rt.sliceSplitInclusiveMut(pairs, testPairs), "next", 8); - const iter44: rt.Iter<[rt.usize, rt.Place]> = rt.iterRev(rt.iterEnumerate(rt.iterSliceMut(held6))); + const held6: Pair.Pair[][] = rt.iterToArray(rt.sliceSplitInclusiveMut(pairs, testPairs), "next", 8); + const iter44: rt.Iter<[rt.usize, rt.Place]> = rt.iterRev(rt.iterEnumerate(rt.iterSliceMut(held6))); while (true) { - const _1843: [rt.usize, rt.Place] | rt.Done = iter44.next(); + const _1843: [rt.usize, rt.Place] | rt.Done = iter44.next(); if (_1843 === rt.DONE) { break; } scribblePairs(rt.usizeAdd(_1843[0], 7), _1843[1].v); } - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held6), (p43: separated_Pair.Pair[]): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held6), (p43: Pair.Pair[]): rt.u8 => { return sumPairs(p43); }), undefined, true); flush(log, out); @@ -1163,7 +1163,7 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi flush(log, out); } rt.byteVecPush(out, sumWords(words)); - const it35: rt.Iter = rt.sliceSplitInclusiveMut(pairs, testPairs); + const it35: rt.Iter = rt.sliceSplitInclusiveMut(pairs, testPairs); let iterStart23: rt.usize = 0; const iterEnd23: rt.usize = 12; while ((_1928 = iterStart23++) < iterEnd23) { @@ -1231,9 +1231,9 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi }), undefined, true); flush(log, out); rt.byteVecPush(out, sumWords(words)); - const iter52: rt.Iter<[rt.usize, separated_Pair.Pair[]]> = rt.iterEnumerate(rt.sliceSplitnMut(pairs, n6, testPairs)); + const iter52: rt.Iter<[rt.usize, Pair.Pair[]]> = rt.iterEnumerate(rt.sliceSplitnMut(pairs, n6, testPairs)); while (true) { - const _2061: [rt.usize, separated_Pair.Pair[]] | rt.Done = iter52.next(); + const _2061: [rt.usize, Pair.Pair[]] | rt.Done = iter52.next(); if (_2061 === rt.DONE) { break; } @@ -1241,16 +1241,16 @@ export function separated(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi } flush(log, out); rt.byteVecPush(out, sumPairs(pairs)); - const held9: separated_Pair.Pair[][] = rt.iterToArray(rt.sliceSplitnMut(pairs, n6, testPairs), "next", 8); - const iter53: rt.Iter<[rt.usize, rt.Place]> = rt.iterRev(rt.iterEnumerate(rt.iterSliceMut(held9))); + const held9: Pair.Pair[][] = rt.iterToArray(rt.sliceSplitnMut(pairs, n6, testPairs), "next", 8); + const iter53: rt.Iter<[rt.usize, rt.Place]> = rt.iterRev(rt.iterEnumerate(rt.iterSliceMut(held9))); while (true) { - const _2083: [rt.usize, rt.Place] | rt.Done = iter53.next(); + const _2083: [rt.usize, rt.Place] | rt.Done = iter53.next(); if (_2083 === rt.DONE) { break; } scribblePairs(rt.usizeAdd(_2083[0], 7), _2083[1].v); } - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held9), (p39: separated_Pair.Pair[]): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held9), (p39: Pair.Pair[]): rt.u8 => { return sumPairs(p39); }), undefined, true); flush(log, out); diff --git a/ts/fixtures/lang/separated/src/lib.rs b/ts/fixtures/lang/separated/src/lib.rs new file mode 100644 index 000000000..5b8120c0c --- /dev/null +++ b/ts/fixtures/lang/separated/src/lib.rs @@ -0,0 +1,21 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#![feature(split_as_slice)] + +#[path = "../../harness.rs"] +pub mod harness; +mod separated; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("separated::separated", separated::separated)] +} diff --git a/ts/fixtures/lang/src/separated.rs b/ts/fixtures/lang/separated/src/separated.rs similarity index 100% rename from ts/fixtures/lang/src/separated.rs rename to ts/fixtures/lang/separated/src/separated.rs diff --git a/ts/fixtures/lang/separated/ts.toml b/ts/fixtures/lang/separated/ts.toml new file mode 100644 index 000000000..9c3b3fb27 --- /dev/null +++ b/ts/fixtures/lang/separated/ts.toml @@ -0,0 +1,2 @@ +package = "lang-separated-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/shapes/Cargo.toml b/ts/fixtures/lang/shapes/Cargo.toml new file mode 100644 index 000000000..7b3550945 --- /dev/null +++ b/ts/fixtures/lang/shapes/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-shapes-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/brands.ts b/ts/fixtures/lang/shapes/brands.ts similarity index 100% rename from ts/fixtures/lang/brands.ts rename to ts/fixtures/lang/shapes/brands.ts diff --git a/ts/fixtures/lang/shapes/caller.ts b/ts/fixtures/lang/shapes/caller.ts new file mode 100644 index 000000000..8d8ea71cd --- /dev/null +++ b/ts/fixtures/lang/shapes/caller.ts @@ -0,0 +1,37 @@ +// The inputs `shapes`' cases name, which run with the generated ones, and a `Fault` +// printed with the `Display` and `Debug` that `printable` brings along, which nothing +// translated calls: native Rust's `entry` prints one for a first byte of 0xff. + +import * as Fault from "./fmt.Fault.ts"; +import { be, edges, op, ops as picks, run as harness } from "./lang.ts"; +import * as rt from "./rt.ts"; + +/** The bytes that pick each case, and a `Fault`'s first byte. */ +export const ops: Uint8Array[] = [...picks, Uint8Array.of(0xff)]; + +export function run(input: rt.ByteSlice): rt.ByteVec { + if (rt.byteSliceFirst(input) !== 0xff) return harness(input); + const fault = Fault.new(rt.byteSliceRange(input, 1)); + const display: rt.Fmt = (f) => Fault.fmt$fmt_Display(fault, f); + const debug: rt.Fmt = (f) => Fault.fmt$fmt_Debug(fault, f); + const text = rt.fmtFormat([ + display, + "|", + rt.fmtSpec({ align: ">", width: 16 }, display), + "|", + debug, + "|", + rt.fmtSpec({ alternate: true }, debug), + ]); + return rt.byteVecFrom(new TextEncoder().encode(text)); +} + +/** `shapes::loops` with each first byte that one of its cases of `!` takes, with one more byte and without. */ +const loops = [0xf1, 0xf3, 0xf4, 0xf5, 0xf6, 0xf9, 0xfa].flatMap((b) => [Uint8Array.of(...op("shapes::loops"), 0, b), Uint8Array.of(...op("shapes::loops"), 0, b, 1)]); + +/** `fmt::ints` of the 64-bit operands random bytes rarely make, each with every format spec, as the high half of a `u128` too. */ +const fmtInts = edges().flatMap((x) => + [0n, 1n, 1n << 32n, 1n << 63n, 0xffffffffffffffffn].flatMap((y) => [3, 4, 9, 10].map((from) => Uint8Array.of(...op("fmt::ints"), from, ...be(x), ...be(y)))), +); + +export const cases: Uint8Array[] = [...loops, ...fmtInts]; diff --git a/ts/fixtures/lang/shapes/expected/core/bool.ts b/ts/fixtures/lang/shapes/expected/core/bool.ts new file mode 100644 index 000000000..4a38187df --- /dev/null +++ b/ts/fixtures/lang/shapes/expected/core/bool.ts @@ -0,0 +1,41 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Void from "../shapes.Void.ts"; + +export function thenSome$0ztng9q(self: boolean, t: rt.Result): rt.Result | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function thenSome$0d5am30(self: boolean, t: rt.u8): rt.u8 | undefined { + if (!self) { + return undefined; + } + return t; +} + +export function then$0h950d8(self: boolean, _: () => rt.u16[]): rt.u16[] | undefined { + if (!self) { + return undefined; + } + return []; +} + +export function then$1i9qaz4(self: boolean, _: () => rt.ByteVec): rt.ByteVec | undefined { + if (!self) { + return undefined; + } + return new rt.ByteVec(); +} + +export function then$1btzga3(self: boolean, f: () => rt.u8): rt.u8 | undefined { + if (!self) { + return undefined; + } + return f(); +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/shapes/expected/core/option.ts b/ts/fixtures/lang/shapes/expected/core/option.ts new file mode 100644 index 000000000..453748371 --- /dev/null +++ b/ts/fixtures/lang/shapes/expected/core/option.ts @@ -0,0 +1,123 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Ticked from "../generics.Ticked.ts"; +import { from$convert_From_shapes_Dir_u8 } from "../shapes.ts"; +import type * as Dir from "../shapes.Dir.ts"; +import type * as Meters from "../shapes.Meters.ts"; +import type * as Point from "../shapes.Point.ts"; +import type * as Shape from "../shapes.Shape.ts"; + +export function unwrapOr$0k15iai(self: rt.char | undefined, default_: rt.char): rt.char { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOrDefault$001fvl5(self: rt.u16 | undefined): rt.u16 { + if (self === undefined) { + return 0; + } + return self; +} + +export function unwrapOrDefault$1q0ps0j(self: rt.u8 | undefined): rt.u8 { + if (self === undefined) { + return 0; + } + return self; +} + +export function map$12l9avg(self: rt.u8 | undefined, f: (a0: rt.u8) => Ticked.Ticked[]): Ticked.Ticked[] | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0600mq0(self: Dir.Dir | undefined, f: (a0: Dir.Dir) => Shape.Shape): Shape.Shape | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$18z3v8h(self: Dir.Dir | undefined, _: (a0: Dir.Dir) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return from$convert_From_shapes_Dir_u8(self); +} + +export function mapOr$1a3irjf(self: rt.ByteVec | undefined, default_: rt.u8, f: (a0: rt.ByteVec) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1t0muvr(self: rt.u8 | undefined, default_: rt.usize, f: (a0: rt.u8) => rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1ybqvup(self: Meters.Meters | undefined, default_: rt.u64, f: (a0: Meters.Meters) => rt.u64): rt.u64 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0rtdylj(self: Point.Point | undefined, default_: rt.u8, f: (a0: Point.Point) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$0aserv9(self: Shape.Shape | undefined, default_: rt.u8, f: (a0: Shape.Shape) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$1hjjwvv(self: [rt.Mutex, rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.Mutex, rt.u8]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function okOr$1vxk0yk(self: rt.u8 | undefined, err: rt.u8): rt.Result { + if (self === undefined) { + return rt.Err(err); + } + return rt.Ok(self); +} + +export function clone$0hmts8n(self: rt.u16[] | undefined): rt.u16[] | undefined { + if (self === undefined) { + return undefined; + } + return rt.vecExact(self.slice(), 2); +} + +export function clone$1grnave(self: rt.ByteVec | undefined): rt.ByteVec | undefined { + if (self === undefined) { + return undefined; + } + return rt.byteVecFrom(rt.byteVecView(self)); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/shapes/expected/core/result.ts b/ts/fixtures/lang/shapes/expected/core/result.ts new file mode 100644 index 000000000..635a98a43 --- /dev/null +++ b/ts/fixtures/lang/shapes/expected/core/result.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function map$1dbyvzi(self: rt.Result, op: (a0: rt.u8) => rt.u8): rt.Result { + if (self.ok) { + return rt.Ok(op(self.value)); + } + return self; +} + +export function mapErr$0dzqwjy(self: rt.Result, op: (a0: string) => rt.u8): rt.Result { + if (self.ok) { + return self as rt.Result; + } + return rt.Err(op(self.error)); +} + +//# sourceMappingURL=result.ts.map diff --git a/ts/fixtures/lang/expected/fmt.Bare.ts b/ts/fixtures/lang/shapes/expected/fmt.Bare.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Bare.ts rename to ts/fixtures/lang/shapes/expected/fmt.Bare.ts diff --git a/ts/fixtures/lang/expected/fmt.Braced.ts b/ts/fixtures/lang/shapes/expected/fmt.Braced.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Braced.ts rename to ts/fixtures/lang/shapes/expected/fmt.Braced.ts diff --git a/ts/fixtures/lang/expected/fmt.Capped.ts b/ts/fixtures/lang/shapes/expected/fmt.Capped.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Capped.ts rename to ts/fixtures/lang/shapes/expected/fmt.Capped.ts diff --git a/ts/fixtures/lang/expected/fmt.Clip.ts b/ts/fixtures/lang/shapes/expected/fmt.Clip.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Clip.ts rename to ts/fixtures/lang/shapes/expected/fmt.Clip.ts diff --git a/ts/fixtures/lang/expected/fmt.Dropper.ts b/ts/fixtures/lang/shapes/expected/fmt.Dropper.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Dropper.ts rename to ts/fixtures/lang/shapes/expected/fmt.Dropper.ts diff --git a/ts/fixtures/lang/expected/fmt.Fails.ts b/ts/fixtures/lang/shapes/expected/fmt.Fails.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Fails.ts rename to ts/fixtures/lang/shapes/expected/fmt.Fails.ts diff --git a/ts/fixtures/lang/expected/fmt.Fault.ts b/ts/fixtures/lang/shapes/expected/fmt.Fault.ts similarity index 85% rename from ts/fixtures/lang/expected/fmt.Fault.ts rename to ts/fixtures/lang/shapes/expected/fmt.Fault.ts index 56105791f..291155142 100644 --- a/ts/fixtures/lang/expected/fmt.Fault.ts +++ b/ts/fixtures/lang/shapes/expected/fmt.Fault.ts @@ -1,17 +1,8 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import * as Any from "./core/any.Any.ts"; import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr } from "./core/option.ts"; -import * as fmt_Pair from "./fmt.Pair.ts"; - -export function asAny$dyns_Erased(self: Fault): Any.Any { - return new Any.of$fmt_Fault(self); -} - -export function asAnyMut$dyns_Erased(self: rt.Place): Any.Any { - return new Any.ofPlace$fmt_Fault(self); -} +import * as Pair from "./fmt.Pair.ts"; export function fmt$fmt_Debug(self: Fault, f: rt.Formatter): rt.Result { if (self.tag === "Short") { @@ -31,7 +22,7 @@ export function fmt$fmt_Debug(self: Fault, f: rt.Formatter): rt.Result fmt_Pair.fmt$fmt_Debug(self._0, f); + const _19: rt.Fmt = (f: rt.Formatter) => Pair.fmt$fmt_Debug(self._0, f); return rt.debugTupleFinish(rt.debugTupleField(rt.fmtDebugTuple(f, _18), _19)); } @@ -43,7 +34,7 @@ export type Fault = | { tag: "Short" } | { tag: "Code"; _0: rt.u16 } | { tag: "TooLarge"; size: rt.usize; max: rt.usize } - | { tag: "At"; _0: fmt_Pair.Pair }; + | { tag: "At"; _0: Pair.Pair }; export function fmt$fmt_Display(self: Fault, f: rt.Formatter): rt.Result { if (self.tag === "Short") { @@ -62,7 +53,7 @@ export function fmt$fmt_Display(self: Fault, f: rt.Formatter): rt.Result fmt_Pair.fmt$fmt_Debug(arg, f)]; + const args6: rt.Fmt[] = [(f: rt.Formatter) => Pair.fmt$fmt_Debug(arg, f)]; return rt.fmtWriteFmt(f, ["at ", args6[0]]); } diff --git a/ts/fixtures/lang/expected/fmt.Gauge.ts b/ts/fixtures/lang/shapes/expected/fmt.Gauge.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Gauge.ts rename to ts/fixtures/lang/shapes/expected/fmt.Gauge.ts diff --git a/ts/fixtures/lang/expected/fmt.Hex.ts b/ts/fixtures/lang/shapes/expected/fmt.Hex.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Hex.ts rename to ts/fixtures/lang/shapes/expected/fmt.Hex.ts diff --git a/ts/fixtures/lang/expected/fmt.Kind.ts b/ts/fixtures/lang/shapes/expected/fmt.Kind.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Kind.ts rename to ts/fixtures/lang/shapes/expected/fmt.Kind.ts diff --git a/ts/fixtures/lang/expected/fmt.Manual.ts b/ts/fixtures/lang/shapes/expected/fmt.Manual.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Manual.ts rename to ts/fixtures/lang/shapes/expected/fmt.Manual.ts diff --git a/ts/fixtures/lang/shapes/expected/fmt.Nested.ts b/ts/fixtures/lang/shapes/expected/fmt.Nested.ts new file mode 100644 index 000000000..ed30d4cea --- /dev/null +++ b/ts/fixtures/lang/shapes/expected/fmt.Nested.ts @@ -0,0 +1,32 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import * as Kind from "./fmt.Kind.ts"; +import * as Pair from "./fmt.Pair.ts"; +import * as Point from "./shapes.Point.ts"; +import * as Shape from "./shapes.Shape.ts"; + +export function fmt$fmt_Debug(self: Nested, f: rt.Formatter): rt.Result { + const names: string[] = ["name", "point", "shape", "tags", "pairs", "maybe", "none", "result", "list", "tuple", "single", "empty", "unit", "boxed"]; + const values: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtStr(self.name, f), (f: rt.Formatter) => Point.fmt$fmt_Debug(self.point, f), (f: rt.Formatter) => Shape.fmt$fmt_Debug(self.shape, f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(self.tags), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(self.pairs, f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$fmt_Debug(value, f)), (f: rt.Formatter) => rt.fmtOption(self.maybe, f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$fmt_Debug(value, f)), (f: rt.Formatter) => rt.fmtOption(self.none, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtResult(self.result, f, rt.u8Debug, rt.fmtStr), (f: rt.Formatter) => rt.fmtList(self.list, f, rt.i16Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(self.tuple[0], f), (f: rt.Formatter) => rt.fmtBool(self.tuple[1], f), (f: rt.Formatter) => rt.fmtStr(self.tuple[2], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(self.single[0], f)], f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(self.empty), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtUnit(self.unit, f), (f: rt.Formatter) => Kind.fmt$fmt_Debug(self.boxed, f)]; + return rt.fmtDebugStructFields(f, "Nested", names, values); +} + +export interface Nested { + name: string; + point: Point.Point; + shape: Shape.Shape; + tags: rt.ByteVec; + pairs: Pair.Pair[]; + maybe: Pair.Pair | undefined; + none: rt.u8 | undefined; + result: rt.Result; + list: rt.i16[]; + tuple: [rt.u8, boolean, string]; + single: [rt.u8]; + empty: rt.ByteVec; + unit: undefined; + boxed: Kind.Kind; +} + +//# sourceMappingURL=fmt.Nested.ts.map diff --git a/ts/fixtures/lang/expected/fmt.Noted.ts b/ts/fixtures/lang/shapes/expected/fmt.Noted.ts similarity index 81% rename from ts/fixtures/lang/expected/fmt.Noted.ts rename to ts/fixtures/lang/shapes/expected/fmt.Noted.ts index 08c9d9154..b33d44023 100644 --- a/ts/fixtures/lang/expected/fmt.Noted.ts +++ b/ts/fixtures/lang/shapes/expected/fmt.Noted.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { note as fmt_note } from "./fmt.ts"; +import { note } from "./fmt.ts"; /** `Display` through `write!` of arguments with effects. */ export interface Noted { @@ -10,8 +10,8 @@ export interface Noted { export function fmt$fmt_Display(self: Noted, f: rt.Formatter): rt.Result { const log: rt.ByteVec = new rt.ByteVec(); - const _7: rt.u8 = fmt_note(log, self._0); - const _11: boolean = fmt_note(log, 1) === self._0; + const _7: rt.u8 = note(log, self._0); + const _11: boolean = note(log, 1) === self._0; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(_7, f), (f: rt.Formatter) => rt.fmtBool(_11, f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(log), f, rt.u8Debug)]; return rt.fmtWriteFmt(f, [args2[0], " ", args2[1], " ", args2[2]]); } diff --git a/ts/fixtures/lang/expected/fmt.Padded.ts b/ts/fixtures/lang/shapes/expected/fmt.Padded.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Padded.ts rename to ts/fixtures/lang/shapes/expected/fmt.Padded.ts diff --git a/ts/fixtures/lang/expected/fmt.Pair.ts b/ts/fixtures/lang/shapes/expected/fmt.Pair.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Pair.ts rename to ts/fixtures/lang/shapes/expected/fmt.Pair.ts diff --git a/ts/fixtures/lang/expected/fmt.Placed.ts b/ts/fixtures/lang/shapes/expected/fmt.Placed.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Placed.ts rename to ts/fixtures/lang/shapes/expected/fmt.Placed.ts diff --git a/ts/fixtures/lang/expected/fmt.Seq.ts b/ts/fixtures/lang/shapes/expected/fmt.Seq.ts similarity index 51% rename from ts/fixtures/lang/expected/fmt.Seq.ts rename to ts/fixtures/lang/shapes/expected/fmt.Seq.ts index 074d03323..ab60e51ad 100644 --- a/ts/fixtures/lang/expected/fmt.Seq.ts +++ b/ts/fixtures/lang/shapes/expected/fmt.Seq.ts @@ -1,16 +1,16 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import * as fmt_Pair from "./fmt.Pair.ts"; +import * as Pair from "./fmt.Pair.ts"; export interface Seq { - _0: fmt_Pair.Pair[]; + _0: Pair.Pair[]; } export function fmt$fmt_Debug(self: Seq, f: rt.Formatter): rt.Result { const _5: rt.DebugList = rt.fmtDebugList(f); - const _6: rt.Iter = rt.iterSlice(self._0); - return rt.debugListFinish(rt.debugListEntries(_5, _6, (value: fmt_Pair.Pair, f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(value, f))); + const _6: rt.Iter = rt.iterSlice(self._0); + return rt.debugListFinish(rt.debugListEntries(_5, _6, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$fmt_Debug(value, f))); } //# sourceMappingURL=fmt.Seq.ts.map diff --git a/ts/fixtures/lang/expected/fmt.Shared.ts b/ts/fixtures/lang/shapes/expected/fmt.Shared.ts similarity index 76% rename from ts/fixtures/lang/expected/fmt.Shared.ts rename to ts/fixtures/lang/shapes/expected/fmt.Shared.ts index 44dc20dc5..c5dca19e6 100644 --- a/ts/fixtures/lang/expected/fmt.Shared.ts +++ b/ts/fixtures/lang/shapes/expected/fmt.Shared.ts @@ -1,12 +1,12 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import * as fmt_Pair from "./fmt.Pair.ts"; +import * as Pair from "./fmt.Pair.ts"; export function fmt$fmt_Debug(self: Shared, f: rt.Formatter): rt.Result { const _3: string = "Shared"; const _4: string = "arc"; - const _5: rt.Fmt = (f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(self.arc.value, f); + const _5: rt.Fmt = (f: rt.Formatter) => Pair.fmt$fmt_Debug(self.arc.value, f); const _7: string = "span"; const _8: rt.Fmt = (f: rt.Formatter) => rt.fmtRange(self.span, f, rt.u16Debug); const _10: string = "upto"; @@ -15,11 +15,11 @@ export function fmt$fmt_Debug(self: Shared, f: rt.Formatter): rt.Result; + arc: rt.Arc; span: rt.Range; upto: { end: rt.u8; inclusive: true }; - constructor(arc: rt.Arc, span: rt.Range, upto: { end: rt.u8; inclusive: true }) { + constructor(arc: rt.Arc, span: rt.Range, upto: { end: rt.u8; inclusive: true }) { this.arc = arc; this.span = span; this.upto = upto; diff --git a/ts/fixtures/lang/expected/fmt.Six.ts b/ts/fixtures/lang/shapes/expected/fmt.Six.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Six.ts rename to ts/fixtures/lang/shapes/expected/fmt.Six.ts diff --git a/ts/fixtures/lang/expected/fmt.Tup.ts b/ts/fixtures/lang/shapes/expected/fmt.Tup.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Tup.ts rename to ts/fixtures/lang/shapes/expected/fmt.Tup.ts diff --git a/ts/fixtures/lang/expected/fmt.Twice.ts b/ts/fixtures/lang/shapes/expected/fmt.Twice.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Twice.ts rename to ts/fixtures/lang/shapes/expected/fmt.Twice.ts diff --git a/ts/fixtures/lang/expected/fmt.Unit.ts b/ts/fixtures/lang/shapes/expected/fmt.Unit.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Unit.ts rename to ts/fixtures/lang/shapes/expected/fmt.Unit.ts diff --git a/ts/fixtures/lang/expected/fmt.Wide.ts b/ts/fixtures/lang/shapes/expected/fmt.Wide.ts similarity index 100% rename from ts/fixtures/lang/expected/fmt.Wide.ts rename to ts/fixtures/lang/shapes/expected/fmt.Wide.ts diff --git a/ts/fixtures/lang/expected/fmt.ts b/ts/fixtures/lang/shapes/expected/fmt.ts similarity index 97% rename from ts/fixtures/lang/expected/fmt.ts rename to ts/fixtures/lang/shapes/expected/fmt.ts index 723e2dd50..f7915af1f 100644 --- a/ts/fixtures/lang/expected/fmt.ts +++ b/ts/fixtures/lang/shapes/expected/fmt.ts @@ -4,7 +4,7 @@ import * as rt from "./rt.ts"; import { copy$array_u8 } from "./lib.ts"; import { thenSome$0d5am30 } from "./core/bool.ts"; import { unwrapOr$0k15iai as option_unwrapOr$0k15iai, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr } from "./core/option.ts"; -import * as fmt_Bare from "./fmt.Bare.ts"; +import * as Bare from "./fmt.Bare.ts"; import * as Braced from "./fmt.Braced.ts"; import * as Capped from "./fmt.Capped.ts"; import * as Clip from "./fmt.Clip.ts"; @@ -17,22 +17,18 @@ import * as Manual from "./fmt.Manual.ts"; import * as Nested from "./fmt.Nested.ts"; import * as Noted from "./fmt.Noted.ts"; import * as Padded from "./fmt.Padded.ts"; -import * as fmt_Pair from "./fmt.Pair.ts"; +import * as Pair from "./fmt.Pair.ts"; import * as Placed from "./fmt.Placed.ts"; import * as Seq from "./fmt.Seq.ts"; import * as Shared from "./fmt.Shared.ts"; import * as Six from "./fmt.Six.ts"; import * as Tup from "./fmt.Tup.ts"; -import * as fmt_Twice from "./fmt.Twice.ts"; -import * as fmt_Unit from "./fmt.Unit.ts"; +import * as Twice from "./fmt.Twice.ts"; +import * as Unit from "./fmt.Unit.ts"; import * as fmt_Wide from "./fmt.Wide.ts"; +import { put } from "./harness.ts"; import * as Point from "./shapes.Point.ts"; -import type * as shapes_Shape from "./shapes.Shape.ts"; - -export function put(out: rt.ByteVec, s: string): void { - rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); - rt.byteVecPush(out, 255); -} +import type * as Shape from "./shapes.Shape.ts"; /** Integers of every width, with each spec. */ export function ints(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { @@ -238,8 +234,8 @@ export function strings(data: rt.ByteSlice, out: rt.ByteVec): void { } export function nested(data: rt.ByteSlice): Nested.Nested { - let _22!: shapes_Shape.Shape; - let _49!: fmt_Pair.Pair | undefined; + let _22!: Shape.Shape; + let _49!: Pair.Pair | undefined; let _61!: rt.Result; let _90!: Kind.Kind; const at: (a0: rt.usize) => rt.u8 = (i: rt.usize): rt.u8 => { @@ -253,14 +249,14 @@ export function nested(data: rt.ByteSlice): Nested.Nested { const _15: Point.Point = { x: rt.i32Sub(at(1) as rt.i32, 128), y: -7 }; const _23: rt.u8 = rt.u8Rem(at(2), 3); if (_23 === 0) { - _22 = { tag: "Dot" } as shapes_Shape.Shape; + _22 = { tag: "Dot" } as Shape.Shape; } else if (_23 === 1) { - _22 = { tag: "Line", _0: { x: 1, y: 2 }, _1: { x: -3, y: 4 } } as shapes_Shape.Shape; + _22 = { tag: "Line", _0: { x: 1, y: 2 }, _1: { x: -3, y: 4 } } as Shape.Shape; } else { - _22 = { tag: "Rect", corner: { x: 0, y: 0 }, width: at(3) as rt.u16, height: 9 } as shapes_Shape.Shape; + _22 = { tag: "Rect", corner: { x: 0, y: 0 }, width: at(3) as rt.u16, height: 9 } as Shape.Shape; } const _35: rt.ByteVec = rt.byteSliceToByteVec(rt.byteSliceRange(data, 0, rt.min(data.length, 4))); - const _40: fmt_Pair.Pair[] = rt.vecExact([{ _0: at(4), _1: -1 }, { _0: 2, _1: { hi: -0x80000000, lo: 0 } as rt.i64 }].slice(), 16); + const _40: Pair.Pair[] = rt.vecExact([{ _0: at(4), _1: -1 }, { _0: 2, _1: { hi: -0x80000000, lo: 0 } as rt.i64 }].slice(), 16); if (!(rt.u8Rem(at(5), 2) === 0)) { _49 = undefined; } else { @@ -305,15 +301,15 @@ export function derived(data: rt.ByteSlice, out: rt.ByteVec): void { put(out, rt.fmtFormat([rt.fmtSpec({ plus: true, precision: 1 }, args10[0])])); const wide: fmt_Wide.Wide = { a: at(0), b: 300, c: 70000, d: { hi: 0xffffffff, lo: 0xffffffff } as rt.u64, e: -1, f: at(1) > 10 }; const six: Six.Six = { _0: at(0), _1: 1, _2: 2, _3: 3, _4: 4, _5: at(1) }; - const _87: fmt_Unit.Unit = {}; - const _88: fmt_Unit.Unit = {}; - const args12: rt.Fmt[] = [(f: rt.Formatter) => fmt_Wide.fmt$fmt_Debug(wide, f), (f: rt.Formatter) => Six.fmt$fmt_Debug(six, f), (f: rt.Formatter) => fmt_Unit.fmt$fmt_Debug(_87, f), (f: rt.Formatter) => fmt_Unit.fmt$fmt_Debug(_88, f)]; + const _87: Unit.Unit = {}; + const _88: Unit.Unit = {}; + const args12: rt.Fmt[] = [(f: rt.Formatter) => fmt_Wide.fmt$fmt_Debug(wide, f), (f: rt.Formatter) => Six.fmt$fmt_Debug(six, f), (f: rt.Formatter) => Unit.fmt$fmt_Debug(_87, f), (f: rt.Formatter) => Unit.fmt$fmt_Debug(_88, f)]; put(out, rt.fmtFormat([args12[0], " ", args12[1], " ", args12[2], " ", rt.fmtSpec({ alternate: true }, args12[3])])); const args14: rt.Fmt[] = [(f: rt.Formatter) => fmt_Wide.fmt$fmt_Debug(wide, f), (f: rt.Formatter) => Six.fmt$fmt_Debug(six, f)]; put(out, rt.fmtFormat([rt.fmtSpec({ alternate: true }, args14[0]), " ", rt.fmtSpec({ alternate: true }, args14[1])])); const point: Point.Point = { x: at(2) as rt.i32, y: -1 }; - const _125: fmt_Pair.Pair = { _0: at(3), _1: -9 }; - const args16: rt.Fmt[] = [(f: rt.Formatter) => Point.fmt$fmt_Debug(point, f), (f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(_125, f)]; + const _125: Pair.Pair = { _0: at(3), _1: -9 }; + const args16: rt.Fmt[] = [(f: rt.Formatter) => Point.fmt$fmt_Debug(point, f), (f: rt.Formatter) => Pair.fmt$fmt_Debug(_125, f)]; put(out, rt.fmtFormat([rt.fmtSpec({ width: 5 }, args16[0]), "|", rt.fmtSpec({ align: "<", width: 4 }, args16[0]), "|", rt.fmtSpec({ alternate: true, width: 4 }, args16[0]), "|", rt.fmtSpec({ align: ">", width: 3 }, args16[1])])); const kinds: Kind.Kind[] = [{ tag: "Empty" } as Kind.Kind, { tag: "One", _0: at(4) } as Kind.Kind, { tag: "Braced" } as Kind.Kind, { tag: "Bare" } as Kind.Kind, { tag: "Many", count: 0, items: new rt.ByteVec() } as Kind.Kind]; const _154: Kind.Kind = kinds[1]; @@ -328,11 +324,11 @@ export function derived(data: rt.ByteSlice, out: rt.ByteVec): void { put(out, rt.fmtFormat([args22[0], " ", args22[1], " ", args22[2], " ", args22[3]])); const _208: Braced.Braced = {}; const _209: Braced.Braced = {}; - const _210: fmt_Bare.Bare = {}; - const _211: fmt_Bare.Bare = {}; - const args24: rt.Fmt[] = [(f: rt.Formatter) => Braced.fmt$fmt_Debug(_208, f), (f: rt.Formatter) => Braced.fmt$fmt_Debug(_209, f), (f: rt.Formatter) => fmt_Bare.fmt$fmt_Debug(_210, f), (f: rt.Formatter) => fmt_Bare.fmt$fmt_Debug(_211, f)]; + const _210: Bare.Bare = {}; + const _211: Bare.Bare = {}; + const args24: rt.Fmt[] = [(f: rt.Formatter) => Braced.fmt$fmt_Debug(_208, f), (f: rt.Formatter) => Braced.fmt$fmt_Debug(_209, f), (f: rt.Formatter) => Bare.fmt$fmt_Debug(_210, f), (f: rt.Formatter) => Bare.fmt$fmt_Debug(_211, f)]; put(out, rt.fmtFormat([args24[0], " ", rt.fmtSpec({ alternate: true }, args24[1]), " ", args24[2], " ", rt.fmtSpec({ alternate: true }, args24[3])])); - rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(Braced.eq$cmp_PartialEq({}, {}) ? 1 : 0, fmt_Bare.eq$cmp_PartialEq({}, {}) ? 1 : 0))); + rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(Braced.eq$cmp_PartialEq({}, {}) ? 1 : 0, Bare.eq$cmp_PartialEq({}, {}) ? 1 : 0))); } /** `v`, logged, so an argument evaluated more than once shows. */ @@ -379,7 +375,7 @@ export function written(data: rt.ByteSlice, out: rt.ByteVec): void { const args8: rt.Fmt[] = [(f: rt.Formatter) => Manual.fmt$fmt_Debug(manual, f), (f: rt.Formatter) => Manual.fmt$fmt_Debug(empty, f)]; put(out, rt.fmtFormat([args8[0], " ", rt.fmtSpec({ alternate: true }, args8[0]), " ", args8[1]])); const seq: Seq.Seq = { _0: rt.vecExact([{ _0: at(3), _1: 0 }, { _0: 1, _1: -1 }].slice(), 16) }; - const _97: fmt_Pair.Pair[] = []; + const _97: Pair.Pair[] = []; const none: Seq.Seq = { _0: _97 }; const args10: rt.Fmt[] = [(f: rt.Formatter) => Seq.fmt$fmt_Debug(seq, f), (f: rt.Formatter) => Seq.fmt$fmt_Debug(none, f)]; put(out, rt.fmtFormat([args10[0], " ", rt.fmtSpec({ alternate: true }, args10[0]), " ", args10[1], " ", rt.fmtSpec({ alternate: true }, args10[1])])); @@ -484,7 +480,7 @@ export function rounding(out: rt.ByteVec): void { /** Panics, each with the message native Rust formats. */ export function panics(kind: rt.u8, rest: rt.ByteSlice, out: rt.ByteVec): void { let r!: rt.Result; - let r2!: rt.Result; + let r2!: rt.Result; let r4!: rt.Result; let r5!: rt.Result; const n: rt.u8 = option_unwrapOr$0r2bmpr(rt.byteSliceFirst(rest), 0); @@ -498,8 +494,8 @@ export function panics(kind: rt.u8, rest: rt.ByteSlice, out: rt.ByteVec): void { rt.panicFmt(["internal error: entered unreachable code: never ", rt.fmtSpec({ alternate: true }, args4[0]), " ", args4[1]]); } else if (_7 === 2) { if (!(n > 200)) { - const _37: fmt_Pair.Pair = { _0: n, _1: 0 }; - const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(n, f), (f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(_37, f)]; + const _37: Pair.Pair = { _0: n, _1: 0 }; + const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(n, f), (f: rt.Formatter) => Pair.fmt$fmt_Debug(_37, f)]; rt.panicFmt(["small ", args6[0], " ", args6[1]]); } } else if (_7 === 3) { @@ -511,13 +507,13 @@ export function panics(kind: rt.u8, rest: rt.ByteSlice, out: rt.ByteVec): void { rt.assertFailed("==", (f: rt.Formatter) => rt.u8Debug(n, f), (f: rt.Formatter) => rt.u8Debug(7, f), undefined as rt.Arguments | undefined); } } else if (_7 === 5) { - const _58: fmt_Pair.Pair = { _0: n, _1: 1 }; - const _60: fmt_Pair.Pair = { _0: n, _1: 1 }; - if (fmt_Pair.eq$cmp_PartialEq(_58, _60)) { + const _58: Pair.Pair = { _0: n, _1: 1 }; + const _60: Pair.Pair = { _0: n, _1: 1 }; + if (Pair.eq$cmp_PartialEq(_58, _60)) { const kind3: string = "!="; const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(n, f)]; const _66: rt.Arguments | undefined = ["same ", args8[0]]; - rt.assertFailed(kind3, (f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(_58, f), (f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(_60, f), _66); + rt.assertFailed(kind3, (f: rt.Formatter) => Pair.fmt$fmt_Debug(_58, f), (f: rt.Formatter) => Pair.fmt$fmt_Debug(_60, f), _66); } } else if (_7 === 6) { if (!(n === 9)) { @@ -537,7 +533,7 @@ export function panics(kind: rt.u8, rest: rt.ByteSlice, out: rt.ByteVec): void { } else { r2 = rt.Ok(n); } - const _110: rt.u8 = rt.resultExpect(r2, "expected a byte", (value: fmt_Pair.Pair, f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(value, f)); + const _110: rt.u8 = rt.resultExpect(r2, "expected a byte", (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$fmt_Debug(value, f)); put(out, rt.fmtToString((f: rt.Formatter) => rt.u8Display(_110, f))); } else if (_7 === 9) { const _121: rt.u8 = rt.resultUnwrapErr(rt.Ok({ x: n as rt.i32, y: 0 }), (value: Point.Point, f: rt.Formatter) => Point.fmt$fmt_Debug(value, f)); @@ -665,7 +661,7 @@ export function wrapped(data: rt.ByteSlice, out: rt.ByteVec): void { const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_167, f, (value: Hex.Hex, f: rt.Formatter) => Hex.fmt$fmt_Debug(value, f)), (f: rt.Formatter) => rt.fmtRangeInclusive(_171, f, (value: Hex.Hex, f: rt.Formatter) => Hex.fmt$fmt_Debug(value, f)), (f: rt.Formatter) => rt.fmtRangeTo(_175, f, (value: Hex.Hex, f: rt.Formatter) => Hex.fmt$fmt_Debug(value, f))]; put(out, rt.fmtFormat([args8[0], "|", rt.fmtSpec({ align: ">", width: 9 }, args8[1]), "|", rt.fmtSpec({ alternate: true }, args8[2])])); const part3 = new rt.Range({ _0: at(7), _1: -1 }, { _0: 1, _1: { hi: -0x80000000, lo: 0 } as rt.i64 }); - const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(part3, f, (value: fmt_Pair.Pair, f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(value, f))]; + const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(part3, f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$fmt_Debug(value, f))]; put(out, rt.fmtFormat([args10[0], "|", rt.fmtSpec({ alternate: true }, args10[0]), "|", rt.fmtSpec({ debugHex: "x" }, args10[0]), "|", rt.fmtSpec({ plus: true }, args10[0])])); const drained: rt.RangeInclusive = new rt.RangeInclusive(rt.u8Rem(at(8), 4), rt.u8Rem(at(9), 4), rt.u8Step); while (rt.iterToOption(drained.next()) !== undefined) { @@ -696,8 +692,8 @@ export function wrapped(data: rt.ByteSlice, out: rt.ByteVec): void { const rc: rt.Arc = new rt.Arc(["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽𽀀𿱀", "😀 🇦", "゙゚ン", "{}"][_310]); const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, rc.value), (f: rt.Formatter) => rt.fmtStr(rc.value, f)]; put(out, rt.fmtFormat([args18[0], "|", rt.fmtSpec({ align: ">", width: 8, precision: 2 }, args18[0]), "|", args18[1]])); - const list: rt.Arc = new rt.Arc(rt.vecExact([{ _0: at(7), _1: 2 }, { _0: 3, _1: -4 }].slice(), 16)); - const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(list.value, f, (value: fmt_Pair.Pair, f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(value, f))]; + const list: rt.Arc = new rt.Arc(rt.vecExact([{ _0: at(7), _1: 2 }, { _0: 3, _1: -4 }].slice(), 16)); + const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(list.value, f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$fmt_Debug(value, f))]; put(out, rt.fmtFormat([args20[0], " ", rt.fmtSpec({ alternate: true }, args20[0])])); const held: rt.Range> = new rt.Range(new rt.Arc(a), new rt.Arc(b)); const _366: rt.Range> = new rt.Range(new rt.Arc(lo), new rt.Arc(hi)); @@ -766,8 +762,8 @@ export function collections(data: rt.ByteSlice, out: rt.ByteVec): void { const units: rt.VecDeque = rt.dequeFromVec(rt.iterToArray(rt.iterMap(new rt.Range(0, rt.u8Rem(at(2), 3)), (_2: rt.u8): undefined => {}), undefined, 0, true), 0) as rt.VecDeque; const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.dequeIter(empty), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(rt.dequeIter(units), f, rt.fmtUnit)]; put(out, rt.fmtFormat([args8[0], "|", rt.fmtSpec({ alternate: true }, args8[0]), "|", args8[1]])); - const part = rt.dequeFromArray([rt.dequeNew(16) as rt.VecDeque, rt.dequeFromArray([{ _0: at(3), _1: -1 }, { _0: 2, _1: 3 }], 16) as rt.VecDeque], 16) as rt.VecDeque>; - const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.dequeIter(part), f, (value: rt.VecDeque, f: rt.Formatter) => rt.fmtList(rt.dequeIter(value), f, (value: fmt_Pair.Pair, f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(value, f)))]; + const part = rt.dequeFromArray([rt.dequeNew(16) as rt.VecDeque, rt.dequeFromArray([{ _0: at(3), _1: -1 }, { _0: 2, _1: 3 }], 16) as rt.VecDeque], 16) as rt.VecDeque>; + const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.dequeIter(part), f, (value: rt.VecDeque, f: rt.Formatter) => rt.fmtList(rt.dequeIter(value), f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$fmt_Debug(value, f)))]; put(out, rt.fmtFormat([args10[0], "|", rt.fmtSpec({ alternate: true }, args10[0])])); const _135: rt.Iter = rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_25: rt.u8): rt.u8 | undefined => { const b5: rt.u8 = _25; @@ -776,7 +772,7 @@ export function collections(data: rt.ByteSlice, out: rt.ByteVec): void { const part2 = rt.btreeExtendKeys(rt.btreeNew(rt.cmpOption(rt.cmp)) as rt.BTreeSet, _135, true, undefined, undefined, 2, true); const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtSet(rt.btreeKeys(part2), f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug))]; put(out, rt.fmtFormat([args12[0], "|", rt.fmtSpec({ alternate: true }, args12[0]), "|", rt.fmtSpec({ zero: true, debugHex: "x", width: 2 }, args12[0])])); - const map: rt.BTreeMap> = rt.btreeNew(rt.cmp) as rt.BTreeMap>; + const map: rt.BTreeMap> = rt.btreeNew(rt.cmp) as rt.BTreeMap>; const iter2: rt.Iter = rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 6); while (true) { const _154: rt.u8 | rt.Done = iter2.next(); @@ -784,13 +780,13 @@ export function collections(data: rt.ByteSlice, out: rt.ByteVec): void { break; } const b2: rt.u8 = _154; - rt.dequePushFront(rt.entryOrInsertWith(rt.entry(map, rt.u8Rem(b2, 4)), (): rt.VecDeque => { - return rt.dequeNew(16) as rt.VecDeque; + rt.dequePushFront(rt.entryOrInsertWith(rt.entry(map, rt.u8Rem(b2, 4)), (): rt.VecDeque => { + return rt.dequeNew(16) as rt.VecDeque; }), { _0: b2, _1: rt.i64Neg(b2 as rt.i64) }); } const _176: rt.BTreeMap = rt.btreeNew(rt.cmp) as rt.BTreeMap; const _178: rt.BTreeSet = rt.btreeNew(rt.cmp) as rt.BTreeSet; - const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtMap(rt.btreeIter(map), f, rt.u8Debug, (value: rt.VecDeque, f: rt.Formatter) => rt.fmtList(rt.dequeIter(value), f, (value: fmt_Pair.Pair, f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(value, f))), (f: rt.Formatter) => rt.fmtMap(rt.btreeIter(_176), f, rt.u8Debug, rt.u8Debug), (f: rt.Formatter) => rt.fmtSet(rt.btreeKeys(_178), f, rt.u8Debug)]; + const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtMap(rt.btreeIter(map), f, rt.u8Debug, (value: rt.VecDeque, f: rt.Formatter) => rt.fmtList(rt.dequeIter(value), f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$fmt_Debug(value, f))), (f: rt.Formatter) => rt.fmtMap(rt.btreeIter(_176), f, rt.u8Debug, rt.u8Debug), (f: rt.Formatter) => rt.fmtSet(rt.btreeKeys(_178), f, rt.u8Debug)]; put(out, rt.fmtFormat([args14[0], "|", rt.fmtSpec({ alternate: true }, args14[0]), "|", args14[1], "|", rt.fmtSpec({ alternate: true }, args14[2])])); const _188: [rt.HashMap, rt.HashSet] = [rt.hashNew(rt.hashing(rt.hashOption(rt.hash8), rt.same)) as rt.HashMap, rt.hashNew() as rt.HashSet]; const one: rt.HashMap = _188[0]; @@ -1004,11 +1000,11 @@ export function iters(data: rt.ByteSlice, out: rt.ByteVec): void { const part2 = ends$iters_slice_IterMut_u8(rt.iterSliceMut(rt.byteSliceView(rt.byteVecSlice(rt.iterToByteVec(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 5), undefined, true)))), front, back); const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtIter(part2, f, rt.u8Debug, ["IterMut"])]; put(out, rt.fmtFormat([args4[0], "|", rt.fmtSpec({ alternate: true }, args4[0])])); - const part3 = ends$iters_vec_IntoIter_fmt_Pair(rt.iterSlice(rt.iterToArray(rt.iterMap(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 4), (_2: rt.u8): fmt_Pair.Pair => { + const part3 = ends$iters_vec_IntoIter_fmt_Pair(rt.iterSlice(rt.iterToArray(rt.iterMap(rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 4), (_2: rt.u8): Pair.Pair => { const b2: rt.u8 = _2; return { _0: b2, _1: rt.i64Neg(b2 as rt.i64) }; }), undefined, 16, true)), front, back); - const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtIter(part3, f, (value: fmt_Pair.Pair, f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(value, f), ["IntoIter"])]; + const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtIter(part3, f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$fmt_Debug(value, f), ["IntoIter"])]; put(out, rt.fmtFormat([args6[0], "|", rt.fmtSpec({ alternate: true }, args6[0])])); const part4 = ends$iters_vec_IntoIter_u8(rt.byteVecIntoIter(rt.byteSliceToByteVec(data)), front, back); const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtIter(part4, f, rt.u8Debug, ["IntoIter"])]; @@ -1489,7 +1485,7 @@ export function skip$iters_vec_Drain_u8(it: rt.Iter, n: rt.usize): rt.Ite return it; } -export function skip$iters_vec_IntoIter_fmt_Pair(it: rt.Iter, n: rt.usize): rt.Iter { +export function skip$iters_vec_IntoIter_fmt_Pair(it: rt.Iter, n: rt.usize): rt.Iter { if (n > 0) { rt.iterNth(it, rt.usizeSub(n, 1)); return it; @@ -1829,8 +1825,8 @@ export function ends$iters_vec_Drain_u8(it: rt.Iter, front: rt.usize, bac } } -export function ends$iters_vec_IntoIter_fmt_Pair(it: rt.Iter, front: rt.usize, back: rt.usize): rt.Iter { - const it2: rt.Iter = skip$iters_vec_IntoIter_fmt_Pair(it, front); +export function ends$iters_vec_IntoIter_fmt_Pair(it: rt.Iter, front: rt.usize, back: rt.usize): rt.Iter { + const it2: rt.Iter = skip$iters_vec_IntoIter_fmt_Pair(it, front); let iterStart: rt.usize = 0; const iterEnd: rt.usize = back; while (true) { @@ -1972,17 +1968,17 @@ export function literals$mut_fmt_Formatter(w: rt.Formatter, c: rt.char): rt.Resu * Literals, a `char` of each width, and empty pieces, each its own call, stopping at the * first error. */ -export function literals$mut_fmt_Twice(w: fmt_Twice.Twice, c: rt.char): rt.Result { - if (fmt_Twice.writeStr$fmt_Write(w, "ab").ok) { - if (fmt_Twice.writeStr$fmt_Write(w, "").ok) { - if (fmt_Twice.writeStr$fmt_Write(w, "").ok) { - if (fmt_Twice.writeChar$fmt_Write(w, c).ok) { - if (fmt_Twice.writeStr$fmt_Write(w, "cxd").ok) { - if (fmt_Twice.writeChar$fmt_Write(w, 128512).ok) { - if (fmt_Twice.writeStr$fmt_Write(w, "\n").ok) { - if (fmt_Twice.writeStr$fmt_Write(w, "{}").ok) { - if (fmt_Twice.writeStr$fmt_Write(w, "").ok) { - return fmt_Twice.writeStr$fmt_Write(w, "end\n"); +export function literals$mut_fmt_Twice(w: Twice.Twice, c: rt.char): rt.Result { + if (Twice.writeStr$fmt_Write(w, "ab").ok) { + if (Twice.writeStr$fmt_Write(w, "").ok) { + if (Twice.writeStr$fmt_Write(w, "").ok) { + if (Twice.writeChar$fmt_Write(w, c).ok) { + if (Twice.writeStr$fmt_Write(w, "cxd").ok) { + if (Twice.writeChar$fmt_Write(w, 128512).ok) { + if (Twice.writeStr$fmt_Write(w, "\n").ok) { + if (Twice.writeStr$fmt_Write(w, "{}").ok) { + if (Twice.writeStr$fmt_Write(w, "").ok) { + return Twice.writeStr$fmt_Write(w, "end\n"); } return rt.Err(new rt.FmtError()); } @@ -2193,9 +2189,9 @@ export function writes(data: rt.ByteSlice, out: rt.ByteVec): void { result(out, literals$mut_mut_fmt_Capped(rt.place(() => _131, (value7) => _131 = value7), 233)); rt.byteVecPush(out, capped.calls); put(out, capped.text); - const twice: fmt_Twice.Twice = { _0: "" }; + const twice: Twice.Twice = { _0: "" }; result(out, literals$mut_fmt_Twice(twice, c)); - result(out, fmt_Twice.writeChar$fmt_Write(twice, 223)); + result(out, Twice.writeChar$fmt_Write(twice, 223)); put(out, twice._0); } diff --git a/ts/fixtures/lang/expected/generics.Either.ts b/ts/fixtures/lang/shapes/expected/generics.Either.ts similarity index 100% rename from ts/fixtures/lang/expected/generics.Either.ts rename to ts/fixtures/lang/shapes/expected/generics.Either.ts diff --git a/ts/fixtures/lang/expected/generics.Fixed.ts b/ts/fixtures/lang/shapes/expected/generics.Fixed.ts similarity index 100% rename from ts/fixtures/lang/expected/generics.Fixed.ts rename to ts/fixtures/lang/shapes/expected/generics.Fixed.ts diff --git a/ts/fixtures/lang/expected/generics.Lends.ts b/ts/fixtures/lang/shapes/expected/generics.Lends.ts similarity index 100% rename from ts/fixtures/lang/expected/generics.Lends.ts rename to ts/fixtures/lang/shapes/expected/generics.Lends.ts diff --git a/ts/fixtures/lang/expected/generics.Run.ts b/ts/fixtures/lang/shapes/expected/generics.Run.ts similarity index 100% rename from ts/fixtures/lang/expected/generics.Run.ts rename to ts/fixtures/lang/shapes/expected/generics.Run.ts diff --git a/ts/fixtures/lang/expected/generics.Runs.ts b/ts/fixtures/lang/shapes/expected/generics.Runs.ts similarity index 94% rename from ts/fixtures/lang/expected/generics.Runs.ts rename to ts/fixtures/lang/shapes/expected/generics.Runs.ts index 56bb84a40..c0d3ee7e6 100644 --- a/ts/fixtures/lang/expected/generics.Runs.ts +++ b/ts/fixtures/lang/shapes/expected/generics.Runs.ts @@ -3,7 +3,7 @@ import * as rt from "./rt.ts"; import { copy$array_u16, copy$array_u8 } from "./lib.ts"; import { clone$0hmts8n as option_clone$0hmts8n, clone$1grnave as option_clone$1grnave } from "./core/option.ts"; -import type * as generics_Run from "./generics.Run.ts"; +import type * as Run from "./generics.Run.ts"; export function clone$Clone_u16(self: Runs): Runs { return new Runs(copy$array_u16(copy$array_u16(self.array as rt.u16[])), rt.vecExact((self.list as rt.u16[]).slice(), 2), self.view as rt.u16[], (self.boxed as rt.u16[]).slice(), rt.cowClone(self.cow as rt.Cow), rt.vecExact((self.pairs as rt.u16[][]).map(copy$array_u16), 4), option_clone$0hmts8n(self.maybe as rt.u16[] | undefined)); @@ -158,26 +158,26 @@ export function push$u8(self: Runs, item: rt.u8): void { } } -export function run$u16(self: Runs): generics_Run.Run { +export function run$u16(self: Runs): Run.Run { const _2: rt.usize = rt.usizeRem((self.list as rt.u16[]).length, 3); if (_2 === 0) { - return { tag: "Listed", _0: rt.vecExact((self.list as rt.u16[]).slice(), 2) } as generics_Run.Run; + return { tag: "Listed", _0: rt.vecExact((self.list as rt.u16[]).slice(), 2) } as Run.Run; } if (_2 === 1) { - return { tag: "Fixed", array: [(self.array as rt.u16[])[0], (self.array as rt.u16[])[2]] } as generics_Run.Run; + return { tag: "Fixed", array: [(self.array as rt.u16[])[0], (self.array as rt.u16[])[2]] } as Run.Run; } - return { tag: "Empty" } as generics_Run.Run; + return { tag: "Empty" } as Run.Run; } -export function run$u8(self: Runs): generics_Run.Run { +export function run$u8(self: Runs): Run.Run { const _2: rt.usize = rt.usizeRem((self.list as rt.ByteVec).length, 3); if (_2 === 0) { - return { tag: "Listed", _0: rt.byteVecFrom(rt.byteVecView(self.list as rt.ByteVec)) } as generics_Run.Run; + return { tag: "Listed", _0: rt.byteVecFrom(rt.byteVecView(self.list as rt.ByteVec)) } as Run.Run; } if (_2 === 1) { - return { tag: "Fixed", array: Uint8Array.of((self.array as Uint8Array)[0], (self.array as Uint8Array)[2]) } as generics_Run.Run; + return { tag: "Fixed", array: Uint8Array.of((self.array as Uint8Array)[0], (self.array as Uint8Array)[2]) } as Run.Run; } - return { tag: "Empty" } as generics_Run.Run; + return { tag: "Empty" } as Run.Run; } //# sourceMappingURL=generics.Runs.ts.map diff --git a/ts/fixtures/lang/expected/generics.Tagged.ts b/ts/fixtures/lang/shapes/expected/generics.Tagged.ts similarity index 100% rename from ts/fixtures/lang/expected/generics.Tagged.ts rename to ts/fixtures/lang/shapes/expected/generics.Tagged.ts diff --git a/ts/fixtures/lang/expected/generics.Ticked.ts b/ts/fixtures/lang/shapes/expected/generics.Ticked.ts similarity index 100% rename from ts/fixtures/lang/expected/generics.Ticked.ts rename to ts/fixtures/lang/shapes/expected/generics.Ticked.ts diff --git a/ts/fixtures/lang/expected/generics.Wrap.ts b/ts/fixtures/lang/shapes/expected/generics.Wrap.ts similarity index 77% rename from ts/fixtures/lang/expected/generics.Wrap.ts rename to ts/fixtures/lang/shapes/expected/generics.Wrap.ts index 60d224ab8..b796487f0 100644 --- a/ts/fixtures/lang/expected/generics.Wrap.ts +++ b/ts/fixtures/lang/shapes/expected/generics.Wrap.ts @@ -1,10 +1,10 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import * as fmt_Pair from "./fmt.Pair.ts"; +import * as Pair from "./fmt.Pair.ts"; import * as Meters from "./shapes.Meters.ts"; import * as Point from "./shapes.Point.ts"; -import * as shapes_Shape from "./shapes.Shape.ts"; +import * as Shape from "./shapes.Shape.ts"; export function fmt$fmt_Debug_Option_u8(self: Wrap, f: rt.Formatter): rt.Result { const _3: string = "Wrap"; @@ -15,10 +15,10 @@ export function fmt$fmt_Debug_Option_u8(self: Wrap, f: rt.For return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } -export function fmt$fmt_Debug_Result_u8_shapes_Shape(self: Wrap>, f: rt.Formatter): rt.Result { +export function fmt$fmt_Debug_Result_u8_shapes_Shape(self: Wrap>, f: rt.Formatter): rt.Result { const _3: string = "Wrap"; const _4: string = "value"; - const _5: rt.Fmt = (f: rt.Formatter) => rt.fmtResult(self.value, f, rt.u8Debug, (value: shapes_Shape.Shape, f: rt.Formatter) => shapes_Shape.fmt$fmt_Debug(value, f)); + const _5: rt.Fmt = (f: rt.Formatter) => rt.fmtResult(self.value, f, rt.u8Debug, (value: Shape.Shape, f: rt.Formatter) => Shape.fmt$fmt_Debug(value, f)); const _7: string = "count"; const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.count, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); @@ -33,16 +33,16 @@ export function fmt$fmt_Debug_Vec_u16(self: Wrap, f: rt.Formatter): rt return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } -export function fmt$fmt_Debug_fmt_Pair(self: Wrap, f: rt.Formatter): rt.Result { +export function fmt$fmt_Debug_fmt_Pair(self: Wrap, f: rt.Formatter): rt.Result { const _3: string = "Wrap"; const _4: string = "value"; - const _5: rt.Fmt = (f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(self.value, f); + const _5: rt.Fmt = (f: rt.Formatter) => Pair.fmt$fmt_Debug(self.value, f); const _7: string = "count"; const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.count, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } -export function fmt$fmt_Debug_generics_Wrap_fmt_Pair(self: Wrap>, f: rt.Formatter): rt.Result { +export function fmt$fmt_Debug_generics_Wrap_fmt_Pair(self: Wrap>, f: rt.Formatter): rt.Result { const _3: string = "Wrap"; const _4: string = "value"; const _5: rt.Fmt = (f: rt.Formatter) => fmt$fmt_Debug_fmt_Pair(self.value, f); @@ -69,10 +69,10 @@ export function fmt$fmt_Debug_shapes_Point(self: Wrap, f: rt.Format return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } -export function fmt$fmt_Debug_shapes_Shape(self: Wrap, f: rt.Formatter): rt.Result { +export function fmt$fmt_Debug_shapes_Shape(self: Wrap, f: rt.Formatter): rt.Result { const _3: string = "Wrap"; const _4: string = "value"; - const _5: rt.Fmt = (f: rt.Formatter) => shapes_Shape.fmt$fmt_Debug(self.value, f); + const _5: rt.Fmt = (f: rt.Formatter) => Shape.fmt$fmt_Debug(self.value, f); const _7: string = "count"; const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.count, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); @@ -87,11 +87,11 @@ export function fmt$fmt_Debug_u8(self: Wrap, f: rt.Formatter): rt.Result< return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } -export function eq$cmp_PartialEq_fmt_Pair(self: Wrap, other: Wrap): boolean { +export function eq$cmp_PartialEq_fmt_Pair(self: Wrap, other: Wrap): boolean { if (!(self.count === other.count)) { return false; } - return fmt_Pair.eq$cmp_PartialEq(self.value, other.value); + return Pair.eq$cmp_PartialEq(self.value, other.value); } /** A generic struct, with methods on every instance, on some, and on one. */ @@ -109,11 +109,11 @@ export function new$Option_u8(value: rt.u8 | undefined): Wrap return new Wrap(value, 0); } -export function new$fmt_Pair(value: fmt_Pair.Pair): Wrap { +export function new$fmt_Pair(value: Pair.Pair): Wrap { return new Wrap(value, 0); } -export function new$generics_Wrap_fmt_Pair(value: Wrap): Wrap> { +export function new$generics_Wrap_fmt_Pair(value: Wrap): Wrap> { return new Wrap(value, 0); } @@ -125,7 +125,7 @@ export function new$shapes_Point(value: Point.Point): Wrap { return new Wrap(value, 0); } -export function new$shapes_Shape(value: shapes_Shape.Shape): Wrap { +export function new$shapes_Shape(value: Shape.Shape): Wrap { return new Wrap(value, 0); } @@ -137,11 +137,11 @@ export function get$Option_u8(self: Wrap): rt.u8 | undefined return self.value; } -export function get$fmt_Pair(self: Wrap): fmt_Pair.Pair { +export function get$fmt_Pair(self: Wrap): Pair.Pair { return self.value; } -export function get$generics_Wrap_fmt_Pair(self: Wrap>): Wrap { +export function get$generics_Wrap_fmt_Pair(self: Wrap>): Wrap { return self.value; } @@ -169,7 +169,7 @@ export function intoInner$shapes_Point(self: Wrap): Point.Point { } /** A method with its own type parameter. */ -export function map$u8_fmt_Pair_generics_methods_closure1(self: Wrap, f: (a0: rt.u8) => fmt_Pair.Pair): Wrap { +export function map$u8_fmt_Pair_generics_methods_closure1(self: Wrap, f: (a0: rt.u8) => Pair.Pair): Wrap { return new Wrap(f(self.value), self.count); } @@ -177,8 +177,8 @@ export function scaled$shapes_Meters(self: Wrap): rt.u64 { return rt.u64SaturatingAdd(Meters.area$shapes_Area(self.value), self.count as rt.u64); } -export function scaled$shapes_Shape(self: Wrap): rt.u64 { - return rt.u64SaturatingAdd(shapes_Shape.area$shapes_Area(self.value), self.count as rt.u64); +export function scaled$shapes_Shape(self: Wrap): rt.u64 { + return rt.u64SaturatingAdd(Shape.area$shapes_Area(self.value), self.count as rt.u64); } export function double$u8(self: Wrap): rt.u16 { @@ -189,8 +189,8 @@ export function area$shapes_Area_shapes_Meters(self: Wrap): rt.u6 return Meters.area$shapes_Area(self.value); } -export function area$shapes_Area_shapes_Shape(self: Wrap): rt.u64 { - return shapes_Shape.area$shapes_Area(self.value); +export function area$shapes_Area_shapes_Shape(self: Wrap): rt.u64 { + return Shape.area$shapes_Area(self.value); } /** A default method, monomorphized for each type. */ @@ -200,7 +200,7 @@ export function describe$shapes_Area_shapes_Meters(self: Wrap, ou } /** A default method, monomorphized for each type. */ -export function describe$shapes_Area_shapes_Shape(self: Wrap, out: rt.ByteVec): void { +export function describe$shapes_Area_shapes_Shape(self: Wrap, out: rt.ByteVec): void { rt.byteVecPush(out, 4); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u64ToBeBytes(area$shapes_Area_shapes_Shape(self)))); } diff --git a/ts/fixtures/lang/expected/generics.ts b/ts/fixtures/lang/shapes/expected/generics.ts similarity index 77% rename from ts/fixtures/lang/expected/generics.ts rename to ts/fixtures/lang/shapes/expected/generics.ts index e26b4709a..cdb366678 100644 --- a/ts/fixtures/lang/expected/generics.ts +++ b/ts/fixtures/lang/shapes/expected/generics.ts @@ -4,20 +4,20 @@ import * as rt from "./rt.ts"; import { copy$array_generics_Either_u8_shapes_Point, copy$generics_Fixed_u16, copy$generics_Fixed_u8, copy$generics_Wrap_shapes_Point, copy$generics_Wrap_u8, copy$shapes_Gauge, drop$generics_Run_generics_Ticked } from "./lib.ts"; import { then$0h950d8, then$1i9qaz4 } from "./core/bool.ts"; import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOrDefault$001fvl5 as option_unwrapOrDefault$001fvl5, unwrapOrDefault$1q0ps0j as option_unwrapOrDefault$1q0ps0j, map$12l9avg as option_map$12l9avg } from "./core/option.ts"; -import { put as fmt_put } from "./fmt.ts"; -import type * as fmt_Pair from "./fmt.Pair.ts"; +import type * as Pair from "./fmt.Pair.ts"; import * as Either from "./generics.Either.ts"; import * as Fixed from "./generics.Fixed.ts"; import type * as Lends from "./generics.Lends.ts"; -import * as generics_Run from "./generics.Run.ts"; +import * as Run from "./generics.Run.ts"; import * as Runs from "./generics.Runs.ts"; -import * as generics_Tagged from "./generics.Tagged.ts"; +import * as Tagged from "./generics.Tagged.ts"; import * as Ticked from "./generics.Ticked.ts"; import * as Wrap from "./generics.Wrap.ts"; +import { put } from "./harness.ts"; import * as shapes_Gauge from "./shapes.Gauge.ts"; import type * as Meters from "./shapes.Meters.ts"; import * as Point from "./shapes.Point.ts"; -import type * as shapes_Shape from "./shapes.Shape.ts"; +import type * as Shape from "./shapes.Shape.ts"; import type * as Track from "./shapes.Track.ts"; /** Each method once per instance: `Wrap` of a struct, an enum, a number, and itself. */ @@ -30,13 +30,13 @@ export function methods(data: rt.ByteSlice, out: rt.ByteVec): void { const byte: Wrap.Wrap = copy$generics_Wrap_u8(Wrap.new$u8(at(1))); Wrap.bump$u8(byte); Wrap.bump$u8(byte); - const nested: Wrap.Wrap> = Wrap.new$generics_Wrap_fmt_Pair(Wrap.new$fmt_Pair({ _0: at(2), _1: -3 })); + const nested: Wrap.Wrap> = Wrap.new$generics_Wrap_fmt_Pair(Wrap.new$fmt_Pair({ _0: at(2), _1: -3 })); const meters: Wrap.Wrap = new Wrap.Wrap({ _0: at(3) as rt.u64 }, at(4)); - const shape: Wrap.Wrap = Wrap.new$shapes_Shape({ tag: "Rect", corner: Wrap.intoInner$shapes_Point(point), width: at(5) as rt.u16, height: 3 } as shapes_Shape.Shape); + const shape: Wrap.Wrap = Wrap.new$shapes_Shape({ tag: "Rect", corner: Wrap.intoInner$shapes_Point(point), width: at(5) as rt.u16, height: 3 } as Shape.Shape); const args2: rt.Fmt[] = [(f: rt.Formatter) => Wrap.fmt$fmt_Debug_shapes_Point(point, f), (f: rt.Formatter) => Wrap.fmt$fmt_Debug_u8(byte, f), (f: rt.Formatter) => Wrap.fmt$fmt_Debug_generics_Wrap_fmt_Pair(nested, f), (f: rt.Formatter) => Wrap.fmt$fmt_Debug_shapes_Shape(shape, f)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3]])); const args4: rt.Fmt[] = [(f: rt.Formatter) => Wrap.fmt$fmt_Debug_generics_Wrap_fmt_Pair(nested, f)]; - fmt_put(out, rt.fmtFormat([rt.fmtSpec({ alternate: true }, args4[0])])); + put(out, rt.fmtFormat([rt.fmtSpec({ alternate: true }, args4[0])])); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u16ToBeBytes(Wrap.double$u8(byte)))); rt.byteVecPush(out, Wrap.get$u8(byte)); rt.byteVecPush(out, Wrap.get$fmt_Pair(Wrap.get$generics_Wrap_fmt_Pair(nested))._0); @@ -44,13 +44,13 @@ export function methods(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u64ToBeBytes(Wrap.scaled$shapes_Shape(shape)))); Wrap.describe$shapes_Area_shapes_Meters(meters, out); Wrap.describe$shapes_Area_shapes_Shape(shape, out); - const mapped: Wrap.Wrap = Wrap.map$u8_fmt_Pair_generics_methods_closure1(byte, (b: rt.u8): fmt_Pair.Pair => { + const mapped: Wrap.Wrap = Wrap.map$u8_fmt_Pair_generics_methods_closure1(byte, (b: rt.u8): Pair.Pair => { return { _0: b, _1: at(6) as rt.i64 }; }); - const _119: Wrap.Wrap = Wrap.new$fmt_Pair({ _0: at(1), _1: 0 }); + const _119: Wrap.Wrap = Wrap.new$fmt_Pair({ _0: at(1), _1: 0 }); const _116: boolean = Wrap.eq$cmp_PartialEq_fmt_Pair(mapped, _119); const args6: rt.Fmt[] = [(f: rt.Formatter) => Wrap.fmt$fmt_Debug_fmt_Pair(mapped, f), (f: rt.Formatter) => rt.fmtBool(_116, f)]; - fmt_put(out, rt.fmtFormat([args6[0], " ", args6[1]])); + put(out, rt.fmtFormat([args6[0], " ", args6[1]])); const iter: rt.Iter> = rt.iterSlice(copy$array_generics_Either_u8_shapes_Point([{ tag: "Left", _0: at(7) } as Either.Either, { tag: "Right", value: Point.new(1, -1) } as Either.Either, { tag: "Neither" } as Either.Either])); while (true) { const _140: Either.Either | rt.Done = iter.next(); @@ -62,7 +62,7 @@ export function methods(data: rt.ByteSlice, out: rt.ByteVec): void { const _153: rt.u8 | undefined = Either.left$u8_shapes_Point(either); const _156: Point.Point | undefined = Either.left$shapes_Point_u8(flipped); const args8: rt.Fmt[] = [(f: rt.Formatter) => Either.fmt$fmt_Debug_u8_shapes_Point(either, f), (f: rt.Formatter) => Either.fmt$fmt_Debug_shapes_Point_u8(flipped, f), (f: rt.Formatter) => rt.fmtOption(_153, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(_156, f, (value: Point.Point, f: rt.Formatter) => Point.fmt$fmt_Debug(value, f))]; - fmt_put(out, rt.fmtFormat([args8[0], " ", rt.fmtSpec({ alternate: true }, args8[1]), " ", args8[2], " ", args8[3]])); + put(out, rt.fmtFormat([args8[0], " ", rt.fmtSpec({ alternate: true }, args8[1]), " ", args8[2], " ", args8[3]])); } const _168: rt.u16[] = []; const list: Wrap.Wrap = new Wrap.Wrap(_168, 1); @@ -71,14 +71,14 @@ export function methods(data: rt.ByteSlice, out: rt.ByteVec): void { Wrap.bump$Vec_u16(list); const none: Wrap.Wrap = new Wrap.Wrap(undefined, 0); const some: Wrap.Wrap = Wrap.new$Option_u8(rt.byteSliceGet(data, 11)); - const err: Wrap.Wrap> = new Wrap.Wrap(rt.Err({ tag: "Dot" } as shapes_Shape.Shape), 2); + const err: Wrap.Wrap> = new Wrap.Wrap(rt.Err({ tag: "Dot" } as Shape.Shape), 2); const _193: rt.u8 = option_unwrapOr$0r2bmpr(Wrap.get$Option_u8(none), some.count); const args10: rt.Fmt[] = [(f: rt.Formatter) => Wrap.fmt$fmt_Debug_Vec_u16(list, f), (f: rt.Formatter) => Wrap.fmt$fmt_Debug_Option_u8(none, f), (f: rt.Formatter) => Wrap.fmt$fmt_Debug_Option_u8(some, f), (f: rt.Formatter) => Wrap.fmt$fmt_Debug_Result_u8_shapes_Shape(err, f), (f: rt.Formatter) => rt.u8Debug(_193, f)]; - fmt_put(out, rt.fmtFormat([args10[0], " ", args10[1], " ", args10[2], " ", args10[3], " ", args10[4]])); - const tagged: generics_Tagged.Tagged, rt.i16> = new generics_Tagged.Tagged({ tag: "Right", value: 500 } as Either.Either, Wrap.new$i16(rt.i16Sub(at(8) as rt.i16, 100)), rt.vecExact([Wrap.new$i16(-1), Wrap.new$i16(at(9) as rt.i16)].slice(), 4)); - const _237: Wrap.Wrap | undefined = generics_Tagged.first$generics_Either_u8_u16_i16(tagged); - const args12: rt.Fmt[] = [(f: rt.Formatter) => generics_Tagged.fmt$fmt_Debug_generics_Either_u8_u16_i16(tagged, f), (f: rt.Formatter) => rt.fmtOption(_237, f, (value: Wrap.Wrap, f: rt.Formatter) => Wrap.fmt$fmt_Debug_i16(value, f))]; - fmt_put(out, rt.fmtFormat([args12[0], " ", args12[1]])); + put(out, rt.fmtFormat([args10[0], " ", args10[1], " ", args10[2], " ", args10[3], " ", args10[4]])); + const tagged: Tagged.Tagged, rt.i16> = new Tagged.Tagged({ tag: "Right", value: 500 } as Either.Either, Wrap.new$i16(rt.i16Sub(at(8) as rt.i16, 100)), rt.vecExact([Wrap.new$i16(-1), Wrap.new$i16(at(9) as rt.i16)].slice(), 4)); + const _237: Wrap.Wrap | undefined = Tagged.first$generics_Either_u8_u16_i16(tagged); + const args12: rt.Fmt[] = [(f: rt.Formatter) => Tagged.fmt$fmt_Debug_generics_Either_u8_u16_i16(tagged, f), (f: rt.Formatter) => rt.fmtOption(_237, f, (value: Wrap.Wrap, f: rt.Formatter) => Wrap.fmt$fmt_Debug_i16(value, f))]; + put(out, rt.fmtFormat([args12[0], " ", args12[1]])); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.i16ToBeBytes(tagged.inner.value))); rt.byteVecPush(out, option_unwrapOr$0r2bmpr(Either.left$u8_u16(tagged.key), 0)); } @@ -151,7 +151,7 @@ export function fill$u8(run: rt.ByteSlice, item: rt.u8): void { */ export function runs(data: rt.ByteSlice, out: rt.ByteVec): void { let _266!: rt.Cow; - let run3!: generics_Run.Run; + let run3!: Run.Run; const data2: rt.ByteVec = rt.iterToByteVec(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): rt.u8 => { return _2; }), undefined, true); @@ -191,16 +191,16 @@ export function runs(data: rt.ByteSlice, out: rt.ByteVec): void { _65.v = n; } fill$u8(_59, 3); - const run: generics_Run.Run = Runs.run$u8(runs); + const run: Run.Run = Runs.run$u8(runs); const fixed: Fixed.Fixed = new Fixed.Fixed(Uint8Array.of(n, n), 1); const copy: Fixed.Fixed = copy$generics_Fixed_u8(fixed); (copy.pair as Uint8Array)[0] = 9; const swapped: Fixed.Fixed = swapped$u8(copy$generics_Fixed_u8(copy)); const _88: rt.usize = Runs.total$u8(runs); const _91: boolean = Runs.eq$cmp_PartialEq_u8(runs, before); - const _95: rt.u8 | undefined = generics_Run.first$u8(run); - const args2: rt.Fmt[] = [(f: rt.Formatter) => Runs.fmt$fmt_Debug_u8(runs, f), (f: rt.Formatter) => Runs.fmt$fmt_Debug_u8(before, f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(taken), f, rt.u8Debug), (f: rt.Formatter) => generics_Run.fmt$fmt_Debug_u8(run, f), (f: rt.Formatter) => Fixed.fmt$fmt_Debug_u8(fixed, f), (f: rt.Formatter) => Fixed.fmt$fmt_Debug_u8(copy, f), (f: rt.Formatter) => Fixed.fmt$fmt_Debug_u8(swapped, f), (f: rt.Formatter) => rt.usizeDisplay(_88, f), (f: rt.Formatter) => rt.fmtBool(_91, f), (f: rt.Formatter) => rt.fmtOption(_95, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(last, f, rt.u8Debug)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7], " ", args2[8], " ", args2[9], " ", args2[10]])); + const _95: rt.u8 | undefined = Run.first$u8(run); + const args2: rt.Fmt[] = [(f: rt.Formatter) => Runs.fmt$fmt_Debug_u8(runs, f), (f: rt.Formatter) => Runs.fmt$fmt_Debug_u8(before, f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(taken), f, rt.u8Debug), (f: rt.Formatter) => Run.fmt$fmt_Debug_u8(run, f), (f: rt.Formatter) => Fixed.fmt$fmt_Debug_u8(fixed, f), (f: rt.Formatter) => Fixed.fmt$fmt_Debug_u8(copy, f), (f: rt.Formatter) => Fixed.fmt$fmt_Debug_u8(swapped, f), (f: rt.Formatter) => rt.usizeDisplay(_88, f), (f: rt.Formatter) => rt.fmtBool(_91, f), (f: rt.Formatter) => rt.fmtOption(_95, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(last, f, rt.u8Debug)]; + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7], " ", args2[8], " ", args2[9], " ", args2[10]])); const data3: rt.u16[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_22: rt.u8): rt.u16 => { return _22 as rt.u16; }), undefined, 2, true); @@ -242,16 +242,16 @@ export function runs(data: rt.ByteSlice, out: rt.ByteVec): void { _181.v = n2; } fill$u16(_175, 3 as rt.u16); - const run2: generics_Run.Run = Runs.run$u16(runs2); + const run2: Run.Run = Runs.run$u16(runs2); const fixed2: Fixed.Fixed = new Fixed.Fixed([n2, n2], 1); const copy2: Fixed.Fixed = copy$generics_Fixed_u16(fixed2); (copy2.pair as rt.u16[])[0] = 9 as rt.u16; const swapped2: Fixed.Fixed = swapped$u16(copy$generics_Fixed_u16(copy2)); const _204: rt.usize = Runs.total$u16(runs2); const _207: boolean = Runs.eq$cmp_PartialEq_u16(runs2, before2); - const _211: rt.u16 | undefined = generics_Run.first$u16(run2); - const args4: rt.Fmt[] = [(f: rt.Formatter) => Runs.fmt$fmt_Debug_u16(runs2, f), (f: rt.Formatter) => Runs.fmt$fmt_Debug_u16(before2, f), (f: rt.Formatter) => rt.fmtList(taken2, f, rt.u16Debug), (f: rt.Formatter) => generics_Run.fmt$fmt_Debug_u16(run2, f), (f: rt.Formatter) => Fixed.fmt$fmt_Debug_u16(fixed2, f), (f: rt.Formatter) => Fixed.fmt$fmt_Debug_u16(copy2, f), (f: rt.Formatter) => Fixed.fmt$fmt_Debug_u16(swapped2, f), (f: rt.Formatter) => rt.usizeDisplay(_204, f), (f: rt.Formatter) => rt.fmtBool(_207, f), (f: rt.Formatter) => rt.fmtOption(_211, f, rt.u16Debug), (f: rt.Formatter) => rt.fmtOption(last2, f, rt.u16Debug)]; - fmt_put(out, rt.fmtFormat([args4[0], " ", args4[1], " ", args4[2], " ", args4[3], " ", args4[4], " ", args4[5], " ", args4[6], " ", args4[7], " ", args4[8], " ", args4[9], " ", args4[10]])); + const _211: rt.u16 | undefined = Run.first$u16(run2); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Runs.fmt$fmt_Debug_u16(runs2, f), (f: rt.Formatter) => Runs.fmt$fmt_Debug_u16(before2, f), (f: rt.Formatter) => rt.fmtList(taken2, f, rt.u16Debug), (f: rt.Formatter) => Run.fmt$fmt_Debug_u16(run2, f), (f: rt.Formatter) => Fixed.fmt$fmt_Debug_u16(fixed2, f), (f: rt.Formatter) => Fixed.fmt$fmt_Debug_u16(copy2, f), (f: rt.Formatter) => Fixed.fmt$fmt_Debug_u16(swapped2, f), (f: rt.Formatter) => rt.usizeDisplay(_204, f), (f: rt.Formatter) => rt.fmtBool(_207, f), (f: rt.Formatter) => rt.fmtOption(_211, f, rt.u16Debug), (f: rt.Formatter) => rt.fmtOption(last2, f, rt.u16Debug)]; + put(out, rt.fmtFormat([args4[0], " ", args4[1], " ", args4[2], " ", args4[3], " ", args4[4], " ", args4[5], " ", args4[6], " ", args4[7], " ", args4[8], " ", args4[9], " ", args4[10]])); const log: rt.Arc> = new rt.Arc(new rt.RefCell(new rt.ByteVec())); const tick: (a0: rt.u8) => Ticked.Ticked = (id: rt.u8): Ticked.Ticked => { return new Ticked.Ticked(id, rt.arcClone(log)); @@ -273,11 +273,11 @@ export function runs(data: rt.ByteSlice, out: rt.ByteVec): void { }))[Symbol.dispose](); const _292: rt.usize = rt.usizeRem(data.length, 3); if (_292 === 0) { - run3 = { tag: "Listed", _0: [tick(8)] } as generics_Run.Run; + run3 = { tag: "Listed", _0: [tick(8)] } as Run.Run; } else if (_292 === 1) { - run3 = { tag: "Fixed", array: [tick(9), tick(10)] } as generics_Run.Run; + run3 = { tag: "Fixed", array: [tick(9), tick(10)] } as Run.Run; } else { - run3 = { tag: "Empty" } as generics_Run.Run; + run3 = { tag: "Empty" } as Run.Run; } drop$generics_Run_generics_Ticked(run3); rt.dropAll(ticks); diff --git a/ts/fixtures/lang/shapes/expected/harness.ts b/ts/fixtures/lang/shapes/expected/harness.ts new file mode 100644 index 000000000..3b7bbcfb0 --- /dev/null +++ b/ts/fixtures/lang/shapes/expected/harness.ts @@ -0,0 +1,46 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/shapes/expected/lib.ts b/ts/fixtures/lang/shapes/expected/lib.ts new file mode 100644 index 000000000..f25959480 --- /dev/null +++ b/ts/fixtures/lang/shapes/expected/lib.ts @@ -0,0 +1,198 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { ints, strings, derived, written, counts, rounding, panics, wrapped, collections, enums, iters, writes, objects } from "./fmt.ts"; +import { methods, runs } from "./generics.ts"; +import type * as Either from "./generics.Either.ts"; +import * as Fixed from "./generics.Fixed.ts"; +import type * as Run from "./generics.Run.ts"; +import type * as Ticked from "./generics.Ticked.ts"; +import * as Wrap from "./generics.Wrap.ts"; +import { copies, order, discriminants, loops, patterns, uninhabited, closures, library, flows } from "./shapes.ts"; +import type * as shapes_Gauge from "./shapes.Gauge.ts"; +import type * as Held from "./shapes.Held.ts"; +import type * as Lens from "./shapes.Lens.ts"; +import type * as Level from "./shapes.Level.ts"; +import type * as Mark from "./shapes.Mark.ts"; +import type * as Point from "./shapes.Point.ts"; +import type * as Shape from "./shapes.Shape.ts"; + +export function copy$Option_shapes_Shape(v: Shape.Shape | undefined): Shape.Shape | undefined { + return v === undefined ? v : copy$shapes_Shape(v); +} + +export function copy$Option_tuple2_ref_sync_Mutex_u8_u8(v: [rt.Mutex, rt.u8] | undefined): [rt.Mutex, rt.u8] | undefined { + return v === undefined ? v : copy$tuple2_ref_sync_Mutex_u8_u8(v); +} + +export function copy$Result_tuple2_ref_sync_Mutex_u8_u8_u8(v: rt.Result<[rt.Mutex, rt.u8], rt.u8>): rt.Result<[rt.Mutex, rt.u8], rt.u8> { + return v.ok ? rt.Ok(copy$tuple2_ref_sync_Mutex_u8_u8(v.value)) : rt.Err(v.error); +} + +export function copy$array_generics_Either_u8_shapes_Point(v: Either.Either[]): Either.Either[] { + return v.map(copy$generics_Either_u8_shapes_Point); +} + +export function copy$array_ref_sync_Mutex_u8(v: rt.Mutex[]): rt.Mutex[] { + return v.slice(); +} + +export function copy$array_shapes_Point(v: Point.Point[]): Point.Point[] { + return v.map(copy$shapes_Point); +} + +export function copy$array_u16(v: rt.u16[]): rt.u16[] { + return v.slice(); +} + +export function copy$array_u8(v: Uint8Array): Uint8Array { + return v.slice(); +} + +export function copy$generics_Either_u8_shapes_Point(v: Either.Either): Either.Either { + if (v.tag === "Left") { + return { tag: "Left", _0: v._0 }; + } + if (v.tag === "Right") { + return { tag: "Right", value: copy$shapes_Point(v.value) }; + } + return v; +} + +export function copy$generics_Fixed_u16(v: Fixed.Fixed): Fixed.Fixed { + return new Fixed.Fixed(copy$array_u16(v.pair as rt.u16[]), v.tag); +} + +export function copy$generics_Fixed_u8(v: Fixed.Fixed): Fixed.Fixed { + return new Fixed.Fixed(copy$array_u8(v.pair as Uint8Array), v.tag); +} + +export function copy$generics_Wrap_shapes_Point(v: Wrap.Wrap): Wrap.Wrap { + return new Wrap.Wrap(copy$shapes_Point(v.value), v.count); +} + +export function copy$generics_Wrap_u8(v: Wrap.Wrap): Wrap.Wrap { + return new Wrap.Wrap(v.value, v.count); +} + +export function copy$ops_ControlFlow_ref_sync_Arc_u8_array1_u8(v: rt.Result>): rt.Result> { + return v.ok ? rt.Ok(copy$array_u8(v.value)) : rt.Err(v.error); +} + +export function copy$ops_ControlFlow_unit_array2_u8(v: rt.Result): rt.Result { + return v.ok ? rt.Ok(copy$array_u8(v.value)) : rt.Err(v.error); +} + +export function copy$shapes_Gauge(v: shapes_Gauge.Gauge): shapes_Gauge.Gauge { + return { level: v.level }; +} + +export function copy$shapes_Held(v: Held.Held): Held.Held { + return { at: copy$shapes_Point(v.at) }; +} + +export function copy$shapes_Lens(v: Lens.Lens): Lens.Lens { + return { slot: v.slot, n: v.n }; +} + +export function copy$shapes_Level(v: Level.Level): Level.Level { + return { _0: v._0 }; +} + +export function copy$shapes_Mark(v: Mark.Mark): Mark.Mark { + return { at: v.at }; +} + +export function copy$shapes_Point(v: Point.Point): Point.Point { + return { x: v.x, y: v.y }; +} + +export function copy$shapes_Shape(v: Shape.Shape): Shape.Shape { + if (v.tag === "Line") { + return { tag: "Line", _0: copy$shapes_Point(v._0), _1: copy$shapes_Point(v._1) }; + } + if (v.tag === "Rect") { + return { tag: "Rect", corner: copy$shapes_Point(v.corner), width: v.width, height: v.height }; + } + return v; +} + +export function copy$task_Poll_array1_u8(v: rt.Poll): rt.Poll { + return v === rt.Pending ? v : copy$array_u8(v); +} + +export function copy$tuple2_ref_sync_Mutex_u8_u8(v: [rt.Mutex, rt.u8]): [rt.Mutex, rt.u8] { + return [v[0], v[1]]; +} + +export function copy$tuple2_shapes_Point_u8(v: [Point.Point, rt.u8]): [Point.Point, rt.u8] { + return [copy$shapes_Point(v[0]), v[1]]; +} + +export function copy$tuple2_u8_u8(v: [rt.u8, rt.u8]): [rt.u8, rt.u8] { + return [v[0], v[1]]; +} + +export function drop$generics_Run_generics_Ticked(_1: Run.Run): void { + if (_1.tag === "Listed") { + rt.dropAll(_1._0 as Ticked.Ticked[]); + } else if (_1.tag === "Fixed") { + rt.dropAll(_1.array as Ticked.Ticked[]); + } +} + +export const out$u8: { err: unknown } = { err: undefined }; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["fmt::ints", ints as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::strings", (_210: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + strings(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::derived", (_211: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + derived(data2, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::written", (_212: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + written(data3, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::panics", panics as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::counts", (_213: rt.u8, data4: rt.ByteSlice, out4: rt.ByteVec): undefined => { + counts(data4, out4); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::rounding", (_214: rt.u8, _310: rt.ByteSlice, out5: rt.ByteVec): undefined => { + rounding(out5); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::wrapped", (_215: rt.u8, data5: rt.ByteSlice, out6: rt.ByteVec): undefined => { + wrapped(data5, out6); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::writes", (_216: rt.u8, data6: rt.ByteSlice, out7: rt.ByteVec): undefined => { + writes(data6, out7); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::collections", (_217: rt.u8, data7: rt.ByteSlice, out8: rt.ByteVec): undefined => { + collections(data7, out8); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::iters", (_218: rt.u8, data8: rt.ByteSlice, out9: rt.ByteVec): undefined => { + iters(data8, out9); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::enums", (_219: rt.u8, data9: rt.ByteSlice, out10: rt.ByteVec): undefined => { + enums(data9, out10); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::objects", (_220: rt.u8, data10: rt.ByteSlice, out11: rt.ByteVec): undefined => { + objects(data10, out11); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["generics::methods", (_221: rt.u8, data11: rt.ByteSlice, out12: rt.ByteVec): undefined => { + methods(data11, out12); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["generics::runs", (_222: rt.u8, data12: rt.ByteSlice, out13: rt.ByteVec): undefined => { + runs(data12, out13); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::copies", (_223: rt.u8, data13: rt.ByteSlice, out14: rt.ByteVec): undefined => { + copies(data13, out14); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::loops", (_224: rt.u8, data14: rt.ByteSlice, out15: rt.ByteVec): undefined => { + loops(data14, out15); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::patterns", (_225: rt.u8, data15: rt.ByteSlice, out16: rt.ByteVec): undefined => { + patterns(data15, out16); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::closures", (_226: rt.u8, data16: rt.ByteSlice, out17: rt.ByteVec): undefined => { + closures(data16, out17); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::discriminants", (_227: rt.u8, data17: rt.ByteSlice, out18: rt.ByteVec): undefined => { + discriminants(data17, out18); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::library", (_228: rt.u8, data18: rt.ByteSlice, out19: rt.ByteVec): undefined => { + library(data18, out19); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::order", (_229: rt.u8, data19: rt.ByteSlice, out20: rt.ByteVec): undefined => { + order(data19, out20); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::flows", (_230: rt.u8, data20: rt.ByteSlice, out21: rt.ByteVec): undefined => { + flows(data20, out21); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["shapes::uninhabited", (_231: rt.u8, data21: rt.ByteSlice, out22: rt.ByteVec): undefined => { + uninhabited(data21, out22); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/shapes.Dir.ts b/ts/fixtures/lang/shapes/expected/shapes.Dir.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Dir.ts rename to ts/fixtures/lang/shapes/expected/shapes.Dir.ts diff --git a/ts/fixtures/lang/shapes/expected/shapes.Filled.ts b/ts/fixtures/lang/shapes/expected/shapes.Filled.ts new file mode 100644 index 000000000..411a5e9c4 --- /dev/null +++ b/ts/fixtures/lang/shapes/expected/shapes.Filled.ts @@ -0,0 +1,49 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { copy$shapes_Point } from "./lib.ts"; +import * as Point from "./shapes.Point.ts"; +import type * as Shape from "./shapes.Shape.ts"; + +/** An `Option` a method matches, filling it between its matches. */ +export interface Filled { + shape: Shape.Shape | undefined; +} + +export function fill(self: Filled): void { + let _2!: Shape.Shape | undefined; + if (self.shape === undefined) { + _2 = { tag: "Line", _0: copy$shapes_Point(Point.new(5, 6)), _1: copy$shapes_Point(Point.new(7, 8)) } as Shape.Shape; + } else if (self.shape.tag === "Dot") { + _2 = { tag: "Line", _0: copy$shapes_Point(Point.new(1, 2)), _1: copy$shapes_Point(Point.new(3, 4)) } as Shape.Shape; + } else { + _2 = undefined; + } + self.shape = _2; +} + +export function run(self: Filled): rt.u8 { + if (self.shape === undefined) { + fill(self); + if ((self.shape as Shape.Shape | undefined) === undefined) { + return 41; + } + if (((self.shape as Shape.Shape | undefined) as Shape.Shape).tag === "Line") { + return copy$shapes_Point((((self.shape as Shape.Shape | undefined) as Shape.Shape) as { tag: "Line"; _0: Point.Point; _1: Point.Point })._1).y & 0xff; + } + return 40; + } + if (self.shape.tag === "Dot") { + fill(self); + if ((self.shape as Shape.Shape | undefined) !== undefined) { + if ((self.shape as Shape.Shape).tag === "Line") { + return copy$shapes_Point(((self.shape as Shape.Shape) as { tag: "Line"; _0: Point.Point; _1: Point.Point })._0).x & 0xff; + } + } + return 42; + } + fill(self); + return 43; +} + +//# sourceMappingURL=shapes.Filled.ts.map diff --git a/ts/fixtures/lang/expected/shapes.Gauge.ts b/ts/fixtures/lang/shapes/expected/shapes.Gauge.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Gauge.ts rename to ts/fixtures/lang/shapes/expected/shapes.Gauge.ts diff --git a/ts/fixtures/lang/expected/shapes.Held.ts b/ts/fixtures/lang/shapes/expected/shapes.Held.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Held.ts rename to ts/fixtures/lang/shapes/expected/shapes.Held.ts diff --git a/ts/fixtures/lang/expected/shapes.Lens.ts b/ts/fixtures/lang/shapes/expected/shapes.Lens.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Lens.ts rename to ts/fixtures/lang/shapes/expected/shapes.Lens.ts diff --git a/ts/fixtures/lang/expected/shapes.Level.ts b/ts/fixtures/lang/shapes/expected/shapes.Level.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Level.ts rename to ts/fixtures/lang/shapes/expected/shapes.Level.ts diff --git a/ts/fixtures/lang/expected/shapes.Machine.ts b/ts/fixtures/lang/shapes/expected/shapes.Machine.ts similarity index 69% rename from ts/fixtures/lang/expected/shapes.Machine.ts rename to ts/fixtures/lang/shapes/expected/shapes.Machine.ts index a681d10fd..e8275e9f3 100644 --- a/ts/fixtures/lang/expected/shapes.Machine.ts +++ b/ts/fixtures/lang/shapes/expected/shapes.Machine.ts @@ -3,30 +3,30 @@ import * as rt from "./rt.ts"; import { copy$shapes_Point } from "./lib.ts"; import * as Point from "./shapes.Point.ts"; -import * as shapes_Shape from "./shapes.Shape.ts"; +import * as Shape from "./shapes.Shape.ts"; /** A state a method matches, changing it between its matches. */ export interface Machine { - state: shapes_Shape.Shape; + state: Shape.Shape; steps: rt.u8; } export function step(self: Machine): void { - let _3!: shapes_Shape.Shape; + let _3!: Shape.Shape; self.steps = rt.u8Add(self.steps, 1); if (self.state.tag === "Dot") { - _3 = { tag: "Line", _0: copy$shapes_Point(Point.new(1, 2)), _1: copy$shapes_Point(Point.new(3, 4)) } as shapes_Shape.Shape; + _3 = { tag: "Line", _0: copy$shapes_Point(Point.new(1, 2)), _1: copy$shapes_Point(Point.new(3, 4)) } as Shape.Shape; } else if (self.state.tag === "Line") { - _3 = { tag: "Rect", corner: copy$shapes_Point(copy$shapes_Point(self.state._0)), width: 5, height: 6 } as shapes_Shape.Shape; + _3 = { tag: "Rect", corner: copy$shapes_Point(copy$shapes_Point(self.state._0)), width: 5, height: 6 } as Shape.Shape; } else { - _3 = { tag: "Dot" } as shapes_Shape.Shape; + _3 = { tag: "Dot" } as Shape.Shape; } self.state = _3; } /** Reads the state, which a shared borrow can't change. */ export function peek(self: Machine): rt.u8 { - return self.steps ^ (rt.u64Low(shapes_Shape.area$shapes_Area(self.state)) & 0xff); + return self.steps ^ (rt.u64Low(Shape.area$shapes_Area(self.state)) & 0xff); } export function log(self: Machine, v: rt.u8): rt.u8 { @@ -37,8 +37,8 @@ export function log(self: Machine, v: rt.u8): rt.u8 { export function run(self: Machine, n: rt.u8): rt.u8 { if (self.state.tag === "Dot") { step(self); - if ((self.state as shapes_Shape.Shape).tag === "Line") { - return (copy$shapes_Point(((self.state as shapes_Shape.Shape) as { tag: "Line"; _0: Point.Point; _1: Point.Point })._1).x & 0xff) ^ self.steps ^ n; + if ((self.state as Shape.Shape).tag === "Line") { + return (copy$shapes_Point(((self.state as Shape.Shape) as { tag: "Line"; _0: Point.Point; _1: Point.Point })._1).x & 0xff) ^ self.steps ^ n; } return 27; } diff --git a/ts/fixtures/lang/expected/shapes.Mark.ts b/ts/fixtures/lang/shapes/expected/shapes.Mark.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Mark.ts rename to ts/fixtures/lang/shapes/expected/shapes.Mark.ts diff --git a/ts/fixtures/lang/expected/shapes.Meters.ts b/ts/fixtures/lang/shapes/expected/shapes.Meters.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Meters.ts rename to ts/fixtures/lang/shapes/expected/shapes.Meters.ts diff --git a/ts/fixtures/lang/expected/shapes.Moved.ts b/ts/fixtures/lang/shapes/expected/shapes.Moved.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Moved.ts rename to ts/fixtures/lang/shapes/expected/shapes.Moved.ts diff --git a/ts/fixtures/lang/expected/shapes.Mover.ts b/ts/fixtures/lang/shapes/expected/shapes.Mover.ts similarity index 67% rename from ts/fixtures/lang/expected/shapes.Mover.ts rename to ts/fixtures/lang/shapes/expected/shapes.Mover.ts index c34c15d17..851592240 100644 --- a/ts/fixtures/lang/expected/shapes.Mover.ts +++ b/ts/fixtures/lang/shapes/expected/shapes.Mover.ts @@ -1,10 +1,10 @@ // Generated by rust2-ts. Do not edit. -import type * as shapes_Held from "./shapes.Held.ts"; +import type * as Held from "./shapes.Held.ts"; /** A mutable borrow of a `Held`, held by value. */ export interface Mover { - held: shapes_Held.Held; + held: Held.Held; } //# sourceMappingURL=shapes.Mover.ts.map diff --git a/ts/fixtures/lang/expected/shapes.Partial.ts b/ts/fixtures/lang/shapes/expected/shapes.Partial.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Partial.ts rename to ts/fixtures/lang/shapes/expected/shapes.Partial.ts diff --git a/ts/fixtures/lang/expected/shapes.Parts.ts b/ts/fixtures/lang/shapes/expected/shapes.Parts.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Parts.ts rename to ts/fixtures/lang/shapes/expected/shapes.Parts.ts diff --git a/ts/fixtures/lang/expected/shapes.Point.ts b/ts/fixtures/lang/shapes/expected/shapes.Point.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Point.ts rename to ts/fixtures/lang/shapes/expected/shapes.Point.ts diff --git a/ts/fixtures/lang/expected/shapes.Shape.ts b/ts/fixtures/lang/shapes/expected/shapes.Shape.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Shape.ts rename to ts/fixtures/lang/shapes/expected/shapes.Shape.ts diff --git a/ts/fixtures/lang/expected/shapes.Signed.ts b/ts/fixtures/lang/shapes/expected/shapes.Signed.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Signed.ts rename to ts/fixtures/lang/shapes/expected/shapes.Signed.ts diff --git a/ts/fixtures/lang/expected/shapes.Slot.ts b/ts/fixtures/lang/shapes/expected/shapes.Slot.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Slot.ts rename to ts/fixtures/lang/shapes/expected/shapes.Slot.ts diff --git a/ts/fixtures/lang/expected/shapes.Track.ts b/ts/fixtures/lang/shapes/expected/shapes.Track.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Track.ts rename to ts/fixtures/lang/shapes/expected/shapes.Track.ts diff --git a/ts/fixtures/lang/expected/shapes.Void.ts b/ts/fixtures/lang/shapes/expected/shapes.Void.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Void.ts rename to ts/fixtures/lang/shapes/expected/shapes.Void.ts diff --git a/ts/fixtures/lang/expected/shapes.Wide.ts b/ts/fixtures/lang/shapes/expected/shapes.Wide.ts similarity index 100% rename from ts/fixtures/lang/expected/shapes.Wide.ts rename to ts/fixtures/lang/shapes/expected/shapes.Wide.ts diff --git a/ts/fixtures/lang/expected/shapes.ts b/ts/fixtures/lang/shapes/expected/shapes.ts similarity index 91% rename from ts/fixtures/lang/expected/shapes.ts rename to ts/fixtures/lang/shapes/expected/shapes.ts index 4c40c18c7..26d80de1a 100644 --- a/ts/fixtures/lang/expected/shapes.ts +++ b/ts/fixtures/lang/shapes/expected/shapes.ts @@ -5,12 +5,12 @@ import { copy$Option_shapes_Shape, copy$Option_tuple2_ref_sync_Mutex_u8_u8, copy import { thenSome$0ztng9q, then$1i9qaz4, then$1btzga3 } from "./core/bool.ts"; import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$0600mq0 as option_map$0600mq0, map$18z3v8h as option_map$18z3v8h, mapOr$1a3irjf as option_mapOr$1a3irjf, mapOr$1t0muvr as option_mapOr$1t0muvr, mapOr$1ybqvup as option_mapOr$1ybqvup, mapOr$0rtdylj as option_mapOr$0rtdylj, mapOr$0aserv9 as option_mapOr$0aserv9, mapOr$1hjjwvv as option_mapOr$1hjjwvv, okOr$1vxk0yk as option_okOr$1vxk0yk } from "./core/option.ts"; import { map$1dbyvzi as result_map$1dbyvzi, mapErr$0dzqwjy as result_mapErr$0dzqwjy } from "./core/result.ts"; -import * as fmt_Pair from "./fmt.Pair.ts"; +import * as Pair from "./fmt.Pair.ts"; import { advance, reset$shapes_Gauge as generics_reset$shapes_Gauge } from "./generics.ts"; -import type * as shapes_Dir from "./shapes.Dir.ts"; +import type * as Dir from "./shapes.Dir.ts"; import * as Filled from "./shapes.Filled.ts"; import type * as shapes_Gauge from "./shapes.Gauge.ts"; -import type * as shapes_Held from "./shapes.Held.ts"; +import type * as Held from "./shapes.Held.ts"; import type * as Lens from "./shapes.Lens.ts"; import type * as Level from "./shapes.Level.ts"; import * as Machine from "./shapes.Machine.ts"; @@ -18,12 +18,12 @@ import type * as Mark from "./shapes.Mark.ts"; import * as Meters from "./shapes.Meters.ts"; import * as Moved from "./shapes.Moved.ts"; import type * as Mover from "./shapes.Mover.ts"; -import type * as shapes_Partial from "./shapes.Partial.ts"; -import type * as shapes_Parts from "./shapes.Parts.ts"; +import type * as Partial from "./shapes.Partial.ts"; +import type * as Parts from "./shapes.Parts.ts"; import * as Point from "./shapes.Point.ts"; -import * as shapes_Shape from "./shapes.Shape.ts"; +import * as Shape from "./shapes.Shape.ts"; import type * as Signed from "./shapes.Signed.ts"; -import type * as shapes_Slot from "./shapes.Slot.ts"; +import type * as Slot from "./shapes.Slot.ts"; import * as Track from "./shapes.Track.ts"; import * as Void from "./shapes.Void.ts"; import type * as shapes_Wide from "./shapes.Wide.ts"; @@ -42,42 +42,42 @@ export function total$shapes_Meters(items: Meters.Meters[], out: rt.ByteVec): rt } } -export function total$shapes_Shape(items: shapes_Shape.Shape[], out: rt.ByteVec): rt.u64 { +export function total$shapes_Shape(items: Shape.Shape[], out: rt.ByteVec): rt.u64 { let sum: rt.u64 = 0; - const iterS: shapes_Shape.Shape[] = items; + const iterS: Shape.Shape[] = items; let iterI: number = 0; while (true) { - const _6: shapes_Shape.Shape | rt.Done = iterI < iterS.length ? iterS[iterI++] : rt.DONE; + const _6: Shape.Shape | rt.Done = iterI < iterS.length ? iterS[iterI++] : rt.DONE; if (_6 === rt.DONE) { return sum; } - shapes_Shape.describe$shapes_Area(_6, out); - sum = rt.u64SaturatingAdd(sum, shapes_Shape.area$shapes_Area(_6)); + Shape.describe$shapes_Area(_6, out); + sum = rt.u64SaturatingAdd(sum, Shape.area$shapes_Area(_6)); } } -export function from$convert_From_shapes_Dir_u8(dir: shapes_Dir.Dir): rt.u8 { +export function from$convert_From_shapes_Dir_u8(dir: Dir.Dir): rt.u8 { return { North: 1, East: 2, South: 4, West: 8 }[dir] & 0xff; } -export function dir(byte: rt.u8): shapes_Dir.Dir | undefined { +export function dir(byte: rt.u8): Dir.Dir | undefined { const _2: rt.u8 = rt.u8Rem(byte, 5); if (_2 === 0) { - return "North" as shapes_Dir.Dir; + return "North" as Dir.Dir; } if (_2 === 1) { - return "East" as shapes_Dir.Dir; + return "East" as Dir.Dir; } if (_2 === 2) { - return "South" as shapes_Dir.Dir; + return "South" as Dir.Dir; } if (_2 === 3) { - return "West" as shapes_Dir.Dir; + return "West" as Dir.Dir; } return undefined; } -export function shape(dataData: Uint8Array, dataStart: number, dataLen: number): shapes_Shape.Shape { +export function shape(dataData: Uint8Array, dataStart: number, dataLen: number): Shape.Shape { if (dataLen !== 0) { const kind: rt.u8 = dataData[dataStart]; const rest: rt.ByteSlice = new rt.ByteSlice(dataData, dataStart + 1, dataLen - 1); @@ -86,14 +86,14 @@ export function shape(dataData: Uint8Array, dataStart: number, dataLen: number): }; const _7: rt.u8 = rt.u8Rem(kind, 3); if (_7 === 0) { - return { tag: "Dot" } as shapes_Shape.Shape; + return { tag: "Dot" } as Shape.Shape; } if (_7 === 1) { - return { tag: "Line", _0: Point.new(at(0), at(1)), _1: Point.new(at(2), at(3)) } as shapes_Shape.Shape; + return { tag: "Line", _0: Point.new(at(0), at(1)), _1: Point.new(at(2), at(3)) } as Shape.Shape; } - return { tag: "Rect", corner: Point.new(at(0), at(1)), width: rt.u16Mul(option_unwrapOr$0r2bmpr(rt.byteSliceGet(rest, 2), 0) as rt.u16, 300), height: option_unwrapOr$0r2bmpr(rt.byteSliceGet(rest, 3), 0) as rt.u16 } as shapes_Shape.Shape; + return { tag: "Rect", corner: Point.new(at(0), at(1)), width: rt.u16Mul(option_unwrapOr$0r2bmpr(rt.byteSliceGet(rest, 2), 0) as rt.u16, 300), height: option_unwrapOr$0r2bmpr(rt.byteSliceGet(rest, 3), 0) as rt.u16 } as Shape.Shape; } - return { tag: "Dot" } as shapes_Shape.Shape; + return { tag: "Dot" } as Shape.Shape; } /** `Copy` aggregates: a copy changes apart from its original. */ @@ -203,8 +203,8 @@ export function copies(data: rt.ByteSlice, out: rt.ByteVec): void { const err: Point.Point = copy$shapes_Point(rt.resultUnwrapErr(fail, rt.u8Debug)); err.y = 3; rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(first.x & 0xff, rt.resultUnwrap(res, rt.u8Debug).x & 0xff, err.y & 0xff, rt.resultUnwrapErr(fail, rt.u8Debug).y & 0xff))); - const shape_: shapes_Shape.Shape = copy$shapes_Shape(shape(data.data, data.start, data.length)); - const before: shapes_Shape.Shape = copy$shapes_Shape(shape_); + const shape_: Shape.Shape = copy$shapes_Shape(shape(data.data, data.start, data.length)); + const before: Shape.Shape = copy$shapes_Shape(shape_); if (shape_.tag !== "Dot") { if (shape_.tag === "Line") { shape_._0.x = 77; @@ -213,14 +213,14 @@ export function copies(data: rt.ByteSlice, out: rt.ByteVec): void { shape_.width = 6; } } - const _256: shapes_Shape.Shape = copy$shapes_Shape(shape_); - const iter3: rt.Iter = rt.iterSlice([copy$shapes_Shape(before), _256]); + const _256: Shape.Shape = copy$shapes_Shape(shape_); + const iter3: rt.Iter = rt.iterSlice([copy$shapes_Shape(before), _256]); while (true) { - const _258: shapes_Shape.Shape | rt.Done = iter3.next(); + const _258: Shape.Shape | rt.Done = iter3.next(); if (_258 === rt.DONE) { break; } - const shape2: shapes_Shape.Shape = _258; + const shape2: Shape.Shape = _258; if (shape2.tag === "Dot") { _265 = rt.bytes(3); } else if (shape2.tag === "Line") { @@ -402,8 +402,8 @@ export function shares(data: rt.ByteSlice, out: rt.ByteVec): void { const _150: rt.Mutex = rt.mutexLock(other); rt.byteVecPush(out, _150.value); rt.mutexUnlock(_150); - const source: shapes_Held.Held = { at: copy$shapes_Point(Point.new(a as rt.i32, 0)) }; - const kept: shapes_Held.Held = hold(copy$shapes_Point(source.at)); + const source: Held.Held = { at: copy$shapes_Point(Point.new(a as rt.i32, 0)) }; + const kept: Held.Held = hold(copy$shapes_Point(source.at)); source.at.x = 9; const read: rt.i32 = movedThenRead(copy$shapes_Point(source.at), source); const by: rt.i32 = movedBy(copy$shapes_Point(source.at), { held: source }); @@ -466,12 +466,12 @@ export function movedAt(live: Point.Point[], at: rt.usize): void { } /** `at`, held. */ -export function hold(at: Point.Point): shapes_Held.Held { +export function hold(at: Point.Point): Held.Held { return { at }; } /** `copy.x`, read after `held` moves right by one, which a copy of its point doesn't see. */ -export function movedThenRead(copy: Point.Point, held: shapes_Held.Held): rt.i32 { +export function movedThenRead(copy: Point.Point, held: Held.Held): rt.i32 { held.at.x = rt.i32Add(held.at.x, 1); return copy.x; } @@ -480,7 +480,7 @@ export function movedThenRead(copy: Point.Point, held: shapes_Held.Held): rt.i32 * `copy.at.x`, read after `at` moves right by one, which a copy of what holds it doesn't * see. */ -export function partMovedThenRead(copy: shapes_Held.Held, at: Point.Point): rt.i32 { +export function partMovedThenRead(copy: Held.Held, at: Point.Point): rt.i32 { at.x = rt.i32Add(at.x, 1); return copy.at.x; } @@ -553,7 +553,7 @@ export function mark(out: rt.ByteVec, b: rt.u8): rt.usize { * written: each field logs as it runs. */ export function order(data: rt.ByteSlice, out: rt.ByteVec): void { - let taken!: shapes_Shape.Shape; + let taken!: Shape.Shape; let _75!: rt.usize; const at: (a0: rt.usize) => rt.u8 = (i2: rt.usize): rt.u8 => { return option_unwrapOr$0r2bmpr(rt.byteSliceGet(data, i2), 0); @@ -561,11 +561,11 @@ export function order(data: rt.ByteSlice, out: rt.ByteVec): void { const _5: rt.u16 = mark(out, at(0)) & 0xffff; const _10: rt.u16 = mark(out, at(1)) & 0xffff; const _16: rt.i32 = mark(out, 2) | 0; - const rect: shapes_Shape.Shape = { tag: "Rect", corner: { x: mark(out, 3) | 0, y: _16 }, width: _10, height: _5 }; + const rect: Shape.Shape = { tag: "Rect", corner: { x: mark(out, 3) | 0, y: _16 }, width: _10, height: _5 }; const _21: Point.Point = Point.new(mark(out, 4) | 0, 0); - const line: shapes_Shape.Shape = { tag: "Line", _0: Point.new(mark(out, 5) | 0, 0), _1: _21 }; + const line: Shape.Shape = { tag: "Line", _0: Point.new(mark(out, 5) | 0, 0), _1: _21 }; const _28: rt.i64 = mark(out, 6) as rt.i64; - const pair: fmt_Pair.Pair = { _0: mark(out, 7) & 0xff, _1: _28 }; + const pair: Pair.Pair = { _0: mark(out, 7) & 0xff, _1: _28 }; const n: Uint8Array = Uint8Array.of(at(2)); const _37: rt.i32 = n[0] as rt.i32; const read: Point.Point = { x: increment(rt.byteSliceFrom(n)) as rt.i32, y: _37 }; @@ -574,9 +574,9 @@ export function order(data: rt.ByteSlice, out: rt.ByteVec): void { const updated: Moved.Moved = { _0: base._0, _1: _49 }; if (rt.u8Rem(at(3), 2) === 0) { const _57: rt.u16 = mark(out, 8) & 0xffff; - taken = { tag: "Rect", corner: Point.new(0, mark(out, 9) | 0), width: _57, height: 1 } as shapes_Shape.Shape; + taken = { tag: "Rect", corner: Point.new(0, mark(out, 9) | 0), width: _57, height: 1 } as Shape.Shape; } else { - taken = { tag: "Dot" } as shapes_Shape.Shape; + taken = { tag: "Dot" } as Shape.Shape; } const _63: rt.usize = mark(out, 10); const _64: rt.usize = rt.usizeDiv(mark(out, 11), 2); @@ -594,7 +594,7 @@ export function order(data: rt.ByteSlice, out: rt.ByteVec): void { const _87: rt.usize = rt.usizeDiv(rt.min(mark(out, 15), len), 2); const _103: rt.usize = sum; const _82: rt.ByteSlice = rt.byteSliceRange(_83, _87, _85); - const args2: rt.Fmt[] = [(f: rt.Formatter) => shapes_Shape.fmt$fmt_Debug(rect, f), (f: rt.Formatter) => shapes_Shape.fmt$fmt_Debug(line, f), (f: rt.Formatter) => fmt_Pair.fmt$fmt_Debug(pair, f), (f: rt.Formatter) => Point.fmt$fmt_Debug(read, f), (f: rt.Formatter) => Moved.fmt$fmt_Debug(updated, f), (f: rt.Formatter) => shapes_Shape.fmt$fmt_Debug(taken, f), (f: rt.Formatter) => rt.usizeDisplay(_64, f), (f: rt.Formatter) => rt.usizeDisplay(_63, f), (f: rt.Formatter) => rt.usizeDisplay(_103, f), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_82), f, rt.u8Debug)]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => Shape.fmt$fmt_Debug(rect, f), (f: rt.Formatter) => Shape.fmt$fmt_Debug(line, f), (f: rt.Formatter) => Pair.fmt$fmt_Debug(pair, f), (f: rt.Formatter) => Point.fmt$fmt_Debug(read, f), (f: rt.Formatter) => Moved.fmt$fmt_Debug(updated, f), (f: rt.Formatter) => Shape.fmt$fmt_Debug(taken, f), (f: rt.Formatter) => rt.usizeDisplay(_64, f), (f: rt.Formatter) => rt.usizeDisplay(_63, f), (f: rt.Formatter) => rt.usizeDisplay(_103, f), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_82), f, rt.u8Debug)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7], " ", args2[8], " ", args2[9]]))); const _125: rt.usize = mark(out, 16); const _127: rt.usize = out.length; @@ -1347,9 +1347,9 @@ export function patterns(data: rt.ByteSlice, out: rt.ByteVec): void { } b6: { if (data.length >= 2) { - const _56: shapes_Dir.Dir | undefined = dir(data.data[data.start]); + const _56: Dir.Dir | undefined = dir(data.data[data.start]); if (_56 !== undefined) { - const d: shapes_Dir.Dir = _56; + const d: Dir.Dir = _56; if (data.data[data.start + 1] > 10) { rt.byteVecPush(out, from$convert_From_shapes_Dir_u8(d)); break b6; @@ -1358,7 +1358,7 @@ export function patterns(data: rt.ByteSlice, out: rt.ByteVec): void { } rt.byteVecPush(out, 238); } - const shape_: shapes_Shape.Shape = shape(data.data, data.start, data.length); + const shape_: Shape.Shape = shape(data.data, data.start, data.length); b8: { if (shape_.tag !== "Dot") { if (shape_.tag === "Line") { @@ -1395,7 +1395,7 @@ export function patterns(data: rt.ByteSlice, out: rt.ByteVec): void { const slice = rt.byteSliceRange(rt.byteSliceFrom(bytes), 1, 3); slice.data[slice.start] = 9; rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(bytes)); - rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u64ToBeBytes(rt.u64Add(total$shapes_Shape([shape_, { tag: "Dot" } as shapes_Shape.Shape], out), total$shapes_Meters([{ _0: 3 }, { _0: { hi: 0xffffffff, lo: 0xffffffff } as rt.u64 }], out))))); + rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u64ToBeBytes(rt.u64Add(total$shapes_Shape([shape_, { tag: "Dot" } as Shape.Shape], out), total$shapes_Meters([{ _0: 3 }, { _0: { hi: 0xffffffff, lo: 0xffffffff } as rt.u64 }], out))))); const parsed: rt.Result = rt.Ok(data.length & 0xff); const a2: rt.u8 = (parsed as { ok: true; value: rt.u8 }).value; rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(a2, (parsed as { ok: true; value: rt.u8 }).value, (parsed as { ok: true; value: rt.u8 }).value, early(a2)))); @@ -1447,7 +1447,7 @@ export function payloads(_dataData: Uint8Array, _dataStart: number, dataLen: num } const part2: rt.u8 | undefined = parity(rt.u8WrappingAdd(n, 1)); const err2: rt.u8 | undefined = part2 === undefined ? out$u8.err as rt.u8 : undefined; - const slot: shapes_Slot.Slot = { res: (err2 !== undefined ? rt.Err(err2 as rt.u8) : rt.Ok(part2 as rt.u8)) as rt.Result }; + const slot: Slot.Slot = { res: (err2 !== undefined ? rt.Err(err2 as rt.u8) : rt.Ok(part2 as rt.u8)) as rt.Result }; if (!slot.res.ok) { const _33: rt.u8 = rt.u8WrappingSub(slot.res.error, 4); slot.res = rt.Err(_33); @@ -1599,8 +1599,8 @@ export function known(_dataData: Uint8Array, _dataStart: number, dataLen: number _29 = some.x & 0xff; } rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(_15, _18, _21, _25, _29))); - const dot = { tag: "Dot" } as shapes_Shape.Shape; - const line = { tag: "Line", _0: Point.new(n as rt.i32, 2), _1: Point.new(3, 4) } as shapes_Shape.Shape; + const dot = { tag: "Dot" } as Shape.Shape; + const line = { tag: "Line", _0: Point.new(n as rt.i32, 2), _1: Point.new(3, 4) } as Shape.Shape; if (dot.tag === "Dot") { _39 = 1; } else if (dot.tag === "Line") { @@ -1617,7 +1617,7 @@ export function known(_dataData: Uint8Array, _dataStart: number, dataLen: number _45 = line.width & 0xff; } rt.byteVecPush(out, _45); - const east = "East" as shapes_Dir.Dir; + const east = "East" as Dir.Dir; if (east === "North") { _52 = 1; } else if (east === "East") { @@ -1671,13 +1671,13 @@ export function rematched(data: rt.ByteSlice, out: rt.ByteVec): void { let _107!: rt.u8; let _118!: rt.u8; let _127!: rt.u8; - let _131!: shapes_Shape.Shape; + let _131!: Shape.Shape; let _189!: rt.u8; let _192!: rt.u8; let lift!: rt.u8; let _206!: rt.u8; let _226!: rt.u8; - const s: shapes_Shape.Shape = shape(data.data, data.start, data.length); + const s: Shape.Shape = shape(data.data, data.start, data.length); if (s.tag === "Dot") { _5 = 2; } else if (s.tag === "Line") { @@ -1700,7 +1700,7 @@ export function rematched(data: rt.ByteSlice, out: rt.ByteVec): void { _19 = s.width & 0xff; } rt.byteVecPush(out, _19); - const d: shapes_Dir.Dir | undefined = dir(data.length & 0xff); + const d: Dir.Dir | undefined = dir(data.length & 0xff); if (d === undefined) { _29 = 15; } else if (d === "North") { @@ -1763,7 +1763,7 @@ export function rematched(data: rt.ByteSlice, out: rt.ByteVec): void { } rt.byteVecPush(out, _97); } - let m: shapes_Shape.Shape = s; + let m: Shape.Shape = s; if (m.tag === "Dot") { const _110: rt.ByteSlice = rt.byteSliceRange(data, rt.min(data.length, 1)); m = shape(_110.data, _110.start, _110.length); @@ -1776,38 +1776,38 @@ export function rematched(data: rt.ByteSlice, out: rt.ByteVec): void { _107 = 20; } rt.byteVecPush(out, _107); - let held = copy$shapes_Shape(m) as shapes_Shape.Shape | undefined; + let held = copy$shapes_Shape(m) as Shape.Shape | undefined; if (held === undefined) { _118 = 22; } else { const taken2 = held; held = undefined; - const taken: shapes_Shape.Shape | undefined = taken2; - if ((held as shapes_Shape.Shape | undefined) === undefined) { - _118 = option_mapOr$0aserv9(taken, 22, (t: shapes_Shape.Shape): rt.u8 => { - return rt.u64Low(shapes_Shape.area$shapes_Area(t)) & 0xff; + const taken: Shape.Shape | undefined = taken2; + if ((held as Shape.Shape | undefined) === undefined) { + _118 = option_mapOr$0aserv9(taken, 22, (t: Shape.Shape): rt.u8 => { + return rt.u64Low(Shape.area$shapes_Area(t)) & 0xff; }); } else { _118 = 21; } } rt.byteVecPush(out, _118); - let cur: shapes_Shape.Shape = s; + let cur: Shape.Shape = s; let iterStart: rt.u8 = 0; const iterEnd: rt.u8 = 3; while ((_127 = iterStart++) < iterEnd) { const i: rt.u8 = _127; if (cur.tag === "Dot") { - _131 = { tag: "Line", _0: Point.new(i as rt.i32, 0), _1: Point.new(0, 0) } as shapes_Shape.Shape; + _131 = { tag: "Line", _0: Point.new(i as rt.i32, 0), _1: Point.new(0, 0) } as Shape.Shape; } else if (cur.tag === "Line") { - _131 = { tag: "Rect", corner: cur._0, width: rt.u16Add(cur._1.x & 0xffff, 1), height: 2 } as shapes_Shape.Shape; + _131 = { tag: "Rect", corner: cur._0, width: rt.u16Add(cur._1.x & 0xffff, 1), height: 2 } as Shape.Shape; } else if (!(cur.width > 1)) { _131 = cur; } else { - _131 = { tag: "Dot" } as shapes_Shape.Shape; + _131 = { tag: "Dot" } as Shape.Shape; } cur = _131; - rt.byteVecPush(out, rt.u64Low(shapes_Shape.area$shapes_Area(cur)) & 0xff); + rt.byteVecPush(out, rt.u64Low(Shape.area$shapes_Area(cur)) & 0xff); } const machine: Machine.Machine = { state: copy$shapes_Shape(s), steps: 0 }; let iterStart2: rt.i32 = 0; @@ -1815,7 +1815,7 @@ export function rematched(data: rt.ByteSlice, out: rt.ByteVec): void { while (iterStart2++ < iterEnd2) { rt.byteVecPush(out, Machine.run(machine, data.length & 0xff)); } - const filled: Filled.Filled = { shape: copy$Option_shapes_Shape(option_map$0600mq0(dir(data.length & 0xff), (_2: shapes_Dir.Dir): shapes_Shape.Shape => { + const filled: Filled.Filled = { shape: copy$Option_shapes_Shape(option_map$0600mq0(dir(data.length & 0xff), (_2: Dir.Dir): Shape.Shape => { return copy$shapes_Shape(s); })) }; let iterStart3: rt.i32 = 0; @@ -1823,7 +1823,7 @@ export function rematched(data: rt.ByteSlice, out: rt.ByteVec): void { while (iterStart3++ < iterEnd3) { rt.byteVecPush(out, Filled.run(filled)); } - let original: shapes_Shape.Shape = shape(data.data, data.start, data.length); + let original: Shape.Shape = shape(data.data, data.start, data.length); if (original.tag === "Dot") { const _183: rt.ByteSlice = rt.byteSliceFrom(Uint8Array.of(1)); original = shape(_183.data, _183.start, _183.length); @@ -1866,7 +1866,7 @@ export function rematched(data: rt.ByteSlice, out: rt.ByteVec): void { } rt.byteVecPush(out, _206); b31: { - let w: shapes_Shape.Shape = s; + let w: Shape.Shape = s; if (w.tag === "Dot") { let i2: rt.usize = 0; while (true) { @@ -1909,7 +1909,7 @@ export function decidedByBool(data: rt.ByteSlice, out: rt.ByteVec): void { let _105!: rt.u8; let _111!: rt.u8; let _113!: boolean; - const s: shapes_Shape.Shape = shape(data.data, data.start, data.length); + const s: Shape.Shape = shape(data.data, data.start, data.length); if (s.tag === "Dot") { _4 = true; } else { @@ -1927,7 +1927,7 @@ export function decidedByBool(data: rt.ByteSlice, out: rt.ByteVec): void { if (s.tag === "Line") { _12 = s._0.x & 0xff; } else { - _12 = ((s as shapes_Shape.Shape) as { tag: "Rect"; corner: Point.Point; width: rt.u16; height: rt.u16 }).width & 0xff; + _12 = ((s as Shape.Shape) as { tag: "Rect"; corner: Point.Point; width: rt.u16; height: rt.u16 }).width & 0xff; } rt.byteVecPush(out, _12); } @@ -1953,21 +1953,21 @@ export function decidedByBool(data: rt.ByteSlice, out: rt.ByteVec): void { _29 = 66; } } else { - _29 = ((s as shapes_Shape.Shape) as { tag: "Rect"; corner: Point.Point; width: rt.u16; height: rt.u16 }).height & 0xff; + _29 = ((s as Shape.Shape) as { tag: "Rect"; corner: Point.Point; width: rt.u16; height: rt.u16 }).height & 0xff; } rt.byteVecPush(out, _29); - if (shapes_Shape.eq$cmp_PartialEq(s, { tag: "Dot" } as shapes_Shape.Shape)) { + if (Shape.eq$cmp_PartialEq(s, { tag: "Dot" } as Shape.Shape)) { rt.byteVecPush(out, 68); } - if (!shapes_Shape.eq$cmp_PartialEq(s, { tag: "Dot" } as shapes_Shape.Shape)) { + if (!Shape.eq$cmp_PartialEq(s, { tag: "Dot" } as Shape.Shape)) { rt.byteVecPush(out, 70); } - const line = { tag: "Line", _0: Point.new(0, 0), _1: Point.new(0, 0) } as shapes_Shape.Shape; - if (shapes_Shape.eq$cmp_PartialEq(s, line)) { - rt.byteVecPush(out, (((s as shapes_Shape.Shape) as { tag: "Line"; _0: Point.Point; _1: Point.Point })._1.x & 0xff) ^ 71); + const line = { tag: "Line", _0: Point.new(0, 0), _1: Point.new(0, 0) } as Shape.Shape; + if (Shape.eq$cmp_PartialEq(s, line)) { + rt.byteVecPush(out, (((s as Shape.Shape) as { tag: "Line"; _0: Point.Point; _1: Point.Point })._1.x & 0xff) ^ 71); } - if (!shapes_Shape.eq$cmp_PartialEq(s, line)) { - if ((s as shapes_Shape.Shape).tag === "Line") { + if (!Shape.eq$cmp_PartialEq(s, line)) { + if ((s as Shape.Shape).tag === "Line") { _61 = 73; } else { _61 = 74; @@ -1975,14 +1975,14 @@ export function decidedByBool(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, _61); } const _64: rt.ByteSlice = rt.byteSliceRange(data, rt.min(data.length, 1)); - const t: shapes_Shape.Shape = shape(_64.data, _64.start, _64.length); + const t: Shape.Shape = shape(_64.data, _64.start, _64.length); if (t.tag === "Rect") { - if (shapes_Shape.eq$cmp_PartialEq(s, t)) { - rt.byteVecPush(out, (((s as shapes_Shape.Shape) as { tag: "Rect"; corner: Point.Point; width: rt.u16; height: rt.u16 }).width & 0xff) ^ 75); + if (Shape.eq$cmp_PartialEq(s, t)) { + rt.byteVecPush(out, (((s as Shape.Shape) as { tag: "Rect"; corner: Point.Point; width: rt.u16; height: rt.u16 }).width & 0xff) ^ 75); } } - let m: shapes_Shape.Shape = s; - if ((m as shapes_Shape.Shape).tag === "Dot") { + let m: Shape.Shape = s; + if ((m as Shape.Shape).tag === "Dot") { dot = true; } else { dot = false; @@ -1996,7 +1996,7 @@ export function decidedByBool(data: rt.ByteSlice, out: rt.ByteVec): void { } rt.byteVecPush(out, _82); } - if ((s as shapes_Shape.Shape).tag === "Dot") { + if ((s as Shape.Shape).tag === "Dot") { dot2 = true; } else { dot2 = false; @@ -2005,14 +2005,14 @@ export function decidedByBool(data: rt.ByteSlice, out: rt.ByteVec): void { dot2 = !dot2; } if (dot2) { - if ((s as shapes_Shape.Shape).tag === "Line") { + if ((s as Shape.Shape).tag === "Line") { _91 = 79; } else { _91 = 80; } rt.byteVecPush(out, _91); } - if ((s as shapes_Shape.Shape).tag === "Dot") { + if ((s as Shape.Shape).tag === "Dot") { seen = true; } else { seen = false; @@ -2029,7 +2029,7 @@ export function decidedByBool(data: rt.ByteSlice, out: rt.ByteVec): void { } rt.byteVecPush(out, _99); } - let cur: shapes_Shape.Shape = s; + let cur: Shape.Shape = s; let wasDot: boolean = false; let iterStart: rt.u8 = 0; const iterEnd: rt.u8 = 3; @@ -2065,13 +2065,13 @@ export function reseated(dataData: Uint8Array, dataStart: number, dataLen: numbe let _37!: rt.u8; let _51!: rt.u8; const _8: rt.ByteSlice = rt.byteSliceFrom(Uint8Array.of(1)); - const _5: [shapes_Shape.Shape, shapes_Shape.Shape] = [shape(dataData, dataStart, dataLen), shape(_8.data, _8.start, _8.length)]; - const a: shapes_Shape.Shape = _5[0]; - const b: shapes_Shape.Shape = _5[1]; - let r: shapes_Shape.Shape = a; + const _5: [Shape.Shape, Shape.Shape] = [shape(dataData, dataStart, dataLen), shape(_8.data, _8.start, _8.length)]; + const a: Shape.Shape = _5[0]; + const b: Shape.Shape = _5[1]; + let r: Shape.Shape = a; if (r.tag === "Dot") { r = b; - if ((r as shapes_Shape.Shape).tag === "Line") { + if ((r as Shape.Shape).tag === "Line") { _12 = 27; } else { _12 = 28; @@ -2080,10 +2080,10 @@ export function reseated(dataData: Uint8Array, dataStart: number, dataLen: numbe _12 = 29; } rt.byteVecPush(out, _12); - let r2: shapes_Shape.Shape = a; + let r2: Shape.Shape = a; if (r2.tag === "Dot") { r2 = b; - if ((r2 as shapes_Shape.Shape).tag === "Line") { + if ((r2 as Shape.Shape).tag === "Line") { _19 = 30; } else { _19 = 31; @@ -2092,12 +2092,12 @@ export function reseated(dataData: Uint8Array, dataStart: number, dataLen: numbe _19 = 32; } rt.byteVecPush(out, _19); - let r3: shapes_Shape.Shape = a; + let r3: Shape.Shape = a; if (r3.tag === "Dot") { ((): undefined => { r3 = b; })(); - if ((r3 as shapes_Shape.Shape).tag === "Line") { + if ((r3 as Shape.Shape).tag === "Line") { _26 = 36; } else { _26 = 37; @@ -2106,13 +2106,13 @@ export function reseated(dataData: Uint8Array, dataStart: number, dataLen: numbe _26 = 38; } rt.byteVecPush(out, _26); - let r4: shapes_Shape.Shape = a; - let other: shapes_Shape.Shape = b; + let r4: Shape.Shape = a; + let other: Shape.Shape = b; if (r4.tag === "Dot") { const swapped = r4; r4 = other; other = swapped; - if ((r4 as shapes_Shape.Shape).tag === "Line") { + if ((r4 as Shape.Shape).tag === "Line") { _37 = 39; } else { _37 = 40; @@ -2121,13 +2121,13 @@ export function reseated(dataData: Uint8Array, dataStart: number, dataLen: numbe _37 = 41; } rt.byteVecPush(out, _37); - let r5: shapes_Shape.Shape = a; + let r5: Shape.Shape = a; let iterStart: rt.i32 = 0; const iterEnd: rt.i32 = 2; while (iterStart++ < iterEnd) { if (r5.tag === "Dot") { r5 = b; - if ((r5 as shapes_Shape.Shape).tag === "Line") { + if ((r5 as Shape.Shape).tag === "Line") { _51 = 42; } else { _51 = 43; @@ -2141,8 +2141,8 @@ export function reseated(dataData: Uint8Array, dataStart: number, dataLen: numbe } /** A parameter pointed elsewhere, after a copy of it that still points where it did. */ -export function rebound(r: shapes_Shape.Shape, b: shapes_Shape.Shape): rt.u8 { - const kept: shapes_Shape.Shape = r; +export function rebound(r: Shape.Shape, b: Shape.Shape): rt.u8 { + const kept: Shape.Shape = r; r = b; if (r.tag === "Line") { if (kept.tag === "Line") { @@ -2183,9 +2183,9 @@ export function uninhabited(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, calls); [counted(rt.place(() => calls, (value7) => calls = value7), a), [counted(rt.place(() => calls, (value8) => calls = value8), b)] as [rt.Result]] as [rt.Result, [rt.Result]]; rt.byteVecPush(out, calls); - const pair: [rt.Result, shapes_Partial.Partial] = [counted(rt.place(() => calls, (value9) => calls = value9), a), { tag: "Real", _0: b } as shapes_Partial.Partial]; + const pair: [rt.Result, Partial.Partial] = [counted(rt.place(() => calls, (value9) => calls = value9), a), { tag: "Real", _0: b } as Partial.Partial]; rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of((pair[0] as { ok: true; value: rt.u8 }).value, (pair[1] as { tag: "Real"; _0: rt.u8 })._0))); - const held: shapes_Parts.Parts = { left: rt.Ok(a), right: thenSome$0ztng9q(rt.u8Rem(b, 2) === 0, rt.Ok((((b as rt.u16)) << 4) & 0xffff)) }; + const held: Parts.Parts = { left: rt.Ok(a), right: thenSome$0ztng9q(rt.u8Rem(b, 2) === 0, rt.Ok((((b as rt.u16)) << 4) & 0xffff)) }; const l: rt.u8 = (held.left as { ok: true; value: rt.u8 }).value; const right: rt.Result | undefined = held.right; if (right === undefined) { @@ -2193,7 +2193,7 @@ export function uninhabited(data: rt.ByteSlice, out: rt.ByteVec): void { } else { rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u16ToBeBytes((right as { ok: true; value: rt.u16 }).value))); } - const _93: [shapes_Partial.Partial, rt.Result] = [{ tag: "Real", _0: a } as shapes_Partial.Partial, held.left]; + const _93: [Partial.Partial, rt.Result] = [{ tag: "Real", _0: a } as Partial.Partial, held.left]; rt.byteVecPush(out, (_93[0] as { tag: "Real"; _0: rt.u8 })._0 ^ (_93[1] as { ok: true; value: rt.u8 }).value); const _101: [rt.Result, rt.u8 | undefined] = [counted(rt.place(() => calls, (value10) => calls = value10), a), rt.byteSliceGet(data, 2)]; if (_101[1] !== undefined) { @@ -2233,9 +2233,9 @@ export function closures(data: rt.ByteSlice, out: rt.ByteVec): void { const whole: Uint8Array = Uint8Array.of(data.length & 0xff); overwrite(rt.byteSliceFrom(whole)); rt.byteVecPush(out, whole[0]); - const parsed: Array = []; + const parsed: Array = []; for (const _53 of rt.byteSliceView(data)) { - const _59: shapes_Dir.Dir | undefined = dir(_53); + const _59: Dir.Dir | undefined = dir(_53); parsed.push(_59); } const tags: rt.ByteVec = new rt.ByteVec(); @@ -2272,8 +2272,8 @@ export function library(data: rt.ByteSlice, out: rt.ByteVec): void { return undefined; }; const _30: (a0: rt.u8) => rt.Poll> = (a3: rt.u8): rt.Poll> => { - let half2!: rt.Result; - const _45: shapes_Dir.Dir | undefined = dir(a3); + let half2!: rt.Result; + const _45: Dir.Dir | undefined = dir(a3); b0: { if (_45 !== undefined) { if (rt.u8Rem(a3, 2) === 1) { @@ -2283,11 +2283,11 @@ export function library(data: rt.ByteSlice, out: rt.ByteVec): void { } half2 = rt.Ok(rt.u8Div(a3, 2)); } - const _132: rt.Result = half2; + const _132: rt.Result = half2; if (_132.ok) { return rt.Ok(_132.value); } - return rt.Err(from$convert_From_shapes_Dir_u8((_132 as { ok: false; error: shapes_Dir.Dir }).error)); + return rt.Err(from$convert_From_shapes_Dir_u8((_132 as { ok: false; error: Dir.Dir }).error)); }; const a: rt.u8 = option_unwrapOr$0r2bmpr(rt.byteSliceFirst(data), 0); const b: rt.u8 = option_unwrapOr$0r2bmpr(rt.byteSliceGet(data, 1), 0); diff --git a/ts/fixtures/lang/src/fmt.rs b/ts/fixtures/lang/shapes/src/fmt.rs similarity index 99% rename from ts/fixtures/lang/src/fmt.rs rename to ts/fixtures/lang/shapes/src/fmt.rs index 899201cd2..221a65b9e 100644 --- a/ts/fixtures/lang/src/fmt.rs +++ b/ts/fixtures/lang/shapes/src/fmt.rs @@ -13,6 +13,7 @@ use std::rc::Rc; use std::sync::Arc; use crate::generics::Wrap; +use crate::harness::put; use crate::shapes::{Point, Shape}; /// Take an integer's big-endian bytes from the front of `data`, zero-padded. @@ -51,11 +52,6 @@ macro_rules! specs { }}; } -pub fn put(out: &mut Vec, s: &str) { - out.extend_from_slice(s.as_bytes()); - out.push(0xff); -} - /// Integers of every width, with each spec. pub fn ints(kind: u8, data: &[u8], out: &mut Vec) { match kind % 12 { diff --git a/ts/fixtures/lang/src/generics.rs b/ts/fixtures/lang/shapes/src/generics.rs similarity index 99% rename from ts/fixtures/lang/src/generics.rs rename to ts/fixtures/lang/shapes/src/generics.rs index 5ac227ee2..1f060363c 100644 --- a/ts/fixtures/lang/src/generics.rs +++ b/ts/fixtures/lang/shapes/src/generics.rs @@ -4,7 +4,8 @@ use std::borrow::Cow; use std::cell::RefCell; use std::rc::Rc; -use crate::fmt::{Pair, put}; +use crate::fmt::Pair; +use crate::harness::put; use crate::shapes::{Area, Meters, Point, Shape, Track}; /// A generic struct, with methods on every instance, on some, and on one. diff --git a/ts/fixtures/lang/shapes/src/lib.rs b/ts/fixtures/lang/shapes/src/lib.rs new file mode 100644 index 000000000..e8120ef3d --- /dev/null +++ b/ts/fixtures/lang/shapes/src/lib.rs @@ -0,0 +1,53 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +mod fmt; +mod generics; +#[path = "../../harness.rs"] +pub mod harness; +mod shapes; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; + +use harness::Case; + +/// The native side's entry: [`harness::run`], except that a case starting with 0xff prints +/// a [`fmt::Fault`], which the translated side prints from TypeScript in `caller.ts`. +pub fn entry(input: &[u8]) -> Vec { + match input.split_first() { + Some((0xff, data)) => fmt::printed(data), + _ => harness::run(input), + } +} + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("fmt::ints", fmt::ints), + ("fmt::strings", |_, data, out| fmt::strings(data, out)), + ("fmt::derived", |_, data, out| fmt::derived(data, out)), + ("fmt::written", |_, data, out| fmt::written(data, out)), + ("fmt::panics", fmt::panics), + ("fmt::counts", |_, data, out| fmt::counts(data, out)), + ("fmt::rounding", |_, _, out| fmt::rounding(out)), + ("fmt::wrapped", |_, data, out| fmt::wrapped(data, out)), + ("fmt::writes", |_, data, out| fmt::writes(data, out)), + ("fmt::collections", |_, data, out| fmt::collections(data, out)), + ("fmt::iters", |_, data, out| fmt::iters(data, out)), + ("fmt::enums", |_, data, out| fmt::enums(data, out)), + ("fmt::objects", |_, data, out| fmt::objects(data, out)), + ("generics::methods", |_, data, out| generics::methods(data, out)), + ("generics::runs", |_, data, out| generics::runs(data, out)), + ("shapes::copies", |_, data, out| shapes::copies(data, out)), + ("shapes::loops", |_, data, out| shapes::loops(data, out)), + ("shapes::patterns", |_, data, out| shapes::patterns(data, out)), + ("shapes::closures", |_, data, out| shapes::closures(data, out)), + ("shapes::discriminants", |_, data, out| shapes::discriminants(data, out)), + ("shapes::library", |_, data, out| shapes::library(data, out)), + ("shapes::order", |_, data, out| shapes::order(data, out)), + ("shapes::flows", |_, data, out| shapes::flows(data, out)), + ("shapes::uninhabited", |_, data, out| shapes::uninhabited(data, out)), + ] +} diff --git a/ts/fixtures/lang/src/shapes.rs b/ts/fixtures/lang/shapes/src/shapes.rs similarity index 100% rename from ts/fixtures/lang/src/shapes.rs rename to ts/fixtures/lang/shapes/src/shapes.rs diff --git a/ts/fixtures/lang/ts.toml b/ts/fixtures/lang/shapes/ts.toml similarity index 71% rename from ts/fixtures/lang/ts.toml rename to ts/fixtures/lang/shapes/ts.toml index 575fe039e..936ffeb4d 100644 --- a/ts/fixtures/lang/ts.toml +++ b/ts/fixtures/lang/shapes/ts.toml @@ -1,3 +1,3 @@ -package = "lang-fixture" +package = "lang-shapes-fixture" roots = ["harness::run", "harness::op", "fmt::Fault"] printable = ["fmt::Fault"] diff --git a/ts/fixtures/lang/singles/Cargo.toml b/ts/fixtures/lang/singles/Cargo.toml new file mode 100644 index 000000000..8c6af8e39 --- /dev/null +++ b/ts/fixtures/lang/singles/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-singles-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/singles/caller.ts b/ts/fixtures/lang/singles/caller.ts new file mode 100644 index 000000000..638bc01ef --- /dev/null +++ b/ts/fixtures/lang/singles/caller.ts @@ -0,0 +1,78 @@ +// The inputs `singles`' cases name, which run with the generated ones. + +import { op as pick } from "./harness.ts"; +import { mulAdds, op, picked, ulpsWithin, wides } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** A single's bits, big-endian, as `singles` takes them. */ +function single(x: number | bigint): number[] { + const bytes = new Uint8Array(4); + const view = new DataView(bytes.buffer); + if (typeof x === "bigint") view.setUint32(0, Number(x)); + else view.setFloat32(0, x); + return [...bytes]; +} + +/** + * `singles`' operands: each side of a half, of 2^23 and 2^24, where each integer type + * saturates, where a single's range and its normals end, the bounds of `Debug`'s + * exponent, infinities, and NaNs, one negative, one with a payload, and one signaling. + */ +const singlesValues: (number | bigint)[] = [ + 0, -0, 0.5, -0.5, 1.5, 2.5, -2.5, 0.49999997, 1, -1, 3, 0.1, 1 / 3, 2 ** 23 - 0.5, 2 ** 23, 2 ** 24, 2 ** 24 + 2, 255.5, -128.5, + 2147483520, 2 ** 31, -(2 ** 31), 4294967040, 2 ** 32, 2 ** 63, -(2 ** 63), 2 ** 64, 2 ** 127, 1e-9, 0.99999994, 1.0000001, 1e-4, 1e16, + 1e-40, 2 ** -149, 2 ** -126, 3.4028234663852886e38, -3.4028234663852886e38, Infinity, -Infinity, NaN, 0xffc00000n, 0x7fc00123n, 0x7f800001n, +]; +const singlesOp = op("singles::singles"); +const singlesCases = [ + ...Array.from({ length: 10 }, (_, kind) => singlesValues.flatMap((a) => singlesValues.map((b) => Uint8Array.of(...singlesOp, kind, ...single(a), ...single(b), 1)))).flat(), + // `from_secs_f32`, `mul_f32`, and `div_f32` panicking, and `Duration::MAX.mul_f32`. + ...[18, 28, 38].flatMap((kind) => singlesValues.map((a) => Uint8Array.of(...singlesOp, kind, ...single(a), ...single(a), 3))), + // Integers whose `f32` rounds once where through an `f64` it would round twice: past + // 2^53, a bit just past halfway between two singles. + ...wides.concat([(1n << 60n) + (1n << 36n) + 1n, (1n << 64n) - (1n << 39n) - 1n, (1n << 127n) + (1n << 103n) + 1n, (1n << 24n) + 1n]).map((v) => { + const bytes = new Uint8Array(16); + new DataView(bytes.buffer).setBigUint64(0, BigInt.asUintN(64, v >> 64n)); + new DataView(bytes.buffer).setBigUint64(8, BigInt.asUintN(64, v)); + return Uint8Array.of(...singlesOp, 2, ...bytes); + }), +]; + +/** `singles::formats`' singles: ties at each precision, carries through nines, and the shortest digits at each end. */ +const singlesFormatted: (number | bigint)[] = [ + ...singlesValues, + 0.125, 0.375, 3.5, 9.5, 99.5, 0.95, 9.995, 1.25, 1.35, 2.675, 9.999999e-5, 1e15, 9999999e9, 1e-7, 123456.79, 16777215, 7.006492e-46, 1.17549421e-38, 8388609, +]; +const singlesFormatsOp = op("singles::formats"); +const singlesParsesOp = op("singles::parses"); +const singlesFormats = [ + ...singlesFormatted.flatMap((a) => Array.from({ length: 12 }, (_, p) => Uint8Array.of(...singlesFormatsOp, 0, ...single(a), p))), + ...singlesFormatted.flatMap((a) => [1, 3, 4].map((kind) => Uint8Array.of(...singlesFormatsOp, kind, ...single(a), 0))), + ...singlesFormatted.flatMap((a) => [[1, 2], [2, 1], [NaN, 1], [1, NaN], [-0, 0], [0, -0]].map(([b, c]) => Uint8Array.of(...singlesFormatsOp, 2, ...single(a), ...single(b), ...single(c)))), + ...singlesValues.map((a) => Uint8Array.of(...singlesParsesOp, 2, ...single(a))), +]; + +/** + * `singles::parses`' texts: std's grammar, past each end of a single's range, and + * decimals within a hair of halfway between two singles, which rounding through the + * nearest double would round twice. + */ +const singlesParsed = [ + "", "+", "-", ".", "e5", "1e", "1.e5", ".5", "+1", "1_000", " 1", "1e40", "-1e40", "1e-50", "-0", "inf", "-infinity", "NaN", "nan1", + "3.4028235e38", "3.4028236e38", "3.40282357e38", "3.4028235677973366e38", "3.4028235677973367e38", "1.4e-45", "7e-46", + "7.006492321624085354618647916449580656401e-46", "7.006492321624085354618647916449580656402e-46", "1.1754942e-38", "1.17549435e-38", + "16777217", "16777217.000000000001", "16777218.99999999999", "16777219", "1.00000005960464477539062499", "1.000000059604644775390625", + "1.00000005960464477539062501", "1.0000000596046448", "0.1", "1e10", "1234567e-10", "12345678e-10", "9007199254740993", + `1${"0".repeat(60)}e-60`, `0.${"0".repeat(60)}1e61`, "1e65535", "1e-65536", +].map((text) => Uint8Array.of(...singlesParsesOp, 0, ...new TextEncoder().encode(text))); + +const singlesMulAdds = mulAdds(3.4028234663852886e38, 2 ** -149, 2 ** -23, op("singles::mul_adds"), single); + +const singlesAt = pick("singles::singles"); + +export function within(input: Uint8Array, native: Uint8Array, translated: Uint8Array): boolean { + return picked(input) === singlesAt && input[2] % 10 === 7 && ulpsWithin(4, native, translated); +} + +export const cases: Uint8Array[] = [...singlesCases, ...singlesFormats, ...singlesParsed, ...singlesMulAdds]; diff --git a/ts/fixtures/lang/singles/expected/core/option.ts b/ts/fixtures/lang/singles/expected/core/option.ts new file mode 100644 index 000000000..0928bfcd9 --- /dev/null +++ b/ts/fixtures/lang/singles/expected/core/option.ts @@ -0,0 +1,33 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$19h8ynp(self: rt.f32 | undefined, default_: rt.f32): rt.f32 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function mapOr$1e4a1e0(self: rt.Ordering | undefined, default_: rt.u8, f: (a0: rt.Ordering) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$15zxk73(self: rt.u8 | undefined, default_: rt.u64, f: (a0: rt.u8) => rt.u64): rt.u64 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/singles/expected/harness.ts b/ts/fixtures/lang/singles/expected/harness.ts new file mode 100644 index 000000000..3b7bbcfb0 --- /dev/null +++ b/ts/fixtures/lang/singles/expected/harness.ts @@ -0,0 +1,46 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/singles/expected/lib.ts b/ts/fixtures/lang/singles/expected/lib.ts new file mode 100644 index 000000000..e77284608 --- /dev/null +++ b/ts/fixtures/lang/singles/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { singles, mulAdds, formats, parses } from "./singles.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["singles::singles", singles as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["singles::formats", formats as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["singles::parses", parses as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["singles::mul_adds", mulAdds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/singles.Gauge.ts b/ts/fixtures/lang/singles/expected/singles.Gauge.ts similarity index 100% rename from ts/fixtures/lang/expected/singles.Gauge.ts rename to ts/fixtures/lang/singles/expected/singles.Gauge.ts diff --git a/ts/fixtures/lang/expected/singles.Reading.ts b/ts/fixtures/lang/singles/expected/singles.Reading.ts similarity index 100% rename from ts/fixtures/lang/expected/singles.Reading.ts rename to ts/fixtures/lang/singles/expected/singles.Reading.ts diff --git a/ts/fixtures/lang/expected/singles.ts b/ts/fixtures/lang/singles/expected/singles.ts similarity index 91% rename from ts/fixtures/lang/expected/singles.ts rename to ts/fixtures/lang/singles/expected/singles.ts index c3d72728c..26ced3cae 100644 --- a/ts/fixtures/lang/expected/singles.ts +++ b/ts/fixtures/lang/singles/expected/singles.ts @@ -2,9 +2,9 @@ import * as rt from "./rt.ts"; import { unwrapOr$19h8ynp as option_unwrapOr$19h8ynp, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, mapOr$1e4a1e0 as option_mapOr$1e4a1e0, mapOr$15zxk73 as option_mapOr$15zxk73 } from "./core/option.ts"; -import { put as fmt_put } from "./fmt.ts"; -import * as singles_Gauge from "./singles.Gauge.ts"; -import * as singles_Reading from "./singles.Reading.ts"; +import { put } from "./harness.ts"; +import * as Gauge from "./singles.Gauge.ts"; +import * as Reading from "./singles.Reading.ts"; /** The bits of an `f32` from the front of `data`, big-endian and zero-padded. */ export function takeBits(data: rt.ByteSlice): [rt.u32, rt.ByteSlice] { @@ -54,7 +54,7 @@ export function putSecs(out: rt.ByteVec, d: rt.Result rt.fmtTryFromFloatSecsErrorDisplay(e, f), (f: rt.Formatter) => rt.fmtTryFromFloatSecsErrorDebug(e, f)]; - fmt_put(out, rt.fmtFormat([args2[0], "|", args2[1]])); + put(out, rt.fmtFormat([args2[0], "|", args2[1]])); } } @@ -282,7 +282,7 @@ export function singles(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void putF32(out, rt.iterSum(rt.iterSlice(_499), rt.f32Add, -0.0)); putF32(out, rt.iterSum(rt.iterSlice([-0.0, -0.0]), rt.f32Add, -0.0)); putF32(out, 0.0); - const g: singles_Gauge.Gauge = { level: a, peak: b }; + const g: Gauge.Gauge = { level: a, peak: b }; raise(rt.place(() => g.level, (value) => g.level = value), b); if (g.peak !== undefined) { const _513: rt.f32 = rt.f32Max(g.peak, g.level); @@ -290,8 +290,8 @@ export function singles(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void } putF32(out, g.level); putF32(out, option_unwrapOr$19h8ynp(g.peak, -1.0)); - const _526: singles_Gauge.Gauge = singles_Gauge.default$Default(); - rt.byteVecPush(out, singles_Gauge.eq$cmp_PartialEq(g, _526) ? 1 : 0); + const _526: Gauge.Gauge = Gauge.default$Default(); + rt.byteVecPush(out, Gauge.eq$cmp_PartialEq(g, _526) ? 1 : 0); rt.byteVecPush(out, g.peak === b ? 1 : 0); let local: rt.f32 = a; raise(rt.place(() => local, (value2) => local = value2), 0.10000000149011612); @@ -398,13 +398,13 @@ export function formats(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const _13: rt.u8 = rt.u8Rem(kind, 5); if (_13 === 0) { const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.f32Display(a, f), (f: rt.Formatter) => rt.f32Debug(a, f), (f: rt.Formatter) => rt.f32LowerExp(a, f), (f: rt.Formatter) => rt.f32UpperExp(a, f), rt.fmtCount(p)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[0]), " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[1]), " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[2]), " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[3]), " ", rt.fmtSpec({ plus: true }, args2[0]), " ", rt.fmtSpec({ plus: true }, args2[1]), " ", rt.fmtSpec({ plus: true, precision: rt.fmtCountOf(args2[4]) }, args2[2])])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[0]), " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[1]), " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[2]), " ", rt.fmtSpec({ precision: rt.fmtCountOf(args2[4]) }, args2[3]), " ", rt.fmtSpec({ plus: true }, args2[0]), " ", rt.fmtSpec({ plus: true }, args2[1]), " ", rt.fmtSpec({ plus: true, precision: rt.fmtCountOf(args2[4]) }, args2[2])])); const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.f32Display(a, f), (f: rt.Formatter) => rt.f32LowerExp(a, f), (f: rt.Formatter) => rt.f32Debug(a, f), (f: rt.Formatter) => rt.f32UpperExp(a, f), rt.fmtCount(w), rt.fmtCount(p)]; - fmt_put(out, rt.fmtFormat([rt.fmtSpec({ zero: true, width: 8, precision: 3 }, args4[0]), "|", rt.fmtSpec({ plus: true, zero: true, width: 12 }, args4[1]), "|", rt.fmtSpec({ align: "<", width: 9 }, args4[0]), "|", rt.fmtSpec({ align: "^", width: 12 }, args4[2]), "|", rt.fmtSpec({ fill: "*", align: ">", width: 10, precision: 1 }, args4[0]), "|", rt.fmtSpec({ alternate: true }, args4[2]), "|", rt.fmtSpec({ fill: "-", align: "^", plus: true, width: 15, precision: 2 }, args4[3]), "|", rt.fmtSpec({ zero: true, width: 10 }, args4[0]), "|", rt.fmtSpec({ align: ">", width: rt.fmtCountOf(args4[4]), precision: rt.fmtCountOf(args4[5]) }, args4[0])])); - fmt_put(out, rt.fmtToString((f: rt.Formatter) => rt.f32Display(a, f))); + put(out, rt.fmtFormat([rt.fmtSpec({ zero: true, width: 8, precision: 3 }, args4[0]), "|", rt.fmtSpec({ plus: true, zero: true, width: 12 }, args4[1]), "|", rt.fmtSpec({ align: "<", width: 9 }, args4[0]), "|", rt.fmtSpec({ align: "^", width: 12 }, args4[2]), "|", rt.fmtSpec({ fill: "*", align: ">", width: 10, precision: 1 }, args4[0]), "|", rt.fmtSpec({ alternate: true }, args4[2]), "|", rt.fmtSpec({ fill: "-", align: "^", plus: true, width: 15, precision: 2 }, args4[3]), "|", rt.fmtSpec({ zero: true, width: 10 }, args4[0]), "|", rt.fmtSpec({ align: ">", width: rt.fmtCountOf(args4[4]), precision: rt.fmtCountOf(args4[5]) }, args4[0])])); + put(out, rt.fmtToString((f: rt.Formatter) => rt.f32Display(a, f))); } else if (_13 === 1) { const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.f32Display(a, f), (f: rt.Formatter) => rt.f32LowerExp(a, f), (f: rt.Formatter) => rt.f32Debug(a, f)]; - fmt_put(out, rt.fmtFormat([rt.fmtSpec({ precision: 160 }, args6[0]), " ", rt.fmtSpec({ precision: 120 }, args6[1]), " ", rt.fmtSpec({ precision: 160 }, args6[2])])); + put(out, rt.fmtFormat([rt.fmtSpec({ precision: 160 }, args6[0]), " ", rt.fmtSpec({ precision: 120 }, args6[1]), " ", rt.fmtSpec({ precision: 160 }, args6[2])])); } else if (_13 === 2) { const _72: [rt.f32, rt.ByteSlice] = take(_6[1]); const b: rt.f32 = _72[0]; @@ -413,8 +413,8 @@ export function formats(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void } else if (_13 === 3) { const _78: rt.f32[] = [Math.fround(a * 0.5), -0.0, 9.999999747378752e-5, 1.0000000272564224e16, NaN]; const part = { level: a, history: _78 }; - const args8: rt.Fmt[] = [(f: rt.Formatter) => singles_Reading.fmt$fmt_Debug(part, f)]; - fmt_put(out, rt.fmtFormat([args8[0], "|", rt.fmtSpec({ precision: 2 }, args8[0]), "|", rt.fmtSpec({ plus: true, zero: true, width: 12 }, args8[0])])); + const args8: rt.Fmt[] = [(f: rt.Formatter) => Reading.fmt$fmt_Debug(part, f)]; + put(out, rt.fmtFormat([args8[0], "|", rt.fmtSpec({ precision: 2 }, args8[0]), "|", rt.fmtSpec({ plus: true, zero: true, width: 12 }, args8[0])])); } else { let state: rt.u32 = (takeBits(data)[0] | 1) >>> 0; let iterStart: rt.i32 = 0; @@ -422,7 +422,7 @@ export function formats(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void while (iterStart++ < iterEnd) { const x: rt.f32 = rt.f32FromBits(step(rt.place(() => state, (value) => state = value))); const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.f32Display(x, f), (f: rt.Formatter) => rt.f32Debug(x, f), (f: rt.Formatter) => rt.f32LowerExp(x, f)]; - fmt_put(out, rt.fmtFormat([args10[0], " ", args10[1], " ", args10[2]])); + put(out, rt.fmtFormat([args10[0], " ", args10[1], " ", args10[2]])); } let iterStart2: rt.i32 = 0; const iterEnd2: rt.i32 = 64; @@ -433,7 +433,7 @@ export function formats(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const r2: rt.u32 = step(rt.place(() => state, (value2) => state = value2)); const x2: rt.f32 = Math.fround(Math.fround(r2 >>> 8) / Math.fround(rt.u32Shl(1, rt.u32Add(rt.u32Rem(r2, 16), 1)))); const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.f32Debug(x2, f), (f: rt.Formatter) => rt.f32LowerExp(x2, f)]; - fmt_put(out, rt.fmtFormat([args12[0], " ", args12[1]])); + put(out, rt.fmtFormat([args12[0], " ", args12[1]])); } } } @@ -508,11 +508,11 @@ export function one(s: string, out: rt.ByteVec): void { const v: rt.f32 = _4.value; putF32(out, v); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.f32Debug(v, f)]; - fmt_put(out, rt.fmtFormat([args2[0]])); + put(out, rt.fmtFormat([args2[0]])); } else { const e: rt.ParseFloatError = _4.error; const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseFloatErrorDisplay(e, f), (f: rt.Formatter) => rt.fmtParseFloatErrorDebug(e, f)]; - fmt_put(out, rt.fmtFormat([args4[0], "|", args4[1]])); + put(out, rt.fmtFormat([args4[0], "|", args4[1]])); } rt.byteVecPush(out, rt.f32FromStr(s).ok ? 1 : 0); } diff --git a/ts/fixtures/lang/singles/src/lib.rs b/ts/fixtures/lang/singles/src/lib.rs new file mode 100644 index 000000000..c06e4f790 --- /dev/null +++ b/ts/fixtures/lang/singles/src/lib.rs @@ -0,0 +1,24 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod singles; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("singles::singles", singles::singles), + ("singles::formats", singles::formats), + ("singles::parses", singles::parses), + ("singles::mul_adds", singles::mul_adds), + ] +} diff --git a/ts/fixtures/lang/src/singles.rs b/ts/fixtures/lang/singles/src/singles.rs similarity index 99% rename from ts/fixtures/lang/src/singles.rs rename to ts/fixtures/lang/singles/src/singles.rs index 79a7555a2..eb195b4d2 100644 --- a/ts/fixtures/lang/src/singles.rs +++ b/ts/fixtures/lang/singles/src/singles.rs @@ -9,7 +9,7 @@ use std::f32::consts; use std::time::Duration; -use crate::fmt::put; +use crate::harness::put; /// The bits of an `f32` from the front of `data`, big-endian and zero-padded. fn take_bits(data: &[u8]) -> (u32, &[u8]) { diff --git a/ts/fixtures/lang/singles/ts.toml b/ts/fixtures/lang/singles/ts.toml new file mode 100644 index 000000000..0b7cb11b4 --- /dev/null +++ b/ts/fixtures/lang/singles/ts.toml @@ -0,0 +1,2 @@ +package = "lang-singles-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/slices/Cargo.toml b/ts/fixtures/lang/slices/Cargo.toml new file mode 100644 index 000000000..1bc6c1ac1 --- /dev/null +++ b/ts/fixtures/lang/slices/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-slices-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/slices/caller.ts b/ts/fixtures/lang/slices/caller.ts new file mode 100644 index 000000000..16366e832 --- /dev/null +++ b/ts/fixtures/lang/slices/caller.ts @@ -0,0 +1,44 @@ +// The inputs `slices`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `subslices` of each kind over zero to four items, at every pair of bounds up to one past + * the end, so parts are empty, at the end, backwards, and out of bounds. + */ +const subslicesOp = op("slices::subslices"); +const subslices = [0, 1, 2, 3, 4].flatMap((n) => + Array.from({ length: 8 * (n + 2) ** 2 }, (_, i) => { + const [kind, a, b] = [i % 8, Math.floor(i / 8) % (n + 2), Math.floor(i / 8 / (n + 2))]; + return Uint8Array.of(...subslicesOp, kind, a, b, ...[0x31, 0xc2, 0x07, 0xfe].slice(0, n)); + }), +); + +/** + * `ranges` of each kind, and each kind of `Bound` at the end, over zero to four items, at + * every pair of bounds up to one past the end and at `usize::MAX`. + */ +const rangesOp = op("slices::ranges"); +const ranges = [0, 1, 2, 3, 4].flatMap((n) => { + const ends = [...Array(n + 2).keys(), 0xff]; + return Array.from({ length: 24 * ends.length ** 2 }, (_, i) => { + const [kind, a, b] = [i % 24, ends[Math.floor(i / 24) % ends.length], ends[Math.floor(i / 24 / ends.length)]]; + return Uint8Array.of(...rangesOp, kind, a, b, ...[0x31, 0xc2, 0x07, 0xfe].slice(0, n)); + }); +}); + +/** + * `edits` of each kind over zero to four items, at every three bounds up to one past the + * end, so parts are empty, at the end, backwards, and out of bounds. + */ +const editsSlicesOp = op("slices::edits"); +const sliceEdits = [0, 1, 2, 3, 4].flatMap((n) => + Array.from({ length: 8 * (n + 2) ** 3 }, (_, i) => { + const [kind, a, b, c] = [i % 8, Math.floor(i / 8) % (n + 2), Math.floor(i / 8 / (n + 2)) % (n + 2), Math.floor(i / 8 / (n + 2) ** 2)]; + return Uint8Array.of(...editsSlicesOp, kind, a, b, c, ...[0x31, 0xc2, 0x07, 0xfe].slice(0, n)); + }), +); + +export const cases: Uint8Array[] = [...subslices, ...ranges, ...sliceEdits]; diff --git a/ts/fixtures/lang/slices/expected/core/option.ts b/ts/fixtures/lang/slices/expected/core/option.ts new file mode 100644 index 000000000..11b2b2f02 --- /dev/null +++ b/ts/fixtures/lang/slices/expected/core/option.ts @@ -0,0 +1,72 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import { digest, digestWords } from "../slices.ts"; +import type * as Item from "../slices.Item.ts"; +import * as Noisy from "../slices.Noisy.ts"; +import type * as Pair from "../slices.Pair.ts"; + +export function map$1wqzuhy(self: rt.u16[] | undefined, f: (a0: rt.u16[]) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0c2keyb(self: rt.ByteSlice | undefined, f: (a0: rt.ByteSlice) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$11y9s7r(self: Pair.Pair[] | undefined, f: (a0: Pair.Pair[]) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0qyyft9(self: rt.u16[] | undefined, _: (a0: rt.u16[]) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return digestWords(self); +} + +export function map$1xk4yz1(self: rt.ByteSlice | undefined, _: (a0: rt.ByteSlice) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return digest(self); +} + +export function map$003seos(self: Item.Item | undefined, f: (a0: Item.Item) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$0a57co2(self: rt.u32 | undefined, f: (a0: rt.u32) => rt.u8): rt.u8 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function mapOr$189goit(self: Noisy.Noisy | undefined, default_: rt.u8, f: (a0: Noisy.Noisy) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function clone$1omlcob(self: Noisy.Noisy | undefined): Noisy.Noisy | undefined { + if (self === undefined) { + return undefined; + } + return Noisy.clone$Clone(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/slices/expected/harness.ts b/ts/fixtures/lang/slices/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/slices/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/slices/expected/lib.ts b/ts/fixtures/lang/slices/expected/lib.ts new file mode 100644 index 000000000..214d21b6f --- /dev/null +++ b/ts/fixtures/lang/slices/expected/lib.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { parts, chunked, subslices, drains, ranges, edits } from "./slices.ts"; +import type * as Pair from "./slices.Pair.ts"; + +export function copy$slices_Pair(v: Pair.Pair): Pair.Pair { + return { a: v.a, b: v.b }; +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["slices::parts", parts as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["slices::drains", drains as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["slices::chunked", chunked as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["slices::subslices", subslices as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["slices::ranges", ranges as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["slices::edits", edits as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/slices.Counted.ts b/ts/fixtures/lang/slices/expected/slices.Counted.ts similarity index 77% rename from ts/fixtures/lang/expected/slices.Counted.ts rename to ts/fixtures/lang/slices/expected/slices.Counted.ts index 47ba2bc67..0bfa358c8 100644 --- a/ts/fixtures/lang/expected/slices.Counted.ts +++ b/ts/fixtures/lang/slices/expected/slices.Counted.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { LOG as slices_LOG } from "./slices.ts"; +import { LOG } from "./slices.ts"; /** * A `Copy` element whose own `Clone` logs, which `fill` and `clone_from_slice` call and @@ -12,7 +12,7 @@ export interface Counted { } export function clone$Clone(self: Counted): Counted { - rt.localKeyWithBorrowMut(slices_LOG, (log: rt.ByteVec): undefined => { + rt.localKeyWithBorrowMut(LOG, (log: rt.ByteVec): undefined => { rt.byteVecPush(log, self.n ^ 64); }); return self; diff --git a/ts/fixtures/lang/expected/slices.Item.ts b/ts/fixtures/lang/slices/expected/slices.Item.ts similarity index 75% rename from ts/fixtures/lang/expected/slices.Item.ts rename to ts/fixtures/lang/slices/expected/slices.Item.ts index 46009abc1..abc8e8ffb 100644 --- a/ts/fixtures/lang/expected/slices.Item.ts +++ b/ts/fixtures/lang/slices/expected/slices.Item.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { LOG as slices_LOG } from "./slices.ts"; +import { LOG } from "./slices.ts"; /** Logs its tag as it drops. */ export class Item { @@ -17,7 +17,7 @@ export class Item { } export function drop$ops_Drop(self: Item): void { - rt.localKeyWithBorrowMut(slices_LOG, (log: rt.ByteVec): undefined => { + rt.localKeyWithBorrowMut(LOG, (log: rt.ByteVec): undefined => { rt.byteVecPush(log, self.tag); }); } diff --git a/ts/fixtures/lang/expected/slices.Noisy.ts b/ts/fixtures/lang/slices/expected/slices.Noisy.ts similarity index 76% rename from ts/fixtures/lang/expected/slices.Noisy.ts rename to ts/fixtures/lang/slices/expected/slices.Noisy.ts index b488dc67c..77c872292 100644 --- a/ts/fixtures/lang/expected/slices.Noisy.ts +++ b/ts/fixtures/lang/slices/expected/slices.Noisy.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { LOG as slices_LOG } from "./slices.ts"; +import { LOG } from "./slices.ts"; /** * Logs its tag with the high bit set as it is cloned, into a clone one higher, and logs @@ -20,14 +20,14 @@ export class Noisy { } export function clone$Clone(self: Noisy): Noisy { - rt.localKeyWithBorrowMut(slices_LOG, (log: rt.ByteVec): undefined => { + rt.localKeyWithBorrowMut(LOG, (log: rt.ByteVec): undefined => { rt.byteVecPush(log, self.tag | 128); }); return new Noisy(rt.u8WrappingAdd(self.tag, 1)); } export function drop$ops_Drop(self: Noisy): void { - rt.localKeyWithBorrowMut(slices_LOG, (log: rt.ByteVec): undefined => { + rt.localKeyWithBorrowMut(LOG, (log: rt.ByteVec): undefined => { rt.byteVecPush(log, self.tag); }); } diff --git a/ts/fixtures/lang/expected/slices.Pair.ts b/ts/fixtures/lang/slices/expected/slices.Pair.ts similarity index 100% rename from ts/fixtures/lang/expected/slices.Pair.ts rename to ts/fixtures/lang/slices/expected/slices.Pair.ts diff --git a/ts/fixtures/lang/expected/slices.ts b/ts/fixtures/lang/slices/expected/slices.ts similarity index 86% rename from ts/fixtures/lang/expected/slices.ts rename to ts/fixtures/lang/slices/expected/slices.ts index fedd95002..0685e7bbc 100644 --- a/ts/fixtures/lang/expected/slices.ts +++ b/ts/fixtures/lang/slices/expected/slices.ts @@ -3,10 +3,10 @@ import * as rt from "./rt.ts"; import { copy$slices_Pair } from "./lib.ts"; import { map$1wqzuhy as option_map$1wqzuhy, map$0c2keyb as option_map$0c2keyb, map$11y9s7r as option_map$11y9s7r, map$0qyyft9 as option_map$0qyyft9, map$1xk4yz1 as option_map$1xk4yz1, map$003seos as option_map$003seos, map$0a57co2 as option_map$0a57co2, mapOr$189goit as option_mapOr$189goit, clone$1omlcob as option_clone$1omlcob } from "./core/option.ts"; -import * as slices_Counted from "./slices.Counted.ts"; -import * as slices_Item from "./slices.Item.ts"; -import * as slices_Noisy from "./slices.Noisy.ts"; -import * as slices_Pair from "./slices.Pair.ts"; +import * as Counted from "./slices.Counted.ts"; +import * as Item from "./slices.Item.ts"; +import * as Noisy from "./slices.Noisy.ts"; +import * as Pair from "./slices.Pair.ts"; export const LOG: rt.LocalKey> = /* @__PURE__ */ new rt.LocalKey(LOG$init, false); @@ -174,7 +174,7 @@ export function scribbleWords(i: rt.usize, chunk: rt.u16[]): void { } } -export function scribblePairs(i: rt.usize, chunk: slices_Pair.Pair[]): void { +export function scribblePairs(i: rt.usize, chunk: Pair.Pair[]): void { const n: rt.usize = chunk.length; rt.idx(chunk, 0); const _5: rt.u8 = rt.u8WrappingAdd(chunk[0].a, i & 0xff); @@ -184,16 +184,16 @@ export function scribblePairs(i: rt.usize, chunk: slices_Pair.Pair[]): void { rt.idx(chunk, _19); const _17: rt.u8 = chunk[_19].b & 0xff; rt.idx(chunk, 0); - const _16: slices_Pair.Pair = { a: _17, b: chunk[0].a as rt.u16 }; + const _16: Pair.Pair = { a: _17, b: chunk[0].a as rt.u16 }; const _30: rt.usize = rt.usizeSub(n, 1); rt.idx(chunk, _30); chunk[_30] = _16; - rt.sliceSort(chunk, rt.cmpLt(slices_Pair.partialCmp$cmp_PartialOrd), 4, true); + rt.sliceSort(chunk, rt.cmpLt(Pair.partialCmp$cmp_PartialOrd), 4, true); rt.sliceSwap(chunk, 0, rt.usizeDiv(n, 2)); } -export function digestPairs(part: slices_Pair.Pair[]): rt.u8 { - return rt.iterFold(rt.iterSlice(part), part.length & 0xff, (acc: rt.u8, p: slices_Pair.Pair): rt.u8 => { +export function digestPairs(part: Pair.Pair[]): rt.u8 { + return rt.iterFold(rt.iterSlice(part), part.length & 0xff, (acc: rt.u8, p: Pair.Pair): rt.u8 => { return rt.u8WrappingMul(acc, 31) ^ p.a ^ ((p.b >> 4) & 0xff); }); } @@ -209,7 +209,7 @@ export function chunked(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const words: rt.u16[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): rt.u16 => { return rt.u16Mul(_2 as rt.u16, 257); }), undefined, 2, true); - const pairs: slices_Pair.Pair[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_25: rt.u8): slices_Pair.Pair => { + const pairs: Pair.Pair[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_25: rt.u8): Pair.Pair => { const b2: rt.u8 = _25; return { a: b2, b: rt.u16Mul(b2 as rt.u16, 3) }; }), undefined, 4, true); @@ -395,43 +395,43 @@ export function chunked(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void } rt.byteVecPush(out, rt.iterCount(rt.sliceChunksMut(words, size)) & 0xff); rt.byteVecPush(out, digestWords(words)); - const iter5: rt.Iter<[rt.usize, slices_Pair.Pair[]]> = rt.iterEnumerate(rt.sliceChunksMut(pairs, size)); + const iter5: rt.Iter<[rt.usize, Pair.Pair[]]> = rt.iterEnumerate(rt.sliceChunksMut(pairs, size)); while (true) { - const _553: [rt.usize, slices_Pair.Pair[]] | rt.Done = iter5.next(); + const _553: [rt.usize, Pair.Pair[]] | rt.Done = iter5.next(); if (_553 === rt.DONE) { break; } scribblePairs(_553[0], _553[1]); } rt.byteVecPush(out, digestPairs(pairs)); - const held3: slices_Pair.Pair[][] = rt.iterToArray(rt.sliceChunksMut(pairs, size), undefined, 8, true); - const iter6: rt.Iter<[rt.usize, rt.Place]> = rt.iterRev(rt.iterEnumerate(rt.iterSliceMut(held3))); + const held3: Pair.Pair[][] = rt.iterToArray(rt.sliceChunksMut(pairs, size), undefined, 8, true); + const iter6: rt.Iter<[rt.usize, rt.Place]> = rt.iterRev(rt.iterEnumerate(rt.iterSliceMut(held3))); while (true) { - const _574: [rt.usize, rt.Place] | rt.Done = iter6.next(); + const _574: [rt.usize, rt.Place] | rt.Done = iter6.next(); if (_574 === rt.DONE) { break; } scribblePairs(rt.usizeAdd(_574[0], 7), _574[1].v); } - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held3), (c12: slices_Pair.Pair[]): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held3), (c12: Pair.Pair[]): rt.u8 => { return digestPairs(c12); }), undefined, true); - const it11: rt.Iter = rt.sliceChunksMut(pairs, size); + const it11: rt.Iter = rt.sliceChunksMut(pairs, size); rt.byteVecPush(out, it11.len() & 0xff); - const _594: slices_Pair.Pair[] | undefined = rt.iterToOption(it11.nextBack()); + const _594: Pair.Pair[] | undefined = rt.iterToOption(it11.nextBack()); if (_594 !== undefined) { scribblePairs(1, _594); } - const _599: slices_Pair.Pair[] | undefined = rt.iterNth(it11, 1); + const _599: Pair.Pair[] | undefined = rt.iterNth(it11, 1); if (_599 !== undefined) { scribblePairs(2, _599); } - const _604: slices_Pair.Pair[] | undefined = rt.iterNthBack(it11, 1); + const _604: Pair.Pair[] | undefined = rt.iterNthBack(it11, 1); if (_604 !== undefined) { scribblePairs(3, _604); } rt.byteVecPush(out, it11.len() & 0xff); - const _613: slices_Pair.Pair[] | undefined = rt.iterLast(it11); + const _613: Pair.Pair[] | undefined = rt.iterLast(it11); if (_613 !== undefined) { scribblePairs(4, _613); } @@ -522,43 +522,43 @@ export function chunked(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void } rt.byteVecPush(out, rt.iterCount(rt.sliceChunksExactMut(words, size)) & 0xff); rt.byteVecPush(out, digestWords(words)); - const iter11: rt.Iter<[rt.usize, slices_Pair.Pair[]]> = rt.iterEnumerate(rt.sliceChunksExactMut(pairs, size)); + const iter11: rt.Iter<[rt.usize, Pair.Pair[]]> = rt.iterEnumerate(rt.sliceChunksExactMut(pairs, size)); while (true) { - const _796: [rt.usize, slices_Pair.Pair[]] | rt.Done = iter11.next(); + const _796: [rt.usize, Pair.Pair[]] | rt.Done = iter11.next(); if (_796 === rt.DONE) { break; } scribblePairs(_796[0], _796[1]); } rt.byteVecPush(out, digestPairs(pairs)); - const held6: slices_Pair.Pair[][] = rt.iterToArray(rt.sliceChunksExactMut(pairs, size), undefined, 8, true); - const iter12: rt.Iter<[rt.usize, rt.Place]> = rt.iterRev(rt.iterEnumerate(rt.iterSliceMut(held6))); + const held6: Pair.Pair[][] = rt.iterToArray(rt.sliceChunksExactMut(pairs, size), undefined, 8, true); + const iter12: rt.Iter<[rt.usize, rt.Place]> = rt.iterRev(rt.iterEnumerate(rt.iterSliceMut(held6))); while (true) { - const _817: [rt.usize, rt.Place] | rt.Done = iter12.next(); + const _817: [rt.usize, rt.Place] | rt.Done = iter12.next(); if (_817 === rt.DONE) { break; } scribblePairs(rt.usizeAdd(_817[0], 7), _817[1].v); } - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held6), (c9: slices_Pair.Pair[]): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held6), (c9: Pair.Pair[]): rt.u8 => { return digestPairs(c9); }), undefined, true); - const it14: rt.Iter = rt.sliceChunksExactMut(pairs, size); + const it14: rt.Iter = rt.sliceChunksExactMut(pairs, size); rt.byteVecPush(out, it14.len() & 0xff); - const _837: slices_Pair.Pair[] | undefined = rt.iterToOption(it14.nextBack()); + const _837: Pair.Pair[] | undefined = rt.iterToOption(it14.nextBack()); if (_837 !== undefined) { scribblePairs(1, _837); } - const _842: slices_Pair.Pair[] | undefined = rt.iterNth(it14, 1); + const _842: Pair.Pair[] | undefined = rt.iterNth(it14, 1); if (_842 !== undefined) { scribblePairs(2, _842); } - const _847: slices_Pair.Pair[] | undefined = rt.iterNthBack(it14, 1); + const _847: Pair.Pair[] | undefined = rt.iterNthBack(it14, 1); if (_847 !== undefined) { scribblePairs(3, _847); } rt.byteVecPush(out, it14.len() & 0xff); - const _856: slices_Pair.Pair[] | undefined = rt.iterLast(it14); + const _856: Pair.Pair[] | undefined = rt.iterLast(it14); if (_856 !== undefined) { scribblePairs(4, _856); } @@ -577,7 +577,7 @@ export function chunked(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void } _888.v = rt.u16WrappingAdd(_888.v, 1); } - const _894: slices_Pair.Pair | undefined = rt.sliceFirst(rt.partsRemainder(rt.sliceChunksExactMut(pairs, size))); + const _894: Pair.Pair | undefined = rt.sliceFirst(rt.partsRemainder(rt.sliceChunksExactMut(pairs, size))); if (_894 !== undefined) { Object.assign(_894, { a: 238, b: 61166 }); } @@ -666,43 +666,43 @@ export function chunked(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void } rt.byteVecPush(out, rt.iterCount(rt.sliceRchunksMut(words, size)) & 0xff); rt.byteVecPush(out, digestWords(words)); - const iter18: rt.Iter<[rt.usize, slices_Pair.Pair[]]> = rt.iterEnumerate(rt.sliceRchunksMut(pairs, size)); + const iter18: rt.Iter<[rt.usize, Pair.Pair[]]> = rt.iterEnumerate(rt.sliceRchunksMut(pairs, size)); while (true) { - const _1070: [rt.usize, slices_Pair.Pair[]] | rt.Done = iter18.next(); + const _1070: [rt.usize, Pair.Pair[]] | rt.Done = iter18.next(); if (_1070 === rt.DONE) { break; } scribblePairs(_1070[0], _1070[1]); } rt.byteVecPush(out, digestPairs(pairs)); - const held9: slices_Pair.Pair[][] = rt.iterToArray(rt.sliceRchunksMut(pairs, size), undefined, 8, true); - const iter19: rt.Iter<[rt.usize, rt.Place]> = rt.iterRev(rt.iterEnumerate(rt.iterSliceMut(held9))); + const held9: Pair.Pair[][] = rt.iterToArray(rt.sliceRchunksMut(pairs, size), undefined, 8, true); + const iter19: rt.Iter<[rt.usize, rt.Place]> = rt.iterRev(rt.iterEnumerate(rt.iterSliceMut(held9))); while (true) { - const _1091: [rt.usize, rt.Place] | rt.Done = iter19.next(); + const _1091: [rt.usize, rt.Place] | rt.Done = iter19.next(); if (_1091 === rt.DONE) { break; } scribblePairs(rt.usizeAdd(_1091[0], 7), _1091[1].v); } - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held9), (c6: slices_Pair.Pair[]): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held9), (c6: Pair.Pair[]): rt.u8 => { return digestPairs(c6); }), undefined, true); - const it19: rt.Iter = rt.sliceRchunksMut(pairs, size); + const it19: rt.Iter = rt.sliceRchunksMut(pairs, size); rt.byteVecPush(out, it19.len() & 0xff); - const _1111: slices_Pair.Pair[] | undefined = rt.iterToOption(it19.nextBack()); + const _1111: Pair.Pair[] | undefined = rt.iterToOption(it19.nextBack()); if (_1111 !== undefined) { scribblePairs(1, _1111); } - const _1116: slices_Pair.Pair[] | undefined = rt.iterNth(it19, 1); + const _1116: Pair.Pair[] | undefined = rt.iterNth(it19, 1); if (_1116 !== undefined) { scribblePairs(2, _1116); } - const _1121: slices_Pair.Pair[] | undefined = rt.iterNthBack(it19, 1); + const _1121: Pair.Pair[] | undefined = rt.iterNthBack(it19, 1); if (_1121 !== undefined) { scribblePairs(3, _1121); } rt.byteVecPush(out, it19.len() & 0xff); - const _1130: slices_Pair.Pair[] | undefined = rt.iterLast(it19); + const _1130: Pair.Pair[] | undefined = rt.iterLast(it19); if (_1130 !== undefined) { scribblePairs(4, _1130); } @@ -793,43 +793,43 @@ export function chunked(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void } rt.byteVecPush(out, rt.iterCount(rt.sliceRchunksExactMut(words, size)) & 0xff); rt.byteVecPush(out, digestWords(words)); - const iter24: rt.Iter<[rt.usize, slices_Pair.Pair[]]> = rt.iterEnumerate(rt.sliceRchunksExactMut(pairs, size)); + const iter24: rt.Iter<[rt.usize, Pair.Pair[]]> = rt.iterEnumerate(rt.sliceRchunksExactMut(pairs, size)); while (true) { - const _1313: [rt.usize, slices_Pair.Pair[]] | rt.Done = iter24.next(); + const _1313: [rt.usize, Pair.Pair[]] | rt.Done = iter24.next(); if (_1313 === rt.DONE) { break; } scribblePairs(_1313[0], _1313[1]); } rt.byteVecPush(out, digestPairs(pairs)); - const held12: slices_Pair.Pair[][] = rt.iterToArray(rt.sliceRchunksExactMut(pairs, size), undefined, 8, true); - const iter25: rt.Iter<[rt.usize, rt.Place]> = rt.iterRev(rt.iterEnumerate(rt.iterSliceMut(held12))); + const held12: Pair.Pair[][] = rt.iterToArray(rt.sliceRchunksExactMut(pairs, size), undefined, 8, true); + const iter25: rt.Iter<[rt.usize, rt.Place]> = rt.iterRev(rt.iterEnumerate(rt.iterSliceMut(held12))); while (true) { - const _1334: [rt.usize, rt.Place] | rt.Done = iter25.next(); + const _1334: [rt.usize, rt.Place] | rt.Done = iter25.next(); if (_1334 === rt.DONE) { break; } scribblePairs(rt.usizeAdd(_1334[0], 7), _1334[1].v); } - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held12), (c3: slices_Pair.Pair[]): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held12), (c3: Pair.Pair[]): rt.u8 => { return digestPairs(c3); }), undefined, true); - const it22: rt.Iter = rt.sliceRchunksExactMut(pairs, size); + const it22: rt.Iter = rt.sliceRchunksExactMut(pairs, size); rt.byteVecPush(out, it22.len() & 0xff); - const _1354: slices_Pair.Pair[] | undefined = rt.iterToOption(it22.nextBack()); + const _1354: Pair.Pair[] | undefined = rt.iterToOption(it22.nextBack()); if (_1354 !== undefined) { scribblePairs(1, _1354); } - const _1359: slices_Pair.Pair[] | undefined = rt.iterNth(it22, 1); + const _1359: Pair.Pair[] | undefined = rt.iterNth(it22, 1); if (_1359 !== undefined) { scribblePairs(2, _1359); } - const _1364: slices_Pair.Pair[] | undefined = rt.iterNthBack(it22, 1); + const _1364: Pair.Pair[] | undefined = rt.iterNthBack(it22, 1); if (_1364 !== undefined) { scribblePairs(3, _1364); } rt.byteVecPush(out, it22.len() & 0xff); - const _1373: slices_Pair.Pair[] | undefined = rt.iterLast(it22); + const _1373: Pair.Pair[] | undefined = rt.iterLast(it22); if (_1373 !== undefined) { scribblePairs(4, _1373); } @@ -905,22 +905,22 @@ export function pokeWords(i: rt.usize, s: rt.u16[]): void { } } -export function pokePairs(i: rt.usize, s: slices_Pair.Pair[]): void { - const _3: slices_Pair.Pair | undefined = rt.sliceFirst(s); +export function pokePairs(i: rt.usize, s: Pair.Pair[]): void { + const _3: Pair.Pair | undefined = rt.sliceFirst(s); if (_3 !== undefined) { _3.a = rt.u8WrappingAdd(_3.a, i & 0xff); } - const _9: slices_Pair.Pair | undefined = rt.sliceLast(s); + const _9: Pair.Pair | undefined = rt.sliceLast(s); if (_9 !== undefined) { Object.assign(_9, { a: _9.b & 0xff, b: rt.u16Mul(_9.a as rt.u16, 7) }); } - rt.sliceSort(s, rt.cmpLt(slices_Pair.partialCmp$cmp_PartialOrd), 4, true); + rt.sliceSort(s, rt.cmpLt(Pair.partialCmp$cmp_PartialOrd), 4, true); if (s.length > 1) { rt.sliceSwap(s, 0, rt.usizeDiv(s.length, 2)); } - const iter: rt.Iter = rt.iterSlice(s); + const iter: rt.Iter = rt.iterSlice(s); while (true) { - const _31: slices_Pair.Pair | rt.Done = iter.next(); + const _31: Pair.Pair | rt.Done = iter.next(); if (_31 === rt.DONE) { break; } @@ -958,7 +958,7 @@ export function subslices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi const words: rt.u16[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 2))), (_2: rt.u8): rt.u16 => { return rt.u16Mul(_2 as rt.u16, 257); }), undefined, 2, true); - const pairs: slices_Pair.Pair[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 2))), (_23: rt.u8): slices_Pair.Pair => { + const pairs: Pair.Pair[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 2))), (_23: rt.u8): Pair.Pair => { const b4: rt.u8 = _23; return { a: b4, b: rt.u16Mul(b4 as rt.u16, 3) }; }), undefined, 4, true); @@ -992,8 +992,8 @@ export function subslices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi if (_95 !== undefined) { _95.v = 48879; } - const outer2: slices_Pair.Pair[] = rt.sliceRangeMut(pairs, 0, b); - const inner: slices_Pair.Pair[] = rt.sliceRangeMut(outer2, rt.usizeDiv(a, 2)); + const outer2: Pair.Pair[] = rt.sliceRangeMut(pairs, 0, b); + const inner: Pair.Pair[] = rt.sliceRangeMut(outer2, rt.usizeDiv(a, 2)); pokePairs(3, rt.sliceRangeMut(inner, rt.min(1, inner.length))); outer2.reverse(); } else if (_45 === 3) { @@ -1008,10 +1008,10 @@ export function subslices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi _119[1].v = swapped2; } } - const _129: [slices_Pair.Pair[], slices_Pair.Pair[]] = rt.sliceSplitAtMut(pairs, b); + const _129: [Pair.Pair[], Pair.Pair[]] = rt.sliceSplitAtMut(pairs, b); pokePairs(4, _129[1]); pokePairs(5, _129[0]); - const _134: [slices_Pair.Pair | undefined, slices_Pair.Pair | undefined] = [rt.sliceFirst(_129[0]), rt.sliceLast(_129[1])]; + const _134: [Pair.Pair | undefined, Pair.Pair | undefined] = [rt.sliceFirst(_129[0]), rt.sliceLast(_129[1])]; if (_134[0] !== undefined) { if (_134[1] !== undefined) { const swapped3 = rt.replaceIn(_134[1], _134[0]); @@ -1030,10 +1030,10 @@ export function subslices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi pokeWords(7, _151[1]); } const n2: rt.usize = pairs.length; - const _163: [slices_Pair.Pair[], slices_Pair.Pair[]] = rt.sliceSplitAtMut(pairs, 0); + const _163: [Pair.Pair[], Pair.Pair[]] = rt.sliceSplitAtMut(pairs, 0); pokePairs(6, _163[1]); rt.byteVecPush(out, _163[0].length & 0xff); - const _173: [slices_Pair.Pair[], slices_Pair.Pair[]] = rt.sliceSplitAtMut(pairs, n2); + const _173: [Pair.Pair[], Pair.Pair[]] = rt.sliceSplitAtMut(pairs, n2); pokePairs(7, _173[0]); rt.byteVecPush(out, _173[1].length & 0xff); const n3: rt.usize = words.length; @@ -1059,16 +1059,16 @@ export function subslices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi _227[0].v = _221[0].v; } } - const _231: [slices_Pair.Pair, slices_Pair.Pair[]] | undefined = rt.sliceSplitFirstMut(pairs, false); + const _231: [Pair.Pair, Pair.Pair[]] | undefined = rt.sliceSplitFirstMut(pairs, false); if (_231 !== undefined) { _231[0].b = _231[1].length & 0xffff; pokePairs(8, _231[1]); - const _240: slices_Pair.Pair | undefined = rt.sliceFirst(_231[1]); + const _240: Pair.Pair | undefined = rt.sliceFirst(_231[1]); if (_240 !== undefined) { Object.assign(_231[0], copy$slices_Pair(_240)); } } - const _244: [slices_Pair.Pair, slices_Pair.Pair[]] | undefined = rt.sliceSplitLastMut(pairs, false); + const _244: [Pair.Pair, Pair.Pair[]] | undefined = rt.sliceSplitLastMut(pairs, false); if (_244 !== undefined) { Object.assign(_244[0], { a: 1, b: 2 }); pokePairs(9, _244[1]); @@ -1087,7 +1087,7 @@ export function subslices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi _261[_261.length - 1] = swapped; pokeWords(13, view); } - const _271: slices_Pair.Pair[] = pairs; + const _271: Pair.Pair[] = pairs; if (_271.length >= 1) { pokePairs(10, rt.sliceView(_271, 0, _271.length - 1)); } @@ -1151,8 +1151,8 @@ export function drains(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const _14: [rt.usize, rt.usize] = [rt.usizeRem(data.data[data.start] as rt.usize, reach), rt.usizeRem(data.data[data.start + 1] as rt.usize, reach)]; const a: rt.usize = _14[0]; const b: rt.usize = _14[1]; - const items: slices_Item.Item[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 2))), (_2: rt.u8): slices_Item.Item => { - return new slices_Item.Item(_2); + const items: Item.Item[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 2))), (_2: rt.u8): Item.Item => { + return new Item.Item(_2); }), undefined, 1, true); const bytes: rt.ByteVec = rt.byteSliceToByteVec(rt.byteSliceRange(data, 2)); const words: rt.u32[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 2))), (_23: rt.u8): rt.u32 => { @@ -1160,13 +1160,13 @@ export function drains(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { }), undefined, 4, true); const _31: rt.u8 = rt.u8Rem(kind, 8); if (_31 === 0) { - const iter: rt.Iter = rt.vecDrain(items, new rt.Range(a, b), rt.drop); + const iter: rt.Iter = rt.vecDrain(items, new rt.Range(a, b), rt.drop); while (true) { - const _38: slices_Item.Item | rt.Done = iter.next(); + const _38: Item.Item | rt.Done = iter.next(); if (_38 === rt.DONE) { break; } - const x: slices_Item.Item = _38; + const x: Item.Item = _38; rt.byteVecPush(out, x.tag); flush(out); x[Symbol.dispose](); @@ -1178,13 +1178,13 @@ export function drains(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { }), "fold", true); } else if (_31 === 1) { const _56: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.usizeStep); - const drain: rt.Iter = rt.vecDrain(items, _56, rt.drop); - rt.iterExtendBytes(out, rt.iterOption(option_map$003seos(rt.iterToOption(drain.next()), (x9: slices_Item.Item): rt.u8 => { + const drain: rt.Iter = rt.vecDrain(items, _56, rt.drop); + rt.iterExtendBytes(out, rt.iterOption(option_map$003seos(rt.iterToOption(drain.next()), (x9: Item.Item): rt.u8 => { const _011: rt.u8 = x9.tag; x9[Symbol.dispose](); return _011; })), undefined, true); - rt.iterExtendBytes(out, rt.iterOption(option_map$003seos(rt.iterToOption(drain.nextBack()), (x10: slices_Item.Item): rt.u8 => { + rt.iterExtendBytes(out, rt.iterOption(option_map$003seos(rt.iterToOption(drain.nextBack()), (x10: Item.Item): rt.u8 => { const _012: rt.u8 = x10.tag; x10[Symbol.dispose](); return _012; @@ -1203,22 +1203,22 @@ export function drains(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { })), undefined, true); rt.drop(drain3); } else if (_31 === 2) { - const taken: slices_Item.Item[] = rt.iterToArray(rt.vecDrain(items, { end: b }, rt.drop), "fold", 1, true); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(taken), (x8: slices_Item.Item): rt.u8 => { + const taken: Item.Item[] = rt.iterToArray(rt.vecDrain(items, { end: b }, rt.drop), "fold", 1, true); + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(taken), (x8: Item.Item): rt.u8 => { return x8.tag; }), undefined, true); rt.dropAll(taken); rt.iterExtendBytes(out, rt.byteVecIntoIter(rt.iterToByteVec(rt.byteVecDrain(bytes, { end: b }), "fold", true)), undefined, true); rt.drop(rt.vecDrain(words, { end: b })); } else if (_31 === 3) { - const drain4: rt.Iter = rt.vecDrain(items, new rt.RangeFrom(a, rt.usizeStep), rt.drop); - rt.iterExtendBytes(out, rt.iterOption(option_map$003seos(rt.iterNth(drain4, 1, rt.drop), (x6: slices_Item.Item): rt.u8 => { + const drain4: rt.Iter = rt.vecDrain(items, new rt.RangeFrom(a, rt.usizeStep), rt.drop); + rt.iterExtendBytes(out, rt.iterOption(option_map$003seos(rt.iterNth(drain4, 1, rt.drop), (x6: Item.Item): rt.u8 => { const _07: rt.u8 = x6.tag; x6[Symbol.dispose](); return _07; })), undefined, true); flush(out); - rt.iterExtendBytes(out, rt.iterOption(option_map$003seos(rt.iterNthBack(drain4, 1, rt.drop), (x7: slices_Item.Item): rt.u8 => { + rt.iterExtendBytes(out, rt.iterOption(option_map$003seos(rt.iterNthBack(drain4, 1, rt.drop), (x7: Item.Item): rt.u8 => { const _08: rt.u8 = x7.tag; x7[Symbol.dispose](); return _08; @@ -1233,7 +1233,7 @@ export function drains(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { return w & 0xff; }), "fold", true); } else if (_31 === 4) { - rt.iterExtendBytes(out, rt.iterOption(option_map$003seos(rt.ownedLast(rt.vecDrain(items, undefined, rt.drop), rt.drop), (x5: slices_Item.Item): rt.u8 => { + rt.iterExtendBytes(out, rt.iterOption(option_map$003seos(rt.ownedLast(rt.vecDrain(items, undefined, rt.drop), rt.drop), (x5: Item.Item): rt.u8 => { const _06: rt.u8 = x5.tag; x5[Symbol.dispose](); return _06; @@ -1241,7 +1241,7 @@ export function drains(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.iterExtendBytes(out, rt.iterOption(rt.ownedLast(rt.byteVecDrain(bytes, undefined))), undefined, true); rt.byteVecPush(out, rt.ownedCount(rt.vecDrain(words, undefined)) & 0xff); } else if (_31 === 5) { - rt.iterExtendBytes(out, rt.iterOption(option_map$003seos(rt.iterToOption(rt.vecDrain(items, new rt.Range(a, b), rt.drop).next()), (x4: slices_Item.Item): rt.u8 => { + rt.iterExtendBytes(out, rt.iterOption(option_map$003seos(rt.iterToOption(rt.vecDrain(items, new rt.Range(a, b), rt.drop).next()), (x4: Item.Item): rt.u8 => { const _05: rt.u8 = x4.tag; x4[Symbol.dispose](); return _05; @@ -1251,13 +1251,13 @@ export function drains(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } else if (_31 === 6) { rt.byteVecPush(out, rt.ownedCount(rt.vecDrain(items, new rt.Range(a, b), rt.drop), rt.drop) & 0xff); } else { - const kept: slices_Item.Item[] = [new slices_Item.Item(238)]; - const _181: rt.Iter = rt.iterFilter(rt.vecDrain(items, new rt.Range(a, b), rt.drop), (x2: slices_Item.Item): boolean => { + const kept: Item.Item[] = [new Item.Item(238)]; + const _181: rt.Iter = rt.iterFilter(rt.vecDrain(items, new rt.Range(a, b), rt.drop), (x2: Item.Item): boolean => { return rt.u8Rem(x2.tag, 2) === 0; }, rt.drop); rt.iterExtend(kept, _181, "next", 1); flush(out); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(kept), (x3: slices_Item.Item): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(kept), (x3: Item.Item): rt.u8 => { return x3.tag; }), undefined, true); const other: rt.ByteVec = rt.byteVecFrom(Uint8Array.of(238)); @@ -1267,7 +1267,7 @@ export function drains(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.dropAll(kept); } flush(out); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(items), (x11: slices_Item.Item): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(items), (x11: Item.Item): rt.u8 => { return x11.tag; }), undefined, true); rt.byteVecPush(out, items.length & 0xff); @@ -1275,7 +1275,7 @@ export function drains(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(words), (_26: rt.u32): rt.u8 => { return _26 & 0xff; }), undefined, true); - items.push(new slices_Item.Item(255)); + items.push(new Item.Item(255)); rt.dropAll(items); flush(out); } @@ -1338,7 +1338,7 @@ export function ranges(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const words: rt.u16[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 2))), (_2: rt.u8): rt.u16 => { return rt.u16Mul(_2 as rt.u16, 257); }), undefined, 2, true); - const pairs: slices_Pair.Pair[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 2))), (_22: rt.u8): slices_Pair.Pair => { + const pairs: Pair.Pair[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 2))), (_22: rt.u8): Pair.Pair => { const b4: rt.u8 = _22; return { a: b4, b: rt.u16Mul(b4 as rt.u16, 3) }; }), undefined, 4, true); @@ -1465,14 +1465,14 @@ export function ranges(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _173 = digestWords(_174); } rt.byteVecPush(out, _173); - const _182: slices_Pair.Pair[] | undefined = rt.sliceGetRange(pairs, a); + const _182: Pair.Pair[] | undefined = rt.sliceGetRange(pairs, a); if (_182 === undefined) { _181 = 238; } else { _181 = digestPairs(_182); } rt.byteVecPush(out, _181); - const _190: slices_Pair.Pair[] | undefined = rt.sliceGetRange(pairs, 0, b); + const _190: Pair.Pair[] | undefined = rt.sliceGetRange(pairs, 0, b); if (_190 === undefined) { _189 = 238; } else { @@ -1520,15 +1520,15 @@ export function ranges(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (_236 !== undefined) { pokeWords(4, _236); } - const _245: slices_Pair.Pair[] = pairs; + const _245: Pair.Pair[] = pairs; const bounds14 = rt.sliceGetBounds(new rt.RangeInclusive(a, b, rt.usizeStep), _245.length); - const _244: slices_Pair.Pair[] | undefined = rt.sliceGetRangeMut(_245, bounds14[0], bounds14[1]); + const _244: Pair.Pair[] | undefined = rt.sliceGetRangeMut(_245, bounds14[0], bounds14[1]); if (_244 === undefined) { rt.byteVecPush(out, 238); } else { pokePairs(5, _244); } - const _250: slices_Pair.Pair[] | undefined = rt.sliceGetRangeMut(pairs, a); + const _250: Pair.Pair[] | undefined = rt.sliceGetRangeMut(pairs, a); if (_250 !== undefined) { pokePairs(6, _250); } @@ -1564,13 +1564,13 @@ export function ranges(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _296 = digest(_297); } rt.byteVecPush(out, _296); - const _307: slices_Pair.Pair[] = pairs; + const _307: Pair.Pair[] = pairs; const bounds8 = rt.sliceGetBounds(folded.clone(), _307.length); - const _306: slices_Pair.Pair[] | undefined = rt.sliceGetRangeMut(_307, bounds8[0], bounds8[1]); + const _306: Pair.Pair[] | undefined = rt.sliceGetRangeMut(_307, bounds8[0], bounds8[1]); if (_306 === undefined) { _305 = 238; } else { - _305 = ((p: slices_Pair.Pair[]): rt.u8 => { + _305 = ((p: Pair.Pair[]): rt.u8 => { return digestPairs(p); })(_306); } @@ -1600,9 +1600,9 @@ export function ranges(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _344 = digest(_345); } rt.byteVecPush(out, _344); - const _354: slices_Pair.Pair[] = pairs; + const _354: Pair.Pair[] = pairs; const bounds2 = rt.sliceGetBounds([lo, hi] as [rt.RangeBound, rt.RangeBound], _354.length); - const _353: slices_Pair.Pair[] | undefined = rt.sliceGetRange(_354, bounds2[0], bounds2[1]); + const _353: Pair.Pair[] | undefined = rt.sliceGetRange(_354, bounds2[0], bounds2[1]); if (_353 === undefined) { _352 = 238; } else { @@ -1639,7 +1639,7 @@ export function ranges(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.iterExtendBytes(out, rt.iterOption(option_map$1wqzuhy(rt.sliceLastChunk(words, 0), (c7: rt.u16[]): rt.u8 => { return digestWords(c7); })), undefined, true); - rt.iterExtendBytes(out, rt.iterOption(option_map$11y9s7r(rt.sliceLastChunk(pairs, 3), (c8: slices_Pair.Pair[]): rt.u8 => { + rt.iterExtendBytes(out, rt.iterOption(option_map$11y9s7r(rt.sliceLastChunk(pairs, 3), (c8: Pair.Pair[]): rt.u8 => { return digestPairs(c8); })), undefined, true); const slice: rt.ByteSlice = rt.byteVecSlice(bytes); @@ -1654,7 +1654,7 @@ export function ranges(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (_428 !== undefined) { rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(digestWords(_428[0]), digestWords(_428[1]))), undefined, true); } - const _439: [slices_Pair.Pair[], slices_Pair.Pair[]] | undefined = rt.sliceSplitLastChunk(pairs, 3); + const _439: [Pair.Pair[], Pair.Pair[]] | undefined = rt.sliceSplitLastChunk(pairs, 3); if (_439 !== undefined) { rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(digestPairs(_439[0]), digestPairs(_439[1]))), undefined, true); } @@ -1681,7 +1681,7 @@ export function ranges(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (_492 !== undefined) { pokeWords(11, _492); } - const _499: slices_Pair.Pair[] | undefined = rt.sliceLastChunkMut(pairs, 3); + const _499: Pair.Pair[] | undefined = rt.sliceLastChunkMut(pairs, 3); if (_499 !== undefined) { pokePairs(12, _499); _499[0].b = 9; @@ -1697,12 +1697,12 @@ export function ranges(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.sliceSwap(_519[1], 0, 3); _519[1][1] = 43981; } - const _530: [slices_Pair.Pair[], slices_Pair.Pair[]] | undefined = rt.sliceSplitAtMutChecked(pairs, 0); + const _530: [Pair.Pair[], Pair.Pair[]] | undefined = rt.sliceSplitAtMutChecked(pairs, 0); if (_530 !== undefined) { pokePairs(14, _530[0]); pokePairs(15, _530[1]); } - const _539: [slices_Pair.Pair[], slices_Pair.Pair[]] | undefined = rt.sliceSplitAtMutChecked(pairs, 2); + const _539: [Pair.Pair[], Pair.Pair[]] | undefined = rt.sliceSplitAtMutChecked(pairs, 2); if (_539 !== undefined) { rt.idx(_539[1], 0); const swapped = _539[0][0]; @@ -1748,15 +1748,15 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const words: rt.u16[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 3))), (_2: rt.u8): rt.u16 => { return rt.u16Mul(_2 as rt.u16, 257); }), undefined, 2, true); - const pairs: slices_Pair.Pair[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 3))), (_29: rt.u8): slices_Pair.Pair => { + const pairs: Pair.Pair[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 3))), (_29: rt.u8): Pair.Pair => { const b4: rt.u8 = _29; return { a: b4, b: rt.u16Mul(b4 as rt.u16, 3) }; }), undefined, 4, true); - const counted: slices_Counted.Counted[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 3))), (_211: rt.u8): slices_Counted.Counted => { + const counted: Counted.Counted[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 3))), (_211: rt.u8): Counted.Counted => { return { n: _211 }; }), undefined, 1, true); - const items: slices_Noisy.Noisy[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 3))), (_212: rt.u8): slices_Noisy.Noisy => { - return new slices_Noisy.Noisy(_212); + const items: Noisy.Noisy[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 3))), (_212: rt.u8): Noisy.Noisy => { + return new Noisy.Noisy(_212); }), undefined, 1, true); const array: rt.u32[] = Array.from({ length: 5 }, (): rt.u32 => { return 0; @@ -1776,35 +1776,35 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteSliceFill(rt.byteSliceRange(rt.byteVecSlice(bytes), part18), 90); rt.sliceRangeMut(words, 0, b).fill(rt.u16Mul(c & 0xffff, 257)); rt.sliceFill(pairs, { a: 1, b: 2 }, copy$slices_Pair); - const _81: slices_Pair.Pair | undefined = rt.sliceFirst(pairs); + const _81: Pair.Pair | undefined = rt.sliceFirst(pairs); if (_81 !== undefined) { _81.a = 9; } - const pair: slices_Pair.Pair = { a: 3, b: c & 0xffff }; + const pair: Pair.Pair = { a: 3, b: c & 0xffff }; rt.sliceFill(rt.sliceRangeMut(pairs, a, b), copy$slices_Pair(pair), copy$slices_Pair); - const _92: slices_Pair.Pair | undefined = rt.sliceGet(pairs, rt.usizeWrappingSub(b, 1)); + const _92: Pair.Pair | undefined = rt.sliceGet(pairs, rt.usizeWrappingSub(b, 1)); if (_92 !== undefined) { _92.b = _92.b ^ 1; } rt.byteVecPush(out, pair.b & 0xff); - rt.sliceFill(rt.sliceRangeMut(counted, 0, b), { n: 17 }, slices_Counted.clone$Clone); + rt.sliceFill(rt.sliceRangeMut(counted, 0, b), { n: 17 }, Counted.clone$Clone); flush(out); - rt.sliceFill(rt.sliceRangeMut(items, a), new slices_Noisy.Noisy(32), slices_Noisy.clone$Clone, rt.drop); + rt.sliceFill(rt.sliceRangeMut(items, a), new Noisy.Noisy(32), Noisy.clone$Clone, rt.drop); flush(out); - rt.sliceFill(rt.sliceRangeMut(items, 0, 0), new slices_Noisy.Noisy(48), slices_Noisy.clone$Clone, rt.drop); + rt.sliceFill(rt.sliceRangeMut(items, 0, 0), new Noisy.Noisy(48), Noisy.clone$Clone, rt.drop); flush(out); - rt.sliceFill(items, new slices_Noisy.Noisy(c & 0xff), slices_Noisy.clone$Clone, rt.drop); + rt.sliceFill(items, new Noisy.Noisy(c & 0xff), Noisy.clone$Clone, rt.drop); flush(out); rt.sliceRangeMut(array, rt.min(a, 5)).fill(c as rt.u32); - const opts: Array = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 3))), (_224: rt.u8): slices_Noisy.Noisy | undefined => { - return new slices_Noisy.Noisy(_224); + const opts: Array = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteSliceRange(data, 3))), (_224: rt.u8): Noisy.Noisy | undefined => { + return new Noisy.Noisy(_224); }), undefined, 2, true); - rt.sliceFill(rt.sliceRangeMut(opts, a), undefined as slices_Noisy.Noisy | undefined, option_clone$1omlcob, rt.drop); + rt.sliceFill(rt.sliceRangeMut(opts, a), undefined as Noisy.Noisy | undefined, option_clone$1omlcob, rt.drop); flush(out); - rt.sliceFill(opts, new slices_Noisy.Noisy(64), option_clone$1omlcob, rt.drop); + rt.sliceFill(opts, new Noisy.Noisy(64), option_clone$1omlcob, rt.drop); flush(out); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(opts), (o: slices_Noisy.Noisy | undefined): rt.u8 => { - return option_mapOr$189goit(o, 238, (x: slices_Noisy.Noisy): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(opts), (o: Noisy.Noisy | undefined): rt.u8 => { + return option_mapOr$189goit(o, 238, (x: Noisy.Noisy): rt.u8 => { return x.tag; }); }), undefined, true); @@ -1819,28 +1819,28 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { n = rt.u8WrappingMul(n, 5); return n as rt.u16; }); - rt.sliceFillWith(pairs, (): slices_Pair.Pair => { + rt.sliceFillWith(pairs, (): Pair.Pair => { n = n ^ 33; return { a: n, b: n as rt.u16 }; }); - rt.sliceFillWith(rt.sliceRangeMut(counted, a, b), (): slices_Counted.Counted => { + rt.sliceFillWith(rt.sliceRangeMut(counted, a, b), (): Counted.Counted => { return { n: 7 }; }); flush(out); let tag: rt.u8 = 96; - rt.sliceFillWith(rt.sliceRangeMut(items, a), (): slices_Noisy.Noisy => { + rt.sliceFillWith(rt.sliceRangeMut(items, a), (): Noisy.Noisy => { rt.localKeyWithBorrowMut(LOG, (log: rt.ByteVec): undefined => { rt.byteVecPush(log, 254); }); tag = rt.u8Add(tag, 1); - return new slices_Noisy.Noisy(tag); + return new Noisy.Noisy(tag); }, rt.drop); flush(out); - const held: slices_Noisy.Noisy = new slices_Noisy.Noisy(112); - const _184: slices_Noisy.Noisy[] = items; + const held: Noisy.Noisy = new Noisy.Noisy(112); + const _184: Noisy.Noisy[] = items; const captured = held; - const _186: () => slices_Noisy.Noisy = rt.closure((): slices_Noisy.Noisy => { - return new slices_Noisy.Noisy(captured.tag ^ 1); + const _186: () => Noisy.Noisy = rt.closure((): Noisy.Noisy => { + return new Noisy.Noisy(captured.tag ^ 1); }, (): void => { captured[Symbol.dispose](); }); @@ -1868,15 +1868,15 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } rt.sliceRotateLeft(_222[1], rt.usizeRem(_222[0], rt.usizeAdd(_222[1].length, 1))); } - const iter3: rt.Iter = rt.sliceChunksExactMut(pairs, size); + const iter3: rt.Iter = rt.sliceChunksExactMut(pairs, size); while (true) { - const _239: slices_Pair.Pair[] | rt.Done = iter3.next(); + const _239: Pair.Pair[] | rt.Done = iter3.next(); if (_239 === rt.DONE) { break; } rt.sliceRotateRight(_239, 1); } - const _246: [slices_Noisy.Noisy[], slices_Noisy.Noisy[]] = rt.sliceSplitAtMut(items, a); + const _246: [Noisy.Noisy[], Noisy.Noisy[]] = rt.sliceSplitAtMut(items, a); rt.sliceRotateRight(_246[0], 0); const n2: rt.usize = _246[1].length; rt.sliceRotateLeft(_246[1], n2); @@ -1893,11 +1893,11 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const _280: rt.u16[] = words; rt.sliceCopyWithin(_280, part10, _280.length, c); rt.sliceCopyWithin(pairs, 0, b, c, copy$slices_Pair); - const _287: slices_Pair.Pair | undefined = rt.sliceGet(pairs, c); + const _287: Pair.Pair | undefined = rt.sliceGet(pairs, c); if (_287 !== undefined) { _287.a = _287.a ^ 255; } - const _293: slices_Counted.Counted[] = counted; + const _293: Counted.Counted[] = counted; const bounds = rt.boundsRange(new rt.RangeInclusive(a, b, rt.usizeStep), _293.length); rt.sliceCopyWithin(_293, bounds[0], bounds[1], c); flush(out); @@ -1916,16 +1916,16 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const _320: [rt.u16[], rt.u16[]] = rt.sliceSplitAtMut(words, a); const n3: rt.usize = rt.min(_320[0].length, _320[1].length); rt.sliceCopyFromSlice(rt.sliceRangeMut(_320[0], 0, n3), rt.sliceRange(_320[1], 0, n3)); - const _336: [slices_Pair.Pair[], slices_Pair.Pair[]] = rt.sliceSplitAtMut(pairs, b); + const _336: [Pair.Pair[], Pair.Pair[]] = rt.sliceSplitAtMut(pairs, b); const n4: rt.usize = rt.min(_336[0].length, _336[1].length); rt.sliceCopyFromSlice(rt.sliceRangeMut(_336[1], 0, n4), rt.sliceRange(_336[0], 0, n4), copy$slices_Pair); - const _350: slices_Pair.Pair | undefined = rt.sliceFirst(_336[0]); + const _350: Pair.Pair | undefined = rt.sliceFirst(_336[0]); if (_350 !== undefined) { _350.b = 48879; } - const _357: slices_Counted.Counted[] = rt.sliceRangeMut(counted, a); + const _357: Counted.Counted[] = rt.sliceRangeMut(counted, a); const part8 = rt.usizeSub(rt.byteSliceRange(data, 3).length, a); - rt.sliceCopyFromSlice(_357, rt.sliceRange(rt.iterToArray(rt.iterMap(new rt.Range(0, c), (n9: rt.usize): slices_Counted.Counted => { + rt.sliceCopyFromSlice(_357, rt.sliceRange(rt.iterToArray(rt.iterMap(new rt.Range(0, c), (n9: rt.usize): Counted.Counted => { return { n: n9 & 0xff }; }), undefined, 1, true), 0, part8)); flush(out); @@ -1934,23 +1934,23 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { }); rt.sliceCopyFromSlice(more, rt.sliceRange(array, 0, 3)); rt.sliceCopyFromSlice(rt.sliceRangeMut(array, 2), more); - const source: slices_Pair.Pair[] = rt.vecFromElem({ a: 4, b: 5 }, c, copy$slices_Pair); + const source: Pair.Pair[] = rt.vecFromElem({ a: 4, b: 5 }, c, copy$slices_Pair); rt.sliceCopyFromSlice(rt.sliceRangeMut(pairs, 0, b), source, copy$slices_Pair); } else if (_60 === 6) { - const source2: slices_Noisy.Noisy[] = rt.iterToArray(rt.iterMap(new rt.Range(0, c), (tag3: rt.usize): slices_Noisy.Noisy => { - return new slices_Noisy.Noisy((tag3 & 0xff) | 80); + const source2: Noisy.Noisy[] = rt.iterToArray(rt.iterMap(new rt.Range(0, c), (tag3: rt.usize): Noisy.Noisy => { + return new Noisy.Noisy((tag3 & 0xff) | 80); }), undefined, 1, true); const n5: rt.usize = rt.min(rt.byteSliceRange(data, 3).length, c); - rt.sliceCloneFromSlice(rt.sliceRangeMut(items, 0, n5), rt.sliceRange(source2, 0, n5), slices_Noisy.clone$Clone, rt.drop); + rt.sliceCloneFromSlice(rt.sliceRangeMut(items, 0, n5), rt.sliceRange(source2, 0, n5), Noisy.clone$Clone, rt.drop); flush(out); - const _403: [slices_Counted.Counted[], slices_Counted.Counted[]] = rt.sliceSplitAtMut(counted, a); + const _403: [Counted.Counted[], Counted.Counted[]] = rt.sliceSplitAtMut(counted, a); const n6: rt.usize = rt.min(_403[0].length, _403[1].length); - rt.sliceCloneFromSlice(rt.sliceRangeMut(_403[0], 0, n6), rt.sliceRange(_403[1], 0, n6), slices_Counted.clone$Clone); + rt.sliceCloneFromSlice(rt.sliceRangeMut(_403[0], 0, n6), rt.sliceRange(_403[1], 0, n6), Counted.clone$Clone); flush(out); - const _420: [slices_Pair.Pair[], slices_Pair.Pair[]] = rt.sliceSplitAtMut(pairs, a); + const _420: [Pair.Pair[], Pair.Pair[]] = rt.sliceSplitAtMut(pairs, a); const n7: rt.usize = rt.min(_420[0].length, _420[1].length); rt.sliceCopyFromSlice(rt.sliceRangeMut(_420[1], 0, n7), rt.sliceRange(_420[0], 0, n7), copy$slices_Pair); - const _434: slices_Pair.Pair | undefined = rt.sliceFirst(_420[0]); + const _434: Pair.Pair | undefined = rt.sliceFirst(_420[0]); if (_434 !== undefined) { _434.b = 48879; } @@ -1958,14 +1958,14 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const _438: rt.u16[] = rt.sliceRangeMut(words, a); const _442: rt.u16[] = [7, 8, 9]; rt.sliceCopyFromSlice(_438, rt.sliceRange(_442, 0, part4)); - rt.sliceCloneFromSlice(rt.sliceRangeMut(items, a), rt.sliceRange(source2, 0, rt.min(b, c)), slices_Noisy.clone$Clone, rt.drop); + rt.sliceCloneFromSlice(rt.sliceRangeMut(items, a), rt.sliceRange(source2, 0, rt.min(b, c)), Noisy.clone$Clone, rt.drop); flush(out); rt.sliceCopyFromSlice(rt.sliceRangeMut(pairs, 0, c), [{ a: 1, b: 1 }, { a: 1, b: 1 }], copy$slices_Pair); rt.dropAll(source2); } else { - const iter4: rt.Iter<[rt.usize, slices_Pair.Pair[]]> = rt.iterEnumerate(rt.sliceChunksMut(pairs, size)); + const iter4: rt.Iter<[rt.usize, Pair.Pair[]]> = rt.iterEnumerate(rt.sliceChunksMut(pairs, size)); while (true) { - const _467: [rt.usize, slices_Pair.Pair[]] | rt.Done = iter4.next(); + const _467: [rt.usize, Pair.Pair[]] | rt.Done = iter4.next(); if (_467 === rt.DONE) { break; } @@ -1980,13 +1980,13 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.sliceRotateLeft(_467[1], 1); } } - const it: rt.Iter = rt.sliceRchunksExactMut(items, size); - const _480: [slices_Noisy.Noisy[] | undefined, slices_Noisy.Noisy[] | undefined] = [rt.iterToOption(it.next()), rt.iterToOption(it.next())]; + const it: rt.Iter = rt.sliceRchunksExactMut(items, size); + const _480: [Noisy.Noisy[] | undefined, Noisy.Noisy[] | undefined] = [rt.iterToOption(it.next()), rt.iterToOption(it.next())]; if (_480[0] !== undefined) { if (_480[1] !== undefined) { - rt.sliceCloneFromSlice(_480[0], _480[1], slices_Noisy.clone$Clone, rt.drop); + rt.sliceCloneFromSlice(_480[0], _480[1], Noisy.clone$Clone, rt.drop); rt.sliceRotateRight(_480[1], 1); - rt.sliceFill(_480[1], new slices_Noisy.Noisy(15), slices_Noisy.clone$Clone, rt.drop); + rt.sliceFill(_480[1], new Noisy.Noisy(15), Noisy.clone$Clone, rt.drop); } } flush(out); @@ -2000,7 +2000,7 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { return a & 0xffff; }); } - const _507: [slices_Counted.Counted[], slices_Counted.Counted[]] | undefined = rt.sliceSplitAtMutChecked(counted, 1); + const _507: [Counted.Counted[], Counted.Counted[]] | undefined = rt.sliceSplitAtMutChecked(counted, 1); if (_507 !== undefined) { rt.sliceCopyFromSlice(_507[0], rt.sliceRange(_507[1], 0, rt.min(1, _507[1].length))); } @@ -2013,10 +2013,10 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { return (w ^ (w >> 8)) & 0xff; }), undefined, true); rt.byteVecPush(out, digestPairs(pairs)); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(counted), (x2: slices_Counted.Counted): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(counted), (x2: Counted.Counted): rt.u8 => { return x2.n; }), undefined, true); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(items), (x3: slices_Noisy.Noisy): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(items), (x3: Noisy.Noisy): rt.u8 => { return x3.tag; }), undefined, true); rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(array), (_226: rt.u32): rt.u8 => { diff --git a/ts/fixtures/lang/slices/src/lib.rs b/ts/fixtures/lang/slices/src/lib.rs new file mode 100644 index 000000000..fc3ffe572 --- /dev/null +++ b/ts/fixtures/lang/slices/src/lib.rs @@ -0,0 +1,26 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod slices; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("slices::parts", slices::parts), + ("slices::drains", slices::drains), + ("slices::chunked", slices::chunked), + ("slices::subslices", slices::subslices), + ("slices::ranges", slices::ranges), + ("slices::edits", slices::edits), + ] +} diff --git a/ts/fixtures/lang/src/slices.rs b/ts/fixtures/lang/slices/src/slices.rs similarity index 100% rename from ts/fixtures/lang/src/slices.rs rename to ts/fixtures/lang/slices/src/slices.rs diff --git a/ts/fixtures/lang/slices/ts.toml b/ts/fixtures/lang/slices/ts.toml new file mode 100644 index 000000000..a4dbd303b --- /dev/null +++ b/ts/fixtures/lang/slices/ts.toml @@ -0,0 +1,2 @@ +package = "lang-slices-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/sorts/Cargo.toml b/ts/fixtures/lang/sorts/Cargo.toml new file mode 100644 index 000000000..a469d25ee --- /dev/null +++ b/ts/fixtures/lang/sorts/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-sorts-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/sorts/caller.ts b/ts/fixtures/lang/sorts/caller.ts new file mode 100644 index 000000000..4c0739714 --- /dev/null +++ b/ts/fixtures/lang/sorts/caller.ts @@ -0,0 +1,17 @@ +// The inputs `sorts`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `sorts` cases of each length std's thresholds part, of each run of keys; `disorders` + * cases of each length, kind of item, and sort; and `btrees` cases of each length. + */ +const sortCases = [ + ...Array.from({ length: 20 * 5 }, (_, i) => Uint8Array.of(...op("sorts::sorts"), i % 20, Math.floor(i / 20), 7, 1, 3)), + ...Array.from({ length: 160 }, (_, kind) => Uint8Array.of(...op("sorts::disorders"), kind, kind % 5, 0x5a, 0xc3, 0x0f, 7)), + ...Array.from({ length: 20 * 5 }, (_, i) => Uint8Array.of(...op("sorts::btrees"), i % 20, Math.floor(i / 20), 2, 9)), +]; + +export const cases: Uint8Array[] = [...sortCases]; diff --git a/ts/fixtures/lang/sorts/expected/core/option.ts b/ts/fixtures/lang/sorts/expected/core/option.ts new file mode 100644 index 000000000..07f3e7865 --- /dev/null +++ b/ts/fixtures/lang/sorts/expected/core/option.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function mapOr$1ttssgs(self: [rt.u8, rt.ByteSlice] | undefined, default_: [rt.u8, rt.ByteSlice], f: (a0: [rt.u8, rt.ByteSlice]) => [rt.u8, rt.ByteSlice]): [rt.u8, rt.ByteSlice] { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/sorts/expected/harness.ts b/ts/fixtures/lang/sorts/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/sorts/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/sorts/expected/lib.ts b/ts/fixtures/lang/sorts/expected/lib.ts new file mode 100644 index 000000000..3d8e272f3 --- /dev/null +++ b/ts/fixtures/lang/sorts/expected/lib.ts @@ -0,0 +1,18 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { sorts, disorders, btrees } from "./sorts.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["sorts::sorts", (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec): undefined => { + sorts(a0, a1.data, a1.start, a1.length, a2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["sorts::disorders", disorders as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["sorts::btrees", (a03: rt.u8, a13: rt.ByteSlice, a23: rt.ByteVec): undefined => { + btrees(a03, a13.data, a13.start, a13.length, a23); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/sorts.Held.ts b/ts/fixtures/lang/sorts/expected/sorts.Held.ts similarity index 100% rename from ts/fixtures/lang/expected/sorts.Held.ts rename to ts/fixtures/lang/sorts/expected/sorts.Held.ts diff --git a/ts/fixtures/lang/expected/sorts.Item.ts b/ts/fixtures/lang/sorts/expected/sorts.Item.ts similarity index 73% rename from ts/fixtures/lang/expected/sorts.Item.ts rename to ts/fixtures/lang/sorts/expected/sorts.Item.ts index ac461d1fc..e150d093e 100644 --- a/ts/fixtures/lang/expected/sorts.Item.ts +++ b/ts/fixtures/lang/sorts/expected/sorts.Item.ts @@ -1,8 +1,8 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { note as sorts_note } from "./sorts.ts"; -import type * as sorts_Held from "./sorts.Held.ts"; +import { note } from "./sorts.ts"; +import type * as Held from "./sorts.Held.ts"; /** Ordered by `key` alone, so `tag` tells equal ones apart, beside `pad`, which sizes it. */ export class Item

{ @@ -26,67 +26,67 @@ export function eq$cmp_PartialEq_unit(self: Item, other: Item>, other: Item>): boolean { - sorts_note(60, self.tag, other.tag); + note(60, self.tag, other.tag); return self.key < other.key; } export function lt$cmp_PartialOrd_array10_u32(self: Item, other: Item): boolean { - sorts_note(60, self.tag, other.tag); + note(60, self.tag, other.tag); return self.key < other.key; } export function lt$cmp_PartialOrd_array1100_u32(self: Item, other: Item): boolean { - sorts_note(60, self.tag, other.tag); + note(60, self.tag, other.tag); return self.key < other.key; } export function lt$cmp_PartialOrd_array22_u32(self: Item, other: Item): boolean { - sorts_note(60, self.tag, other.tag); + note(60, self.tag, other.tag); return self.key < other.key; } export function lt$cmp_PartialOrd_array30_u32(self: Item, other: Item): boolean { - sorts_note(60, self.tag, other.tag); + note(60, self.tag, other.tag); return self.key < other.key; } -export function lt$cmp_PartialOrd_sorts_Held(self: Item, other: Item): boolean { - sorts_note(60, self.tag, other.tag); +export function lt$cmp_PartialOrd_sorts_Held(self: Item, other: Item): boolean { + note(60, self.tag, other.tag); return self.key < other.key; } export function lt$cmp_PartialOrd_unit(self: Item, other: Item): boolean { - sorts_note(60, self.tag, other.tag); + note(60, self.tag, other.tag); return self.key < other.key; } export function cmp$cmp_Ord_Cell_u32(self: Item>, other: Item>): rt.Ordering { - sorts_note(99, self.tag, other.tag); + note(99, self.tag, other.tag); return rt.cmp(self.key, other.key); } export function cmp$cmp_Ord_array10_u32(self: Item, other: Item): rt.Ordering { - sorts_note(99, self.tag, other.tag); + note(99, self.tag, other.tag); return rt.cmp(self.key, other.key); } export function cmp$cmp_Ord_array22_u32(self: Item, other: Item): rt.Ordering { - sorts_note(99, self.tag, other.tag); + note(99, self.tag, other.tag); return rt.cmp(self.key, other.key); } export function cmp$cmp_Ord_array30_u32(self: Item, other: Item): rt.Ordering { - sorts_note(99, self.tag, other.tag); + note(99, self.tag, other.tag); return rt.cmp(self.key, other.key); } -export function cmp$cmp_Ord_sorts_Held(self: Item, other: Item): rt.Ordering { - sorts_note(99, self.tag, other.tag); +export function cmp$cmp_Ord_sorts_Held(self: Item, other: Item): rt.Ordering { + note(99, self.tag, other.tag); return rt.cmp(self.key, other.key); } export function cmp$cmp_Ord_unit(self: Item, other: Item): rt.Ordering { - sorts_note(99, self.tag, other.tag); + note(99, self.tag, other.tag); return rt.cmp(self.key, other.key); } diff --git a/ts/fixtures/lang/expected/sorts.ts b/ts/fixtures/lang/sorts/expected/sorts.ts similarity index 64% rename from ts/fixtures/lang/expected/sorts.ts rename to ts/fixtures/lang/sorts/expected/sorts.ts index 83ee0f5db..ce804a84c 100644 --- a/ts/fixtures/lang/expected/sorts.ts +++ b/ts/fixtures/lang/sorts/expected/sorts.ts @@ -1,10 +1,9 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { copy$tuple2_u32_u32 } from "./lib.ts"; import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, mapOr$1ttssgs as option_mapOr$1ttssgs } from "./core/option.ts"; -import type * as sorts_Held from "./sorts.Held.ts"; -import * as sorts_Item from "./sorts.Item.ts"; +import type * as Held from "./sorts.Held.ts"; +import * as Item from "./sorts.Item.ts"; export const LOG: rt.LocalKey> = /* @__PURE__ */ new rt.LocalKey(LOG$init, false); @@ -21,7 +20,7 @@ export function begin(): void { export function note(what: rt.u8, a: rt.u16, b: rt.u16): void { ((log: rt.Cell<[rt.u32, rt.u32]>): undefined => { - const _52: [rt.u32, rt.u32] = copy$tuple2_u32_u32(log.v); + const _52: [rt.u32, rt.u32] = log.v; let hash: rt.u32 = _52[0]; const count: rt.u32 = _52[1]; const iter: rt.Iter = rt.iterSlice(Uint8Array.of(what, a & 0xff, (a >> 8) & 0xff, b & 0xff, (b >> 8) & 0xff)); @@ -37,7 +36,7 @@ export function note(what: rt.u8, a: rt.u16, b: rt.u16): void { } /** Puts the log's hash and count, then each tag in order, or a hash of them past 64. */ -export function put$Cell_u32(v: sorts_Item.Item>[], out: rt.ByteVec): void { +export function put$Cell_u32(v: Item.Item>[], out: rt.ByteVec): void { const _5: [rt.u32, rt.u32] = ((log: rt.Cell<[rt.u32, rt.u32]>): [rt.u32, rt.u32] => { return rt.cellReplace(log, [2166136261, 0]); })(LOG.get()); @@ -46,18 +45,18 @@ export function put$Cell_u32(v: sorts_Item.Item>[], out: rt.Byte rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(hash).reverse()), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(count).reverse()), undefined, true); if (!(v.length <= 64)) { - rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.iterFold(rt.iterSlice(v), 0, (h: rt.u32, x2: sorts_Item.Item>): rt.u32 => { + rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.iterFold(rt.iterSlice(v), 0, (h: rt.u32, x2: Item.Item>): rt.u32 => { return rt.u32WrappingMul((h ^ x2.tag as rt.u32) >>> 0, 16777619); })).reverse()), undefined, true); } else { - rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (x: sorts_Item.Item>): Uint8Array => { + rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (x: Item.Item>): Uint8Array => { return rt.u16ToBeBytes(x.tag).reverse(); }, (value: Uint8Array) => rt.iterSlice(value), false, 2), undefined, true); } } /** Puts the log's hash and count, then each tag in order, or a hash of them past 64. */ -export function put$array10_u32(v: sorts_Item.Item[], out: rt.ByteVec): void { +export function put$array10_u32(v: Item.Item[], out: rt.ByteVec): void { const _5: [rt.u32, rt.u32] = ((log: rt.Cell<[rt.u32, rt.u32]>): [rt.u32, rt.u32] => { return rt.cellReplace(log, [2166136261, 0]); })(LOG.get()); @@ -66,18 +65,18 @@ export function put$array10_u32(v: sorts_Item.Item[], out: rt.ByteVec) rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(hash).reverse()), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(count).reverse()), undefined, true); if (!(v.length <= 64)) { - rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.iterFold(rt.iterSlice(v), 0, (h: rt.u32, x2: sorts_Item.Item): rt.u32 => { + rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.iterFold(rt.iterSlice(v), 0, (h: rt.u32, x2: Item.Item): rt.u32 => { return rt.u32WrappingMul((h ^ x2.tag as rt.u32) >>> 0, 16777619); })).reverse()), undefined, true); } else { - rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (x: sorts_Item.Item): Uint8Array => { + rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (x: Item.Item): Uint8Array => { return rt.u16ToBeBytes(x.tag).reverse(); }, (value: Uint8Array) => rt.iterSlice(value), false, 2), undefined, true); } } /** Puts the log's hash and count, then each tag in order, or a hash of them past 64. */ -export function put$array1100_u32(v: sorts_Item.Item[], out: rt.ByteVec): void { +export function put$array1100_u32(v: Item.Item[], out: rt.ByteVec): void { const _5: [rt.u32, rt.u32] = ((log: rt.Cell<[rt.u32, rt.u32]>): [rt.u32, rt.u32] => { return rt.cellReplace(log, [2166136261, 0]); })(LOG.get()); @@ -86,18 +85,18 @@ export function put$array1100_u32(v: sorts_Item.Item[], out: rt.ByteVe rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(hash).reverse()), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(count).reverse()), undefined, true); if (!(v.length <= 64)) { - rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.iterFold(rt.iterSlice(v), 0, (h: rt.u32, x2: sorts_Item.Item): rt.u32 => { + rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.iterFold(rt.iterSlice(v), 0, (h: rt.u32, x2: Item.Item): rt.u32 => { return rt.u32WrappingMul((h ^ x2.tag as rt.u32) >>> 0, 16777619); })).reverse()), undefined, true); } else { - rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (x: sorts_Item.Item): Uint8Array => { + rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (x: Item.Item): Uint8Array => { return rt.u16ToBeBytes(x.tag).reverse(); }, (value: Uint8Array) => rt.iterSlice(value), false, 2), undefined, true); } } /** Puts the log's hash and count, then each tag in order, or a hash of them past 64. */ -export function put$array22_u32(v: sorts_Item.Item[], out: rt.ByteVec): void { +export function put$array22_u32(v: Item.Item[], out: rt.ByteVec): void { const _5: [rt.u32, rt.u32] = ((log: rt.Cell<[rt.u32, rt.u32]>): [rt.u32, rt.u32] => { return rt.cellReplace(log, [2166136261, 0]); })(LOG.get()); @@ -106,18 +105,18 @@ export function put$array22_u32(v: sorts_Item.Item[], out: rt.ByteVec) rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(hash).reverse()), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(count).reverse()), undefined, true); if (!(v.length <= 64)) { - rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.iterFold(rt.iterSlice(v), 0, (h: rt.u32, x2: sorts_Item.Item): rt.u32 => { + rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.iterFold(rt.iterSlice(v), 0, (h: rt.u32, x2: Item.Item): rt.u32 => { return rt.u32WrappingMul((h ^ x2.tag as rt.u32) >>> 0, 16777619); })).reverse()), undefined, true); } else { - rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (x: sorts_Item.Item): Uint8Array => { + rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (x: Item.Item): Uint8Array => { return rt.u16ToBeBytes(x.tag).reverse(); }, (value: Uint8Array) => rt.iterSlice(value), false, 2), undefined, true); } } /** Puts the log's hash and count, then each tag in order, or a hash of them past 64. */ -export function put$array30_u32(v: sorts_Item.Item[], out: rt.ByteVec): void { +export function put$array30_u32(v: Item.Item[], out: rt.ByteVec): void { const _5: [rt.u32, rt.u32] = ((log: rt.Cell<[rt.u32, rt.u32]>): [rt.u32, rt.u32] => { return rt.cellReplace(log, [2166136261, 0]); })(LOG.get()); @@ -126,18 +125,18 @@ export function put$array30_u32(v: sorts_Item.Item[], out: rt.ByteVec) rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(hash).reverse()), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(count).reverse()), undefined, true); if (!(v.length <= 64)) { - rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.iterFold(rt.iterSlice(v), 0, (h: rt.u32, x2: sorts_Item.Item): rt.u32 => { + rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.iterFold(rt.iterSlice(v), 0, (h: rt.u32, x2: Item.Item): rt.u32 => { return rt.u32WrappingMul((h ^ x2.tag as rt.u32) >>> 0, 16777619); })).reverse()), undefined, true); } else { - rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (x: sorts_Item.Item): Uint8Array => { + rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (x: Item.Item): Uint8Array => { return rt.u16ToBeBytes(x.tag).reverse(); }, (value: Uint8Array) => rt.iterSlice(value), false, 2), undefined, true); } } /** Puts the log's hash and count, then each tag in order, or a hash of them past 64. */ -export function put$sorts_Held(v: sorts_Item.Item[], out: rt.ByteVec): void { +export function put$sorts_Held(v: Item.Item[], out: rt.ByteVec): void { const _5: [rt.u32, rt.u32] = ((log: rt.Cell<[rt.u32, rt.u32]>): [rt.u32, rt.u32] => { return rt.cellReplace(log, [2166136261, 0]); })(LOG.get()); @@ -146,18 +145,18 @@ export function put$sorts_Held(v: sorts_Item.Item[], out: rt.By rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(hash).reverse()), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(count).reverse()), undefined, true); if (!(v.length <= 64)) { - rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.iterFold(rt.iterSlice(v), 0, (h: rt.u32, x2: sorts_Item.Item): rt.u32 => { + rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.iterFold(rt.iterSlice(v), 0, (h: rt.u32, x2: Item.Item): rt.u32 => { return rt.u32WrappingMul((h ^ x2.tag as rt.u32) >>> 0, 16777619); })).reverse()), undefined, true); } else { - rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (x: sorts_Item.Item): Uint8Array => { + rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (x: Item.Item): Uint8Array => { return rt.u16ToBeBytes(x.tag).reverse(); }, (value: Uint8Array) => rt.iterSlice(value), false, 2), undefined, true); } } /** Puts the log's hash and count, then each tag in order, or a hash of them past 64. */ -export function put$unit(v: sorts_Item.Item[], out: rt.ByteVec): void { +export function put$unit(v: Item.Item[], out: rt.ByteVec): void { const _5: [rt.u32, rt.u32] = ((log: rt.Cell<[rt.u32, rt.u32]>): [rt.u32, rt.u32] => { return rt.cellReplace(log, [2166136261, 0]); })(LOG.get()); @@ -166,11 +165,11 @@ export function put$unit(v: sorts_Item.Item[], out: rt.ByteVec): void rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(hash).reverse()), undefined, true); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(count).reverse()), undefined, true); if (!(v.length <= 64)) { - rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.iterFold(rt.iterSlice(v), 0, (h: rt.u32, x2: sorts_Item.Item): rt.u32 => { + rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.iterFold(rt.iterSlice(v), 0, (h: rt.u32, x2: Item.Item): rt.u32 => { return rt.u32WrappingMul((h ^ x2.tag as rt.u32) >>> 0, 16777619); })).reverse()), undefined, true); } else { - rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (x: sorts_Item.Item): Uint8Array => { + rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(v), (x: Item.Item): Uint8Array => { return rt.u16ToBeBytes(x.tag).reverse(); }, (value: Uint8Array) => rt.iterSlice(value), false, 2), undefined, true); } @@ -193,7 +192,7 @@ export function sorts(kind: rt.u8, dataData: Uint8Array, dataStart: number, data return new rt.Cell(0); }, out); if (n <= 300) { - sorted$sorts_Held_sorts_sorts_closure2(keys_, (): sorts_Held.Held => { + sorted$sorts_Held_sorts_sorts_closure2(keys_, (): Held.Held => { return { _0: rt.bytes(2) }; }, out); sorted$array10_u32_sorts_sorts_closure3(keys_, (): rt.u32[] => { @@ -213,12 +212,12 @@ export function sorts(kind: rt.u8, dataData: Uint8Array, dataStart: number, data }, out); } if (n === 2000) { - const v: sorts_Item.Item[] = items$array1100_u32_sorts_sorts_closure6(keys_, (): rt.u32[] => { + const v: Item.Item[] = items$array1100_u32_sorts_sorts_closure6(keys_, (): rt.u32[] => { return Array.from({ length: 1100 }, (): rt.u32 => { return 0; }); }); - rt.sliceSort(v, sorts_Item.lt$cmp_PartialOrd_array1100_u32, 4404, true); + rt.sliceSort(v, Item.lt$cmp_PartialOrd_array1100_u32, 4404, true); put$array1100_u32(v, out); } } @@ -265,147 +264,147 @@ export function keys(n: rt.usize, dataData: Uint8Array, dataStart: number, dataL } /** `keys` as items, each padded by `pad` and tagged by where it is. */ -export function items$Cell_u32_ref_sorts_sorts_closure1(keys: rt.u16[], pad: () => rt.Cell): sorts_Item.Item>[] { - return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): sorts_Item.Item> => { - return new sorts_Item.Item(_2[1], _2[0] & 0xffff, pad()); +export function items$Cell_u32_ref_sorts_sorts_closure1(keys: rt.u16[], pad: () => rt.Cell): Item.Item>[] { + return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): Item.Item> => { + return new Item.Item(_2[1], _2[0] & 0xffff, pad()); }), undefined, 8, true); } /** `keys` as items, each padded by `pad` and tagged by where it is. */ -export function items$Cell_u32_sorts_disorders_closure3(keys: rt.u16[], pad: () => rt.Cell): sorts_Item.Item>[] { - return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): sorts_Item.Item> => { - return new sorts_Item.Item(_2[1], _2[0] & 0xffff, pad()); +export function items$Cell_u32_sorts_disorders_closure3(keys: rt.u16[], pad: () => rt.Cell): Item.Item>[] { + return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): Item.Item> => { + return new Item.Item(_2[1], _2[0] & 0xffff, pad()); }), undefined, 8, true); } /** `keys` as items, each padded by `pad` and tagged by where it is. */ -export function items$array10_u32_ref_sorts_sorts_closure3(keys: rt.u16[], pad: () => rt.u32[]): sorts_Item.Item[] { - return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): sorts_Item.Item => { - return new sorts_Item.Item(_2[1], _2[0] & 0xffff, pad()); +export function items$array10_u32_ref_sorts_sorts_closure3(keys: rt.u16[], pad: () => rt.u32[]): Item.Item[] { + return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): Item.Item => { + return new Item.Item(_2[1], _2[0] & 0xffff, pad()); }), undefined, 44, true); } /** `keys` as items, each padded by `pad` and tagged by where it is. */ -export function items$array10_u32_sorts_disorders_closure1(keys: rt.u16[], pad: () => rt.u32[]): sorts_Item.Item[] { - return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): sorts_Item.Item => { - return new sorts_Item.Item(_2[1], _2[0] & 0xffff, pad()); +export function items$array10_u32_sorts_disorders_closure1(keys: rt.u16[], pad: () => rt.u32[]): Item.Item[] { + return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): Item.Item => { + return new Item.Item(_2[1], _2[0] & 0xffff, pad()); }), undefined, 44, true); } /** `keys` as items, each padded by `pad` and tagged by where it is. */ -export function items$array1100_u32_sorts_sorts_closure6(keys: rt.u16[], pad: () => rt.u32[]): sorts_Item.Item[] { - return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): sorts_Item.Item => { - return new sorts_Item.Item(_2[1], _2[0] & 0xffff, pad()); +export function items$array1100_u32_sorts_sorts_closure6(keys: rt.u16[], pad: () => rt.u32[]): Item.Item[] { + return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): Item.Item => { + return new Item.Item(_2[1], _2[0] & 0xffff, pad()); }), undefined, 4404, true); } /** `keys` as items, each padded by `pad` and tagged by where it is. */ -export function items$array22_u32_ref_sorts_sorts_closure4(keys: rt.u16[], pad: () => rt.u32[]): sorts_Item.Item[] { - return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): sorts_Item.Item => { - return new sorts_Item.Item(_2[1], _2[0] & 0xffff, pad()); +export function items$array22_u32_ref_sorts_sorts_closure4(keys: rt.u16[], pad: () => rt.u32[]): Item.Item[] { + return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): Item.Item => { + return new Item.Item(_2[1], _2[0] & 0xffff, pad()); }), undefined, 92, true); } /** `keys` as items, each padded by `pad` and tagged by where it is. */ -export function items$array30_u32_ref_sorts_sorts_closure5(keys: rt.u16[], pad: () => rt.u32[]): sorts_Item.Item[] { - return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): sorts_Item.Item => { - return new sorts_Item.Item(_2[1], _2[0] & 0xffff, pad()); +export function items$array30_u32_ref_sorts_sorts_closure5(keys: rt.u16[], pad: () => rt.u32[]): Item.Item[] { + return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): Item.Item => { + return new Item.Item(_2[1], _2[0] & 0xffff, pad()); }), undefined, 124, true); } /** `keys` as items, each padded by `pad` and tagged by where it is. */ -export function items$array30_u32_sorts_btrees_closure3(keys: rt.u16[], pad: () => rt.u32[]): sorts_Item.Item[] { - return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): sorts_Item.Item => { - return new sorts_Item.Item(_2[1], _2[0] & 0xffff, pad()); +export function items$array30_u32_sorts_btrees_closure3(keys: rt.u16[], pad: () => rt.u32[]): Item.Item[] { + return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): Item.Item => { + return new Item.Item(_2[1], _2[0] & 0xffff, pad()); }), undefined, 124, true); } /** `keys` as items, each padded by `pad` and tagged by where it is. */ -export function items$array30_u32_sorts_disorders_closure2(keys: rt.u16[], pad: () => rt.u32[]): sorts_Item.Item[] { - return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): sorts_Item.Item => { - return new sorts_Item.Item(_2[1], _2[0] & 0xffff, pad()); +export function items$array30_u32_sorts_disorders_closure2(keys: rt.u16[], pad: () => rt.u32[]): Item.Item[] { + return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): Item.Item => { + return new Item.Item(_2[1], _2[0] & 0xffff, pad()); }), undefined, 124, true); } /** `keys` as items, each padded by `pad` and tagged by where it is. */ -export function items$sorts_Held_ref_sorts_sorts_closure2(keys: rt.u16[], pad: () => sorts_Held.Held): sorts_Item.Item[] { - return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): sorts_Item.Item => { - return new sorts_Item.Item(_2[1], _2[0] & 0xffff, pad()); +export function items$sorts_Held_ref_sorts_sorts_closure2(keys: rt.u16[], pad: () => Held.Held): Item.Item[] { + return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): Item.Item => { + return new Item.Item(_2[1], _2[0] & 0xffff, pad()); }), undefined, 6, true); } /** `keys` as items, each padded by `pad` and tagged by where it is. */ -export function items$unit_ref_sorts_sorts_closure0(keys: rt.u16[], pad: () => undefined): sorts_Item.Item[] { - return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): sorts_Item.Item => { +export function items$unit_ref_sorts_sorts_closure0(keys: rt.u16[], pad: () => undefined): Item.Item[] { + return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): Item.Item => { const i: rt.usize = _2[0]; const key: rt.u16 = _2[1]; const _52: rt.u16 = i & 0xffff; pad(); - return new sorts_Item.Item(key, _52, undefined); + return new Item.Item(key, _52, undefined); }), undefined, 4, true); } /** `keys` as items, each padded by `pad` and tagged by where it is. */ -export function items$unit_sorts_btrees_closure0(keys: rt.u16[], pad: () => undefined): sorts_Item.Item[] { - return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): sorts_Item.Item => { +export function items$unit_sorts_btrees_closure0(keys: rt.u16[], pad: () => undefined): Item.Item[] { + return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): Item.Item => { const i: rt.usize = _2[0]; const key: rt.u16 = _2[1]; const _52: rt.u16 = i & 0xffff; pad(); - return new sorts_Item.Item(key, _52, undefined); + return new Item.Item(key, _52, undefined); }), undefined, 4, true); } /** `keys` as items, each padded by `pad` and tagged by where it is. */ -export function items$unit_sorts_btrees_closure1(keys: rt.u16[], pad: () => undefined): sorts_Item.Item[] { - return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): sorts_Item.Item => { +export function items$unit_sorts_btrees_closure1(keys: rt.u16[], pad: () => undefined): Item.Item[] { + return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): Item.Item => { const i: rt.usize = _2[0]; const key: rt.u16 = _2[1]; const _52: rt.u16 = i & 0xffff; pad(); - return new sorts_Item.Item(key, _52, undefined); + return new Item.Item(key, _52, undefined); }), undefined, 4, true); } /** `keys` as items, each padded by `pad` and tagged by where it is. */ -export function items$unit_sorts_disorders_closure0(keys: rt.u16[], pad: () => undefined): sorts_Item.Item[] { - return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): sorts_Item.Item => { +export function items$unit_sorts_disorders_closure0(keys: rt.u16[], pad: () => undefined): Item.Item[] { + return rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(keys)), (_2: [rt.usize, rt.u16]): Item.Item => { const i: rt.usize = _2[0]; const key: rt.u16 = _2[1]; const _52: rt.u16 = i & 0xffff; pad(); - return new sorts_Item.Item(key, _52, undefined); + return new Item.Item(key, _52, undefined); }), undefined, 4, true); } /** Each sort of `keys` as items padded by `pad`, and what it tested and left. */ export function sorted$Cell_u32_sorts_sorts_closure1(keys: rt.u16[], pad: () => rt.Cell, out: rt.ByteVec): void { - const items: () => sorts_Item.Item>[] = (): sorts_Item.Item>[] => { + const items: () => Item.Item>[] = (): Item.Item>[] => { return items$Cell_u32_ref_sorts_sorts_closure1(keys, pad); }; - const v: sorts_Item.Item>[] = items(); - rt.sliceSort(v, sorts_Item.lt$cmp_PartialOrd_Cell_u32, 8, false); + const v: Item.Item>[] = items(); + rt.sliceSort(v, Item.lt$cmp_PartialOrd_Cell_u32, 8, false); put$Cell_u32(v, out); - const v2: sorts_Item.Item>[] = items(); - rt.sliceSortUnstable(v2, sorts_Item.lt$cmp_PartialOrd_Cell_u32, 8, false, false); + const v2: Item.Item>[] = items(); + rt.sliceSortUnstable(v2, Item.lt$cmp_PartialOrd_Cell_u32, 8, false, false); put$Cell_u32(v2, out); - const v3: sorts_Item.Item>[] = items(); - rt.sliceSort(v3, rt.cmpLt((a: sorts_Item.Item>, b: sorts_Item.Item>): rt.Ordering => { + const v3: Item.Item>[] = items(); + rt.sliceSort(v3, rt.cmpLt((a: Item.Item>, b: Item.Item>): rt.Ordering => { note(98, a.tag, b.tag); return rt.cmp(b.key, a.key); }), 8, false); put$Cell_u32(v3, out); - const v4: sorts_Item.Item>[] = items(); - rt.sliceSortUnstable(v4, rt.cmpLt(sorts_Item.cmp$cmp_Ord_Cell_u32), 8, false, false); + const v4: Item.Item>[] = items(); + rt.sliceSortUnstable(v4, rt.cmpLt(Item.cmp$cmp_Ord_Cell_u32), 8, false, false); put$Cell_u32(v4, out); - const v5: sorts_Item.Item>[] = items(); - rt.sliceSort(v5, rt.keyLt((x: sorts_Item.Item>): rt.u16 => { + const v5: Item.Item>[] = items(); + rt.sliceSort(v5, rt.keyLt((x: Item.Item>): rt.u16 => { note(107, x.tag, 0); return rt.u16Div(x.key, 4); }, rt.lt), 8, false); put$Cell_u32(v5, out); - const v6: sorts_Item.Item>[] = items(); - rt.sliceSortUnstable(v6, rt.keyLt((x2: sorts_Item.Item>): rt.u16 => { + const v6: Item.Item>[] = items(); + rt.sliceSortUnstable(v6, rt.keyLt((x2: Item.Item>): rt.u16 => { note(107, x2.tag, 0); return rt.u16Rem(x2.key, 3); }, rt.lt), 8, false, false); @@ -414,32 +413,32 @@ export function sorted$Cell_u32_sorts_sorts_closure1(keys: rt.u16[], pad: () => /** Each sort of `keys` as items padded by `pad`, and what it tested and left. */ export function sorted$array10_u32_sorts_sorts_closure3(keys: rt.u16[], pad: () => rt.u32[], out: rt.ByteVec): void { - const items: () => sorts_Item.Item[] = (): sorts_Item.Item[] => { + const items: () => Item.Item[] = (): Item.Item[] => { return items$array10_u32_ref_sorts_sorts_closure3(keys, pad); }; - const v: sorts_Item.Item[] = items(); - rt.sliceSort(v, sorts_Item.lt$cmp_PartialOrd_array10_u32, 44, true); + const v: Item.Item[] = items(); + rt.sliceSort(v, Item.lt$cmp_PartialOrd_array10_u32, 44, true); put$array10_u32(v, out); - const v2: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v2, sorts_Item.lt$cmp_PartialOrd_array10_u32, 44, true, true); + const v2: Item.Item[] = items(); + rt.sliceSortUnstable(v2, Item.lt$cmp_PartialOrd_array10_u32, 44, true, true); put$array10_u32(v2, out); - const v3: sorts_Item.Item[] = items(); - rt.sliceSort(v3, rt.cmpLt((a: sorts_Item.Item, b: sorts_Item.Item): rt.Ordering => { + const v3: Item.Item[] = items(); + rt.sliceSort(v3, rt.cmpLt((a: Item.Item, b: Item.Item): rt.Ordering => { note(98, a.tag, b.tag); return rt.cmp(b.key, a.key); }), 44, true); put$array10_u32(v3, out); - const v4: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v4, rt.cmpLt(sorts_Item.cmp$cmp_Ord_array10_u32), 44, true, true); + const v4: Item.Item[] = items(); + rt.sliceSortUnstable(v4, rt.cmpLt(Item.cmp$cmp_Ord_array10_u32), 44, true, true); put$array10_u32(v4, out); - const v5: sorts_Item.Item[] = items(); - rt.sliceSort(v5, rt.keyLt((x: sorts_Item.Item): rt.u16 => { + const v5: Item.Item[] = items(); + rt.sliceSort(v5, rt.keyLt((x: Item.Item): rt.u16 => { note(107, x.tag, 0); return rt.u16Div(x.key, 4); }, rt.lt), 44, true); put$array10_u32(v5, out); - const v6: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v6, rt.keyLt((x2: sorts_Item.Item): rt.u16 => { + const v6: Item.Item[] = items(); + rt.sliceSortUnstable(v6, rt.keyLt((x2: Item.Item): rt.u16 => { note(107, x2.tag, 0); return rt.u16Rem(x2.key, 3); }, rt.lt), 44, true, true); @@ -448,32 +447,32 @@ export function sorted$array10_u32_sorts_sorts_closure3(keys: rt.u16[], pad: () /** Each sort of `keys` as items padded by `pad`, and what it tested and left. */ export function sorted$array22_u32_sorts_sorts_closure4(keys: rt.u16[], pad: () => rt.u32[], out: rt.ByteVec): void { - const items: () => sorts_Item.Item[] = (): sorts_Item.Item[] => { + const items: () => Item.Item[] = (): Item.Item[] => { return items$array22_u32_ref_sorts_sorts_closure4(keys, pad); }; - const v: sorts_Item.Item[] = items(); - rt.sliceSort(v, sorts_Item.lt$cmp_PartialOrd_array22_u32, 92, true); + const v: Item.Item[] = items(); + rt.sliceSort(v, Item.lt$cmp_PartialOrd_array22_u32, 92, true); put$array22_u32(v, out); - const v2: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v2, sorts_Item.lt$cmp_PartialOrd_array22_u32, 92, true, true); + const v2: Item.Item[] = items(); + rt.sliceSortUnstable(v2, Item.lt$cmp_PartialOrd_array22_u32, 92, true, true); put$array22_u32(v2, out); - const v3: sorts_Item.Item[] = items(); - rt.sliceSort(v3, rt.cmpLt((a: sorts_Item.Item, b: sorts_Item.Item): rt.Ordering => { + const v3: Item.Item[] = items(); + rt.sliceSort(v3, rt.cmpLt((a: Item.Item, b: Item.Item): rt.Ordering => { note(98, a.tag, b.tag); return rt.cmp(b.key, a.key); }), 92, true); put$array22_u32(v3, out); - const v4: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v4, rt.cmpLt(sorts_Item.cmp$cmp_Ord_array22_u32), 92, true, true); + const v4: Item.Item[] = items(); + rt.sliceSortUnstable(v4, rt.cmpLt(Item.cmp$cmp_Ord_array22_u32), 92, true, true); put$array22_u32(v4, out); - const v5: sorts_Item.Item[] = items(); - rt.sliceSort(v5, rt.keyLt((x: sorts_Item.Item): rt.u16 => { + const v5: Item.Item[] = items(); + rt.sliceSort(v5, rt.keyLt((x: Item.Item): rt.u16 => { note(107, x.tag, 0); return rt.u16Div(x.key, 4); }, rt.lt), 92, true); put$array22_u32(v5, out); - const v6: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v6, rt.keyLt((x2: sorts_Item.Item): rt.u16 => { + const v6: Item.Item[] = items(); + rt.sliceSortUnstable(v6, rt.keyLt((x2: Item.Item): rt.u16 => { note(107, x2.tag, 0); return rt.u16Rem(x2.key, 3); }, rt.lt), 92, true, true); @@ -482,32 +481,32 @@ export function sorted$array22_u32_sorts_sorts_closure4(keys: rt.u16[], pad: () /** Each sort of `keys` as items padded by `pad`, and what it tested and left. */ export function sorted$array30_u32_sorts_sorts_closure5(keys: rt.u16[], pad: () => rt.u32[], out: rt.ByteVec): void { - const items: () => sorts_Item.Item[] = (): sorts_Item.Item[] => { + const items: () => Item.Item[] = (): Item.Item[] => { return items$array30_u32_ref_sorts_sorts_closure5(keys, pad); }; - const v: sorts_Item.Item[] = items(); - rt.sliceSort(v, sorts_Item.lt$cmp_PartialOrd_array30_u32, 124, true); + const v: Item.Item[] = items(); + rt.sliceSort(v, Item.lt$cmp_PartialOrd_array30_u32, 124, true); put$array30_u32(v, out); - const v2: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v2, sorts_Item.lt$cmp_PartialOrd_array30_u32, 124, true, true); + const v2: Item.Item[] = items(); + rt.sliceSortUnstable(v2, Item.lt$cmp_PartialOrd_array30_u32, 124, true, true); put$array30_u32(v2, out); - const v3: sorts_Item.Item[] = items(); - rt.sliceSort(v3, rt.cmpLt((a: sorts_Item.Item, b: sorts_Item.Item): rt.Ordering => { + const v3: Item.Item[] = items(); + rt.sliceSort(v3, rt.cmpLt((a: Item.Item, b: Item.Item): rt.Ordering => { note(98, a.tag, b.tag); return rt.cmp(b.key, a.key); }), 124, true); put$array30_u32(v3, out); - const v4: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v4, rt.cmpLt(sorts_Item.cmp$cmp_Ord_array30_u32), 124, true, true); + const v4: Item.Item[] = items(); + rt.sliceSortUnstable(v4, rt.cmpLt(Item.cmp$cmp_Ord_array30_u32), 124, true, true); put$array30_u32(v4, out); - const v5: sorts_Item.Item[] = items(); - rt.sliceSort(v5, rt.keyLt((x: sorts_Item.Item): rt.u16 => { + const v5: Item.Item[] = items(); + rt.sliceSort(v5, rt.keyLt((x: Item.Item): rt.u16 => { note(107, x.tag, 0); return rt.u16Div(x.key, 4); }, rt.lt), 124, true); put$array30_u32(v5, out); - const v6: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v6, rt.keyLt((x2: sorts_Item.Item): rt.u16 => { + const v6: Item.Item[] = items(); + rt.sliceSortUnstable(v6, rt.keyLt((x2: Item.Item): rt.u16 => { note(107, x2.tag, 0); return rt.u16Rem(x2.key, 3); }, rt.lt), 124, true, true); @@ -515,33 +514,33 @@ export function sorted$array30_u32_sorts_sorts_closure5(keys: rt.u16[], pad: () } /** Each sort of `keys` as items padded by `pad`, and what it tested and left. */ -export function sorted$sorts_Held_sorts_sorts_closure2(keys: rt.u16[], pad: () => sorts_Held.Held, out: rt.ByteVec): void { - const items: () => sorts_Item.Item[] = (): sorts_Item.Item[] => { +export function sorted$sorts_Held_sorts_sorts_closure2(keys: rt.u16[], pad: () => Held.Held, out: rt.ByteVec): void { + const items: () => Item.Item[] = (): Item.Item[] => { return items$sorts_Held_ref_sorts_sorts_closure2(keys, pad); }; - const v: sorts_Item.Item[] = items(); - rt.sliceSort(v, sorts_Item.lt$cmp_PartialOrd_sorts_Held, 6, true); + const v: Item.Item[] = items(); + rt.sliceSort(v, Item.lt$cmp_PartialOrd_sorts_Held, 6, true); put$sorts_Held(v, out); - const v2: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v2, sorts_Item.lt$cmp_PartialOrd_sorts_Held, 6, true, false); + const v2: Item.Item[] = items(); + rt.sliceSortUnstable(v2, Item.lt$cmp_PartialOrd_sorts_Held, 6, true, false); put$sorts_Held(v2, out); - const v3: sorts_Item.Item[] = items(); - rt.sliceSort(v3, rt.cmpLt((a: sorts_Item.Item, b: sorts_Item.Item): rt.Ordering => { + const v3: Item.Item[] = items(); + rt.sliceSort(v3, rt.cmpLt((a: Item.Item, b: Item.Item): rt.Ordering => { note(98, a.tag, b.tag); return rt.cmp(b.key, a.key); }), 6, true); put$sorts_Held(v3, out); - const v4: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v4, rt.cmpLt(sorts_Item.cmp$cmp_Ord_sorts_Held), 6, true, false); + const v4: Item.Item[] = items(); + rt.sliceSortUnstable(v4, rt.cmpLt(Item.cmp$cmp_Ord_sorts_Held), 6, true, false); put$sorts_Held(v4, out); - const v5: sorts_Item.Item[] = items(); - rt.sliceSort(v5, rt.keyLt((x: sorts_Item.Item): rt.u16 => { + const v5: Item.Item[] = items(); + rt.sliceSort(v5, rt.keyLt((x: Item.Item): rt.u16 => { note(107, x.tag, 0); return rt.u16Div(x.key, 4); }, rt.lt), 6, true); put$sorts_Held(v5, out); - const v6: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v6, rt.keyLt((x2: sorts_Item.Item): rt.u16 => { + const v6: Item.Item[] = items(); + rt.sliceSortUnstable(v6, rt.keyLt((x2: Item.Item): rt.u16 => { note(107, x2.tag, 0); return rt.u16Rem(x2.key, 3); }, rt.lt), 6, true, false); @@ -550,32 +549,32 @@ export function sorted$sorts_Held_sorts_sorts_closure2(keys: rt.u16[], pad: () = /** Each sort of `keys` as items padded by `pad`, and what it tested and left. */ export function sorted$unit_sorts_sorts_closure0(keys: rt.u16[], pad: () => undefined, out: rt.ByteVec): void { - const items: () => sorts_Item.Item[] = (): sorts_Item.Item[] => { + const items: () => Item.Item[] = (): Item.Item[] => { return items$unit_ref_sorts_sorts_closure0(keys, pad); }; - const v: sorts_Item.Item[] = items(); - rt.sliceSort(v, sorts_Item.lt$cmp_PartialOrd_unit, 4, true); + const v: Item.Item[] = items(); + rt.sliceSort(v, Item.lt$cmp_PartialOrd_unit, 4, true); put$unit(v, out); - const v2: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v2, sorts_Item.lt$cmp_PartialOrd_unit, 4, true, true); + const v2: Item.Item[] = items(); + rt.sliceSortUnstable(v2, Item.lt$cmp_PartialOrd_unit, 4, true, true); put$unit(v2, out); - const v3: sorts_Item.Item[] = items(); - rt.sliceSort(v3, rt.cmpLt((a: sorts_Item.Item, b: sorts_Item.Item): rt.Ordering => { + const v3: Item.Item[] = items(); + rt.sliceSort(v3, rt.cmpLt((a: Item.Item, b: Item.Item): rt.Ordering => { note(98, a.tag, b.tag); return rt.cmp(b.key, a.key); }), 4, true); put$unit(v3, out); - const v4: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v4, rt.cmpLt(sorts_Item.cmp$cmp_Ord_unit), 4, true, true); + const v4: Item.Item[] = items(); + rt.sliceSortUnstable(v4, rt.cmpLt(Item.cmp$cmp_Ord_unit), 4, true, true); put$unit(v4, out); - const v5: sorts_Item.Item[] = items(); - rt.sliceSort(v5, rt.keyLt((x: sorts_Item.Item): rt.u16 => { + const v5: Item.Item[] = items(); + rt.sliceSort(v5, rt.keyLt((x: Item.Item): rt.u16 => { note(107, x.tag, 0); return rt.u16Div(x.key, 4); }, rt.lt), 4, true); put$unit(v5, out); - const v6: sorts_Item.Item[] = items(); - rt.sliceSortUnstable(v6, rt.keyLt((x2: sorts_Item.Item): rt.u16 => { + const v6: Item.Item[] = items(); + rt.sliceSortUnstable(v6, rt.keyLt((x2: Item.Item): rt.u16 => { note(107, x2.tag, 0); return rt.u16Rem(x2.key, 3); }, rt.lt), 4, true, true); @@ -618,9 +617,9 @@ export function disorders(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi } export function disordered$Cell_u32_sorts_disorders_closure3(keys: rt.u16[], stable: boolean, pad: () => rt.Cell, data: rt.ByteSlice, out: rt.ByteVec): void { - const v: sorts_Item.Item>[] = items$Cell_u32_sorts_disorders_closure3(keys, pad); + const v: Item.Item>[] = items$Cell_u32_sorts_disorders_closure3(keys, pad); const calls: rt.Cell = new rt.Cell(0); - const by: (a0: sorts_Item.Item>, a1: sorts_Item.Item>) => rt.Ordering = (a: sorts_Item.Item>, b: sorts_Item.Item>): rt.Ordering => { + const by: (a0: Item.Item>, a1: Item.Item>) => rt.Ordering = (a: Item.Item>, b: Item.Item>): rt.Ordering => { note(63, a.tag, b.tag); const i: rt.usize = calls.v; rt.cellSet(calls, rt.usizeAdd(i, 1)); @@ -643,9 +642,9 @@ export function disordered$Cell_u32_sorts_disorders_closure3(keys: rt.u16[], sta } export function disordered$array10_u32_sorts_disorders_closure1(keys: rt.u16[], stable: boolean, pad: () => rt.u32[], data: rt.ByteSlice, out: rt.ByteVec): void { - const v: sorts_Item.Item[] = items$array10_u32_sorts_disorders_closure1(keys, pad); + const v: Item.Item[] = items$array10_u32_sorts_disorders_closure1(keys, pad); const calls: rt.Cell = new rt.Cell(0); - const by: (a0: sorts_Item.Item, a1: sorts_Item.Item) => rt.Ordering = (a: sorts_Item.Item, b: sorts_Item.Item): rt.Ordering => { + const by: (a0: Item.Item, a1: Item.Item) => rt.Ordering = (a: Item.Item, b: Item.Item): rt.Ordering => { note(63, a.tag, b.tag); const i: rt.usize = calls.v; rt.cellSet(calls, rt.usizeAdd(i, 1)); @@ -668,9 +667,9 @@ export function disordered$array10_u32_sorts_disorders_closure1(keys: rt.u16[], } export function disordered$array30_u32_sorts_disorders_closure2(keys: rt.u16[], stable: boolean, pad: () => rt.u32[], data: rt.ByteSlice, out: rt.ByteVec): void { - const v: sorts_Item.Item[] = items$array30_u32_sorts_disorders_closure2(keys, pad); + const v: Item.Item[] = items$array30_u32_sorts_disorders_closure2(keys, pad); const calls: rt.Cell = new rt.Cell(0); - const by: (a0: sorts_Item.Item, a1: sorts_Item.Item) => rt.Ordering = (a: sorts_Item.Item, b: sorts_Item.Item): rt.Ordering => { + const by: (a0: Item.Item, a1: Item.Item) => rt.Ordering = (a: Item.Item, b: Item.Item): rt.Ordering => { note(63, a.tag, b.tag); const i: rt.usize = calls.v; rt.cellSet(calls, rt.usizeAdd(i, 1)); @@ -693,9 +692,9 @@ export function disordered$array30_u32_sorts_disorders_closure2(keys: rt.u16[], } export function disordered$unit_sorts_disorders_closure0(keys: rt.u16[], stable: boolean, pad: () => undefined, data: rt.ByteSlice, out: rt.ByteVec): void { - const v: sorts_Item.Item[] = items$unit_sorts_disorders_closure0(keys, pad); + const v: Item.Item[] = items$unit_sorts_disorders_closure0(keys, pad); const calls: rt.Cell = new rt.Cell(0); - const by: (a0: sorts_Item.Item, a1: sorts_Item.Item) => rt.Ordering = (a: sorts_Item.Item, b: sorts_Item.Item): rt.Ordering => { + const by: (a0: Item.Item, a1: Item.Item) => rt.Ordering = (a: Item.Item, b: Item.Item): rt.Ordering => { note(63, a.tag, b.tag); const i: rt.usize = calls.v; rt.cellSet(calls, rt.usizeAdd(i, 1)); @@ -729,20 +728,20 @@ export function btrees(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat rt.panic("index out of bounds: the len is " + 20 + " but the index is " + _8); } const keys_: rt.u16[] = keys(rt.min([0, 1, 2, 9, 13, 16, 17, 18, 20, 21, 32, 33, 48, 64, 65, 100, 300, 2000, 4096, 4097][_8], 300), dataData, dataStart, dataLen); - const _17: rt.Iter> = rt.iterSlice(items$unit_sorts_btrees_closure0(keys_, (): undefined => {})); - put$unit(rt.iterToArray(rt.btreeKeys(rt.btreeCollectKeys(rt.btreeNew(sorts_Item.cmp$cmp_Ord_unit) as rt.BTreeSet>, rt.iterToArray(_17, "next", 4, true, 4), 4, true, sorts_Item.lt$cmp_PartialOrd_unit, sorts_Item.eq$cmp_PartialEq_unit)), undefined, 4, true), out); - const _27: rt.Iter<[sorts_Item.Item, rt.u16]> = rt.iterMap(rt.iterSlice(items$unit_sorts_btrees_closure1(keys_, (): undefined => {})), (x: sorts_Item.Item): [sorts_Item.Item, rt.u16] => { - return [x, x.tag] as [sorts_Item.Item, rt.u16]; + const _17: rt.Iter> = rt.iterSlice(items$unit_sorts_btrees_closure0(keys_, (): undefined => {})); + put$unit(rt.iterToArray(rt.btreeKeys(rt.btreeCollectKeys(rt.btreeNew(Item.cmp$cmp_Ord_unit) as rt.BTreeSet>, rt.iterToArray(_17, "next", 4, true, 4), 4, true, Item.lt$cmp_PartialOrd_unit, Item.eq$cmp_PartialEq_unit)), undefined, 4, true), out); + const _27: rt.Iter<[Item.Item, rt.u16]> = rt.iterMap(rt.iterSlice(items$unit_sorts_btrees_closure1(keys_, (): undefined => {})), (x: Item.Item): [Item.Item, rt.u16] => { + return [x, x.tag] as [Item.Item, rt.u16]; }); - put$unit(rt.iterToArray(rt.btreeKeys(rt.btreeCollect(rt.btreeNew(sorts_Item.cmp$cmp_Ord_unit) as rt.BTreeMap, rt.u16>, rt.iterToArray(_27, undefined, 6, true), 6, true, sorts_Item.eq$cmp_PartialEq_unit)), undefined, 4, true), out); - const _38: rt.Iter<[sorts_Item.Item, rt.u16]> = rt.iterMap(rt.iterSlice(items$array30_u32_sorts_btrees_closure3(keys_, (): rt.u32[] => { + put$unit(rt.iterToArray(rt.btreeKeys(rt.btreeCollect(rt.btreeNew(Item.cmp$cmp_Ord_unit) as rt.BTreeMap, rt.u16>, rt.iterToArray(_27, undefined, 6, true), 6, true, Item.eq$cmp_PartialEq_unit)), undefined, 4, true), out); + const _38: rt.Iter<[Item.Item, rt.u16]> = rt.iterMap(rt.iterSlice(items$array30_u32_sorts_btrees_closure3(keys_, (): rt.u32[] => { return Array.from({ length: 30 }, (): rt.u32 => { return 0; }); - })), (x2: sorts_Item.Item): [sorts_Item.Item, rt.u16] => { - return [x2, x2.tag] as [sorts_Item.Item, rt.u16]; + })), (x2: Item.Item): [Item.Item, rt.u16] => { + return [x2, x2.tag] as [Item.Item, rt.u16]; }); - put$array30_u32(rt.iterToArray(rt.btreeKeys(rt.btreeCollect(rt.btreeNew(sorts_Item.cmp$cmp_Ord_array30_u32) as rt.BTreeMap, rt.u16>, rt.iterToArray(_38, undefined, 128, true), 128, true, sorts_Item.eq$cmp_PartialEq_array30_u32)), undefined, 124, true), out); + put$array30_u32(rt.iterToArray(rt.btreeKeys(rt.btreeCollect(rt.btreeNew(Item.cmp$cmp_Ord_array30_u32) as rt.BTreeMap, rt.u16>, rt.iterToArray(_38, undefined, 128, true), 128, true, Item.eq$cmp_PartialEq_array30_u32)), undefined, 124, true), out); } //# sourceMappingURL=sorts.ts.map diff --git a/ts/fixtures/lang/sorts/src/lib.rs b/ts/fixtures/lang/sorts/src/lib.rs new file mode 100644 index 000000000..d00703202 --- /dev/null +++ b/ts/fixtures/lang/sorts/src/lib.rs @@ -0,0 +1,23 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod sorts; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("sorts::sorts", sorts::sorts), + ("sorts::disorders", sorts::disorders), + ("sorts::btrees", sorts::btrees), + ] +} diff --git a/ts/fixtures/lang/src/sorts.rs b/ts/fixtures/lang/sorts/src/sorts.rs similarity index 100% rename from ts/fixtures/lang/src/sorts.rs rename to ts/fixtures/lang/sorts/src/sorts.rs diff --git a/ts/fixtures/lang/sorts/ts.toml b/ts/fixtures/lang/sorts/ts.toml new file mode 100644 index 000000000..330d020fc --- /dev/null +++ b/ts/fixtures/lang/sorts/ts.toml @@ -0,0 +1,2 @@ +package = "lang-sorts-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/splits/Cargo.toml b/ts/fixtures/lang/splits/Cargo.toml new file mode 100644 index 000000000..829dd581d --- /dev/null +++ b/ts/fixtures/lang/splits/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-splits-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/splits/expected/core/option.ts b/ts/fixtures/lang/splits/expected/core/option.ts new file mode 100644 index 000000000..2a488c6a7 --- /dev/null +++ b/ts/fixtures/lang/splits/expected/core/option.ts @@ -0,0 +1,26 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function mapOr$11e0ggl(self: [rt.ByteSlice, rt.ByteSlice] | undefined, default_: rt.u8, f: (a0: [rt.ByteSlice, rt.ByteSlice]) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function okOr$0q0ogpn(self: [rt.ByteSlice, rt.ByteSlice] | undefined, err: rt.u8 | undefined): rt.Result<[rt.ByteSlice, rt.ByteSlice], rt.u8 | undefined> { + if (self === undefined) { + return rt.Err(err); + } + return rt.Ok(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/splits/expected/harness.ts b/ts/fixtures/lang/splits/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/splits/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/splits/expected/lib.ts b/ts/fixtures/lang/splits/expected/lib.ts new file mode 100644 index 000000000..13c13771f --- /dev/null +++ b/ts/fixtures/lang/splits/expected/lib.ts @@ -0,0 +1,18 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { splits } from "./splits.ts"; + +export const out$tuple2_ref_slice_u8_ref_slice_u8: { p_0Data: Uint8Array; p_0Start: number; p_0Len: number; p_1Data: Uint8Array; p_1Start: number; p_1Len: number } = { p_0Data: undefined as never, p_0Start: undefined as never, p_0Len: undefined as never, p_1Data: undefined as never, p_1Start: undefined as never, p_1Len: undefined as never }; + +export const out$tuple3_u8_u16_ref_slice_u8: { err: unknown; p_1: rt.u16; p_2Data: Uint8Array; p_2Start: number; p_2Len: number } = { err: undefined, p_1: undefined as never, p_2Data: undefined as never, p_2Start: undefined as never, p_2Len: undefined as never }; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["splits::splits", splits as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/splits.Short.ts b/ts/fixtures/lang/splits/expected/splits.Short.ts similarity index 100% rename from ts/fixtures/lang/expected/splits.Short.ts rename to ts/fixtures/lang/splits/expected/splits.Short.ts diff --git a/ts/fixtures/lang/expected/splits.ts b/ts/fixtures/lang/splits/expected/splits.ts similarity index 100% rename from ts/fixtures/lang/expected/splits.ts rename to ts/fixtures/lang/splits/expected/splits.ts diff --git a/ts/fixtures/lang/splits/src/lib.rs b/ts/fixtures/lang/splits/src/lib.rs new file mode 100644 index 000000000..7e4e7bdab --- /dev/null +++ b/ts/fixtures/lang/splits/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod splits; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("splits::splits", splits::splits)] +} diff --git a/ts/fixtures/lang/src/splits.rs b/ts/fixtures/lang/splits/src/splits.rs similarity index 100% rename from ts/fixtures/lang/src/splits.rs rename to ts/fixtures/lang/splits/src/splits.rs diff --git a/ts/fixtures/lang/splits/ts.toml b/ts/fixtures/lang/splits/ts.toml new file mode 100644 index 000000000..7d6e678a6 --- /dev/null +++ b/ts/fixtures/lang/splits/ts.toml @@ -0,0 +1,2 @@ +package = "lang-splits-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/src/harness.rs b/ts/fixtures/lang/src/harness.rs deleted file mode 100644 index 066bedc77..000000000 --- a/ts/fixtures/lang/src/harness.rs +++ /dev/null @@ -1,364 +0,0 @@ -//! The entry point both sides of the differential test run. The first two bytes pick a -//! case and the rest is its input. - -use crate::{ - args, arrays, ascii, atomics, borrows, bounds, boxes, capacity, captures, cells, chars, chunks, clones, - collections, combinators, conversions, counts, cows, cycles, defaults, durations, dyns, edits, elements, ends, - errors, fields, floats, fmt, folds, generics, hashes, heap, hints, holds, ints, iters, joins, keys, lengths, lists, - locals, locks, manual, methods, nested, objects, orders, pointers, refs, results, returns, rings, saturates, - searches, separated, shapes, singles, slices, sorts, splits, statics, strs, tuples, utf8, wrappers, wraps, zeros, -}; - -/// The native side's entry: [`run`], except that a case starting with 0xff prints a -/// [`fmt::Fault`], which the translated side prints from TypeScript in `caller.ts`. -pub fn entry(input: &[u8]) -> Vec { - match input.split_first() { - Some((0xff, data)) => fmt::printed(data), - _ => run(input), - } -} - -/// What a case runs on the third byte and the rest. -type Case = fn(u8, &[u8], &mut Vec); - -/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo -/// their count, so a case added at the end moves no other. -fn cases() -> Vec<(&'static str, Case)> { - vec![ - ("ints::u8_op", ints::u8_op), - ("ints::u16_op", ints::u16_op), - ("ints::u32_op", ints::u32_op), - ("ints::u64_op", ints::u64_op), - ("ints::u128_op", ints::u128_op), - ("ints::usize_op", ints::usize_op), - ("ints::i8_op", ints::i8_op), - ("ints::i16_op", ints::i16_op), - ("ints::i32_op", ints::i32_op), - ("ints::i64_op", ints::i64_op), - ("ints::i128_op", ints::i128_op), - ("ints::isize_op", ints::isize_op), - ("ints::neg", neg), - ("ints::cast", cast), - ("ints::convert", |_, data, out| ints::convert(data, out)), - ("shapes::copies", |_, data, out| shapes::copies(data, out)), - ("shapes::loops", |_, data, out| shapes::loops(data, out)), - ("shapes::patterns", |_, data, out| shapes::patterns(data, out)), - ("shapes::closures", |_, data, out| shapes::closures(data, out)), - ("shapes::discriminants", |_, data, out| shapes::discriminants(data, out)), - ("shapes::library", |_, data, out| shapes::library(data, out)), - ("fmt::ints", fmt::ints), - ("fmt::strings", |_, data, out| fmt::strings(data, out)), - ("fmt::derived", |_, data, out| fmt::derived(data, out)), - ("fmt::written", |_, data, out| fmt::written(data, out)), - ("fmt::panics", fmt::panics), - ("generics::methods", |_, data, out| generics::methods(data, out)), - ("iters::adaptors", iters::adaptors), - ("iters::consumers", iters::consumers), - ("iters::ranges", |_, data, out| iters::ranges(data, out)), - ("iters::options", |_, data, out| iters::options(data, out)), - ("iters::own", |_, data, out| iters::own(data, out)), - ("iters::values", |_, data, out| iters::values(data, out)), - ("shapes::order", |_, data, out| shapes::order(data, out)), - ("collections::hash_maps", collections::hash_maps), - ("collections::sets", collections::sets), - ("collections::btree_maps", collections::btree_maps), - ("collections::deques", |_, data, out| collections::deques(data, out)), - ("shapes::flows", |_, data, out| shapes::flows(data, out)), - ("keys::keys", keys::keys), - ("chars::chars", chars::chars), - ("strs::strs", strs::strs), - ("collections::vecs", |_, data, out| collections::vecs(data, out)), - ("strs::slices", strs::slices), - ("collections::stores", |_, data, out| collections::stores(data, out)), - ("chunks::chunks", chunks::chunks), - ("cows::cows", cows::cows), - ("durations::durations", durations::durations), - ("combinators::combinators", combinators::combinators), - ("splits::splits", splits::splits), - ("nested::nested", nested::nested), - ("refs::refs", |_, data, out| refs::refs(data, out)), - ("fmt::counts", |_, data, out| fmt::counts(data, out)), - ("fmt::rounding", |_, _, out| fmt::rounding(out)), - ("iters::skips", iters::skips), - ("wrappers::wrappers", wrappers::wrappers), - ("edits::edits", edits::edits), - ("utf8::decodes", utf8::decodes), - ("floats::floats", floats::floats), - ("atomics::atomics", atomics::atomics), - ("keys::overrides", keys::overrides), - ("dyns::dyns", |_, data, out| dyns::dyns(data, out)), - ("cells::cells", cells::cells), - ("dyns::shared", |_, data, out| dyns::shared(data, out)), - ("iters::ranked", iters::ranked), - ("captures::captures", captures::captures), - ("locks::locks", |_, data, out| locks::locks(data, out)), - ("locks::relock", |_, data, out| locks::relock(data, out)), - ("locals::locals", |_, data, out| locals::locals(data, out)), - ("statics::statics", |_, data, out| statics::statics(data, out)), - ("locks::rwlocks", |_, data, out| locks::rwlocks(data, out)), - ("borrows::borrows", |_, data, out| borrows::borrows(data, out)), - ("defaults::defaults", |_, data, out| defaults::defaults(data, out)), - ("counts::arcs", |_, data, out| counts::arcs(data, out)), - ("counts::rcs", |_, data, out| counts::rcs(data, out)), - ("counts::cyclic_arcs", |_, data, out| counts::cyclic_arcs(data, out)), - ("counts::cyclic_rcs", |_, data, out| counts::cyclic_rcs(data, out)), - ("counts::unique_arcs", |_, data, out| counts::unique_arcs(data, out)), - ("counts::unique_rcs", |_, data, out| counts::unique_rcs(data, out)), - ("dyns::anys", |_, data, out| dyns::anys(data, out)), - ("dyns::fns", |_, data, out| dyns::fns(data, out)), - ("pointers::copies", |_, data, out| pointers::copies(data, out)), - ("pointers::lists", |_, data, out| pointers::lists(data, out)), - ("pointers::nested", |_, data, out| pointers::nested(data, out)), - ("pointers::places", |_, data, out| pointers::places(data, out)), - ("pointers::sentinels", |_, data, out| pointers::sentinels(data, out)), - ("pointers::shared", |_, data, out| pointers::shared(data, out)), - ("pointers::unchecked", |_, data, out| pointers::unchecked(data, out)), - ("edits::bytes", edits::bytes), - ("arrays::from_fns", |_, data, out| arrays::from_fns(data, out)), - ("collections::optionals", collections::optionals), - ("objects::objects", |_, data, out| objects::objects(data, out)), - ("holds::holds", holds::holds), - ("fmt::wrapped", |_, data, out| fmt::wrapped(data, out)), - ("refs::to_refs", |_, data, out| refs::to_refs(data, out)), - ("orders::orders", orders::orders), - ("counts::cloned_arcs", |_, data, out| counts::cloned_arcs(data, out)), - ("counts::cloned_rcs", |_, data, out| counts::cloned_rcs(data, out)), - ("counts::copies", |_, data, out| counts::copies(data, out)), - ("statics::cells", |_, data, out| statics::cells(data, out)), - ("iters::returned", |_, data, out| iters::returned(data, out)), - ("hashes::values", hashes::values), - ("hashes::random", |_, data, out| hashes::random(data, out)), - ("floats::formats", floats::formats), - ("floats::parses", floats::parses), - ("orders::bytes", |_, data, out| orders::bytes(data, out)), - ("slices::parts", slices::parts), - ("slices::drains", slices::drains), - ("slices::chunked", slices::chunked), - ("statics::onces", |_, data, out| statics::onces(data, out)), - ("fmt::writes", |_, data, out| fmt::writes(data, out)), - ("bounds::bounds", bounds::bounds), - ("pointers::cells", |_, data, out| pointers::cells(data, out)), - ("ints::parses", ints::parses), - ("strs::edits", strs::edits), - ("slices::subslices", slices::subslices), - ("hashes::bytes", |_, data, out| hashes::bytes(data, out)), - ("keys::bytes", keys::bytes), - ("strs::parses", strs::parses), - ("pointers::rebound", |_, data, out| pointers::rebound(data, out)), - ("slices::ranges", slices::ranges), - ("iters::reducers", |_, data, out| iters::reducers(data, out)), - ("pointers::writers", |_, data, out| pointers::writers(data, out)), - ("errors::eqs", errors::eqs), - ("slices::edits", slices::edits), - ("strs::iters", strs::iters), - ("strs::drains", strs::drains), - ("strs::hinted", strs::hinted), - ("pointers::made", |_, data, out| pointers::made(data, out)), - ("arrays::as_slices", |_, data, out| arrays::as_slices(data, out)), - ("ints::widenings", ints::widenings), - ("shapes::uninhabited", |_, data, out| shapes::uninhabited(data, out)), - ("keys::lent_keys", keys::lent_keys), - ("keys::lent_values", keys::lent_values), - ("singles::singles", singles::singles), - ("singles::formats", singles::formats), - ("singles::parses", singles::parses), - ("iters::peeked_others", |_, data, out| iters::peeked_others(data, out)), - ("hints::hints", hints::hints), - ("hints::reserves", hints::reserves), - ("collections::set_ops", collections::set_ops), - ("folds::folds", folds::folds), - ("zeros::zeros", zeros::zeros), - ("arrays::maps", |_, data, out| arrays::maps(data, out)), - ("arrays::lent", |_, data, out| arrays::lent(data, out)), - ("floats::mul_adds", floats::mul_adds), - ("singles::mul_adds", singles::mul_adds), - ("fmt::collections", |_, data, out| fmt::collections(data, out)), - ("collections::unlike_eqs", collections::unlike_eqs), - ("zeros::impls", zeros::impls), - ("zeros::keys", zeros::keys), - ("keys::arrays", keys::arrays), - ("iters::zips", iters::zips), - ("iters::zips_back", iters::zips_back), - ("collections::own_nes", collections::own_nes), - ("fmt::iters", |_, data, out| fmt::iters(data, out)), - ("zeros::unread", zeros::unread), - ("iters::range_froms", iters::range_froms), - ("iters::range_methods", iters::range_methods), - ("clones::iters", clones::iters), - ("collections::cell_eqs", collections::cell_eqs), - ("iters::compares", iters::compares), - ("collections::unlike_compares", collections::unlike_compares), - ("collections::ref_orders", collections::ref_orders), - ("cycles::cycles", cycles::cycles), - ("pointers::lapsed", |_, data, out| pointers::lapsed(data, out)), - ("cows::slices", cows::slices), - ("cows::bytes", cows::bytes), - ("wraps::u8s", wraps::u8s), - ("wraps::u16s", wraps::u16s), - ("wraps::u32s", wraps::u32s), - ("wraps::u64s", wraps::u64s), - ("wraps::u128s", wraps::u128s), - ("wraps::usizes", wraps::usizes), - ("wraps::i8s", wraps::i8s), - ("wraps::i16s", wraps::i16s), - ("wraps::i32s", wraps::i32s), - ("wraps::i64s", wraps::i64s), - ("wraps::i128s", wraps::i128s), - ("wraps::isizes", wraps::isizes), - ("fmt::enums", |_, data, out| fmt::enums(data, out)), - ("pointers::segments", |_, data, out| pointers::segments(data, out)), - ("pointers::uninit_runs", |_, data, out| pointers::uninit_runs(data, out)), - ("pointers::beside_written", |_, data, out| { - pointers::beside_written(data, out) - }), - ("keys::byte_refs", keys::byte_refs), - ("orders::held", |_, data, out| orders::held(data, out)), - ("joins::joins", joins::joins), - ("pointers::iterated_runs", |_, data, out| { - pointers::iterated_runs(data, out) - }), - ("zeros::writes", zeros::writes), - ("orders::tuples", |_, data, out| orders::tuples(data, out)), - ("tuples::tuples", tuples::tuples), - ("saturates::u8s", saturates::u8s), - ("saturates::u16s", saturates::u16s), - ("saturates::u32s", saturates::u32s), - ("saturates::u64s", saturates::u64s), - ("saturates::u128s", saturates::u128s), - ("saturates::usizes", saturates::usizes), - ("saturates::i8s", saturates::i8s), - ("saturates::i16s", saturates::i16s), - ("saturates::i32s", saturates::i32s), - ("saturates::i64s", saturates::i64s), - ("saturates::i128s", saturates::i128s), - ("saturates::isizes", saturates::isizes), - ("methods::u8s", methods::u8s), - ("methods::u16s", methods::u16s), - ("methods::u32s", methods::u32s), - ("methods::u64s", methods::u64s), - ("methods::u128s", methods::u128s), - ("methods::usizes", methods::usizes), - ("methods::i8s", methods::i8s), - ("methods::i16s", methods::i16s), - ("methods::i32s", methods::i32s), - ("methods::i64s", methods::i64s), - ("methods::i128s", methods::i128s), - ("methods::isizes", methods::isizes), - ("separated::separated", separated::separated), - ("pointers::waiters", |_, data, out| pointers::waiters(data, out)), - ("boxes::boxes", boxes::boxes), - ("ascii::bytes", ascii::bytes), - ("ascii::chars", ascii::chars), - ("ascii::slices", ascii::slices), - ("arrays::given", arrays::given), - ("pointers::taken", |_, data, out| pointers::taken(data, out)), - ("pointers::bytes", |_, data, out| pointers::bytes(data, out)), - ("pointers::loaded", |_, data, out| pointers::loaded(data, out)), - ("orders::btrees", orders::btrees), - ("lengths::lengths", lengths::lengths), - ("iters::option_items", |_, data, out| iters::option_items(data, out)), - ("lists::lists", lists::lists), - ("pointers::reattached", |_, data, out| pointers::reattached(data, out)), - ("pointers::part_written", |_, data, out| { - pointers::part_written(data, out) - }), - ("pointers::aimed", |_, data, out| pointers::aimed(data, out)), - ("ascii::parts", ascii::parts), - ("boxes::places", boxes::places), - ("arrays::flattened", arrays::flattened), - ("args::args", args::args), - ("returns::returns", returns::returns), - ("generics::runs", |_, data, out| generics::runs(data, out)), - ("borrows::guards", |_, data, out| borrows::guards(data, out)), - ("results::results", results::results), - ("fields::fields", fields::fields), - ("strs::gets", strs::gets), - ("refs::adapted", |_, data, out| refs::adapted(data, out)), - ("borrows::maps", |_, data, out| borrows::maps(data, out)), - ("locks::mapped", |_, data, out| locks::mapped(data, out)), - ("boxes::impls", boxes::impls), - ("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)), - ("capacity::vecs", capacity::vecs), - ("capacity::deques", capacity::deques), - ("capacity::heaps", capacity::heaps), - ("capacity::collects", capacity::collects), - ("capacity::maps", capacity::maps), - ("locks::downgraded", |_, data, out| locks::downgraded(data, out)), - ("borrows::leaks", |_, data, out| borrows::leaks(data, out)), - ("collections::deque_ranges", collections::deque_ranges), - ("ends::ends", ends::ends), - ("elements::vecs", |_, data, out| elements::vecs(data, out)), - ("elements::arrays", |_, data, out| elements::arrays(data, out)), - ("elements::segments", |_, data, out| elements::segments(data, out)), - ("elements::inline", |_, data, out| elements::inline(data, out)), - ("elements::edges", |_, data, out| elements::edges(data, out)), - ("heap::spills", |_, data, out| heap::spills(data, out)), - ("heap::layouts", |_, data, out| heap::layouts(data, out)), - ("heap::remnants", |_, data, out| heap::remnants(data, out)), - ("manual::arcs", |_, data, out| manual::arcs(data, out)), - ("elements::raw_slices", |_, data, out| elements::raw_slices(data, out)), - ("elements::empty_parts", |_, data, out| elements::empty_parts(data, out)), - ("hashes::own", |_, data, out| hashes::own(data, out)), - ("refs::compared", refs::compared), - ("rings::slices", rings::slices), - ("fmt::objects", |_, data, out| fmt::objects(data, out)), - ("sorts::sorts", sorts::sorts), - ("sorts::disorders", sorts::disorders), - ("sorts::btrees", sorts::btrees), - ("dyns::pointers", |_, data, out| dyns::pointers(data, out)), - ("searches::searches", searches::searches), - ("searches::texts", searches::texts), - ("dyns::iters", |_, data, out| dyns::iters(data, out)), - ("errors::objects", |_, data, out| errors::objects(data, out)), - ("iters::lent", |_, data, out| iters::lent(data, out)), - ] -} - -/// Run one case. -pub fn run(input: &[u8]) -> Vec { - let mut out = Vec::new(); - let [high, low, kind, data @ ..] = input else { - return out; - }; - let cases = cases(); - let (_, case) = cases[usize::from(u16::from_be_bytes([*high, *low])) % cases.len()]; - case(*kind, data, &mut out); - out -} - -/// The first two bytes, as one big-endian number, that pick the case named `name`, which -/// `caller.ts` targets by. -pub fn op(name: &str) -> u16 { - let Some(i) = cases().iter().position(|&(n, _)| n == name) else { - panic!("no case {name}"); - }; - // A first byte of 0xff is `entry`'s, which prints a `Fault` instead. - match u16::try_from(i) { - Ok(op) if op >> 8 != 0xff => op, - _ => panic!("case {name} is past what two bytes pick"), - } -} - -/// Negate the signed type `kind` picks. -fn neg(kind: u8, data: &[u8], out: &mut Vec) { - match kind % 6 { - 0 => ints::i8_neg(data, out), - 1 => ints::i16_neg(data, out), - 2 => ints::i32_neg(data, out), - 3 => ints::i64_neg(data, out), - 4 => ints::i128_neg(data, out), - _ => ints::isize_neg(data, out), - } -} - -/// Cast from the type `kind` picks to the one the next byte does, or without one, to -/// a type `kind` also picks. -fn cast(kind: u8, data: &[u8], out: &mut Vec) { - match data.split_first() { - Some((&to, data)) => ints::cast(kind, to, data, out), - None => ints::cast(kind, kind / 12, data, out), - } -} diff --git a/ts/fixtures/lang/src/lib.rs b/ts/fixtures/lang/src/lib.rs deleted file mode 100644 index d83547fda..000000000 --- a/ts/fixtures/lang/src/lib.rs +++ /dev/null @@ -1,118 +0,0 @@ -//! The language the driver translates, exercised against native Rust: every integer -//! width's arithmetic, casts, and inherent methods, `f64`, `char`s and the `str` methods over them, -//! `Cow`, boxed slices and text, `Duration`, control flow, patterns, byte slices split apart, -//! passed as their parts, returned in a slot, and held as their parts in fields, `Copy` -//! aggregates, closures and what they write of what they captured, traits, generic -//! types, formatting, collections, `LinkedList`s, UTF-8 decoding, `&mut` to values JS copies, whole -//! writes through a `&mut` to an object, the standard library calls it maps, `Option`'s -//! and `Result`'s combinators from core's MIR, `Result`'s iterators, `Option`s of values that can already be -//! `undefined`, atomics, `static` ones included, trait objects, one-time cells, mutexes, -//! `Cell`s, `UnsafeCell`s, `RefCell`s, read-write locks, and thread-locals, the defaults -//! of std types, the counts of shared pointers, arrays `array::from_fn` and `map` make, -//! their elements each lent, arrays as slices, maps of `Option`s, values held back past a -//! write of a variable they name, what -//! `Hash` writes into `DefaultHasher` and `RandomState`, slices' `windows` and chunks, -//! mutable ones written through, their parts by inclusive and checked ranges and by fixed -//! size, slices split by a predicate, `Vec::drain`, `concat` and `join` of slices of -//! slices, the order, equality, and -//! hashes of bytes, ranges of `Bound`s and of the crate's own `RangeBounds`, the equality -//! of `Result`s and std's errors, inclusive ranges read through each adaptor, iterators' -//! size hints, the crate's own iterators read from the back and by their length, the capacity overflows collections reserving by them panic with, the -//! capacity of a `Vec`, `VecDeque`, and `BinaryHeap` as each grows and shrinks, pointers -//! into arrays moved, measured, and copied between, memory from `alloc` typed by a cast of -//! its pointer, grown, shrunk, and freed, and the `Layout`s it is laid out by, values -//! held by `ManuallyDrop`, which drops them only when asked, tuples of -//! collections collected and extended by their items, zero-sized values, which MIR -//! 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. - -#![feature( - cell_leak, - hasher_prefixfree_extras, - iter_order_by, - mapped_lock_guards, - once_cell_try, - refcell_try_map, - split_as_slice, - wrapping_int_impl, - wrapping_next_power_of_two -)] - -mod args; -mod arrays; -mod ascii; -mod atomics; -mod borrows; -mod bounds; -mod boxes; -mod capacity; -mod captures; -mod cells; -mod chars; -mod chunks; -mod clones; -mod collections; -mod combinators; -mod conversions; -mod counts; -mod cows; -mod cycles; -mod defaults; -mod durations; -mod dyns; -mod edits; -mod elements; -mod ends; -mod errors; -mod fields; -mod floats; -mod fmt; -mod folds; -mod generics; -pub mod harness; -mod hashes; -mod heap; -mod hints; -mod holds; -mod ints; -mod iters; -mod joins; -mod keys; -mod lengths; -mod lists; -mod locals; -mod locks; -mod manual; -mod methods; -mod nested; -mod objects; -mod orders; -mod pointers; -mod refs; -mod results; -mod returns; -mod rings; -mod saturates; -mod searches; -mod separated; -mod shapes; -mod singles; -mod slices; -mod sorts; -mod splits; -mod statics; -mod strs; -mod tuples; -mod utf8; -#[cfg(target_arch = "wasm32")] -#[path = "../../wasm.rs"] -mod wasm; -mod wrappers; -mod wraps; -mod zeros; -#[cfg(target_arch = "wasm32")] -use harness::entry; diff --git a/ts/fixtures/lang/statics/Cargo.toml b/ts/fixtures/lang/statics/Cargo.toml new file mode 100644 index 000000000..c943e2922 --- /dev/null +++ b/ts/fixtures/lang/statics/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-statics-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/statics/caller.ts b/ts/fixtures/lang/statics/caller.ts new file mode 100644 index 000000000..0bda51884 --- /dev/null +++ b/ts/fixtures/lang/statics/caller.ts @@ -0,0 +1,14 @@ +// The inputs `statics`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `statics::onces` scripts: a `Once` forced, called, and forced again, which drops the + * function it never runs, each static's, each `call_once` and `call_once_force` run again + * from within itself, and crossbeam-epoch's `OnceLock` of each kind. + */ +const onces = [[1, 0, 1, 7], [0, 6, 1, 2, 3, 4, 5, 11], [2, 14, 8], [9], [3, 15], [4, 17, 23, 29, 4]].map((bytes) => Uint8Array.of(...op("statics::onces"), 0, ...bytes)); + +export const cases: Uint8Array[] = [...onces]; diff --git a/ts/fixtures/lang/statics/expected/harness.ts b/ts/fixtures/lang/statics/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/statics/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/statics/expected/lib.ts b/ts/fixtures/lang/statics/expected/lib.ts new file mode 100644 index 000000000..af4d9796b --- /dev/null +++ b/ts/fixtures/lang/statics/expected/lib.ts @@ -0,0 +1,33 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { statics, cells, onces } from "./statics.ts"; +import * as Lock from "./statics.Lock.ts"; + +export function drop$statics_Lock_Rc_unit(_1: Lock.Lock>): void { + Lock.drop$ops_Drop_Rc_unit(_1); +} + +export function drop$statics_Lock_tuple2_u8_Rc_unit(_1: Lock.Lock<[rt.u8, rt.Arc]>): void { + Lock.drop$ops_Drop_tuple2_u8_Rc_unit(_1); +} + +export function drop$tuple2_u8_Rc_unit(_1: [rt.u8, rt.Arc]): void { + _1[1][Symbol.dispose](); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["statics::statics", (_22: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + statics(data, out); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["statics::cells", (_23: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + cells(data2, out2); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["statics::onces", (_24: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + onces(data3, out3); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/statics.Collector.ts b/ts/fixtures/lang/statics/expected/statics.Collector.ts similarity index 100% rename from ts/fixtures/lang/expected/statics.Collector.ts rename to ts/fixtures/lang/statics/expected/statics.Collector.ts diff --git a/ts/fixtures/lang/expected/statics.Counter.ts b/ts/fixtures/lang/statics/expected/statics.Counter.ts similarity index 100% rename from ts/fixtures/lang/expected/statics.Counter.ts rename to ts/fixtures/lang/statics/expected/statics.Counter.ts diff --git a/ts/fixtures/lang/expected/statics.Lock.ts b/ts/fixtures/lang/statics/expected/statics.Lock.ts similarity index 100% rename from ts/fixtures/lang/expected/statics.Lock.ts rename to ts/fixtures/lang/statics/expected/statics.Lock.ts diff --git a/ts/fixtures/lang/expected/statics.Node.ts b/ts/fixtures/lang/statics/expected/statics.Node.ts similarity index 100% rename from ts/fixtures/lang/expected/statics.Node.ts rename to ts/fixtures/lang/statics/expected/statics.Node.ts diff --git a/ts/fixtures/lang/expected/statics.Raw.ts b/ts/fixtures/lang/statics/expected/statics.Raw.ts similarity index 100% rename from ts/fixtures/lang/expected/statics.Raw.ts rename to ts/fixtures/lang/statics/expected/statics.Raw.ts diff --git a/ts/fixtures/lang/expected/statics.ts b/ts/fixtures/lang/statics/expected/statics.ts similarity index 86% rename from ts/fixtures/lang/expected/statics.ts rename to ts/fixtures/lang/statics/expected/statics.ts index ce829adac..2ea5084e1 100644 --- a/ts/fixtures/lang/expected/statics.ts +++ b/ts/fixtures/lang/statics/expected/statics.ts @@ -2,11 +2,11 @@ import * as rt from "./rt.ts"; import { drop$statics_Lock_Rc_unit, drop$statics_Lock_tuple2_u8_Rc_unit } from "./lib.ts"; -import { LATER, read as elsewhere_read } from "./statics/elsewhere.ts"; +import { LATER, read } from "./statics/elsewhere.ts"; import * as Collector from "./statics.Collector.ts"; import type * as Counter from "./statics.Counter.ts"; -import * as statics_Lock from "./statics.Lock.ts"; -import type * as statics_Node from "./statics.Node.ts"; +import * as Lock from "./statics.Lock.ts"; +import type * as Node from "./statics.Node.ts"; import type * as Raw from "./statics.Raw.ts"; export const COUNT: rt.Atomic = /* @__PURE__ */ new rt.Atomic({ hi: 0xffffffff, lo: 0xfffffffd } as rt.u64); @@ -103,7 +103,7 @@ export const SHARED: rt.LazyCell> = /* @__PURE__ */ new rt.Lazy return LATER; }); -export const SLOT: rt.Atomic = /* @__PURE__ */ new rt.Atomic(rt.NULL); +export const SLOT: rt.Atomic = /* @__PURE__ */ new rt.Atomic(rt.NULL); export const ONCE: rt.OnceLock<[rt.u8, rt.u32]> = /* @__PURE__ */ new rt.OnceLock(undefined); @@ -168,17 +168,17 @@ export function cells(data: rt.ByteSlice, out: rt.ByteVec): void { continue; } if (_68 === 4) { - const node: statics_Node.Node = { value: n2 }; - const old: statics_Node.Node = rt.atomicSwap(SLOT, node, 3); + const node: Node.Node = { value: n2 }; + const old: Node.Node = rt.atomicSwap(SLOT, node, 3); rt.byteVecPush(out, old === rt.NULL ? 1 : 0); rt.byteVecPush(out, rt.atomicLoad(SLOT, 2).value); - const _116: rt.Result = rt.atomicCompareExchange(SLOT, old, rt.NULL, 3, 2); + const _116: rt.Result = rt.atomicCompareExchange(SLOT, old, rt.NULL, 3, 2); if (_116.ok) { rt.byteVecPush(out, 253); } else { rt.byteVecPush(out, _116.error === node ? 1 : 0); } - const _125: rt.Result = rt.atomicCompareExchange(SLOT, node, rt.NULL, 3, 2); + const _125: rt.Result = rt.atomicCompareExchange(SLOT, node, rt.NULL, 3, 2); if (_125.ok) { rt.byteVecPush(out, _125.value.value); } else { @@ -208,7 +208,7 @@ export function cells(data: rt.ByteSlice, out: rt.ByteVec): void { } if (_68 === 7) { if (rt.u8Rem(n2, 2) === 0) { - rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(rt.atomicFetch(SHARED.force(), rt.u8WrappingAdd, n2, 0), rt.atomicLoad(LATER, 0), elsewhere_read())), undefined, true); + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(rt.atomicFetch(SHARED.force(), rt.u8WrappingAdd, n2, 0), rt.atomicLoad(LATER, 0), read())), undefined, true); rt.atomicStore(LATER, 40, 0); continue; } @@ -233,8 +233,8 @@ export function cells(data: rt.ByteSlice, out: rt.ByteVec): void { rt.atomicStore(COUNTER.hits, 4294967295 - 1, 0); } -export const COLLECTOR: rt.LazyCell> = /* @__PURE__ */ new rt.LazyCell((): statics_Lock.Lock => { - return new statics_Lock.Lock(new rt.OnceLock(undefined), new rt.Cell((new Collector.Collector((undefined as unknown) as rt.Arc) as unknown) as Collector.Collector)); +export const COLLECTOR: rt.LazyCell> = /* @__PURE__ */ new rt.LazyCell((): Lock.Lock => { + return new Lock.Lock(new rt.OnceLock(undefined), new rt.Cell((new Collector.Collector((undefined as unknown) as rt.Arc) as unknown) as Collector.Collector)); }); export const STARTED: rt.Once = /* @__PURE__ */ new rt.OnceLock(undefined); @@ -288,25 +288,25 @@ export function onces(data: rt.ByteSlice, out: rt.ByteVec): void { }); } } else if (_13 === 4) { - const collector: Collector.Collector = statics_Lock.getOrInit$statics_Collector_statics_onces_closure5(COLLECTOR.force(), (): Collector.Collector => { + const collector: Collector.Collector = Lock.getOrInit$statics_Collector_statics_onces_closure5(COLLECTOR.force(), (): Collector.Collector => { return new Collector.Collector(new rt.Arc(16909060)); }); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(collector.global.value).reverse()), undefined, true); rt.byteVecPush(out, collector.global.strong & 0xff); } else if (!(rt.u8Rem(n, 3) === 0)) { if (!(rt.u8Rem(n, 3) === 1)) { - drop$statics_Lock_Rc_unit(statics_Lock.new$Rc_unit()); + drop$statics_Lock_Rc_unit(Lock.new$Rc_unit()); rt.byteVecPush(out, owned.strong & 0xff); } else { - const slot2: statics_Lock.Lock<[rt.u8, rt.Arc]> = statics_Lock.new$tuple2_u8_Rc_unit(); + const slot2: Lock.Lock<[rt.u8, rt.Arc]> = Lock.new$tuple2_u8_Rc_unit(); const captured3 = rt.arcClone(owned); - rt.byteVecPush(out, statics_Lock.getOrInit$tuple2_u8_Rc_unit_statics_onces_closure8(slot2, rt.closure((): [rt.u8, rt.Arc] => { + rt.byteVecPush(out, Lock.getOrInit$tuple2_u8_Rc_unit_statics_onces_closure8(slot2, rt.closure((): [rt.u8, rt.Arc] => { return [n, captured3] as [rt.u8, rt.Arc]; }, (): void => { captured3[Symbol.dispose](); }))[0]); const captured4 = rt.arcClone(owned); - rt.byteVecPush(out, statics_Lock.getOrInit$tuple2_u8_Rc_unit_statics_onces_closure9(slot2, rt.closure((): [rt.u8, rt.Arc] => { + rt.byteVecPush(out, Lock.getOrInit$tuple2_u8_Rc_unit_statics_onces_closure9(slot2, rt.closure((): [rt.u8, rt.Arc] => { return [238, captured4] as [rt.u8, rt.Arc]; }, (): void => { captured4[Symbol.dispose](); @@ -316,15 +316,15 @@ export function onces(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, owned.strong & 0xff); } } else { - const slot: statics_Lock.Lock> = statics_Lock.new$Rc_unit(); + const slot: Lock.Lock> = Lock.new$Rc_unit(); const captured = rt.arcClone(owned); - rt.byteVecPush(out, statics_Lock.getOrInit$Rc_unit_statics_onces_closure6(slot, rt.closure((): rt.Arc => { + rt.byteVecPush(out, Lock.getOrInit$Rc_unit_statics_onces_closure6(slot, rt.closure((): rt.Arc => { return captured; }, (): void => { captured[Symbol.dispose](); })).strong & 0xff); const captured2 = rt.arcClone(owned); - rt.byteVecPush(out, statics_Lock.getOrInit$Rc_unit_statics_onces_closure7(slot, rt.closure((): rt.Arc => { + rt.byteVecPush(out, Lock.getOrInit$Rc_unit_statics_onces_closure7(slot, rt.closure((): rt.Arc => { return captured2; }, (): void => { captured2[Symbol.dispose](); diff --git a/ts/fixtures/lang/expected/statics/elsewhere.ts b/ts/fixtures/lang/statics/expected/statics/elsewhere.ts similarity index 100% rename from ts/fixtures/lang/expected/statics/elsewhere.ts rename to ts/fixtures/lang/statics/expected/statics/elsewhere.ts diff --git a/ts/fixtures/lang/statics/src/lib.rs b/ts/fixtures/lang/statics/src/lib.rs new file mode 100644 index 000000000..3f02ac517 --- /dev/null +++ b/ts/fixtures/lang/statics/src/lib.rs @@ -0,0 +1,23 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod statics; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("statics::statics", |_, data, out| statics::statics(data, out)), + ("statics::cells", |_, data, out| statics::cells(data, out)), + ("statics::onces", |_, data, out| statics::onces(data, out)), + ] +} diff --git a/ts/fixtures/lang/src/statics.rs b/ts/fixtures/lang/statics/src/statics.rs similarity index 100% rename from ts/fixtures/lang/src/statics.rs rename to ts/fixtures/lang/statics/src/statics.rs diff --git a/ts/fixtures/lang/statics/ts.toml b/ts/fixtures/lang/statics/ts.toml new file mode 100644 index 000000000..b2d698138 --- /dev/null +++ b/ts/fixtures/lang/statics/ts.toml @@ -0,0 +1,2 @@ +package = "lang-statics-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/strs/Cargo.toml b/ts/fixtures/lang/strs/Cargo.toml new file mode 100644 index 000000000..1e26404cd --- /dev/null +++ b/ts/fixtures/lang/strs/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-strs-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/strs/caller.ts b/ts/fixtures/lang/strs/caller.ts new file mode 100644 index 000000000..63e591d87 --- /dev/null +++ b/ts/fixtures/lang/strs/caller.ts @@ -0,0 +1,56 @@ +// The inputs `strs`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `strs::edits` of each edit on `aé\u{800}😀`, a char of each UTF-8 width, at every byte + * offset into it and up to two past its end, each made a raw offset by its byte's bits. + */ +const editsOp = op("strs::edits"); +const edits = Array.from({ length: 14 * 16 * 16 }, (_, i) => Uint8Array.of(...editsOp, 4, 2, 7, 9, 14, i >> 8, (i >> 4) & 15, i & 15)); + +/** + * `strs::drains` of each range and way to end the drain on `aé\u{800}😀`, at every byte + * offset into it and up to two past its end, reading none, two from either end, or three + * from the back. + */ +const drainsOp = op("strs::drains"); +const drains = Array.from({ length: 32 * 13 * 13 }, (_, i) => { + const [form, a, b] = [i % 32, Math.floor(i / 32) % 13, Math.floor(i / 416)]; + return Uint8Array.of(...drainsOp, 4, 2, 7, 9, 14, form, a, b, [0, 0x0a, 0x1f][(form + a + b) % 3]); +}); + +/** `strs::iters` of each kind, on no text, text of each UTF-8 width, and parts between `/`s, empty ones too. */ +const iters = Array.from({ length: 12 }, (_, kind) => [[], [2, 7, 9, 14], [0, 2, 0, 0, 7, 9], [14, 0]].map((data) => Uint8Array.of(...op("strs::iters"), kind, ...data))).flat(); + +/** + * `strs::strs`' splits and `rsplit_once` by `/`, and `strs::slices`' by an empty and a + * one-char pattern, on no text, a separator alone, twice, and at either end, read from + * either end. + */ +const separatorEnds = [[], [0], [0, 0], [0, 2], [2, 0], [0, 2, 0], [0x80, 2, 0], [2, 0x80, 0x80], [0, 0x82, 0x80, 7]]; +const splitEnds = separatorEnds.flatMap((data) => [ + ...[1, 3].map((kind) => Uint8Array.of(...op("strs::strs"), kind, ...data)), + ...[2, 2 | 8].map((kind) => Uint8Array.of(...op("strs::slices"), kind, ...data)), +]); + +/** `strs::hinted` of each adaptor and each pair of range lengths, each way, on `aé` alone. */ +const hintedOp = op("strs::hinted"); +const hinted = Array.from({ length: 10 * 7 * 21 }, (_, i) => Uint8Array.of(...hintedOp, i % 10, Math.floor(i / 10) % 7, Math.floor(i / 70))); + +/** + * `strs::gets` of each kind at every pair of byte offsets up to two past the end of its 13 + * bytes of text, and of no text, and at `usize::MAX`. + */ +const getsOp = op("strs::gets"); +const getsAt = (n: number) => [...Array.from({ length: n + 3 }, (_, i) => i), 0xff]; +const gets = [0, 0x10].flatMap((text) => { + const at = getsAt(text === 0 ? 13 : 0); + return Array.from({ length: 16 * at.length * at.length }, (_, i) => + Uint8Array.of(...getsOp, text | (i % 16), at[Math.floor(i / 16) % at.length], at[Math.floor(i / 16 / at.length)]), + ); +}); + +export const cases: Uint8Array[] = [...edits, ...drains, ...iters, ...splitEnds, ...hinted, ...gets]; diff --git a/ts/fixtures/lang/strs/expected/core/bool.ts b/ts/fixtures/lang/strs/expected/core/bool.ts new file mode 100644 index 000000000..2bfc616b4 --- /dev/null +++ b/ts/fixtures/lang/strs/expected/core/bool.ts @@ -0,0 +1,10 @@ +// Generated by rust2-ts. Do not edit. + +export function then$0havnzo(self: boolean, f: () => string): string | undefined { + if (!self) { + return undefined; + } + return f(); +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/strs/expected/core/char/methods.ts b/ts/fixtures/lang/strs/expected/core/char/methods.ts new file mode 100644 index 000000000..992b1a141 --- /dev/null +++ b/ts/fixtures/lang/strs/expected/core/char/methods.ts @@ -0,0 +1,27 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../../rt.ts"; + +export function toDigit$01k9ewn(self: rt.char, radix: rt.u32): rt.u32 | undefined { + let value!: rt.u32; + if (radix >= 2) { + if (radix <= 36) { + b1: { + if (self > 57) { + if (radix > 10) { + value = rt.u32Add((rt.u32WrappingSub(self as rt.u32, 65 as rt.u32) & 4294967263) >>> 0, 10); + break b1; + } + } + value = rt.u32WrappingSub(self as rt.u32, 48 as rt.u32); + } + if (!(value < radix)) { + return undefined; + } + return value; + } + } + rt.panicFmt(["to_digit: invalid radix -- radix must be in the range 2 to 36 inclusive"]); +} + +//# sourceMappingURL=methods.ts.map diff --git a/ts/fixtures/lang/strs/expected/core/num.ts b/ts/fixtures/lang/strs/expected/core/num.ts new file mode 100644 index 000000000..fc2cf0169 --- /dev/null +++ b/ts/fixtures/lang/strs/expected/core/num.ts @@ -0,0 +1,1878 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import { toDigit$01k9ewn } from "../core/char/methods.ts"; + +export function canNotOverflow$0q497dn(radix: rt.u32, isSignedTy: boolean, _digitsData: Uint8Array, _digitsStart: number, digitsLen: number): boolean { + if (!(radix <= 16)) { + return false; + } + return digitsLen <= rt.usizeSub(rt.usizeMul(16, 2), isSignedTy ? 1 : 0); +} + +export function canNotOverflow$1wu8g18(radix: rt.u32, isSignedTy: boolean, _digitsData: Uint8Array, _digitsStart: number, digitsLen: number): boolean { + if (!(radix <= 16)) { + return false; + } + return digitsLen <= rt.usizeSub(rt.usizeMul(2, 2), isSignedTy ? 1 : 0); +} + +export function canNotOverflow$0uown4l(radix: rt.u32, isSignedTy: boolean, _digitsData: Uint8Array, _digitsStart: number, digitsLen: number): boolean { + if (!(radix <= 16)) { + return false; + } + return digitsLen <= rt.usizeSub(rt.usizeMul(4, 2), isSignedTy ? 1 : 0); +} + +export function canNotOverflow$03q1vv8(radix: rt.u32, isSignedTy: boolean, _digitsData: Uint8Array, _digitsStart: number, digitsLen: number): boolean { + if (!(radix <= 16)) { + return false; + } + return digitsLen <= rt.usizeSub(rt.usizeMul(8, 2), isSignedTy ? 1 : 0); +} + +export function canNotOverflow$0aqh4yo(radix: rt.u32, isSignedTy: boolean, _digitsData: Uint8Array, _digitsStart: number, digitsLen: number): boolean { + if (!(radix <= 16)) { + return false; + } + return digitsLen <= rt.usizeSub(rt.usizeMul(1, 2), isSignedTy ? 1 : 0); +} + +export function fromAsciiBytesRadixPanic(radix: rt.u32): never { + doPanic$0sx2e1f(radix); +} + +export function doPanic$0sx2e1f(radix: rt.u32): never { + runtime$0bn0geu(radix); +} + +export function runtime$0bn0geu(radix: rt.u32): never { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(radix, f)]; + rt.panicFmt(["from_ascii_bytes_radix: radix must lie in the range `[2, 36]` - found ", args2[0]]); +} + +export function fromAsciiBytesRadixImpl$0xhcrxt(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = rt.i128Gt(0, { hi: -0x80000000, w2: 0, w1: 0, lo: 0 } as rt.i128); + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.i128 = 0; + b5: { + if (!canNotOverflow$0q497dn(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.i128 | undefined = rt.i128CheckedMul(result, radix as rt.i128); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.i128 = _92 as rt.i128; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.i128 | undefined = rt.i128CheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.i128 | undefined = rt.i128CheckedMul(result, radix as rt.i128); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.i128 = _67 as rt.i128; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.i128 | undefined = rt.i128CheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.i128WrappingMul(result, radix as rt.i128); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.i128WrappingSub(result, _49 as rt.i128); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.i128WrappingMul(result, radix as rt.i128); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.i128WrappingAdd(result, _32 as rt.i128); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromAsciiBytesRadixImpl$0jbbuu8(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = 0 > -32768; + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.i16 = 0; + b5: { + if (!canNotOverflow$1wu8g18(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.i16 | undefined = rt.i16CheckedMul(result, (radix << 16) >> 16); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.i16 = (_92 << 16) >> 16; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.i16 | undefined = rt.i16CheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.i16 | undefined = rt.i16CheckedMul(result, (radix << 16) >> 16); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.i16 = (_67 << 16) >> 16; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.i16 | undefined = rt.i16CheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.i16WrappingMul(result, (radix << 16) >> 16); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.i16WrappingSub(result, (_49 << 16) >> 16); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.i16WrappingMul(result, (radix << 16) >> 16); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.i16WrappingAdd(result, (_32 << 16) >> 16); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromAsciiBytesRadixImpl$0p2idzk(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = 0 > -2147483648; + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.i32 = 0; + b5: { + if (!canNotOverflow$0uown4l(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.i32 | undefined = rt.i32CheckedMul(result, radix | 0); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.i32 = _92 | 0; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.i32 | undefined = rt.i32CheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.i32 | undefined = rt.i32CheckedMul(result, radix | 0); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.i32 = _67 | 0; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.i32 | undefined = rt.i32CheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.i32WrappingMul(result, radix | 0); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.i32WrappingSub(result, _49 | 0); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.i32WrappingMul(result, radix | 0); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.i32WrappingAdd(result, _32 | 0); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromAsciiBytesRadixImpl$01tfvb9(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = rt.i64Gt(0, { hi: -0x80000000, lo: 0 } as rt.i64); + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.i64 = 0; + b5: { + if (!canNotOverflow$03q1vv8(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.i64 | undefined = rt.i64CheckedMul(result, radix as rt.i64); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.i64 = _92 as rt.i64; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.i64 | undefined = rt.i64CheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.i64 | undefined = rt.i64CheckedMul(result, radix as rt.i64); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.i64 = _67 as rt.i64; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.i64 | undefined = rt.i64CheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.i64WrappingMul(result, radix as rt.i64); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.i64WrappingSub(result, _49 as rt.i64); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.i64WrappingMul(result, radix as rt.i64); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.i64WrappingAdd(result, _32 as rt.i64); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromAsciiBytesRadixImpl$18og5o1(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = 0 > -128; + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.i8 = 0; + b5: { + if (!canNotOverflow$0aqh4yo(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.i8 | undefined = rt.i8CheckedMul(result, (radix << 24) >> 24); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.i8 = (_92 << 24) >> 24; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.i8 | undefined = rt.i8CheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.i8 | undefined = rt.i8CheckedMul(result, (radix << 24) >> 24); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.i8 = (_67 << 24) >> 24; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.i8 | undefined = rt.i8CheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.i8WrappingMul(result, (radix << 24) >> 24); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.i8WrappingSub(result, (_49 << 24) >> 24); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.i8WrappingMul(result, (radix << 24) >> 24); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.i8WrappingAdd(result, (_32 << 24) >> 24); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromAsciiBytesRadixImpl$05ylgyc(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = 0 > -2147483648; + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.isize = 0; + b5: { + if (!canNotOverflow$0uown4l(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.isize | undefined = rt.isizeCheckedMul(result, radix | 0); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.isize = _92 | 0; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.isize | undefined = rt.isizeCheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.isize | undefined = rt.isizeCheckedMul(result, radix | 0); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.isize = _67 | 0; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.isize | undefined = rt.isizeCheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.isizeWrappingMul(result, radix | 0); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.isizeWrappingSub(result, _49 | 0); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.isizeWrappingMul(result, radix | 0); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.isizeWrappingAdd(result, _32 | 0); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromAsciiBytesRadixImpl$0r1q6uy(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = rt.u128Gt(0, 0); + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.u128 = 0; + b5: { + if (!canNotOverflow$0q497dn(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.u128 | undefined = rt.u128CheckedMul(result, radix as rt.u128); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.u128 = _92 as rt.u128; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.u128 | undefined = rt.u128CheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.u128 | undefined = rt.u128CheckedMul(result, radix as rt.u128); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.u128 = _67 as rt.u128; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.u128 | undefined = rt.u128CheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.u128WrappingMul(result, radix as rt.u128); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u128WrappingSub(result, _49 as rt.u128); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.u128WrappingMul(result, radix as rt.u128); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u128WrappingAdd(result, _32 as rt.u128); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromAsciiBytesRadixImpl$1ukmfx2(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = 0 > 0; + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.u16 = 0; + b5: { + if (!canNotOverflow$1wu8g18(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.u16 | undefined = rt.u16CheckedMul(result, radix & 0xffff); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.u16 = _92 & 0xffff; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.u16 | undefined = rt.u16CheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.u16 | undefined = rt.u16CheckedMul(result, radix & 0xffff); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.u16 = _67 & 0xffff; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.u16 | undefined = rt.u16CheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.u16WrappingMul(result, radix & 0xffff); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u16WrappingSub(result, _49 & 0xffff); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.u16WrappingMul(result, radix & 0xffff); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u16WrappingAdd(result, _32 & 0xffff); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromAsciiBytesRadixImpl$0ax4wbr(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = 0 > 0; + if (src.length === 1) { + const value5 = src.data[src.start]; + if (value5 === 43 || value5 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value6 = src.data[src.start]; + if (value6 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value6 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.u32 = 0; + b5: { + if (!canNotOverflow$0uown4l(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.u32 | undefined = rt.u32CheckedMul(result, radix); + const _84: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_84 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.u32 = _84; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _95: rt.u32 | undefined = rt.u32CheckedSub(result, x4); + if (_95 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _95; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.u32 | undefined = rt.u32CheckedMul(result, radix); + const _61: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_61 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.u32 = _61; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _72: rt.u32 | undefined = rt.u32CheckedAdd(result, x3); + if (_72 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _72; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.u32WrappingMul(result, radix); + const _46: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_46 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u32WrappingSub(result, _46); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.u32WrappingMul(result, radix); + const _31: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_31 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u32WrappingAdd(result, _31); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromAsciiBytesRadixImpl$02xpj41(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = rt.u64Gt(0, 0); + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.u64 = 0; + b5: { + if (!canNotOverflow$03q1vv8(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.u64 | undefined = rt.u64CheckedMul(result, radix as rt.u64); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.u64 = _92 as rt.u64; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.u64 | undefined = rt.u64CheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.u64 | undefined = rt.u64CheckedMul(result, radix as rt.u64); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.u64 = _67 as rt.u64; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.u64 | undefined = rt.u64CheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.u64WrappingMul(result, radix as rt.u64); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u64WrappingSub(result, _49 as rt.u64); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.u64WrappingMul(result, radix as rt.u64); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u64WrappingAdd(result, _32 as rt.u64); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromAsciiBytesRadixImpl$1n9fygl(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = 0 > 0; + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.u8 = 0; + b5: { + if (!canNotOverflow$0aqh4yo(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.u8 | undefined = rt.u8CheckedMul(result, radix & 0xff); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.u8 = _92 & 0xff; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.u8 | undefined = rt.u8CheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.u8 | undefined = rt.u8CheckedMul(result, radix & 0xff); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.u8 = _67 & 0xff; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.u8 | undefined = rt.u8CheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.u8WrappingMul(result, radix & 0xff); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u8WrappingSub(result, _49 & 0xff); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.u8WrappingMul(result, radix & 0xff); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.u8WrappingAdd(result, _32 & 0xff); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +export function fromAsciiBytesRadixImpl$00hojjd(src: rt.ByteSlice, radix: rt.u32): rt.Result { + let _12_0!: boolean; + let _12_1Data!: Uint8Array; + let _12_1Start!: number; + let _12_1Len!: number; + if (!(2 > radix)) { + if (!(radix > 36)) { + if (!(src.length === 0)) { + const isSignedTy: boolean = 0 > 0; + if (src.length === 1) { + const value7 = src.data[src.start]; + if (value7 === 43 || value7 === 45) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + } + b3: { + if (src.length >= 1) { + const value8 = src.data[src.start]; + if (value8 === 43) { + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start + 1; + _12_1Len = src.length - 1; + break b3; + } + if (value8 === 45) { + const rest2: rt.ByteSlice = rt.byteSliceRange(src, 1); + if (isSignedTy) { + _12_0 = false; + _12_1Data = rest2.data; + _12_1Start = rest2.start; + _12_1Len = rest2.length; + break b3; + } + } + } + _12_0 = true; + _12_1Data = src.data; + _12_1Start = src.start; + _12_1Len = src.length; + } + const isPositive: boolean = _12_0; + let digitsData: Uint8Array = _12_1Data; + let digitsStart: number = _12_1Start; + let digitsLen: number = _12_1Len; + let result: rt.usize = 0; + b5: { + if (!canNotOverflow$0uown4l(radix, isSignedTy, digitsData, digitsStart, digitsLen)) { + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c4: rt.u8 = digitsData[digitsStart]; + const restData5: Uint8Array = digitsData; + const restStart5: number = digitsStart + 1; + const restLen5: number = digitsLen - 1; + const mul2: rt.usize | undefined = rt.usizeCheckedMul(result, radix as rt.usize); + const _92: rt.u32 | undefined = toDigit$01k9ewn(c4 as rt.char, radix); + if (_92 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x4: rt.usize = _92 as rt.usize; + if (mul2 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = mul2; + const _103: rt.usize | undefined = rt.usizeCheckedSub(result, x4); + if (_103 === undefined) { + return rt.Err({ kind: "NegOverflow" as rt.IntErrorKind }); + } + result = _103; + digitsData = restData5; + digitsStart = restStart5; + digitsLen = restLen5; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c3: rt.u8 = digitsData[digitsStart]; + const restData4: Uint8Array = digitsData; + const restStart4: number = digitsStart + 1; + const restLen4: number = digitsLen - 1; + const mul: rt.usize | undefined = rt.usizeCheckedMul(result, radix as rt.usize); + const _67: rt.u32 | undefined = toDigit$01k9ewn(c3 as rt.char, radix); + if (_67 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + const x3: rt.usize = _67 as rt.usize; + if (mul === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = mul; + const _78: rt.usize | undefined = rt.usizeCheckedAdd(result, x3); + if (_78 === undefined) { + return rt.Err({ kind: "PosOverflow" as rt.IntErrorKind }); + } + result = _78; + digitsData = restData4; + digitsStart = restStart4; + digitsLen = restLen4; + } + } + if (!isPositive) { + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c2: rt.u8 = digitsData[digitsStart]; + const restData3: Uint8Array = digitsData; + const restStart3: number = digitsStart + 1; + const restLen3: number = digitsLen - 1; + result = rt.usizeWrappingMul(result, radix as rt.usize); + const _49: rt.u32 | undefined = toDigit$01k9ewn(c2 as rt.char, radix); + if (_49 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.usizeWrappingSub(result, _49 as rt.usize); + digitsData = restData3; + digitsStart = restStart3; + digitsLen = restLen3; + } + } + while (true) { + if (!(digitsLen >= 1)) { + break b5; + } + const c: rt.u8 = digitsData[digitsStart]; + const restData2: Uint8Array = digitsData; + const restStart2: number = digitsStart + 1; + const restLen2: number = digitsLen - 1; + result = rt.usizeWrappingMul(result, radix as rt.usize); + const _32: rt.u32 | undefined = toDigit$01k9ewn(c as rt.char, radix); + if (_32 === undefined) { + return rt.Err({ kind: "InvalidDigit" as rt.IntErrorKind }); + } + result = rt.usizeWrappingAdd(result, _32 as rt.usize); + digitsData = restData2; + digitsStart = restStart2; + digitsLen = restLen2; + } + } + return rt.Ok(result); + } + return rt.Err({ kind: "Empty" as rt.IntErrorKind }); + } + } + fromAsciiBytesRadixPanic(radix); +} + +//# sourceMappingURL=num.ts.map diff --git a/ts/fixtures/lang/expected/core/num/nonzero.ts b/ts/fixtures/lang/strs/expected/core/num/nonzero.ts similarity index 100% rename from ts/fixtures/lang/expected/core/num/nonzero.ts rename to ts/fixtures/lang/strs/expected/core/num/nonzero.ts diff --git a/ts/fixtures/lang/strs/expected/core/option.ts b/ts/fixtures/lang/strs/expected/core/option.ts new file mode 100644 index 000000000..5edc961eb --- /dev/null +++ b/ts/fixtures/lang/strs/expected/core/option.ts @@ -0,0 +1,47 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$1rbuegs(self: rt.ByteSlice | undefined, default_: rt.ByteSlice): rt.ByteSlice { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$1iemzn8(self: string | undefined, default_: string): string { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$0gl6wke(self: [rt.usize, string] | undefined, f: (a0: [rt.usize, string]) => string): string | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function mapOr$16umieg(self: [rt.usize, string] | undefined, default_: rt.usize, f: (a0: [rt.usize, string]) => rt.usize): rt.usize { + if (self === undefined) { + return default_; + } + return f(self); +} + +export function mapOr$147z9gi(self: rt.usize | undefined, default_: string, f: (a0: rt.usize) => string): string { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/expected/core/str.ts b/ts/fixtures/lang/strs/expected/core/str.ts similarity index 54% rename from ts/fixtures/lang/expected/core/str.ts rename to ts/fixtures/lang/strs/expected/core/str.ts index c46867777..4004f68f2 100644 --- a/ts/fixtures/lang/expected/core/str.ts +++ b/ts/fixtures/lang/strs/expected/core/str.ts @@ -1,7 +1,6 @@ // Generated by rust2-ts. Do not edit. import * as rt from "../rt.ts"; -import { fromStr$0zyj6he as num_fromStr$0zyj6he, fromStr$17ewwma as num_fromStr$17ewwma, fromStr$0zhqfgx as num_fromStr$0zhqfgx, fromStr$116mp4t as num_fromStr$116mp4t, fromStr$0ovlgjd as num_fromStr$0ovlgjd, fromStr$1grmucc as num_fromStr$1grmucc, fromStr$0qvzsmz as num_fromStr$0qvzsmz, fromStr$0yqu2i9 as num_fromStr$0yqu2i9, fromStr$08wf09w as num_fromStr$08wf09w, fromStr$1ypcnp8 as num_fromStr$1ypcnp8, fromStr$1hq0zfa as num_fromStr$1hq0zfa, fromStr$10ypyht as num_fromStr$10ypyht } from "../core/num.ts"; import { fromStr$0evev4b as nonzero_fromStr$0evev4b, fromStr$1lm2uzl as nonzero_fromStr$1lm2uzl, fromStr$0gvyqp3 as nonzero_fromStr$0gvyqp3, fromStr$19lq810 as nonzero_fromStr$19lq810, fromStr$1lyc2jq as nonzero_fromStr$1lyc2jq, fromStr$06k4xxy as nonzero_fromStr$06k4xxy, fromStr$0xht6mx as nonzero_fromStr$0xht6mx, fromStr$021o7ki as nonzero_fromStr$021o7ki, fromStr$1myv2t6 as nonzero_fromStr$1myv2t6, fromStr$10p52cj as nonzero_fromStr$10p52cj, fromStr$081k88g as nonzero_fromStr$081k88g, fromStr$1gsgexo as nonzero_fromStr$1gsgexo } from "../core/num/nonzero.ts"; import { fromStr$05d44vn as traits_fromStr$05d44vn } from "../core/str/traits.ts"; @@ -9,30 +8,6 @@ export function parse$0vh4cry(self: string): rt.Result { - return num_fromStr$0zyj6he(self); -} - -export function parse$0xnscjy(self: string): rt.Result { - return num_fromStr$17ewwma(self); -} - -export function parse$12szghw(self: string): rt.Result { - return num_fromStr$0zhqfgx(self); -} - -export function parse$11m1f1e(self: string): rt.Result { - return num_fromStr$116mp4t(self); -} - -export function parse$1ci7nyc(self: string): rt.Result { - return num_fromStr$0ovlgjd(self); -} - -export function parse$07xyv4i(self: string): rt.Result { - return num_fromStr$1grmucc(self); -} - export function parse$1bh1yup(self: string): rt.Result { return nonzero_fromStr$081k88g(self); } @@ -81,28 +56,4 @@ export function parse$02m155k(self: string): rt.Result { - return num_fromStr$0qvzsmz(self); -} - -export function parse$0fi19ig(self: string): rt.Result { - return num_fromStr$0yqu2i9(self); -} - -export function parse$1aq2uo0(self: string): rt.Result { - return num_fromStr$08wf09w(self); -} - -export function parse$0o4ono0(self: string): rt.Result { - return num_fromStr$1ypcnp8(self); -} - -export function parse$0at0fdl(self: string): rt.Result { - return num_fromStr$1hq0zfa(self); -} - -export function parse$08wetap(self: string): rt.Result { - return num_fromStr$10ypyht(self); -} - //# sourceMappingURL=str.ts.map diff --git a/ts/fixtures/lang/strs/expected/core/str/traits.ts b/ts/fixtures/lang/strs/expected/core/str/traits.ts new file mode 100644 index 000000000..ecae3ef54 --- /dev/null +++ b/ts/fixtures/lang/strs/expected/core/str/traits.ts @@ -0,0 +1,15 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../../rt.ts"; + +export function fromStr$05d44vn(s: string): rt.Result { + if (!(s === "true")) { + if (!(s === "false")) { + return rt.Err(new rt.ParseBoolError()); + } + return rt.Ok(false); + } + return rt.Ok(true); +} + +//# sourceMappingURL=traits.ts.map diff --git a/ts/fixtures/lang/strs/expected/harness.ts b/ts/fixtures/lang/strs/expected/harness.ts new file mode 100644 index 000000000..7c19e53ff --- /dev/null +++ b/ts/fixtures/lang/strs/expected/harness.ts @@ -0,0 +1,64 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +/** A char of the alphabet for each byte, by its low bits. */ +export function text(data: rt.ByteSlice): string { + let s: string = ""; + const iterS: Uint8Array = rt.byteSliceView(data); + let iterI: number = 0; + while (true) { + const _5: rt.u8 | rt.Done = iterI < iterS.length ? iterS[iterI++] : rt.DONE; + if (_5 === rt.DONE) { + return s; + } + const _13: rt.usize = rt.u8Rem(_5, 16) as rt.usize; + if (!(_13 < 16)) { + rt.panic("index out of bounds: the len is " + 16 + " but the index is " + _13); + } + s = s + String.fromCodePoint([47, 92, 97, 48, 57, 127, 128, 233, 2047, 2048, 55295, 57344, 65535, 65536, 128512, 1114111][_13]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/strs/expected/lib.ts b/ts/fixtures/lang/strs/expected/lib.ts new file mode 100644 index 000000000..386762ccd --- /dev/null +++ b/ts/fixtures/lang/strs/expected/lib.ts @@ -0,0 +1,18 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { strs, slices, edits, parses, iters, drains, hinted, gets } from "./strs.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["strs::strs", strs as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::slices", slices as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::edits", (a03: rt.u8, a13: rt.ByteSlice, a23: rt.ByteVec): undefined => { + edits(a03, a13.data, a13.start, a13.length, a23); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::parses", parses as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::iters", iters as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::drains", (a06: rt.u8, a16: rt.ByteSlice, a26: rt.ByteVec): undefined => { + drains(a06, a16.data, a16.start, a16.length, a26); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::hinted", hinted as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["strs::gets", gets as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/strs.Counted.ts b/ts/fixtures/lang/strs/expected/strs.Counted.ts similarity index 100% rename from ts/fixtures/lang/expected/strs.Counted.ts rename to ts/fixtures/lang/strs/expected/strs.Counted.ts diff --git a/ts/fixtures/lang/expected/strs.Named.ts b/ts/fixtures/lang/strs/expected/strs.Named.ts similarity index 100% rename from ts/fixtures/lang/expected/strs.Named.ts rename to ts/fixtures/lang/strs/expected/strs.Named.ts diff --git a/ts/fixtures/lang/expected/strs.ts b/ts/fixtures/lang/strs/expected/strs.ts similarity index 83% rename from ts/fixtures/lang/expected/strs.ts rename to ts/fixtures/lang/strs/expected/strs.ts index f09ce273b..624b86bdd 100644 --- a/ts/fixtures/lang/expected/strs.ts +++ b/ts/fixtures/lang/strs/expected/strs.ts @@ -3,30 +3,12 @@ import * as rt from "./rt.ts"; import { then$0havnzo } from "./core/bool.ts"; import { fromStr$0evev4b as nonzero_fromStr$0evev4b, fromStrRadix$1dc3cul as nonzero_fromStrRadix$1dc3cul, fromStr$1lm2uzl as nonzero_fromStr$1lm2uzl, fromStrRadix$1cv6o7i as nonzero_fromStrRadix$1cv6o7i, fromStr$0gvyqp3 as nonzero_fromStr$0gvyqp3, fromStrRadix$18imw6k as nonzero_fromStrRadix$18imw6k, fromStr$19lq810 as nonzero_fromStr$19lq810, fromStrRadix$1u3fi38 as nonzero_fromStrRadix$1u3fi38, fromStr$1lyc2jq as nonzero_fromStr$1lyc2jq, fromStrRadix$0yvapq5 as nonzero_fromStrRadix$0yvapq5, fromStr$06k4xxy as nonzero_fromStr$06k4xxy, fromStrRadix$0rmwudb as nonzero_fromStrRadix$0rmwudb, fromStr$0xht6mx as nonzero_fromStr$0xht6mx, fromStrRadix$0qjnxek as nonzero_fromStrRadix$0qjnxek, fromStr$021o7ki as nonzero_fromStr$021o7ki, fromStrRadix$0dk3w71 as nonzero_fromStrRadix$0dk3w71, fromStr$1myv2t6 as nonzero_fromStr$1myv2t6, fromStrRadix$0o6ntrm as nonzero_fromStrRadix$0o6ntrm, fromStr$10p52cj as nonzero_fromStr$10p52cj, fromStrRadix$0ebk8xe as nonzero_fromStrRadix$0ebk8xe, fromStr$081k88g as nonzero_fromStr$081k88g, fromStrRadix$17xzbib as nonzero_fromStrRadix$17xzbib, fromStr$1gsgexo as nonzero_fromStr$1gsgexo, fromStrRadix$0k1ynqn as nonzero_fromStrRadix$0k1ynqn } from "./core/num/nonzero.ts"; -import { unwrapOr$1iemzn8 as option_unwrapOr$1iemzn8, unwrapOr$1rbuegs as option_unwrapOr$1rbuegs, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$0gl6wke as option_map$0gl6wke, mapOr$16umieg as option_mapOr$16umieg, mapOr$147z9gi as option_mapOr$147z9gi } from "./core/option.ts"; +import { unwrapOr$1rbuegs as option_unwrapOr$1rbuegs, unwrapOr$1iemzn8 as option_unwrapOr$1iemzn8, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$0gl6wke as option_map$0gl6wke, mapOr$16umieg as option_mapOr$16umieg, mapOr$147z9gi as option_mapOr$147z9gi } from "./core/option.ts"; import { parse$0vh4cry, parse$1bh1yup, parse$034rhh2, parse$1wp6z3o, parse$00wf0ig, parse$1bfudtm, parse$16jvjal, parse$0y8gj7z, parse$0y6waa4, parse$1s5pqso, parse$129b0a7, parse$150tkxc, parse$02m155k } from "./core/str.ts"; import { fromStr$05d44vn as traits_fromStr$05d44vn } from "./core/str/traits.ts"; -import { put as fmt_put } from "./fmt.ts"; -import * as strs_Counted from "./strs.Counted.ts"; -import * as strs_Named from "./strs.Named.ts"; - -/** A char of the alphabet for each byte, by its low bits. */ -export function text(data: rt.ByteSlice): string { - let s: string = ""; - const iterS: Uint8Array = rt.byteSliceView(data); - let iterI: number = 0; - while (true) { - const _5: rt.u8 | rt.Done = iterI < iterS.length ? iterS[iterI++] : rt.DONE; - if (_5 === rt.DONE) { - return s; - } - const _13: rt.usize = rt.u8Rem(_5, 16) as rt.usize; - if (!(_13 < 16)) { - rt.panic("index out of bounds: the len is " + 16 + " but the index is " + _13); - } - s = s + String.fromCodePoint([47, 92, 97, 48, 57, 127, 128, 233, 2047, 2048, 55295, 57344, 65535, 65536, 128512, 1114111][_13]); - } -} +import { put, text } from "./harness.ts"; +import * as Counted from "./strs.Counted.ts"; +import * as Named from "./strs.Named.ts"; /** Whether the `i`th step reads from the back: by the byte's high bit. */ export function fromBack(data: rt.ByteSlice, i: rt.usize): boolean { @@ -117,12 +99,12 @@ export function strs(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } if (part !== undefined) { const part2: string = part; - fmt_put(out, part2); + put(out, part2); rt.byteVecPush(out, rt.stringLen(part2) & 0xff); i2 = rt.usizeAdd(i2, 1); } else { rt.byteVecPush(out, i2 & 0xff); - fmt_put(out, option_unwrapOr$1iemzn8(rt.iterToOption(rt.strSplit(s, String.fromCodePoint(sep)).next()), "none")); + put(out, option_unwrapOr$1iemzn8(rt.iterToOption(rt.strSplit(s, String.fromCodePoint(sep)).next()), "none")); const parts2: rt.Iter = rt.strSplitTerminator(s, String.fromCodePoint(sep)); let i3: rt.usize = 0; while (true) { @@ -132,7 +114,7 @@ export function strs(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { part3 = rt.iterToOption(parts2.nextBack()); } if (part3 !== undefined) { - fmt_put(out, part3); + put(out, part3); i3 = rt.usizeAdd(i3, 1); } else { rt.byteVecPush(out, i3 & 0xff); @@ -159,7 +141,7 @@ export function strs(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { part5 = rt.iterToOption(parts3.nextBack()); } if (part5 !== undefined) { - fmt_put(out, part5); + put(out, part5); i4 = rt.usizeAdd(i4, 1); } else { putSeen(out, seen); @@ -168,26 +150,26 @@ export function strs(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } } if (_13 === 3) { - fmt_put(out, rt.strTrimStartMatches(s, String.fromCodePoint(sep))); - fmt_put(out, rt.strTrimEndMatches(s, String.fromCodePoint(sep))); - fmt_put(out, rt.strTrimEndMatches(rt.strTrimStartMatches(s, String.fromCodePoint(sep)), String.fromCodePoint(sep))); + put(out, rt.strTrimStartMatches(s, String.fromCodePoint(sep))); + put(out, rt.strTrimEndMatches(s, String.fromCodePoint(sep))); + put(out, rt.strTrimEndMatches(rt.strTrimStartMatches(s, String.fromCodePoint(sep)), String.fromCodePoint(sep))); rt.byteVecPush(out, rt.strStartsWith(s, String.fromCodePoint(sep)) ? 1 : 0); putOffset(out, rt.strRfind(s, String.fromCodePoint(sep))); const _143: [string, string] | undefined = rt.strRsplitOnce(s, String.fromCodePoint(sep)); if (_143 === undefined) { rt.byteVecPush(out, 253); } else { - fmt_put(out, _143[0]); - fmt_put(out, _143[1]); + put(out, _143[0]); + put(out, _143[1]); } } else if (_13 === 4) { const seen2: rt.char[] = []; - fmt_put(out, rt.strTrimStartMatches(s, (c5: rt.char): boolean => { + put(out, rt.strTrimStartMatches(s, (c5: rt.char): boolean => { seen2.push(c5); return c5 === sep; })); putSeen(out, seen2); - fmt_put(out, rt.strTrimEndMatches(s, (c6: rt.char): boolean => { + put(out, rt.strTrimEndMatches(s, (c6: rt.char): boolean => { seen2.push(c6); return c6 !== sep; })); @@ -195,7 +177,7 @@ export function strs(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, rt.strStartsWith(s, (c7: rt.char): boolean => { return rt.isAsciiDigit(c7); }) ? 1 : 0); - fmt_put(out, rt.strTrimStartMatches(s, digit)); + put(out, rt.strTrimStartMatches(s, digit)); putOffset(out, rt.strRfind(s, (c8: rt.char): boolean => { seen2.push(c8); return c8 === sep; @@ -215,7 +197,7 @@ export function strs(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const at: rt.usize = item[0]; const matched: string = item[1]; putOffset(out, at); - fmt_put(out, matched); + put(out, matched); i5 = rt.usizeAdd(i5, 1); } else { for (const _214 of rt.iterToArray(rt.iterMap(rt.strMatchIndices(s, "/"), (_2: [rt.usize, string]): rt.usize => { @@ -230,12 +212,12 @@ export function strs(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (_13 === 6) { const parts4: string[] = unescape(s); for (const _226 of parts4) { - fmt_put(out, _226); + put(out, _226); } - fmt_put(out, escape(parts4)); + put(out, escape(parts4)); } else { let built: string = ""; - const named: strs_Named.Named = { name: "" }; + const named: Named.Named = { name: "" }; const each: string[] = ["", ""]; const iter4: rt.Iter<[rt.usize, rt.char]> = rt.iterEnumerate(rt.strChars(s)); while (true) { @@ -252,7 +234,7 @@ export function strs(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _260 = c3; } named.name = named.name + String.fromCodePoint(_260); - strs_Named.add(named, c3); + Named.add(named, c3); const at2 = rt.idx(each, rt.usizeRem(i6, 2)); each[at2] = each[at2] + String.fromCodePoint(c3); const _271: rt.char | undefined = rt.charFromU32(rt.u32Add(c3 as rt.u32, 1)); @@ -261,20 +243,20 @@ export function strs(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } } named.name = named.name + "􏿿"; - fmt_put(out, built); - fmt_put(out, named.name); - fmt_put(out, each[rt.idx(each, 0)]); - fmt_put(out, each[rt.idx(each, 1)]); + put(out, built); + put(out, named.name); + put(out, each[rt.idx(each, 0)]); + put(out, each[rt.idx(each, 1)]); const before: string = built; const len: rt.usize = rt.stringLen(built); const empty: boolean = built.length === 0; built = built + String.fromCodePoint(sep); - fmt_put(out, before); + put(out, before); rt.byteVecPush(out, len & 0xff); rt.byteVecPush(out, empty ? 1 : 0); const taken2 = built; built = ""; - fmt_put(out, taken2); + put(out, taken2); rt.byteVecPush(out, built.length === 0 ? 1 : 0); } } @@ -316,11 +298,11 @@ export function slices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (_18 === rt.DONE) { break; } - fmt_put(out, _18); + put(out, _18); n = rt.i32Add(n, 1); } rt.byteVecPush(out, n & 0xff); - fmt_put(out, option_unwrapOr$1iemzn8(rt.iterLast(rt.strSplit(s, p)), "none")); + put(out, option_unwrapOr$1iemzn8(rt.iterLast(rt.strSplit(s, p)), "none")); } else { if (_8 === 1) { const iter2: rt.Iter<[rt.usize, string]> = rt.strMatchIndices(s, p); @@ -331,18 +313,18 @@ export function slices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } const at: rt.usize = _42[0]; putOffset(out, at); - fmt_put(out, _42[1]); - fmt_put(out, rt.strSlice(s, 0, at)); + put(out, _42[1]); + put(out, rt.strSlice(s, 0, at)); const part6 = rt.usizeAdd(at, rt.stringLen(_42[1])); - fmt_put(out, rt.strSlice(s, part6)); + put(out, rt.strSlice(s, part6)); const part7 = rt.usizeAdd(at, rt.stringLen(_42[1])); - fmt_put(out, rt.strSlice(s, at, part7)); + put(out, rt.strSlice(s, at, part7)); } } if (_8 === 2) { - fmt_put(out, rt.strTrimStartMatches(s, p)); - fmt_put(out, rt.strTrimEndMatches(s, p)); - fmt_put(out, rt.strTrimEndMatches(rt.strTrimStartMatches(s, p), p)); + put(out, rt.strTrimStartMatches(s, p)); + put(out, rt.strTrimEndMatches(s, p)); + put(out, rt.strTrimEndMatches(rt.strTrimStartMatches(s, p), p)); rt.byteVecPush(out, rt.strStartsWith(s, p) ? 1 : 0); rt.byteVecPush(out, rt.strContains(s, p) ? 1 : 0); rt.byteVecPush(out, rt.strContains(s, p) ? 1 : 0); @@ -355,8 +337,8 @@ export function slices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (_123 === undefined) { rt.byteVecPush(out, 253); } else { - fmt_put(out, _123[0]); - fmt_put(out, _123[1]); + put(out, _123[0]); + put(out, _123[1]); } } else { if (_8 === 3) { @@ -373,25 +355,25 @@ export function slices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (_139 === rt.DONE) { break b0; } - fmt_put(out, _139); + put(out, _139); } } if (_8 === 4) { const keep: rt.usize = rt.usizeAdd(rt.u8Rem(rt.u8Div(kind, 8), 4) as rt.usize, 1); - fmt_put(out, option_unwrapOr$1iemzn8(option_map$0gl6wke(rt.iterNth(rt.strMatchIndices(s, "/"), rt.usizeSub(keep, 1)), (_2: [rt.usize, string]): string => { + put(out, option_unwrapOr$1iemzn8(option_map$0gl6wke(rt.iterNth(rt.strMatchIndices(s, "/"), rt.usizeSub(keep, 1)), (_2: [rt.usize, string]): string => { return rt.strSlice(s, 0, _2[0]); }), "none")); const part5 = option_mapOr$16umieg(rt.iterNth(rt.strMatchIndices(s, "/"), rt.usizeSub(keep, 1)), rt.stringLen(s), (_22: [rt.usize, string]): rt.usize => { return rt.usizeAdd(_22[0], 1); }); - fmt_put(out, rt.strSlice(s, part5)); + put(out, rt.strSlice(s, part5)); } else if (_8 === 5) { const parts: string[] = rt.iterToArray(rt.strSplit(s, "/"), "next", 8); - fmt_put(out, rt.strsJoin(parts, p)); - fmt_put(out, rt.strsJoin(rt.iterToArray(rt.iterMap(rt.iterSlice(parts), (part3: string): string => { + put(out, rt.strsJoin(parts, p)); + put(out, rt.strsJoin(rt.iterToArray(rt.iterMap(rt.iterSlice(parts), (part3: string): string => { return part3; }), undefined, 12, true), p)); - fmt_put(out, rt.strsJoin(["a", "", s], "/")); + put(out, rt.strsJoin(["a", "", s], "/")); } else { const at2: (a0: rt.u8) => rt.usize = (b2: rt.u8): rt.usize => { if ((kind & 32) === 0) { @@ -416,7 +398,7 @@ export function slices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } else { sliced = rt.strSlice(s, 0); } - fmt_put(out, sliced); + put(out, sliced); } } } @@ -597,7 +579,7 @@ export function edit(s: rt.Place, op: rt.u8, a: rt.u8, b: rt.u8, out: rt } else if (_24 === 9) { const edit = rt.stringSplitOff(s.v, i); s.v = edit[0]; - fmt_put(out, edit[1]); + put(out, edit[1]); } else if (_24 === 10) { const _67: rt.u8 = rt.u8Rem(b, 7); if (_67 === 0) { @@ -669,7 +651,7 @@ export function edits(kind: rt.u8, dataData: Uint8Array, dataStart: number, data } const head: rt.ByteSlice = new rt.ByteSlice(dataData, dataStart, mid); let s: string = text(head); - const named: strs_Named.Named = { name: text(head) }; + const named: Named.Named = { name: text(head) }; const iter: rt.Iter = rt.byteSliceChunks(new rt.ByteSlice(dataData, dataStart + mid, dataLen - mid), 3); while (true) { const _18: rt.ByteSlice | rt.Done = iter.next(); @@ -702,15 +684,15 @@ export function edits(kind: rt.u8, dataData: Uint8Array, dataStart: number, data const _61: rt.usize = offset(s, a); const edit_ = rt.stringSplitOff(s, _61); s = edit_[0]; - fmt_put(out, edit_[1]); + put(out, edit_[1]); } else { s = ""; } } else { edit(rt.place(() => s, (value) => s = value), op, a, b, out); } - fmt_put(out, s); - fmt_put(out, named.name); + put(out, s); + put(out, named.name); } } @@ -757,11 +739,11 @@ export function parses(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (parsed.ok) { const arg26 = parsed.value; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(arg26, f)]; - fmt_put(out, rt.fmtFormat([args2[0]])); + put(out, rt.fmtFormat([args2[0]])); } else { const part13 = new rt.ParseBoolError(); const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseBoolErrorDisplay(part13, f), (f: rt.Formatter) => rt.fmtParseBoolErrorDebug(part13, f)]; - fmt_put(out, rt.fmtFormat([args4[0], "|", args4[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args4[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args4[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args4[1]), "|", rt.fmtSpec({ alternate: true }, args4[1])])); + put(out, rt.fmtFormat([args4[0], "|", args4[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args4[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args4[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args4[1]), "|", rt.fmtSpec({ alternate: true }, args4[1])])); } } parse$0vh4cry(_49); @@ -776,11 +758,11 @@ export function parses(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (parsed2.ok) { const arg25 = parsed2.value; const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtCharDebug(arg25, f)]; - fmt_put(out, rt.fmtFormat([args6[0]])); + put(out, rt.fmtFormat([args6[0]])); } else { const e: rt.ParseCharError = parsed2.error; const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseCharErrorDisplay(e, f), (f: rt.Formatter) => rt.fmtParseCharErrorDebug(e, f)]; - fmt_put(out, rt.fmtFormat([args8[0], "|", args8[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args8[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args8[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args8[1]), "|", rt.fmtSpec({ alternate: true }, args8[1])])); + put(out, rt.fmtFormat([args8[0], "|", args8[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args8[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args8[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args8[1]), "|", rt.fmtSpec({ alternate: true }, args8[1])])); } } rt.charFromStr(_49); @@ -796,28 +778,28 @@ export function parses(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (parsed3.ok) { const arg23 = parsed3.value; const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Debug(arg23, f)]; - fmt_put(out, rt.fmtFormat([args10[0]])); + put(out, rt.fmtFormat([args10[0]])); } else { const e2: rt.ParseIntError = parsed3.error; const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e2, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e2, f)]; - fmt_put(out, rt.fmtFormat([args12[0], "|", args12[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args12[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args12[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args12[1]), "|", rt.fmtSpec({ alternate: true }, args12[1])])); + put(out, rt.fmtFormat([args12[0], "|", args12[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args12[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args12[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args12[1]), "|", rt.fmtSpec({ alternate: true }, args12[1])])); } } const _139: rt.Result = parse$150tkxc(_49); if (!_139.ok) { const part12 = _139.error.kind; const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, part12)]; - fmt_put(out, rt.fmtFormat([args14[0]])); + put(out, rt.fmtFormat([args14[0]])); } const _195: rt.Result = nonzero_fromStrRadix$1dc3cul(_49, radix2); if (_195.ok) { const arg24 = _195.value; const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(arg24, f)]; - fmt_put(out, rt.fmtFormat([args16[0]])); + put(out, rt.fmtFormat([args16[0]])); } else { const e4: rt.ParseIntError = _195.error; const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e4, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e4, f)]; - fmt_put(out, rt.fmtFormat([args18[0], "|", args18[1]])); + put(out, rt.fmtFormat([args18[0], "|", args18[1]])); } } else if (_53 === 3) { const radix3: rt.u32 = radix; @@ -831,28 +813,28 @@ export function parses(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (parsed4.ok) { const arg21 = parsed4.value; const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.u16Debug(arg21, f)]; - fmt_put(out, rt.fmtFormat([args20[0]])); + put(out, rt.fmtFormat([args20[0]])); } else { const e5: rt.ParseIntError = parsed4.error; const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e5, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e5, f)]; - fmt_put(out, rt.fmtFormat([args22[0], "|", args22[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args22[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args22[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args22[1]), "|", rt.fmtSpec({ alternate: true }, args22[1])])); + put(out, rt.fmtFormat([args22[0], "|", args22[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args22[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args22[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args22[1]), "|", rt.fmtSpec({ alternate: true }, args22[1])])); } } const _226: rt.Result = parse$0y6waa4(_49); if (!_226.ok) { const part11 = _226.error.kind; const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, part11)]; - fmt_put(out, rt.fmtFormat([args24[0]])); + put(out, rt.fmtFormat([args24[0]])); } const _282: rt.Result = nonzero_fromStrRadix$1cv6o7i(_49, radix3); if (_282.ok) { const arg22 = _282.value; const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.u16Display(arg22, f)]; - fmt_put(out, rt.fmtFormat([args26[0]])); + put(out, rt.fmtFormat([args26[0]])); } else { const e7: rt.ParseIntError = _282.error; const args28: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e7, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e7, f)]; - fmt_put(out, rt.fmtFormat([args28[0], "|", args28[1]])); + put(out, rt.fmtFormat([args28[0], "|", args28[1]])); } } else if (_53 === 4) { const radix4: rt.u32 = radix; @@ -866,28 +848,28 @@ export function parses(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (parsed5.ok) { const arg19 = parsed5.value; const args30: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Debug(arg19, f)]; - fmt_put(out, rt.fmtFormat([args30[0]])); + put(out, rt.fmtFormat([args30[0]])); } else { const e8: rt.ParseIntError = parsed5.error; const args32: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e8, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e8, f)]; - fmt_put(out, rt.fmtFormat([args32[0], "|", args32[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args32[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args32[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args32[1]), "|", rt.fmtSpec({ alternate: true }, args32[1])])); + put(out, rt.fmtFormat([args32[0], "|", args32[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args32[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args32[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args32[1]), "|", rt.fmtSpec({ alternate: true }, args32[1])])); } } const _313: rt.Result = parse$1s5pqso(_49); if (!_313.ok) { const part10 = _313.error.kind; const args34: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, part10)]; - fmt_put(out, rt.fmtFormat([args34[0]])); + put(out, rt.fmtFormat([args34[0]])); } const _369: rt.Result = nonzero_fromStrRadix$18imw6k(_49, radix4); if (_369.ok) { const arg20 = _369.value; const args36: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(arg20, f)]; - fmt_put(out, rt.fmtFormat([args36[0]])); + put(out, rt.fmtFormat([args36[0]])); } else { const e10: rt.ParseIntError = _369.error; const args38: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e10, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e10, f)]; - fmt_put(out, rt.fmtFormat([args38[0], "|", args38[1]])); + put(out, rt.fmtFormat([args38[0], "|", args38[1]])); } } else if (_53 === 5) { const radix5: rt.u32 = radix; @@ -901,28 +883,28 @@ export function parses(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (parsed6.ok) { const arg17 = parsed6.value; const args40: rt.Fmt[] = [(f: rt.Formatter) => rt.u64Debug(arg17, f)]; - fmt_put(out, rt.fmtFormat([args40[0]])); + put(out, rt.fmtFormat([args40[0]])); } else { const e11: rt.ParseIntError = parsed6.error; const args42: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e11, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e11, f)]; - fmt_put(out, rt.fmtFormat([args42[0], "|", args42[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args42[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args42[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args42[1]), "|", rt.fmtSpec({ alternate: true }, args42[1])])); + put(out, rt.fmtFormat([args42[0], "|", args42[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args42[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args42[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args42[1]), "|", rt.fmtSpec({ alternate: true }, args42[1])])); } } const _400: rt.Result = parse$129b0a7(_49); if (!_400.ok) { const part9 = _400.error.kind; const args44: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, part9)]; - fmt_put(out, rt.fmtFormat([args44[0]])); + put(out, rt.fmtFormat([args44[0]])); } const _456: rt.Result = nonzero_fromStrRadix$1u3fi38(_49, radix5); if (_456.ok) { const arg18 = _456.value; const args46: rt.Fmt[] = [(f: rt.Formatter) => rt.u64Display(arg18, f)]; - fmt_put(out, rt.fmtFormat([args46[0]])); + put(out, rt.fmtFormat([args46[0]])); } else { const e13: rt.ParseIntError = _456.error; const args48: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e13, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e13, f)]; - fmt_put(out, rt.fmtFormat([args48[0], "|", args48[1]])); + put(out, rt.fmtFormat([args48[0], "|", args48[1]])); } } else if (_53 === 6) { const radix6: rt.u32 = radix; @@ -936,28 +918,28 @@ export function parses(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (parsed7.ok) { const arg15 = parsed7.value; const args50: rt.Fmt[] = [(f: rt.Formatter) => rt.u128Debug(arg15, f)]; - fmt_put(out, rt.fmtFormat([args50[0]])); + put(out, rt.fmtFormat([args50[0]])); } else { const e14: rt.ParseIntError = parsed7.error; const args52: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e14, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e14, f)]; - fmt_put(out, rt.fmtFormat([args52[0], "|", args52[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args52[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args52[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args52[1]), "|", rt.fmtSpec({ alternate: true }, args52[1])])); + put(out, rt.fmtFormat([args52[0], "|", args52[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args52[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args52[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args52[1]), "|", rt.fmtSpec({ alternate: true }, args52[1])])); } } const _487: rt.Result = parse$0y8gj7z(_49); if (!_487.ok) { const part8 = _487.error.kind; const args54: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, part8)]; - fmt_put(out, rt.fmtFormat([args54[0]])); + put(out, rt.fmtFormat([args54[0]])); } const _543: rt.Result = nonzero_fromStrRadix$0yvapq5(_49, radix6); if (_543.ok) { const arg16 = _543.value; const args56: rt.Fmt[] = [(f: rt.Formatter) => rt.u128Display(arg16, f)]; - fmt_put(out, rt.fmtFormat([args56[0]])); + put(out, rt.fmtFormat([args56[0]])); } else { const e16: rt.ParseIntError = _543.error; const args58: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e16, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e16, f)]; - fmt_put(out, rt.fmtFormat([args58[0], "|", args58[1]])); + put(out, rt.fmtFormat([args58[0], "|", args58[1]])); } } else if (_53 === 7) { const radix7: rt.u32 = radix; @@ -971,28 +953,28 @@ export function parses(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (parsed8.ok) { const arg13 = parsed8.value; const args60: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDebug(arg13, f)]; - fmt_put(out, rt.fmtFormat([args60[0]])); + put(out, rt.fmtFormat([args60[0]])); } else { const e17: rt.ParseIntError = parsed8.error; const args62: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e17, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e17, f)]; - fmt_put(out, rt.fmtFormat([args62[0], "|", args62[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args62[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args62[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args62[1]), "|", rt.fmtSpec({ alternate: true }, args62[1])])); + put(out, rt.fmtFormat([args62[0], "|", args62[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args62[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args62[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args62[1]), "|", rt.fmtSpec({ alternate: true }, args62[1])])); } } const _574: rt.Result = parse$02m155k(_49); if (!_574.ok) { const part7 = _574.error.kind; const args64: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, part7)]; - fmt_put(out, rt.fmtFormat([args64[0]])); + put(out, rt.fmtFormat([args64[0]])); } const _630: rt.Result = nonzero_fromStrRadix$0rmwudb(_49, radix7); if (_630.ok) { const arg14 = _630.value; const args66: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(arg14, f)]; - fmt_put(out, rt.fmtFormat([args66[0]])); + put(out, rt.fmtFormat([args66[0]])); } else { const e19: rt.ParseIntError = _630.error; const args68: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e19, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e19, f)]; - fmt_put(out, rt.fmtFormat([args68[0], "|", args68[1]])); + put(out, rt.fmtFormat([args68[0], "|", args68[1]])); } } else if (_53 === 8) { const radix8: rt.u32 = radix; @@ -1006,28 +988,28 @@ export function parses(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (parsed9.ok) { const arg11 = parsed9.value; const args70: rt.Fmt[] = [(f: rt.Formatter) => rt.i8Debug(arg11, f)]; - fmt_put(out, rt.fmtFormat([args70[0]])); + put(out, rt.fmtFormat([args70[0]])); } else { const e20: rt.ParseIntError = parsed9.error; const args72: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e20, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e20, f)]; - fmt_put(out, rt.fmtFormat([args72[0], "|", args72[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args72[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args72[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args72[1]), "|", rt.fmtSpec({ alternate: true }, args72[1])])); + put(out, rt.fmtFormat([args72[0], "|", args72[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args72[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args72[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args72[1]), "|", rt.fmtSpec({ alternate: true }, args72[1])])); } } const _661: rt.Result = parse$1bfudtm(_49); if (!_661.ok) { const part6 = _661.error.kind; const args74: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, part6)]; - fmt_put(out, rt.fmtFormat([args74[0]])); + put(out, rt.fmtFormat([args74[0]])); } const _717: rt.Result = nonzero_fromStrRadix$0qjnxek(_49, radix8); if (_717.ok) { const arg12 = _717.value; const args76: rt.Fmt[] = [(f: rt.Formatter) => rt.i8Display(arg12, f)]; - fmt_put(out, rt.fmtFormat([args76[0]])); + put(out, rt.fmtFormat([args76[0]])); } else { const e22: rt.ParseIntError = _717.error; const args78: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e22, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e22, f)]; - fmt_put(out, rt.fmtFormat([args78[0], "|", args78[1]])); + put(out, rt.fmtFormat([args78[0], "|", args78[1]])); } } else if (_53 === 9) { const radix9: rt.u32 = radix; @@ -1041,28 +1023,28 @@ export function parses(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (parsed10.ok) { const arg9 = parsed10.value; const args80: rt.Fmt[] = [(f: rt.Formatter) => rt.i16Debug(arg9, f)]; - fmt_put(out, rt.fmtFormat([args80[0]])); + put(out, rt.fmtFormat([args80[0]])); } else { const e23: rt.ParseIntError = parsed10.error; const args82: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e23, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e23, f)]; - fmt_put(out, rt.fmtFormat([args82[0], "|", args82[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args82[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args82[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args82[1]), "|", rt.fmtSpec({ alternate: true }, args82[1])])); + put(out, rt.fmtFormat([args82[0], "|", args82[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args82[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args82[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args82[1]), "|", rt.fmtSpec({ alternate: true }, args82[1])])); } } const _748: rt.Result = parse$034rhh2(_49); if (!_748.ok) { const part5 = _748.error.kind; const args84: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, part5)]; - fmt_put(out, rt.fmtFormat([args84[0]])); + put(out, rt.fmtFormat([args84[0]])); } const _804: rt.Result = nonzero_fromStrRadix$0dk3w71(_49, radix9); if (_804.ok) { const arg10 = _804.value; const args86: rt.Fmt[] = [(f: rt.Formatter) => rt.i16Display(arg10, f)]; - fmt_put(out, rt.fmtFormat([args86[0]])); + put(out, rt.fmtFormat([args86[0]])); } else { const e25: rt.ParseIntError = _804.error; const args88: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e25, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e25, f)]; - fmt_put(out, rt.fmtFormat([args88[0], "|", args88[1]])); + put(out, rt.fmtFormat([args88[0], "|", args88[1]])); } } else if (_53 === 10) { const radix10: rt.u32 = radix; @@ -1076,28 +1058,28 @@ export function parses(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (parsed11.ok) { const arg7 = parsed11.value; const args90: rt.Fmt[] = [(f: rt.Formatter) => rt.i32Debug(arg7, f)]; - fmt_put(out, rt.fmtFormat([args90[0]])); + put(out, rt.fmtFormat([args90[0]])); } else { const e26: rt.ParseIntError = parsed11.error; const args92: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e26, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e26, f)]; - fmt_put(out, rt.fmtFormat([args92[0], "|", args92[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args92[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args92[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args92[1]), "|", rt.fmtSpec({ alternate: true }, args92[1])])); + put(out, rt.fmtFormat([args92[0], "|", args92[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args92[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args92[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args92[1]), "|", rt.fmtSpec({ alternate: true }, args92[1])])); } } const _835: rt.Result = parse$1wp6z3o(_49); if (!_835.ok) { const part4 = _835.error.kind; const args94: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, part4)]; - fmt_put(out, rt.fmtFormat([args94[0]])); + put(out, rt.fmtFormat([args94[0]])); } const _891: rt.Result = nonzero_fromStrRadix$0o6ntrm(_49, radix10); if (_891.ok) { const arg8 = _891.value; const args96: rt.Fmt[] = [(f: rt.Formatter) => rt.i32Display(arg8, f)]; - fmt_put(out, rt.fmtFormat([args96[0]])); + put(out, rt.fmtFormat([args96[0]])); } else { const e28: rt.ParseIntError = _891.error; const args98: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e28, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e28, f)]; - fmt_put(out, rt.fmtFormat([args98[0], "|", args98[1]])); + put(out, rt.fmtFormat([args98[0], "|", args98[1]])); } } else if (_53 === 11) { const radix11: rt.u32 = radix; @@ -1111,28 +1093,28 @@ export function parses(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (parsed12.ok) { const arg5 = parsed12.value; const args100: rt.Fmt[] = [(f: rt.Formatter) => rt.i64Debug(arg5, f)]; - fmt_put(out, rt.fmtFormat([args100[0]])); + put(out, rt.fmtFormat([args100[0]])); } else { const e29: rt.ParseIntError = parsed12.error; const args102: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e29, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e29, f)]; - fmt_put(out, rt.fmtFormat([args102[0], "|", args102[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args102[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args102[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args102[1]), "|", rt.fmtSpec({ alternate: true }, args102[1])])); + put(out, rt.fmtFormat([args102[0], "|", args102[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args102[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args102[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args102[1]), "|", rt.fmtSpec({ alternate: true }, args102[1])])); } } const _922: rt.Result = parse$00wf0ig(_49); if (!_922.ok) { const part3 = _922.error.kind; const args104: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, part3)]; - fmt_put(out, rt.fmtFormat([args104[0]])); + put(out, rt.fmtFormat([args104[0]])); } const _978: rt.Result = nonzero_fromStrRadix$0ebk8xe(_49, radix11); if (_978.ok) { const arg6 = _978.value; const args106: rt.Fmt[] = [(f: rt.Formatter) => rt.i64Display(arg6, f)]; - fmt_put(out, rt.fmtFormat([args106[0]])); + put(out, rt.fmtFormat([args106[0]])); } else { const e31: rt.ParseIntError = _978.error; const args108: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e31, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e31, f)]; - fmt_put(out, rt.fmtFormat([args108[0], "|", args108[1]])); + put(out, rt.fmtFormat([args108[0], "|", args108[1]])); } } else if (_53 === 12) { const radix12: rt.u32 = radix; @@ -1146,28 +1128,28 @@ export function parses(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (parsed13.ok) { const arg3 = parsed13.value; const args110: rt.Fmt[] = [(f: rt.Formatter) => rt.i128Debug(arg3, f)]; - fmt_put(out, rt.fmtFormat([args110[0]])); + put(out, rt.fmtFormat([args110[0]])); } else { const e32: rt.ParseIntError = parsed13.error; const args112: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e32, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e32, f)]; - fmt_put(out, rt.fmtFormat([args112[0], "|", args112[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args112[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args112[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args112[1]), "|", rt.fmtSpec({ alternate: true }, args112[1])])); + put(out, rt.fmtFormat([args112[0], "|", args112[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args112[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args112[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args112[1]), "|", rt.fmtSpec({ alternate: true }, args112[1])])); } } const _1009: rt.Result = parse$1bh1yup(_49); if (!_1009.ok) { const part2 = _1009.error.kind; const args114: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, part2)]; - fmt_put(out, rt.fmtFormat([args114[0]])); + put(out, rt.fmtFormat([args114[0]])); } const _1065: rt.Result = nonzero_fromStrRadix$17xzbib(_49, radix12); if (_1065.ok) { const arg4 = _1065.value; const args116: rt.Fmt[] = [(f: rt.Formatter) => rt.i128Display(arg4, f)]; - fmt_put(out, rt.fmtFormat([args116[0]])); + put(out, rt.fmtFormat([args116[0]])); } else { const e34: rt.ParseIntError = _1065.error; const args118: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e34, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e34, f)]; - fmt_put(out, rt.fmtFormat([args118[0], "|", args118[1]])); + put(out, rt.fmtFormat([args118[0], "|", args118[1]])); } } else { const radix13: rt.u32 = radix; @@ -1181,28 +1163,28 @@ export function parses(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (parsed14.ok) { const arg = parsed14.value; const args120: rt.Fmt[] = [(f: rt.Formatter) => rt.isizeDebug(arg, f)]; - fmt_put(out, rt.fmtFormat([args120[0]])); + put(out, rt.fmtFormat([args120[0]])); } else { const e35: rt.ParseIntError = parsed14.error; const args122: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e35, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e35, f)]; - fmt_put(out, rt.fmtFormat([args122[0], "|", args122[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args122[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args122[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args122[1]), "|", rt.fmtSpec({ alternate: true }, args122[1])])); + put(out, rt.fmtFormat([args122[0], "|", args122[1], "|", rt.fmtSpec({ align: ">", width: 50 }, args122[0]), "|", rt.fmtSpec({ align: "<", width: 3, precision: 5 }, args122[0]), "|", rt.fmtSpec({ align: ">", width: 20 }, args122[1]), "|", rt.fmtSpec({ alternate: true }, args122[1])])); } } const _1096: rt.Result = parse$16jvjal(_49); if (!_1096.ok) { const part = _1096.error.kind; const args124: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, part)]; - fmt_put(out, rt.fmtFormat([args124[0]])); + put(out, rt.fmtFormat([args124[0]])); } const _1152: rt.Result = nonzero_fromStrRadix$0k1ynqn(_49, radix13); if (_1152.ok) { const arg2 = _1152.value; const args126: rt.Fmt[] = [(f: rt.Formatter) => rt.isizeDisplay(arg2, f)]; - fmt_put(out, rt.fmtFormat([args126[0]])); + put(out, rt.fmtFormat([args126[0]])); } else { const e37: rt.ParseIntError = _1152.error; const args128: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtParseIntErrorDisplay(e37, f), (f: rt.Formatter) => rt.fmtParseIntErrorDebug(e37, f)]; - fmt_put(out, rt.fmtFormat([args128[0], "|", args128[1]])); + put(out, rt.fmtFormat([args128[0], "|", args128[1]])); } } } @@ -1217,42 +1199,42 @@ export function iters(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const chars: rt.char[] = rt.iterToArray(rt.strChars(s), "next", 4); const parts: string[] = rt.iterToArray(rt.strSplit(s, "/"), "next", 8); const nexts: rt.Cell = new rt.Cell(0); - const named: strs_Named.Named = { name: text(rt.byteSliceRange(data, 0, rt.usizeDiv(data.length, 2))) }; + const named: Named.Named = { name: text(rt.byteSliceRange(data, 0, rt.usizeDiv(data.length, 2))) }; const _21: rt.u8 = rt.u8Rem(kind, 4); if (_21 === 0) { - fmt_put(out, rt.stringExtendChars("", rt.strChars(s))); - fmt_put(out, rt.stringExtendChars("", rt.iterFilter(rt.iterRev(rt.strChars(s)), (c: rt.char): boolean => { + put(out, rt.stringExtendChars("", rt.strChars(s))); + put(out, rt.stringExtendChars("", rt.iterFilter(rt.iterRev(rt.strChars(s)), (c: rt.char): boolean => { return !rt.isAsciiDigit(c); }))); - fmt_put(out, rt.stringExtendChars("", rt.iterSlice(chars))); - fmt_put(out, rt.stringExtendChars("", rt.iterSkip(rt.iterSlice(chars), 1))); + put(out, rt.stringExtendChars("", rt.iterSlice(chars))); + put(out, rt.stringExtendChars("", rt.iterSkip(rt.iterSlice(chars), 1))); rt.iterEmpty(); - fmt_put(out, rt.stringExtendChars("", rt.iterEmpty() as rt.Iter)); - fmt_put(out, rt.stringExtendChars("", rt.iterOption(rt.charFromU32(kind as rt.u32)))); - fmt_put(out, rt.stringExtendChars("", rt.iterFrom({ items: chars, nexts }, (it: strs_Counted.Counted) => strs_Counted.next$iter_Iterator_char(it)))); + put(out, rt.stringExtendChars("", rt.iterEmpty() as rt.Iter)); + put(out, rt.stringExtendChars("", rt.iterOption(rt.charFromU32(kind as rt.u32)))); + put(out, rt.stringExtendChars("", rt.iterFrom({ items: chars, nexts }, (it: Counted.Counted) => Counted.next$iter_Iterator_char(it)))); } else if (_21 === 1) { - fmt_put(out, rt.stringExtend("", rt.iterSlice(parts))); - fmt_put(out, rt.stringExtend("", rt.iterRev(rt.strSplit(s, "/")))); - fmt_put(out, rt.stringFromStrings(rt.iterMap(rt.iterSlice(parts), (p3: string): string => { + put(out, rt.stringExtend("", rt.iterSlice(parts))); + put(out, rt.stringExtend("", rt.iterRev(rt.strSplit(s, "/")))); + put(out, rt.stringFromStrings(rt.iterMap(rt.iterSlice(parts), (p3: string): string => { return p3; }))); - fmt_put(out, rt.stringFromStrings(rt.iterFilter(rt.iterMap(rt.strSplit(s, "/"), (p4: string): string => { + put(out, rt.stringFromStrings(rt.iterFilter(rt.iterMap(rt.strSplit(s, "/"), (p4: string): string => { const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, p4)]; return rt.fmtFormat([args4[0], args4[0]]); }), (p5: string): boolean => { return !((p5.length === 0)); }))); rt.iterEmpty(); - fmt_put(out, rt.stringFromStrings(rt.iterEmpty() as rt.Iter)); - fmt_put(out, rt.stringExtendChars("", rt.iterRev(rt.strChars(s)))); - fmt_put(out, rt.stringExtend("", rt.iterSlice(parts))); + put(out, rt.stringFromStrings(rt.iterEmpty() as rt.Iter)); + put(out, rt.stringExtendChars("", rt.iterRev(rt.strChars(s)))); + put(out, rt.stringExtend("", rt.iterSlice(parts))); const owned: string[] = rt.iterToArray(rt.iterMap(rt.iterSlice(parts), (p6: string): string => { return p6; }), undefined, 12, true); - fmt_put(out, rt.stringFromStrings(rt.iterMap(rt.iterSlice(owned), (p7: string): string => { + put(out, rt.stringFromStrings(rt.iterMap(rt.iterSlice(owned), (p7: string): string => { return p7; }))); - fmt_put(out, rt.stringFromStrings(rt.iterFrom({ items: owned, nexts }, (it: strs_Counted.Counted) => strs_Counted.next$iter_Iterator_String(it)))); + put(out, rt.stringFromStrings(rt.iterFrom({ items: owned, nexts }, (it: Counted.Counted) => Counted.next$iter_Iterator_String(it)))); } else if (_21 === 2) { let t: string = "é"; const _153: rt.char[] = chars; @@ -1262,9 +1244,9 @@ export function iters(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { named.name = rt.stringExtendChars(named.name, rt.iterSlice(chars)); rt.iterEmpty(); named.name = rt.stringExtendChars(named.name, rt.iterEmpty() as rt.Iter); - const counted3: strs_Counted.Counted = { items: chars, nexts }; - t = rt.stringExtendChars(t, rt.iterFrom(counted3, (it: strs_Counted.Counted) => strs_Counted.next$iter_Iterator_char(it))); - fmt_put(out, t); + const counted3: Counted.Counted = { items: chars, nexts }; + t = rt.stringExtendChars(t, rt.iterFrom(counted3, (it: Counted.Counted) => Counted.next$iter_Iterator_char(it))); + put(out, t); } else { let t2: string = ""; const _179: rt.Iter = rt.strSplit(s, "/"); @@ -1282,11 +1264,11 @@ export function iters(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { named.name = rt.stringExtend(named.name, _197); rt.iterEmpty(); named.name = rt.stringExtend(named.name, rt.iterEmpty() as rt.Iter); - const counted4: strs_Counted.Counted = { items: parts, nexts }; - t2 = rt.stringExtend(t2, rt.iterFrom(counted4, (it: strs_Counted.Counted) => strs_Counted.next$iter_Iterator_ref_str(it))); - fmt_put(out, t2); + const counted4: Counted.Counted = { items: parts, nexts }; + t2 = rt.stringExtend(t2, rt.iterFrom(counted4, (it: Counted.Counted) => Counted.next$iter_Iterator_ref_str(it))); + put(out, t2); } - fmt_put(out, named.name); + put(out, named.name); rt.byteVecPush(out, nexts.v); } @@ -1360,9 +1342,9 @@ export function drainBy(s: rt.Place, form: rt.u8, a: rt.u8, b: rt.u8, st _71 = false; } else if (_49 === 2) { _71 = false; - fmt_put(out, rt.stringExtendChars("", drain, true)); + put(out, rt.stringExtendChars("", drain, true)); } else { - fmt_put(out, rt.stringDrainAsStr(drain)); + put(out, rt.stringDrainAsStr(drain)); _71 = false; const iter2: rt.Iter = rt.iterRev(drain); while (true) { @@ -1393,7 +1375,7 @@ export function drains(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } const head: rt.ByteSlice = new rt.ByteSlice(dataData, dataStart, mid); let s: string = text(head); - const named: strs_Named.Named = { name: text(head) }; + const named: Named.Named = { name: text(head) }; const iter: rt.Iter = rt.byteSliceChunks(new rt.ByteSlice(dataData, dataStart + mid, dataLen - mid), 4); while (true) { const _18: rt.ByteSlice | rt.Done = iter.next(); @@ -1413,7 +1395,7 @@ export function drains(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat const _49: rt.u8 = rt.u8Rem(form, 4); if (_49 === 0) { const _56: { end: rt.usize } = { end: offset(s, a) }; - fmt_put(out, rt.stringExtendChars("", rt.stringDrain(rt.place(() => s, (value5) => s = value5), _56), true)); + put(out, rt.stringExtendChars("", rt.stringDrain(rt.place(() => s, (value5) => s = value5), _56), true)); } else if (_49 === 1) { const _64: rt.RangeFrom = new rt.RangeFrom(offset(s, a), rt.usizeStep); rt.byteVecPush(out, rt.ownedCount(rt.stringDrain(rt.place(() => s, (value4) => s = value4), _64)) & 0xff); @@ -1426,8 +1408,8 @@ export function drains(kind: rt.u8, dataData: Uint8Array, dataStart: number, dat } else { drainBy(rt.place(() => s, (value) => s = value), form, a, b, steps, out); } - fmt_put(out, s); - fmt_put(out, named.name); + put(out, s); + put(out, named.name); } } @@ -1545,7 +1527,7 @@ export function hinted(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const _172: rt.Place = rt.place(() => t, (value2) => t = value2); _172.v = rt.stringExtendChars(_172.v, chars); } - fmt_put(out, t); + put(out, t); } /** A part a checked read gives, or 0xfe if it gave none. */ @@ -1553,7 +1535,7 @@ export function putPart(out: rt.ByteVec, part: string | undefined): void { if (part === undefined) { rt.byteVecPush(out, 254); } else { - fmt_put(out, part); + put(out, part); } } @@ -1563,7 +1545,7 @@ export function putUpper(out: rt.ByteVec, part: rt.Place | undefined): v rt.byteVecPush(out, 254); } else { part.v = rt.strToAsciiUppercase(part.v); - fmt_put(out, part.v); + put(out, part.v); } } @@ -1636,26 +1618,26 @@ export function gets(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { putPart(out, rt.strGet(s, bounds21[0], bounds21[1])); } else if (_20 === 3) { const bounds17 = rt.strInclusive(s, new rt.RangeInclusive(a, b, rt.usizeStep)); - fmt_put(out, rt.strSlice(s, bounds17[0], bounds17[1])); + put(out, rt.strSlice(s, bounds17[0], bounds17[1])); } else if (_20 === 4) { const bounds16 = rt.strInclusive(s, { end: b, inclusive: true }); - fmt_put(out, rt.strSlice(s, bounds16[0], bounds16[1])); + put(out, rt.strSlice(s, bounds16[0], bounds16[1])); } else if (_20 === 5) { const _70: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.usizeStep); const bounds15 = rt.strInclusive(string, _70); - fmt_put(out, rt.strSlice(string, bounds15[0], bounds15[1])); + put(out, rt.strSlice(string, bounds15[0], bounds15[1])); } else if (_20 === 6) { const bounds14 = rt.strInclusive(string, { end: b, inclusive: true }); - fmt_put(out, rt.strSlice(string, bounds14[0], bounds14[1])); + put(out, rt.strSlice(string, bounds14[0], bounds14[1])); } else if (_20 === 7) { const bounds13 = rt.strInclusive(s, exhausted(a, b)); - fmt_put(out, rt.strSlice(s, bounds13[0], bounds13[1])); + put(out, rt.strSlice(s, bounds13[0], bounds13[1])); } else if (_20 === 8) { const bounds12 = rt.boundsRange([{ tag: "Excluded", _0: a } as rt.RangeBound, { tag: "Included", _0: b } as rt.RangeBound] as [rt.RangeBound, rt.RangeBound], rt.stringLen(s)); - fmt_put(out, rt.strSlice(s, bounds12[0], bounds12[1])); + put(out, rt.strSlice(s, bounds12[0], bounds12[1])); } else if (_20 === 9) { const bounds11 = rt.boundsRange([{ tag: "Included", _0: a } as rt.RangeBound, { tag: "Excluded", _0: b } as rt.RangeBound] as [rt.RangeBound, rt.RangeBound], rt.stringLen(string)); - fmt_put(out, rt.strSlice(string, bounds11[0], bounds11[1])); + put(out, rt.strSlice(string, bounds11[0], bounds11[1])); } else if (_20 === 10) { const _89: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.usizeStep); const s7 = rt.place(() => string, (value6) => string = value6); @@ -1671,33 +1653,33 @@ export function gets(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const s10 = rt.place(() => string, (value9) => string = value9); const bounds10 = rt.sliceGetBounds([{ tag: "Excluded", _0: a } as rt.RangeBound, { tag: "Included", _0: b } as rt.RangeBound] as [rt.RangeBound, rt.RangeBound], rt.stringLen(s10.v)); putUpper(out, rt.strGetMut(s10, bounds10[0], bounds10[1])); - fmt_put(out, string); + put(out, string); } else if (_20 === 11) { const _113: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.usizeStep); const s6 = rt.place(() => string, (value5) => string = value5); const bounds6 = rt.strInclusive(s6.v, _113); const _111: rt.Place = rt.strPart(s6, bounds6[0], bounds6[1]); _111.v = rt.strToAsciiUppercase(_111.v); - fmt_put(out, string); + put(out, string); } else if (_20 === 12) { const s5 = rt.place(() => string, (value4) => string = value4); const bounds5 = rt.strInclusive(s5.v, { end: b, inclusive: true }); const _118: rt.Place = rt.strPart(s5, bounds5[0], bounds5[1]); _118.v = rt.strToAsciiUppercase(_118.v); - fmt_put(out, string); + put(out, string); } else if (_20 === 13) { const _128: rt.RangeInclusive = exhausted(a, b); const s4 = rt.place(() => string, (value3) => string = value3); const bounds4 = rt.strInclusive(s4.v, _128); const _126: rt.Place = rt.strPart(s4, bounds4[0], bounds4[1]); _126.v = rt.strToAsciiUppercase(_126.v); - fmt_put(out, string); + put(out, string); } else if (_20 === 14) { const s3 = rt.place(() => string, (value2) => string = value2); const bounds3 = rt.boundsRange([{ tag: "Excluded", _0: a } as rt.RangeBound, { tag: "Excluded", _0: b } as rt.RangeBound] as [rt.RangeBound, rt.RangeBound], rt.stringLen(s3.v)); const _133: rt.Place = rt.strPart(s3, bounds3[0], bounds3[1]); _133.v = rt.strToAsciiUppercase(_133.v); - fmt_put(out, string); + put(out, string); } else { const s2 = rt.place(() => string, (value) => string = value); const bounds = rt.strInclusive(s2.v, { end: b, inclusive: true }); @@ -1707,7 +1689,7 @@ export function gets(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const bounds2 = rt.strInclusive(part.v, _150); const _149: rt.Place = rt.strPart(part, bounds2[0], bounds2[1]); _149.v = rt.strToAsciiUppercase(_149.v); - fmt_put(out, string); + put(out, string); } } diff --git a/ts/fixtures/lang/strs/src/lib.rs b/ts/fixtures/lang/strs/src/lib.rs new file mode 100644 index 000000000..48ea601e5 --- /dev/null +++ b/ts/fixtures/lang/strs/src/lib.rs @@ -0,0 +1,28 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod strs; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("strs::strs", strs::strs), + ("strs::slices", strs::slices), + ("strs::edits", strs::edits), + ("strs::parses", strs::parses), + ("strs::iters", strs::iters), + ("strs::drains", strs::drains), + ("strs::hinted", strs::hinted), + ("strs::gets", strs::gets), + ] +} diff --git a/ts/fixtures/lang/src/strs.rs b/ts/fixtures/lang/strs/src/strs.rs similarity index 98% rename from ts/fixtures/lang/src/strs.rs rename to ts/fixtures/lang/strs/src/strs.rs index 978597a31..aa100ec4e 100644 --- a/ts/fixtures/lang/src/strs.rs +++ b/ts/fixtures/lang/strs/src/strs.rs @@ -6,36 +6,7 @@ use std::ops::Bound; -use crate::fmt::put; - -/// Separators, digits, and chars where a UTF-8 or UTF-16 length changes. -const ALPHABET: [char; 16] = [ - '/', - '\\', - 'a', - '0', - '9', - '\u{7f}', - '\u{80}', - 'é', - '\u{7ff}', - '\u{800}', - '\u{d7ff}', - '\u{e000}', - '\u{ffff}', - '\u{10000}', - '😀', - '\u{10ffff}', -]; - -/// A char of the alphabet for each byte, by its low bits. -pub fn text(data: &[u8]) -> String { - let mut s = String::new(); - for &b in data { - s.push(ALPHABET[(b % 16) as usize]); - } - s -} +use crate::harness::{ALPHABET, put, text}; /// Whether the `i`th step reads from the back: by the byte's high bit. fn from_back(data: &[u8], i: usize) -> bool { diff --git a/ts/fixtures/lang/strs/ts.toml b/ts/fixtures/lang/strs/ts.toml new file mode 100644 index 000000000..7a28150ea --- /dev/null +++ b/ts/fixtures/lang/strs/ts.toml @@ -0,0 +1,2 @@ +package = "lang-strs-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/tuples/Cargo.toml b/ts/fixtures/lang/tuples/Cargo.toml new file mode 100644 index 000000000..e2a08f38c --- /dev/null +++ b/ts/fixtures/lang/tuples/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-tuples-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/tuples/expected/core/option.ts b/ts/fixtures/lang/tuples/expected/core/option.ts new file mode 100644 index 000000000..9786cd3ba --- /dev/null +++ b/ts/fixtures/lang/tuples/expected/core/option.ts @@ -0,0 +1,33 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function map$1pb5zw8(self: rt.u8 | undefined, f: (a0: rt.u8) => [rt.u16, rt.u8]): [rt.u16, rt.u8] | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$1fmzefe(self: rt.u8 | undefined, f: (a0: rt.u8) => [rt.u8, rt.u8]): [rt.u8, rt.u8] | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function mapOr$02k4ito(self: rt.usize | undefined, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/tuples/expected/harness.ts b/ts/fixtures/lang/tuples/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/tuples/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/tuples/expected/lib.ts b/ts/fixtures/lang/tuples/expected/lib.ts new file mode 100644 index 000000000..6a028d7a2 --- /dev/null +++ b/ts/fixtures/lang/tuples/expected/lib.ts @@ -0,0 +1,39 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { tuples } from "./tuples.ts"; +import type * as Logged from "./tuples.Logged.ts"; +import type * as Spot from "./tuples.Spot.ts"; +import type * as Tally from "./tuples.Tally.ts"; + +export function copy$tuples_Spot(v: Spot.Spot): Spot.Spot { + return { x: v.x, y: v.y }; +} + +export function drop$Result_tuple2_tuples_Logged_u8_u8(_1: rt.Result<[Logged.Logged, rt.u8], rt.u8>): void { + if (_1.ok) { + drop$tuple2_tuples_Logged_u8(_1.value); + } +} + +export function drop$tuple2_Vec_tuples_Logged_tuples_Tally(_1: [Logged.Logged[], Tally.Tally]): void { + rt.dropAll(_1[0]); +} + +export function drop$tuple2_tuples_Logged_u8(_1: [Logged.Logged, rt.u8]): void { + _1[0][Symbol.dispose](); +} + +export function drop$tuple2_u8_tuples_Logged(_1: [rt.u8, Logged.Logged]): void { + _1[1][Symbol.dispose](); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["tuples::tuples", tuples as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/tuples/expected/std/thread/local.ts b/ts/fixtures/lang/tuples/expected/std/thread/local.ts new file mode 100644 index 000000000..a41ea1713 --- /dev/null +++ b/ts/fixtures/lang/tuples/expected/std/thread/local.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../../rt.ts"; + +export function set$0xuu1fw(self: rt.LocalKey>, value: rt.u8): void { + rt.localKeyInitializeWith(self, new rt.Cell(value), (value2: rt.Cell | undefined, cell: rt.Cell): undefined => { + if (value2 !== undefined) { + rt.cellSet(cell, value2.v); + } + }); +} + +export function get$18ignl5(self: rt.LocalKey>): rt.u8 { + return ((a0: rt.Cell): rt.u8 => { + return a0.v; + })(self.get()); +} + +//# sourceMappingURL=local.ts.map diff --git a/ts/fixtures/lang/expected/tuples.Last.ts b/ts/fixtures/lang/tuples/expected/tuples.Last.ts similarity index 100% rename from ts/fixtures/lang/expected/tuples.Last.ts rename to ts/fixtures/lang/tuples/expected/tuples.Last.ts diff --git a/ts/fixtures/lang/expected/tuples.Logged.ts b/ts/fixtures/lang/tuples/expected/tuples.Logged.ts similarity index 100% rename from ts/fixtures/lang/expected/tuples.Logged.ts rename to ts/fixtures/lang/tuples/expected/tuples.Logged.ts diff --git a/ts/fixtures/lang/expected/tuples.Spot.ts b/ts/fixtures/lang/tuples/expected/tuples.Spot.ts similarity index 100% rename from ts/fixtures/lang/expected/tuples.Spot.ts rename to ts/fixtures/lang/tuples/expected/tuples.Spot.ts diff --git a/ts/fixtures/lang/expected/tuples.Tally.ts b/ts/fixtures/lang/tuples/expected/tuples.Tally.ts similarity index 96% rename from ts/fixtures/lang/expected/tuples.Tally.ts rename to ts/fixtures/lang/tuples/expected/tuples.Tally.ts index f31058db2..24571b54e 100644 --- a/ts/fixtures/lang/expected/tuples.Tally.ts +++ b/ts/fixtures/lang/tuples/expected/tuples.Tally.ts @@ -2,8 +2,8 @@ import * as rt from "./rt.ts"; import { mapOr$02k4ito as option_mapOr$02k4ito } from "./core/option.ts"; -import { set$0xuu1fw as local_set$0xuu1fw, get$18ignl5 as local_get$18ignl5 } from "./std/thread/local.ts"; -import { NEXT as tuples_NEXT, call } from "./tuples.ts"; +import { set$0xuu1fw, get$18ignl5 } from "./std/thread/local.ts"; +import { NEXT, call } from "./tuples.ts"; /** * The crate's own collection: `default` logs the id it takes, and each `extend` the size @@ -15,8 +15,8 @@ export interface Tally { } export function default$Default(): Tally { - const id: rt.u8 = local_get$18ignl5(tuples_NEXT); - local_set$0xuu1fw(tuples_NEXT, rt.u8WrappingAdd(id, 1)); + const id: rt.u8 = get$18ignl5(NEXT); + set$0xuu1fw(NEXT, rt.u8WrappingAdd(id, 1)); call(rt.byteSliceFrom(Uint8Array.of(208, id))); return { id, sum: 0 }; } diff --git a/ts/fixtures/lang/expected/tuples.ts b/ts/fixtures/lang/tuples/expected/tuples.ts similarity index 76% rename from ts/fixtures/lang/expected/tuples.ts rename to ts/fixtures/lang/tuples/expected/tuples.ts index 22d7fbcab..4c1343d22 100644 --- a/ts/fixtures/lang/expected/tuples.ts +++ b/ts/fixtures/lang/tuples/expected/tuples.ts @@ -1,13 +1,13 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { copy$tuple2_u8_u8, copy$tuples_Spot, drop$Result_tuple2_tuples_Logged_u8_u8, drop$tuple2_Vec_tuples_Logged_tuples_Tally, drop$tuple2_tuples_Logged_u8, drop$tuple2_u8_tuples_Logged } from "./lib.ts"; -import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$1fmzefe as option_map$1fmzefe, map$1pb5zw8 as option_map$1pb5zw8 } from "./core/option.ts"; -import { set$0xuu1fw as local_set$0xuu1fw } from "./std/thread/local.ts"; +import { copy$tuples_Spot, drop$Result_tuple2_tuples_Logged_u8_u8, drop$tuple2_Vec_tuples_Logged_tuples_Tally, drop$tuple2_tuples_Logged_u8, drop$tuple2_u8_tuples_Logged } from "./lib.ts"; +import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, map$1pb5zw8 as option_map$1pb5zw8, map$1fmzefe as option_map$1fmzefe } from "./core/option.ts"; +import { set$0xuu1fw } from "./std/thread/local.ts"; import * as Last from "./tuples.Last.ts"; -import * as tuples_Logged from "./tuples.Logged.ts"; +import * as Logged from "./tuples.Logged.ts"; import type * as Spot from "./tuples.Spot.ts"; -import * as tuples_Tally from "./tuples.Tally.ts"; +import * as Tally from "./tuples.Tally.ts"; /** Puts what was logged since the last flush, after a marker. */ export function flush(log: rt.RefCell, out: rt.ByteVec): void { @@ -339,7 +339,7 @@ export function borrowed(data: rt.ByteSlice, out: rt.ByteVec): void { } return [_23[0], _23[1], _54, marks[_72]] as [rt.u8, Spot.Spot, [rt.u8, rt.u8], rt.char]; }); - rt.tupleExtend(t, _10, [rt.byteVecPart(), rt.copiedPart(rt.vecPart(4), copy$tuples_Spot), rt.copiedPart(rt.hashPart(undefined, undefined, 469762048), copy$tuple2_u8_u8), rt.STRING_CHARS_PART]); + rt.tupleExtend(t, _10, [rt.byteVecPart(), rt.copiedPart(rt.vecPart(4), copy$tuples_Spot), rt.hashPart(undefined, undefined, 469762048), rt.STRING_CHARS_PART]); const _17: Spot.Spot[] = []; const ones: [Spot.Spot[]] = [_17]; const _20: rt.Iter<[Spot.Spot]> = rt.iterMap(rt.iterSlice(points), (p: Spot.Spot): [Spot.Spot] => { @@ -371,64 +371,64 @@ export function borrowed(data: rt.ByteSlice, out: rt.ByteVec): void { */ export function dropped(data: rt.ByteSlice, out: rt.ByteVec): void { const log: rt.Arc> = new rt.Arc(new rt.RefCell(new rt.ByteVec())); - const logged: (a0: rt.u8, a1: rt.u8) => tuples_Logged.Logged = (id: rt.u8, key: rt.u8): tuples_Logged.Logged => { - return new tuples_Logged.Logged(id, key, rt.arcClone(log)); + const logged: (a0: rt.u8, a1: rt.u8) => Logged.Logged = (id: rt.u8, key: rt.u8): Logged.Logged => { + return new Logged.Logged(id, key, rt.arcClone(log)); }; - const _12: rt.Iter<[tuples_Logged.Logged, [rt.u8, tuples_Logged.Logged], tuples_Logged.Logged]> = rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(data))), (_2: [rt.usize, rt.u8]): [tuples_Logged.Logged, [rt.u8, tuples_Logged.Logged], tuples_Logged.Logged] => { + const _12: rt.Iter<[Logged.Logged, [rt.u8, Logged.Logged], Logged.Logged]> = rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(data))), (_2: [rt.usize, rt.u8]): [Logged.Logged, [rt.u8, Logged.Logged], Logged.Logged] => { const i: rt.usize = _2[0]; const b: rt.u8 = _2[1]; const i2: rt.u8 = i & 0xff; - return [logged(i2, b), [rt.u8Rem(b, 4), logged(64 | i2, 0)] as [rt.u8, tuples_Logged.Logged], logged(128 | i2, rt.u8Rem(b, 3))] as [tuples_Logged.Logged, [rt.u8, tuples_Logged.Logged], tuples_Logged.Logged]; + return [logged(i2, b), [rt.u8Rem(b, 4), logged(64 | i2, 0)] as [rt.u8, Logged.Logged], logged(128 | i2, rt.u8Rem(b, 3))] as [Logged.Logged, [rt.u8, Logged.Logged], Logged.Logged]; }); - const _11: [tuples_Logged.Logged[], rt.HashMap, rt.BTreeSet] = rt.tupleExtend([[], rt.hashNew() as rt.HashMap, rt.btreeNew(tuples_Logged.cmp$cmp_Ord) as rt.BTreeSet] as [tuples_Logged.Logged[], rt.HashMap, rt.BTreeSet], _12, [rt.vecPart(8), rt.hashPart(undefined, rt.drop, 117440512), rt.btreeKeysPart(rt.drop)]); - const v: tuples_Logged.Logged[] = _11[0]; - const map: rt.HashMap = _11[1]; - const set: rt.BTreeSet = _11[2]; + const _11: [Logged.Logged[], rt.HashMap, rt.BTreeSet] = rt.tupleExtend([[], rt.hashNew() as rt.HashMap, rt.btreeNew(Logged.cmp$cmp_Ord) as rt.BTreeSet] as [Logged.Logged[], rt.HashMap, rt.BTreeSet], _12, [rt.vecPart(8), rt.hashPart(undefined, rt.drop, 117440512), rt.btreeKeysPart(rt.drop)]); + const v: Logged.Logged[] = _11[0]; + const map: rt.HashMap = _11[1]; + const set: rt.BTreeSet = _11[2]; flush(log.value, out); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(v), (l: tuples_Logged.Logged): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(v), (l: Logged.Logged): rt.u8 => { return l.id; }), undefined, true); - const held: [rt.u8, tuples_Logged.Logged][] = rt.iterToArray(rt.hashIter(map, undefined, rt.drop), "next", 12); - rt.sliceSort(held, rt.keyLt((_24: [rt.u8, tuples_Logged.Logged]): rt.u8 => { + const held: [rt.u8, Logged.Logged][] = rt.iterToArray(rt.hashIter(map, undefined, rt.drop), "next", 12); + rt.sliceSort(held, rt.keyLt((_24: [rt.u8, Logged.Logged]): rt.u8 => { return _24[0]; }, rt.lt), 12, true); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held), (_25: [rt.u8, tuples_Logged.Logged]): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held), (_25: [rt.u8, Logged.Logged]): rt.u8 => { return _25[0] ^ _25[1].id; }), undefined, true); - rt.iterExtendBytes(out, rt.iterMap(rt.btreeKeys(set), (l2: tuples_Logged.Logged): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.btreeKeys(set), (l2: Logged.Logged): rt.u8 => { return l2.id; }), undefined, true); rt.dropAll(v); rt.dropAll(held, drop$tuple2_u8_tuples_Logged); rt.btreeDrop(set, rt.drop); flush(log.value, out); - const _49: rt.Iter<[[rt.u8, tuples_Logged.Logged], tuples_Logged.Logged]> = rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(data))), (_27: [rt.usize, rt.u8]): [[rt.u8, tuples_Logged.Logged], tuples_Logged.Logged] => { + const _49: rt.Iter<[[rt.u8, Logged.Logged], Logged.Logged]> = rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(data))), (_27: [rt.usize, rt.u8]): [[rt.u8, Logged.Logged], Logged.Logged] => { const i3: rt.usize = _27[0]; const b2: rt.u8 = _27[1]; - return [[rt.u8Rem(b2, 3), logged(i3 & 0xff, 0)] as [rt.u8, tuples_Logged.Logged], logged(128 | (i3 & 0xff), rt.u8Rem(b2, 5))] as [[rt.u8, tuples_Logged.Logged], tuples_Logged.Logged]; + return [[rt.u8Rem(b2, 3), logged(i3 & 0xff, 0)] as [rt.u8, Logged.Logged], logged(128 | (i3 & 0xff), rt.u8Rem(b2, 5))] as [[rt.u8, Logged.Logged], Logged.Logged]; }); - const _48: [rt.BTreeMap, rt.HashSet] = rt.tupleExtend([rt.btreeNew(rt.cmp) as rt.BTreeMap, rt.hashNew(rt.hashing(tuples_Logged.hash$Hash_hash_DefaultHasher as (a0: tuples_Logged.Logged, a1: rt.Hasher) => undefined, tuples_Logged.eq$cmp_PartialEq)) as rt.HashSet] as [rt.BTreeMap, rt.HashSet], _49, [rt.btreePart(undefined, rt.drop), rt.hashKeysPart(rt.drop, 117440512)]); - const tree: rt.BTreeMap = _48[0]; - const keys: rt.HashSet = _48[1]; + const _48: [rt.BTreeMap, rt.HashSet] = rt.tupleExtend([rt.btreeNew(rt.cmp) as rt.BTreeMap, rt.hashNew(rt.hashing(Logged.hash$Hash_hash_DefaultHasher as (a0: Logged.Logged, a1: rt.Hasher) => undefined, Logged.eq$cmp_PartialEq)) as rt.HashSet] as [rt.BTreeMap, rt.HashSet], _49, [rt.btreePart(undefined, rt.drop), rt.hashKeysPart(rt.drop, 117440512)]); + const tree: rt.BTreeMap = _48[0]; + const keys: rt.HashSet = _48[1]; flush(log.value, out); - const held2: tuples_Logged.Logged[] = rt.iterToArray(rt.hashKeys(keys), "next", 4); - rt.sliceSort(held2, rt.keyLt((l3: tuples_Logged.Logged): rt.u8 => { + const held2: Logged.Logged[] = rt.iterToArray(rt.hashKeys(keys), "next", 4); + rt.sliceSort(held2, rt.keyLt((l3: Logged.Logged): rt.u8 => { return l3.key; }, rt.lt), 4, true); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held2), (l4: tuples_Logged.Logged): rt.u8 => { + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(held2), (l4: Logged.Logged): rt.u8 => { return l4.id; }), undefined, true); rt.btreeDrop(tree, undefined, rt.drop); flush(log.value, out); - const source: [tuples_Logged.Logged, rt.u8][] = rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(data))), (_29: [rt.usize, rt.u8]): [tuples_Logged.Logged, rt.u8] => { + const source: [Logged.Logged, rt.u8][] = rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(data))), (_29: [rt.usize, rt.u8]): [Logged.Logged, rt.u8] => { const i4: rt.usize = _29[0]; const b3: rt.u8 = _29[1]; - return [logged(i4 & 0xff, b3), b3] as [tuples_Logged.Logged, rt.u8]; + return [logged(i4 & 0xff, b3), b3] as [Logged.Logged, rt.u8]; }), undefined, 12, true); const n: rt.usize = rt.u8Rem(option_unwrapOr$0r2bmpr(rt.byteSliceFirst(data), 0), 8) as rt.usize; - const _87: rt.Iter<[tuples_Logged.Logged, rt.u8]> = rt.iterTake(rt.iterSlice(source, drop$tuple2_tuples_Logged_u8), n, drop$tuple2_tuples_Logged_u8); - const _86: [tuples_Logged.Logged[], rt.ByteVec] = rt.tupleExtend([[], new rt.ByteVec()] as [tuples_Logged.Logged[], rt.ByteVec], _87, [rt.vecPart(8), rt.byteVecPart()], "fold"); - const taken: tuples_Logged.Logged[] = _86[0]; + const _87: rt.Iter<[Logged.Logged, rt.u8]> = rt.iterTake(rt.iterSlice(source, drop$tuple2_tuples_Logged_u8), n, drop$tuple2_tuples_Logged_u8); + const _86: [Logged.Logged[], rt.ByteVec] = rt.tupleExtend([[], new rt.ByteVec()] as [Logged.Logged[], rt.ByteVec], _87, [rt.vecPart(8), rt.byteVecPart()], "fold"); + const taken: Logged.Logged[] = _86[0]; const bytes: rt.ByteVec = _86[1]; flush(log.value, out); rt.iterExtendBytes(out, rt.byteVecIntoIter(bytes), undefined, true); @@ -592,7 +592,7 @@ export function own(data: rt.ByteSlice, out: rt.ByteVec): void { } return 237; }), undefined, true); - local_set$0xuu1fw(NEXT, 0); + set$0xuu1fw(NEXT, 0); rt.localKeyWithBorrowMut(CALLS, (a0: rt.ByteVec): undefined => { rt.byteVecClear(a0); }); @@ -601,15 +601,15 @@ export function own(data: rt.ByteSlice, out: rt.ByteVec): void { }), (_22: rt.u8): [rt.u8] => { return [_22] as [rt.u8]; }); - rt.byteVecPush(out, rt.tupleExtendOne([tuples_Tally.default$Default()] as [tuples_Tally.Tally], _12, (c, items) => rt.ownExtend(c, items, tuples_Tally.extend$iter_Extend_u8_iter_Map_iter_Map_iter_Inspect_slice_Iter_u8_tuples_own_closure1_tuples_own_closure2_iter_FromIterator_tuple1_T_tuple1_ExtendT_from_iter_closure0_u8_tuples_Tally_iter_Map_iter_Inspect_slice_Iter_u8_tuples_own_closure1_tuples_own_closure2 as (a0: tuples_Tally.Tally, a1: rt.Iter) => undefined))[0].sum); + rt.byteVecPush(out, rt.tupleExtendOne([Tally.default$Default()] as [Tally.Tally], _12, (c, items) => rt.ownExtend(c, items, Tally.extend$iter_Extend_u8_iter_Map_iter_Map_iter_Inspect_slice_Iter_u8_tuples_own_closure1_tuples_own_closure2_iter_FromIterator_tuple1_T_tuple1_ExtendT_from_iter_closure0_u8_tuples_Tally_iter_Map_iter_Inspect_slice_Iter_u8_tuples_own_closure1_tuples_own_closure2 as (a0: Tally.Tally, a1: rt.Iter) => undefined))[0].sum); calls(out); - const one: [tuples_Tally.Tally] = [tuples_Tally.default$Default()]; + const one: [Tally.Tally] = [Tally.default$Default()]; const _24: rt.Iter<[rt.u8]> = rt.iterMap(rt.iterFilter(rt.iterSlice(rt.byteSliceView(rt.byteVecSlice(data2))), (_23: rt.u8): boolean => { return (_23 & 1) === 0; }), (_28: rt.u8): [rt.u8] => { return [_28] as [rt.u8]; }); - rt.tupleExtendOne(one, _24, (c2, items2) => rt.ownExtend(c2, items2, tuples_Tally.extend$iter_Extend_u8_iter_Map_iter_Map_iter_Filter_slice_Iter_u8_tuples_own_closure3_tuples_own_closure4_iter_Extend_tuple1_T_tuple1_ExtendT_extend_closure0_u8_tuples_Tally_iter_Map_iter_Filter_slice_Iter_u8_tuples_own_closure3_tuples_own_closure4 as (a0: tuples_Tally.Tally, a1: rt.Iter) => undefined)); + rt.tupleExtendOne(one, _24, (c2, items2) => rt.ownExtend(c2, items2, Tally.extend$iter_Extend_u8_iter_Map_iter_Map_iter_Filter_slice_Iter_u8_tuples_own_closure3_tuples_own_closure4_iter_Extend_tuple1_T_tuple1_ExtendT_extend_closure0_u8_tuples_Tally_iter_Map_iter_Filter_slice_Iter_u8_tuples_own_closure3_tuples_own_closure4 as (a0: Tally.Tally, a1: rt.Iter) => undefined)); rt.byteVecPush(out, one[0].sum); calls(out); const _35: rt.Iter<[rt.u8, rt.u8]> = rt.iterMap(rt.iterInspect(rt.iterSlice(rt.byteSliceView(rt.byteVecSlice(data2))), (b7: rt.u8): undefined => { @@ -618,9 +618,9 @@ export function own(data: rt.ByteSlice, out: rt.ByteVec): void { const b8: rt.u8 = _29; return [b8 ^ 90, b8] as [rt.u8, rt.u8]; }); - const _34: [rt.ByteVec, tuples_Tally.Tally] = rt.tupleExtend([new rt.ByteVec(), tuples_Tally.default$Default()] as [rt.ByteVec, tuples_Tally.Tally], _35, [rt.byteVecPart(), rt.ownPart(tuples_Tally.extend$iter_Extend_u8_Option_u8 as (a0: tuples_Tally.Tally, a1: rt.u8 | undefined) => undefined)]); + const _34: [rt.ByteVec, Tally.Tally] = rt.tupleExtend([new rt.ByteVec(), Tally.default$Default()] as [rt.ByteVec, Tally.Tally], _35, [rt.byteVecPart(), rt.ownPart(Tally.extend$iter_Extend_u8_Option_u8 as (a0: Tally.Tally, a1: rt.u8 | undefined) => undefined)]); const v: rt.ByteVec = _34[0]; - const t2: tuples_Tally.Tally = _34[1]; + const t2: Tally.Tally = _34[1]; rt.iterExtendBytes(out, rt.byteVecIntoIter(v), undefined, true); rt.byteVecPush(out, t2.sum); calls(out); @@ -628,8 +628,8 @@ export function own(data: rt.ByteSlice, out: rt.ByteVec): void { const b9: rt.u8 = _210; return [b9, (((b9 as rt.u16)) << 3) & 0xffff] as [rt.u8, rt.u16]; }); - const _46: [tuples_Tally.Tally, rt.u16[]] = rt.tupleExtend([tuples_Tally.default$Default(), []] as [tuples_Tally.Tally, rt.u16[]], _47, [rt.ownPart(tuples_Tally.extend$iter_Extend_u8_Option_u8 as (a0: tuples_Tally.Tally, a1: rt.u8 | undefined) => undefined), rt.vecPart(2)]); - const t3: tuples_Tally.Tally = _46[0]; + const _46: [Tally.Tally, rt.u16[]] = rt.tupleExtend([Tally.default$Default(), []] as [Tally.Tally, rt.u16[]], _47, [rt.ownPart(Tally.extend$iter_Extend_u8_Option_u8 as (a0: Tally.Tally, a1: rt.u8 | undefined) => undefined), rt.vecPart(2)]); + const t3: Tally.Tally = _46[0]; const w: rt.u16[] = _46[1]; rt.byteVecPush(out, t3.sum); rt.iterExtendBytes(out, rt.iterFlatMap(rt.iterSlice(w), (n: rt.u16): Uint8Array => { @@ -642,8 +642,8 @@ export function own(data: rt.ByteSlice, out: rt.ByteVec): void { const b11: rt.u8 = _211; return [b11, b11 as rt.char, ~b11 & 0xff] as [rt.u8, rt.char, rt.u8]; }); - const _62: [tuples_Tally.Tally, string, tuples_Tally.Tally] = rt.tupleExtend([tuples_Tally.default$Default(), "", tuples_Tally.default$Default()] as [tuples_Tally.Tally, string, tuples_Tally.Tally], _63, [rt.ownPart(tuples_Tally.extend$iter_Extend_u8_Option_u8 as (a0: tuples_Tally.Tally, a1: rt.u8 | undefined) => undefined), rt.STRING_CHARS_PART, rt.ownPart(tuples_Tally.extend$iter_Extend_u8_Option_u8 as (a0: tuples_Tally.Tally, a1: rt.u8 | undefined) => undefined)]); - const a: tuples_Tally.Tally = _62[0]; + const _62: [Tally.Tally, string, Tally.Tally] = rt.tupleExtend([Tally.default$Default(), "", Tally.default$Default()] as [Tally.Tally, string, Tally.Tally], _63, [rt.ownPart(Tally.extend$iter_Extend_u8_Option_u8 as (a0: Tally.Tally, a1: rt.u8 | undefined) => undefined), rt.STRING_CHARS_PART, rt.ownPart(Tally.extend$iter_Extend_u8_Option_u8 as (a0: Tally.Tally, a1: rt.u8 | undefined) => undefined)]); + const a: Tally.Tally = _62[0]; const s: string = _62[1]; rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(a.sum, _62[2].sum)), undefined, true); rt.iterExtendBytes(out, rt.strBytes(s), undefined, true); @@ -652,10 +652,10 @@ export function own(data: rt.ByteSlice, out: rt.ByteVec): void { const b12: rt.u8 = _212; return [b12 as rt.char, rt.u8Add(97, rt.u8Rem(b12, 26)) as rt.char, b12] as [rt.char, rt.char, rt.u8]; }); - const _80: [string, Last.Last, tuples_Tally.Tally] = rt.tupleExtend(["", Last.default$Default(), tuples_Tally.default$Default()] as [string, Last.Last, tuples_Tally.Tally], _81, [rt.STRING_CHARS_PART, rt.ownPart(Last.extend$iter_Extend_char_Option_char as (a0: rt.Place, a1: rt.char | undefined) => undefined, true), rt.ownPart(tuples_Tally.extend$iter_Extend_u8_Option_u8 as (a0: tuples_Tally.Tally, a1: rt.u8 | undefined) => undefined)]); + const _80: [string, Last.Last, Tally.Tally] = rt.tupleExtend(["", Last.default$Default(), Tally.default$Default()] as [string, Last.Last, Tally.Tally], _81, [rt.STRING_CHARS_PART, rt.ownPart(Last.extend$iter_Extend_char_Option_char as (a0: rt.Place, a1: rt.char | undefined) => undefined, true), rt.ownPart(Tally.extend$iter_Extend_u8_Option_u8 as (a0: Tally.Tally, a1: rt.u8 | undefined) => undefined)]); const s2: string = _80[0]; const last: Last.Last = _80[1]; - const t4: tuples_Tally.Tally = _80[2]; + const t4: Tally.Tally = _80[2]; rt.iterExtendBytes(out, rt.strBytes(s2), undefined, true); Last.put(last, out); rt.byteVecPush(out, t4.sum); @@ -664,9 +664,9 @@ export function own(data: rt.ByteSlice, out: rt.ByteVec): void { const b13: rt.u8 = _214; return [b13, [b13] as [rt.u8]] as [rt.u8, [rt.u8]]; }); - const _96: [rt.ByteVec, [tuples_Tally.Tally]] = rt.tupleExtend([new rt.ByteVec(), [tuples_Tally.default$Default()]] as [rt.ByteVec, [tuples_Tally.Tally]], _97, [rt.byteVecPart(), rt.tuplePart([rt.ownPart(tuples_Tally.extend$iter_Extend_u8_Option_u8 as (a0: tuples_Tally.Tally, a1: rt.u8 | undefined) => undefined)])]); + const _96: [rt.ByteVec, [Tally.Tally]] = rt.tupleExtend([new rt.ByteVec(), [Tally.default$Default()]] as [rt.ByteVec, [Tally.Tally]], _97, [rt.byteVecPart(), rt.tuplePart([rt.ownPart(Tally.extend$iter_Extend_u8_Option_u8 as (a0: Tally.Tally, a1: rt.u8 | undefined) => undefined)])]); const v2: rt.ByteVec = _96[0]; - const t5: tuples_Tally.Tally = _96[1][0]; + const t5: Tally.Tally = _96[1][0]; rt.iterExtendBytes(out, rt.byteVecIntoIter(v2), undefined, true); rt.byteVecPush(out, t5.sum); calls(out); @@ -674,7 +674,7 @@ export function own(data: rt.ByteSlice, out: rt.ByteVec): void { return [_216 as rt.char] as [rt.char]; }); Last.put(rt.tupleExtendOne([Last.default$Default()] as [Last.Last], _107, (c3, items3) => rt.ownExtend(c3, items3, Last.extend$iter_Extend_char_iter_Map_iter_Map_slice_Iter_u8_tuples_own_closure13_iter_FromIterator_tuple1_T_tuple1_ExtendT_from_iter_closure0_char_tuples_Last_iter_Map_slice_Iter_u8_tuples_own_closure13 as (a0: rt.Place, a1: rt.Iter) => undefined, true))[0], out); - const t6: [tuples_Tally.Tally, rt.ByteVec, Last.Last] = [tuples_Tally.default$Default(), rt.byteVecFrom(Uint8Array.of(7)), { tag: "Seen", _0: 113, _1: 9 } as Last.Last]; + const t6: [Tally.Tally, rt.ByteVec, Last.Last] = [Tally.default$Default(), rt.byteVecFrom(Uint8Array.of(7)), { tag: "Seen", _0: 113, _1: 9 } as Last.Last]; const _120: rt.Iter<[rt.u8, rt.u8, rt.char]> = rt.iterMap(rt.byteSliceChunks(rt.byteVecSlice(data2), 2), (c4: rt.ByteSlice): [rt.u8, rt.u8, rt.char] => { rt.idx(c4, 0); const _310: rt.u8 = c4.data[c4.start]; @@ -683,20 +683,20 @@ export function own(data: rt.ByteSlice, out: rt.ByteVec): void { rt.idx(c4, 0); return [_310, _76, c4.data[c4.start] as rt.char] as [rt.u8, rt.u8, rt.char]; }); - rt.tupleExtend(t6, _120, [rt.ownPart(tuples_Tally.extend$iter_Extend_u8_Option_u8 as (a0: tuples_Tally.Tally, a1: rt.u8 | undefined) => undefined), rt.byteVecPart(), rt.ownPart(Last.extend$iter_Extend_char_Option_char as (a0: rt.Place, a1: rt.char | undefined) => undefined, true)]); + rt.tupleExtend(t6, _120, [rt.ownPart(Tally.extend$iter_Extend_u8_Option_u8 as (a0: Tally.Tally, a1: rt.u8 | undefined) => undefined), rt.byteVecPart(), rt.ownPart(Last.extend$iter_Extend_char_Option_char as (a0: rt.Place, a1: rt.char | undefined) => undefined, true)]); rt.byteVecPush(out, t6[0].sum); rt.iterExtendBytes(out, rt.byteVecIntoIter(t6[1]), undefined, true); Last.put(t6[2], out); calls(out); - const parsed: rt.Result<[tuples_Tally.Tally, rt.ByteVec], rt.u8> = rt.iterCollectResult(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteVecSlice(data2))), (_217: rt.u8): rt.Result<[rt.u8, rt.u8], rt.u8> => { + const parsed: rt.Result<[Tally.Tally, rt.ByteVec], rt.u8> = rt.iterCollectResult(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteVecSlice(data2))), (_217: rt.u8): rt.Result<[rt.u8, rt.u8], rt.u8> => { const b15: rt.u8 = _217; if (!(b15 === 0)) { return rt.Ok([b15, b15] as [rt.u8, rt.u8]); } return rt.Err(b15); - }), (values: rt.Iter<[rt.u8, rt.u8]>) => rt.tupleExtend([tuples_Tally.default$Default(), new rt.ByteVec()] as [tuples_Tally.Tally, rt.ByteVec], values, [rt.ownPart(tuples_Tally.extend$iter_Extend_u8_Option_u8 as (a0: tuples_Tally.Tally, a1: rt.u8 | undefined) => undefined), rt.byteVecPart()])); + }), (values: rt.Iter<[rt.u8, rt.u8]>) => rt.tupleExtend([Tally.default$Default(), new rt.ByteVec()] as [Tally.Tally, rt.ByteVec], values, [rt.ownPart(Tally.extend$iter_Extend_u8_Option_u8 as (a0: Tally.Tally, a1: rt.u8 | undefined) => undefined), rt.byteVecPart()])); if (parsed.ok) { - const t7: tuples_Tally.Tally = parsed.value[0]; + const t7: Tally.Tally = parsed.value[0]; const v3: rt.ByteVec = parsed.value[1]; rt.byteVecPush(out, t7.sum); rt.iterExtendBytes(out, rt.byteVecIntoIter(v3), undefined, true); @@ -704,35 +704,35 @@ export function own(data: rt.ByteSlice, out: rt.ByteVec): void { rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(250, parsed.error)), undefined, true); } calls(out); - const found: [rt.ByteVec, tuples_Tally.Tally] | undefined = rt.iterCollectOption(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteVecSlice(data2))), (_218: rt.u8): [rt.u8, rt.u8] | undefined => { + const found: [rt.ByteVec, Tally.Tally] | undefined = rt.iterCollectOption(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteVecSlice(data2))), (_218: rt.u8): [rt.u8, rt.u8] | undefined => { const b16: rt.u8 = _218; return option_map$1fmzefe(rt.u8CheckedSub(b16, 4), (n2: rt.u8): [rt.u8, rt.u8] => { return [n2, b16] as [rt.u8, rt.u8]; }); - }), (values: rt.Iter<[rt.u8, rt.u8]>) => rt.tupleExtend([new rt.ByteVec(), tuples_Tally.default$Default()] as [rt.ByteVec, tuples_Tally.Tally], values, [rt.byteVecPart(), rt.ownPart(tuples_Tally.extend$iter_Extend_u8_Option_u8 as (a0: tuples_Tally.Tally, a1: rt.u8 | undefined) => undefined)])); + }), (values: rt.Iter<[rt.u8, rt.u8]>) => rt.tupleExtend([new rt.ByteVec(), Tally.default$Default()] as [rt.ByteVec, Tally.Tally], values, [rt.byteVecPart(), rt.ownPart(Tally.extend$iter_Extend_u8_Option_u8 as (a0: Tally.Tally, a1: rt.u8 | undefined) => undefined)])); if (found === undefined) { rt.byteVecPush(out, 249); } else { const v4: rt.ByteVec = found[0]; - const t8: tuples_Tally.Tally = found[1]; + const t8: Tally.Tally = found[1]; rt.iterExtendBytes(out, rt.byteVecIntoIter(v4), undefined, true); rt.byteVecPush(out, t8.sum); } calls(out); const log: rt.Arc> = new rt.Arc(new rt.RefCell(new rt.ByteVec())); - const held: rt.Result<[tuples_Logged.Logged[], tuples_Tally.Tally], rt.u8> = rt.iterCollectResult(rt.iterSlice(rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(rt.byteVecSlice(data2)))), (_219: [rt.usize, rt.u8]): rt.Result<[tuples_Logged.Logged, rt.u8], rt.u8> => { + const held: rt.Result<[Logged.Logged[], Tally.Tally], rt.u8> = rt.iterCollectResult(rt.iterSlice(rt.iterToArray(rt.iterMap(rt.iterEnumerate(rt.iterSlice(rt.byteSliceView(rt.byteVecSlice(data2)))), (_219: [rt.usize, rt.u8]): rt.Result<[Logged.Logged, rt.u8], rt.u8> => { const i: rt.usize = _219[0]; const b17: rt.u8 = _219[1]; if (!(128 <= b17)) { - return rt.Ok([new tuples_Logged.Logged(i & 0xff, b17, rt.arcClone(log)), b17] as [tuples_Logged.Logged, rt.u8]); + return rt.Ok([new Logged.Logged(i & 0xff, b17, rt.arcClone(log)), b17] as [Logged.Logged, rt.u8]); } return rt.Err(b17); - }), undefined, 12, true), drop$Result_tuple2_tuples_Logged_u8_u8), (values: rt.Iter<[tuples_Logged.Logged, rt.u8]>) => rt.tupleExtend([[], tuples_Tally.default$Default()] as [tuples_Logged.Logged[], tuples_Tally.Tally], values, [rt.vecPart(8), rt.ownPart(tuples_Tally.extend$iter_Extend_u8_Option_u8 as (a0: tuples_Tally.Tally, a1: rt.u8 | undefined) => undefined)], "fold"), drop$tuple2_Vec_tuples_Logged_tuples_Tally); + }), undefined, 12, true), drop$Result_tuple2_tuples_Logged_u8_u8), (values: rt.Iter<[Logged.Logged, rt.u8]>) => rt.tupleExtend([[], Tally.default$Default()] as [Logged.Logged[], Tally.Tally], values, [rt.vecPart(8), rt.ownPart(Tally.extend$iter_Extend_u8_Option_u8 as (a0: Tally.Tally, a1: rt.u8 | undefined) => undefined)], "fold"), drop$tuple2_Vec_tuples_Logged_tuples_Tally); flush(log.value, out); if (held.ok) { - const v5: tuples_Logged.Logged[] = held.value[0]; - const t9: tuples_Tally.Tally = held.value[1]; - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(v5), (l: tuples_Logged.Logged): rt.u8 => { + const v5: Logged.Logged[] = held.value[0]; + const t9: Tally.Tally = held.value[1]; + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(v5), (l: Logged.Logged): rt.u8 => { return l.id; }), undefined, true); rt.byteVecPush(out, t9.sum); @@ -742,7 +742,7 @@ export function own(data: rt.ByteSlice, out: rt.ByteVec): void { } flush(log.value, out); calls(out); - const nested: rt.Result<[tuples_Tally.Tally] | undefined, rt.u8> = rt.iterCollectResult(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteVecSlice(data2))), (_221: rt.u8): rt.Result<[rt.u8] | undefined, rt.u8> => { + const nested: rt.Result<[Tally.Tally] | undefined, rt.u8> = rt.iterCollectResult(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteVecSlice(data2))), (_221: rt.u8): rt.Result<[rt.u8] | undefined, rt.u8> => { const b18: rt.u8 = _221; if (!(240 <= b18)) { if (!(224 <= b18)) { @@ -751,7 +751,7 @@ export function own(data: rt.ByteSlice, out: rt.ByteVec): void { return rt.OK; } return rt.Err(b18); - }), (values: rt.Iter<[rt.u8] | undefined>) => rt.iterCollectOption(values, (values: rt.Iter<[rt.u8]>) => rt.tupleExtendOne([tuples_Tally.default$Default()] as [tuples_Tally.Tally], values, (c5, items4) => rt.ownExtend(c5, items4, tuples_Tally.extend$iter_Extend_u8_iter_Map_iter_adapters_GenericShunt_iter_adapters_GenericShunt_iter_Map_slice_Iter_u8_tuples_own_closure19_Result_never_u8_Option_never_iter_FromIterator_tuple1_T_tuple1_ExtendT_from_iter_closure0_u8_tuples_Tally_iter_adapters_GenericShunt_iter_adapters_GenericShunt_iter_Map_slice_Iter_u8_tuples_own_closure19_Result_never_u8_Option_never as (a0: tuples_Tally.Tally, a1: rt.Iter) => undefined)))); + }), (values: rt.Iter<[rt.u8] | undefined>) => rt.iterCollectOption(values, (values: rt.Iter<[rt.u8]>) => rt.tupleExtendOne([Tally.default$Default()] as [Tally.Tally], values, (c5, items4) => rt.ownExtend(c5, items4, Tally.extend$iter_Extend_u8_iter_Map_iter_adapters_GenericShunt_iter_adapters_GenericShunt_iter_Map_slice_Iter_u8_tuples_own_closure19_Result_never_u8_Option_never_iter_FromIterator_tuple1_T_tuple1_ExtendT_from_iter_closure0_u8_tuples_Tally_iter_adapters_GenericShunt_iter_adapters_GenericShunt_iter_Map_slice_Iter_u8_tuples_own_closure19_Result_never_u8_Option_never as (a0: Tally.Tally, a1: rt.Iter) => undefined)))); if (nested.ok) { if (nested.value === undefined) { rt.byteVecPush(out, 249); @@ -762,13 +762,13 @@ export function own(data: rt.ByteSlice, out: rt.ByteVec): void { rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(250, nested.error)), undefined, true); } calls(out); - const alone: rt.Result<[tuples_Tally.Tally], rt.u8> = rt.iterCollectResult(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteVecSlice(data2))), (_222: rt.u8): rt.Result<[rt.u8], rt.u8> => { + const alone: rt.Result<[Tally.Tally], rt.u8> = rt.iterCollectResult(rt.iterMap(rt.iterSlice(rt.byteSliceView(rt.byteVecSlice(data2))), (_222: rt.u8): rt.Result<[rt.u8], rt.u8> => { const b19: rt.u8 = _222; if (!(b19 === 255)) { return rt.Ok([b19] as [rt.u8]); } return rt.Err(b19); - }), (values: rt.Iter<[rt.u8]>) => rt.tupleExtendOne([tuples_Tally.default$Default()] as [tuples_Tally.Tally], values, (c6, items5) => rt.ownExtend(c6, items5, tuples_Tally.extend$iter_Extend_u8_iter_Map_iter_adapters_GenericShunt_iter_Map_slice_Iter_u8_tuples_own_closure20_Result_never_u8_iter_FromIterator_tuple1_T_tuple1_ExtendT_from_iter_closure0_u8_tuples_Tally_iter_adapters_GenericShunt_iter_Map_slice_Iter_u8_tuples_own_closure20_Result_never_u8 as (a0: tuples_Tally.Tally, a1: rt.Iter) => undefined))); + }), (values: rt.Iter<[rt.u8]>) => rt.tupleExtendOne([Tally.default$Default()] as [Tally.Tally], values, (c6, items5) => rt.ownExtend(c6, items5, Tally.extend$iter_Extend_u8_iter_Map_iter_adapters_GenericShunt_iter_Map_slice_Iter_u8_tuples_own_closure20_Result_never_u8_iter_FromIterator_tuple1_T_tuple1_ExtendT_from_iter_closure0_u8_tuples_Tally_iter_adapters_GenericShunt_iter_Map_slice_Iter_u8_tuples_own_closure20_Result_never_u8 as (a0: Tally.Tally, a1: rt.Iter) => undefined))); if (alone.ok) { rt.byteVecPush(out, alone.value[0].sum); } else { @@ -789,14 +789,14 @@ export function ownPanicked(data: rt.ByteSlice, out: rt.ByteVec): void { } return 238; }); - local_set$0xuu1fw(NEXT, 0); + set$0xuu1fw(NEXT, 0); if (rt.u8Rem(option_unwrapOr$0r2bmpr(rt.byteSliceGet(data, 1), 0), 2) === 0) { const _25: rt.Iter<[rt.u8, rt.u8, rt.char]> = rt.iterMap(items, (b3: rt.u8): [rt.u8, rt.u8, rt.char] => { return [b3, b3, b3 as rt.char] as [rt.u8, rt.u8, rt.char]; }); - const _24: [rt.ByteVec, tuples_Tally.Tally, string] = rt.tupleExtend([new rt.ByteVec(), tuples_Tally.default$Default(), ""] as [rt.ByteVec, tuples_Tally.Tally, string], _25, [rt.byteVecPart(), rt.ownPart(tuples_Tally.extend$iter_Extend_u8_Option_u8 as (a0: tuples_Tally.Tally, a1: rt.u8 | undefined) => undefined), rt.STRING_CHARS_PART]); + const _24: [rt.ByteVec, Tally.Tally, string] = rt.tupleExtend([new rt.ByteVec(), Tally.default$Default(), ""] as [rt.ByteVec, Tally.Tally, string], _25, [rt.byteVecPart(), rt.ownPart(Tally.extend$iter_Extend_u8_Option_u8 as (a0: Tally.Tally, a1: rt.u8 | undefined) => undefined), rt.STRING_CHARS_PART]); const v: rt.ByteVec = _24[0]; - const t: tuples_Tally.Tally = _24[1]; + const t: Tally.Tally = _24[1]; const s: string = _24[2]; rt.iterExtendBytes(out, rt.byteVecIntoIter(v), undefined, true); rt.byteVecPush(out, t.sum); @@ -805,7 +805,7 @@ export function ownPanicked(data: rt.ByteSlice, out: rt.ByteVec): void { const _35: rt.Iter<[rt.u8]> = rt.iterMap(items, (b2: rt.u8): [rt.u8] => { return [b2] as [rt.u8]; }); - rt.byteVecPush(out, rt.tupleExtendOne([tuples_Tally.default$Default()] as [tuples_Tally.Tally], _35, (c, items2) => rt.ownExtend(c, items2, tuples_Tally.extend$iter_Extend_u8_iter_Map_iter_Map_iter_Map_iter_Enumerate_slice_Iter_u8_tuples_own_panicked_closure0_tuples_own_panicked_closure2_iter_FromIterator_tuple1_T_tuple1_ExtendT_from_iter_closure0_u8_tuples_Tally_iter_Map_iter_Map_iter_Enumerate_slice_Iter_u8_tuples_own_panicked_closure0_tuples_own_panicked_closure2 as (a0: tuples_Tally.Tally, a1: rt.Iter) => undefined))[0].sum); + rt.byteVecPush(out, rt.tupleExtendOne([Tally.default$Default()] as [Tally.Tally], _35, (c, items2) => rt.ownExtend(c, items2, Tally.extend$iter_Extend_u8_iter_Map_iter_Map_iter_Map_iter_Enumerate_slice_Iter_u8_tuples_own_panicked_closure0_tuples_own_panicked_closure2_iter_FromIterator_tuple1_T_tuple1_ExtendT_from_iter_closure0_u8_tuples_Tally_iter_Map_iter_Map_iter_Enumerate_slice_Iter_u8_tuples_own_panicked_closure0_tuples_own_panicked_closure2 as (a0: Tally.Tally, a1: rt.Iter) => undefined))[0].sum); } } diff --git a/ts/fixtures/lang/tuples/src/lib.rs b/ts/fixtures/lang/tuples/src/lib.rs new file mode 100644 index 000000000..d8b67cb2c --- /dev/null +++ b/ts/fixtures/lang/tuples/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod tuples; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("tuples::tuples", tuples::tuples)] +} diff --git a/ts/fixtures/lang/src/tuples.rs b/ts/fixtures/lang/tuples/src/tuples.rs similarity index 100% rename from ts/fixtures/lang/src/tuples.rs rename to ts/fixtures/lang/tuples/src/tuples.rs diff --git a/ts/fixtures/lang/tuples/ts.toml b/ts/fixtures/lang/tuples/ts.toml new file mode 100644 index 000000000..bc65869ea --- /dev/null +++ b/ts/fixtures/lang/tuples/ts.toml @@ -0,0 +1,2 @@ +package = "lang-tuples-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/utf8/Cargo.toml b/ts/fixtures/lang/utf8/Cargo.toml new file mode 100644 index 000000000..419cb3e76 --- /dev/null +++ b/ts/fixtures/lang/utf8/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-utf8-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/utf8/caller.ts b/ts/fixtures/lang/utf8/caller.ts new file mode 100644 index 000000000..afcc1bdb1 --- /dev/null +++ b/ts/fixtures/lang/utf8/caller.ts @@ -0,0 +1,25 @@ +// The inputs `utf8`'s cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `utf8::decodes` of raw bytes: a byte order mark, which std keeps, and the sequences at + * each edge of what it takes: surrogates, overlongs, past U+10FFFF, and cut short at the + * end or by another byte. + */ +const utf8 = [ + [0xef, 0xbb, 0xbf, 0x61], + [0xed, 0x9f, 0xbf, 0xed, 0xa0, 0x80, 0xed, 0xbf, 0xbf], + [0xc0, 0x80, 0xc1, 0xbf, 0xc2, 0x80], + [0xe0, 0x80, 0x80, 0xe0, 0x9f, 0xbf, 0xe0, 0xa0, 0x80], + [0xf0, 0x80, 0x80, 0x80, 0xf0, 0x8f, 0xbf, 0xbf, 0xf0, 0x90, 0x80, 0x80], + [0xf4, 0x8f, 0xbf, 0xbf, 0xf4, 0x90, 0x80, 0x80, 0xf5, 0x80, 0x80, 0x80], + [0xf0, 0x9f, 0x98, 0x80, 0xf0, 0x9f, 0x98, 0x41, 0xe2, 0x82, 0x41, 0xf0, 0x9f, 0x98], + [0xe2, 0x82], + [0xc2], + [0x80, 0xf8, 0xff], +].map((bytes) => Uint8Array.of(...op("utf8::decodes"), 0, ...bytes)); + +export const cases: Uint8Array[] = [...utf8]; diff --git a/ts/fixtures/lang/utf8/expected/core/option.ts b/ts/fixtures/lang/utf8/expected/core/option.ts new file mode 100644 index 000000000..d52610286 --- /dev/null +++ b/ts/fixtures/lang/utf8/expected/core/option.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function mapOr$02k4ito(self: rt.usize | undefined, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/utf8/expected/harness.ts b/ts/fixtures/lang/utf8/expected/harness.ts new file mode 100644 index 000000000..3b7bbcfb0 --- /dev/null +++ b/ts/fixtures/lang/utf8/expected/harness.ts @@ -0,0 +1,46 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/utf8/expected/lib.ts b/ts/fixtures/lang/utf8/expected/lib.ts new file mode 100644 index 000000000..d15066979 --- /dev/null +++ b/ts/fixtures/lang/utf8/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { decodes } from "./utf8.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["utf8::decodes", decodes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/utf8.ts b/ts/fixtures/lang/utf8/expected/utf8.ts similarity index 88% rename from ts/fixtures/lang/expected/utf8.ts rename to ts/fixtures/lang/utf8/expected/utf8.ts index ecf804f91..80b53b512 100644 --- a/ts/fixtures/lang/expected/utf8.ts +++ b/ts/fixtures/lang/utf8/expected/utf8.ts @@ -2,7 +2,7 @@ import * as rt from "./rt.ts"; import { mapOr$02k4ito as option_mapOr$02k4ito } from "./core/option.ts"; -import { put as fmt_put } from "./fmt.ts"; +import { put } from "./harness.ts"; export function decodes(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { let bytes!: rt.ByteVec; @@ -27,7 +27,7 @@ export function decodes(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void if (_18.ok) { const s: string = _18.value; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtStr(s, f)]; - fmt_put(out, rt.fmtFormat([args2[0]])); + put(out, rt.fmtFormat([args2[0]])); rt.byteVecPush(out, rt.stringLen(s) & 0xff); } else { const e: rt.Utf8Error = _18.error; @@ -36,7 +36,7 @@ export function decodes(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void return n & 0xff; })); const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtUtf8ErrorDisplay(e, f), (f: rt.Formatter) => rt.fmtUtf8ErrorDebug(e, f)]; - fmt_put(out, rt.fmtFormat([args4[0], "|", rt.fmtSpec({ align: ">", width: 64 }, args4[0]), "|", args4[1], "|", rt.fmtSpec({ alternate: true }, args4[1])])); + put(out, rt.fmtFormat([args4[0], "|", rt.fmtSpec({ align: ">", width: 64 }, args4[0]), "|", args4[1], "|", rt.fmtSpec({ alternate: true }, args4[1])])); } } const _61: rt.Result = rt.strFromUtf8(rt.byteVecSlice(bytes)); diff --git a/ts/fixtures/lang/utf8/src/lib.rs b/ts/fixtures/lang/utf8/src/lib.rs new file mode 100644 index 000000000..3efca4a31 --- /dev/null +++ b/ts/fixtures/lang/utf8/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +mod utf8; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("utf8::decodes", utf8::decodes)] +} diff --git a/ts/fixtures/lang/src/utf8.rs b/ts/fixtures/lang/utf8/src/utf8.rs similarity index 98% rename from ts/fixtures/lang/src/utf8.rs rename to ts/fixtures/lang/utf8/src/utf8.rs index 31283b38c..10149c633 100644 --- a/ts/fixtures/lang/src/utf8.rs +++ b/ts/fixtures/lang/utf8/src/utf8.rs @@ -4,7 +4,7 @@ //! truncated, overlong, surrogate, and past-the-last-char sequences std refuses as often //! as the ones it takes. -use crate::fmt::put; +use crate::harness::put; /// Lead bytes at each width's edges and past them, then continuation bytes at the edges /// of the ranges a lead byte allows after it. diff --git a/ts/fixtures/lang/utf8/ts.toml b/ts/fixtures/lang/utf8/ts.toml new file mode 100644 index 000000000..2941ef9d4 --- /dev/null +++ b/ts/fixtures/lang/utf8/ts.toml @@ -0,0 +1,2 @@ +package = "lang-utf8-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/wrappers/Cargo.toml b/ts/fixtures/lang/wrappers/Cargo.toml new file mode 100644 index 000000000..6a81cc371 --- /dev/null +++ b/ts/fixtures/lang/wrappers/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-wrappers-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/wrappers/expected/core/option.ts b/ts/fixtures/lang/wrappers/expected/core/option.ts new file mode 100644 index 000000000..f2635ab41 --- /dev/null +++ b/ts/fixtures/lang/wrappers/expected/core/option.ts @@ -0,0 +1,26 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function unwrapOr$1tvry1i(self: rt.u64 | undefined, default_: rt.u64): rt.u64 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function mapOr$02k4ito(self: rt.usize | undefined, default_: rt.u8, f: (a0: rt.usize) => rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/wrappers/expected/harness.ts b/ts/fixtures/lang/wrappers/expected/harness.ts new file mode 100644 index 000000000..3b7bbcfb0 --- /dev/null +++ b/ts/fixtures/lang/wrappers/expected/harness.ts @@ -0,0 +1,46 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +/** Write `s` and the byte no UTF-8 holds, which ends it. */ +export function put(out: rt.ByteVec, s: string): void { + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); + rt.byteVecPush(out, 255); +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/wrappers/expected/lib.ts b/ts/fixtures/lang/wrappers/expected/lib.ts new file mode 100644 index 000000000..bd8608d52 --- /dev/null +++ b/ts/fixtures/lang/wrappers/expected/lib.ts @@ -0,0 +1,14 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { wrappers } from "./wrappers.ts"; + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["wrappers::wrappers", wrappers as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/wrappers.Scale.ts b/ts/fixtures/lang/wrappers/expected/wrappers.Scale.ts similarity index 100% rename from ts/fixtures/lang/expected/wrappers.Scale.ts rename to ts/fixtures/lang/wrappers/expected/wrappers.Scale.ts diff --git a/ts/fixtures/lang/expected/wrappers.Tally.ts b/ts/fixtures/lang/wrappers/expected/wrappers.Tally.ts similarity index 100% rename from ts/fixtures/lang/expected/wrappers.Tally.ts rename to ts/fixtures/lang/wrappers/expected/wrappers.Tally.ts diff --git a/ts/fixtures/lang/expected/wrappers.ts b/ts/fixtures/lang/wrappers/expected/wrappers.ts similarity index 96% rename from ts/fixtures/lang/expected/wrappers.ts rename to ts/fixtures/lang/wrappers/expected/wrappers.ts index 4b3521a46..b100dee97 100644 --- a/ts/fixtures/lang/expected/wrappers.ts +++ b/ts/fixtures/lang/wrappers/expected/wrappers.ts @@ -2,9 +2,9 @@ import * as rt from "./rt.ts"; import { unwrapOr$1tvry1i as option_unwrapOr$1tvry1i, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, mapOr$02k4ito as option_mapOr$02k4ito } from "./core/option.ts"; -import { put as fmt_put } from "./fmt.ts"; -import * as wrappers_Scale from "./wrappers.Scale.ts"; -import * as wrappers_Tally from "./wrappers.Tally.ts"; +import { put } from "./harness.ts"; +import * as Scale from "./wrappers.Scale.ts"; +import * as Tally from "./wrappers.Tally.ts"; export function putU64(out: rt.ByteVec, v: rt.u64): void { rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u64ToBeBytes(v))); @@ -245,7 +245,7 @@ export function boundOf(kind: rt.u8, a: rt.u64): rt.RangeBound { } export function wrappers(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { - let scale!: wrappers_Scale.Scale; + let scale!: Scale.Scale; let name!: string; const _5: (a0: rt.u8) => rt.u64 = (b3: rt.u8): rt.u64 => { const _3: rt.u8 = rt.u8Rem(b3, 4); @@ -329,8 +329,8 @@ export function wrappers(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void rt.byteVecPush(out, rt.iterToArray(rt.iterBorrow(collected), undefined, 8, true).length & 0xff); bounds$ops_RangeInclusive_u64(out, collected); const gathered: rt.RangeInclusive = new rt.RangeInclusive(lo, hi, rt.u64Step); - const _154: wrappers_Tally.Tally = rt.iterFold(rt.iterBorrow(gathered), new wrappers_Tally.Tally(0), (t: wrappers_Tally.Tally, x7: rt.u64): wrappers_Tally.Tally => { - const _010: wrappers_Tally.Tally = new wrappers_Tally.Tally(rt.u64Add(t._0, x7)); + const _154: Tally.Tally = rt.iterFold(rt.iterBorrow(gathered), new Tally.Tally(0), (t: Tally.Tally, x7: rt.u64): Tally.Tally => { + const _010: Tally.Tally = new Tally.Tally(rt.u64Add(t._0, x7)); t[Symbol.dispose](); return _010; }); @@ -460,7 +460,7 @@ export function wrappers(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void rt.byteVecPush(out, d); rt.byteVecPush(out, i2 & 0xff); } - fmt_put(out, "held"); + put(out, "held"); } else if (_21 === 3) { const n: rt.u64 | undefined = rt.nonZero(a); if (n === undefined) { @@ -472,7 +472,7 @@ export function wrappers(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void const _519: rt.u64 = option_unwrapOr$1tvry1i(rt.nonZero(b), n2); const _516: boolean = rt.u64Eq(n2, _519); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u64Display(n2, f), (f: rt.Formatter) => rt.u64Debug(n2, f), (f: rt.Formatter) => rt.fmtBool(_516, f)]; - fmt_put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2]])); + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2]])); rt.byteVecPush(out, rt.u64Gt(n2, { _0: 1 }._0) ? 1 : 0); rt.byteVecPush(out, rt.cmp(n2, { _0: 1000 }._0) & 0xff); } @@ -505,9 +505,9 @@ export function wrappers(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void } else { name = "one"; } - fmt_put(out, name); - rt.byteVecPush(out, wrappers_Scale.eq$cmp_PartialEq(scale, { _0: 1000 }) ? 1 : 0); - rt.byteVecPush(out, wrappers_Scale.partialCmp$cmp_PartialOrd(scale, { _0: { hi: 0xffffffff, lo: 0xffffffff } as rt.u64 }) === -1 ? 1 : 0); + put(out, name); + rt.byteVecPush(out, Scale.eq$cmp_PartialEq(scale, { _0: 1000 }) ? 1 : 0); + rt.byteVecPush(out, Scale.partialCmp$cmp_PartialOrd(scale, { _0: { hi: 0xffffffff, lo: 0xffffffff } as rt.u64 }) === -1 ? 1 : 0); putU64(out, scale._0); } } diff --git a/ts/fixtures/lang/wrappers/src/lib.rs b/ts/fixtures/lang/wrappers/src/lib.rs new file mode 100644 index 000000000..7d670e129 --- /dev/null +++ b/ts/fixtures/lang/wrappers/src/lib.rs @@ -0,0 +1,19 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +mod wrappers; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![("wrappers::wrappers", wrappers::wrappers)] +} diff --git a/ts/fixtures/lang/src/wrappers.rs b/ts/fixtures/lang/wrappers/src/wrappers.rs similarity index 99% rename from ts/fixtures/lang/src/wrappers.rs rename to ts/fixtures/lang/wrappers/src/wrappers.rs index 8cb14113a..298c89483 100644 --- a/ts/fixtures/lang/src/wrappers.rs +++ b/ts/fixtures/lang/wrappers/src/wrappers.rs @@ -7,7 +7,7 @@ use std::collections::{BTreeMap, BTreeSet}; use std::num::NonZero; use std::ops::{Bound, RangeBounds}; -use crate::fmt::put; +use crate::harness::put; /// A rate that is never 0, as a timescale is. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] diff --git a/ts/fixtures/lang/wrappers/ts.toml b/ts/fixtures/lang/wrappers/ts.toml new file mode 100644 index 000000000..6f1b24a94 --- /dev/null +++ b/ts/fixtures/lang/wrappers/ts.toml @@ -0,0 +1,2 @@ +package = "lang-wrappers-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/wraps/Cargo.toml b/ts/fixtures/lang/wraps/Cargo.toml new file mode 100644 index 000000000..1b90b3c97 --- /dev/null +++ b/ts/fixtures/lang/wraps/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-wraps-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/wraps/caller.ts b/ts/fixtures/lang/wraps/caller.ts new file mode 100644 index 000000000..8846ef63c --- /dev/null +++ b/ts/fixtures/lang/wraps/caller.ts @@ -0,0 +1,37 @@ +// The inputs `wraps`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** + * `wraps::*` of every kind at every width, over operands at the edges of its range: 0, 1, + * either end, the sign bit's neighbors, which make `MIN / -1`, and at 128 bits values past + * 2^64. Shift amounts are at, past, and many times past the width, which std masks. + */ +function wraps(): Uint8Array[] { + const widths: [string, number][] = [["u8s", 8], ["u16s", 16], ["u32s", 32], ["u64s", 64], ["u128s", 128], ["usizes", 32], ["i8s", 8], ["i16s", 16], ["i32s", 32], ["i64s", 64], ["i128s", 128], ["isizes", 32]]; + const cases: Uint8Array[] = []; + for (const [name, bits] of widths) { + const o = op(`wraps::${name}`); + const width = BigInt(bits); + const mask = (1n << width) - 1n; + const sign = 1n << (width - 1n); + const edges = [0n, 1n, 3n, mask, mask - 1n, sign, sign - 1n, sign + 1n]; + if (bits === 128) edges.push(1n << 64n, (1n << 64n) + 3n, 0x9e3779b97f4a7c150123456789abcdefn); + const be = (v: bigint) => Array.from({ length: bits / 8 }, (_, i) => Number((v >> BigInt(bits - 8 - 8 * i)) & 0xffn)); + // The amount's low byte and its high byte, which reads as `high << 24`. + const shifts = [[0, 0], [1, 0], [bits - 1, 0], [bits, 0], [bits + 1, 0], [2 * bits + 3, 0], [5, 1]]; + let i = 0; + for (const a of edges) { + for (const b of edges) { + const c = edges[(i * 5 + 3) % edges.length]; + const [low, high] = shifts[i++ % shifts.length]; + for (let kind = 0; kind < 24; kind++) cases.push(Uint8Array.of(...o, kind, ...be(a), ...be(b), ...be(c), low, high)); + } + } + } + return cases; +} + +export const cases: Uint8Array[] = [...wraps()]; diff --git a/ts/fixtures/lang/wraps/expected/core/option.ts b/ts/fixtures/lang/wraps/expected/core/option.ts new file mode 100644 index 000000000..45fcd396d --- /dev/null +++ b/ts/fixtures/lang/wraps/expected/core/option.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function isSomeAnd$08u1px1(self: rt.Ordering | undefined, f: (a0: rt.Ordering) => boolean): boolean { + if (self === undefined) { + return false; + } + return f(self); +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/wraps/expected/harness.ts b/ts/fixtures/lang/wraps/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/wraps/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/wraps/expected/lib.ts b/ts/fixtures/lang/wraps/expected/lib.ts new file mode 100644 index 000000000..4d7ea3877 --- /dev/null +++ b/ts/fixtures/lang/wraps/expected/lib.ts @@ -0,0 +1,63 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { u8s, u16s, u32s, u64s, u128s, usizes, i8s, i16s, i32s, i64s, i128s, isizes } from "./wraps.ts"; +import * as Tick from "./wraps.Tick.ts"; + +export function copy$wraps_Tick_i128(v: Tick.Tick): Tick.Tick { + return new Tick.Tick(v._0); +} + +export function copy$wraps_Tick_i16(v: Tick.Tick): Tick.Tick { + return new Tick.Tick(v._0); +} + +export function copy$wraps_Tick_i32(v: Tick.Tick): Tick.Tick { + return new Tick.Tick(v._0); +} + +export function copy$wraps_Tick_i64(v: Tick.Tick): Tick.Tick { + return new Tick.Tick(v._0); +} + +export function copy$wraps_Tick_i8(v: Tick.Tick): Tick.Tick { + return new Tick.Tick(v._0); +} + +export function copy$wraps_Tick_isize(v: Tick.Tick): Tick.Tick { + return new Tick.Tick(v._0); +} + +export function copy$wraps_Tick_u128(v: Tick.Tick): Tick.Tick { + return new Tick.Tick(v._0); +} + +export function copy$wraps_Tick_u16(v: Tick.Tick): Tick.Tick { + return new Tick.Tick(v._0); +} + +export function copy$wraps_Tick_u32(v: Tick.Tick): Tick.Tick { + return new Tick.Tick(v._0); +} + +export function copy$wraps_Tick_u64(v: Tick.Tick): Tick.Tick { + return new Tick.Tick(v._0); +} + +export function copy$wraps_Tick_u8(v: Tick.Tick): Tick.Tick { + return new Tick.Tick(v._0); +} + +export function copy$wraps_Tick_usize(v: Tick.Tick): Tick.Tick { + return new Tick.Tick(v._0); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["wraps::u8s", u8s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::u16s", u16s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::u32s", u32s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::u64s", u64s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::u128s", u128s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::usizes", usizes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::i8s", i8s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::i16s", i16s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::i32s", i32s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::i64s", i64s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::i128s", i128s as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["wraps::isizes", isizes as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/wraps.Tick.ts b/ts/fixtures/lang/wraps/expected/wraps.Tick.ts similarity index 100% rename from ts/fixtures/lang/expected/wraps.Tick.ts rename to ts/fixtures/lang/wraps/expected/wraps.Tick.ts diff --git a/ts/fixtures/lang/expected/wraps.ts b/ts/fixtures/lang/wraps/expected/wraps.ts similarity index 100% rename from ts/fixtures/lang/expected/wraps.ts rename to ts/fixtures/lang/wraps/expected/wraps.ts diff --git a/ts/fixtures/lang/wraps/src/lib.rs b/ts/fixtures/lang/wraps/src/lib.rs new file mode 100644 index 000000000..ea1a1be67 --- /dev/null +++ b/ts/fixtures/lang/wraps/src/lib.rs @@ -0,0 +1,32 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +mod wraps; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("wraps::u8s", wraps::u8s), + ("wraps::u16s", wraps::u16s), + ("wraps::u32s", wraps::u32s), + ("wraps::u64s", wraps::u64s), + ("wraps::u128s", wraps::u128s), + ("wraps::usizes", wraps::usizes), + ("wraps::i8s", wraps::i8s), + ("wraps::i16s", wraps::i16s), + ("wraps::i32s", wraps::i32s), + ("wraps::i64s", wraps::i64s), + ("wraps::i128s", wraps::i128s), + ("wraps::isizes", wraps::isizes), + ] +} diff --git a/ts/fixtures/lang/src/wraps.rs b/ts/fixtures/lang/wraps/src/wraps.rs similarity index 100% rename from ts/fixtures/lang/src/wraps.rs rename to ts/fixtures/lang/wraps/src/wraps.rs diff --git a/ts/fixtures/lang/wraps/ts.toml b/ts/fixtures/lang/wraps/ts.toml new file mode 100644 index 000000000..18c727cc2 --- /dev/null +++ b/ts/fixtures/lang/wraps/ts.toml @@ -0,0 +1,2 @@ +package = "lang-wraps-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/lang/zeros/Cargo.toml b/ts/fixtures/lang/zeros/Cargo.toml new file mode 100644 index 000000000..be32f37ea --- /dev/null +++ b/ts/fixtures/lang/zeros/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "lang-zeros-fixture" +description = "A part of the language rust2-ts translates, exercised against native Rust" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lib] +# The cdylib is the native side of the differential test, built for wasm32. +crate-type = ["lib", "cdylib"] + +[lints] +workspace = true diff --git a/ts/fixtures/lang/zeros/caller.ts b/ts/fixtures/lang/zeros/caller.ts new file mode 100644 index 000000000..1df1a06e9 --- /dev/null +++ b/ts/fixtures/lang/zeros/caller.ts @@ -0,0 +1,15 @@ +// The inputs `zeros`' cases name, which run with the generated ones. + +import { op } from "./lang.ts"; + +export { ops, run } from "./lang.ts"; + +/** `zeros::zeros` of each case, on up to three bytes. */ +const zerosOp = op("zeros::zeros"); +const zeros = Array.from({ length: 7 * 4 }, (_, i) => Uint8Array.of(...zerosOp, i % 7, ...Array.from({ length: Math.floor(i / 7) }, (_, b) => b))); + +/** `zeros::writes` of each case, on up to three bytes: the last past the slice it swaps in. */ +const writesOp = op("zeros::writes"); +const writes = Array.from({ length: 5 * 4 }, (_, i) => Uint8Array.of(...writesOp, i % 5, ...Array.from({ length: Math.floor(i / 5) }, (_, b) => b))); + +export const cases: Uint8Array[] = [...zeros, ...writes]; diff --git a/ts/fixtures/lang/zeros/expected/core/bool.ts b/ts/fixtures/lang/zeros/expected/core/bool.ts new file mode 100644 index 000000000..91286d446 --- /dev/null +++ b/ts/fixtures/lang/zeros/expected/core/bool.ts @@ -0,0 +1,12 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; + +export function thenSome$1j8foe9(self: boolean, _: undefined): undefined | rt.None { + if (!self) { + return rt.None; + } + return undefined; +} + +//# sourceMappingURL=bool.ts.map diff --git a/ts/fixtures/lang/zeros/expected/core/option.ts b/ts/fixtures/lang/zeros/expected/core/option.ts new file mode 100644 index 000000000..f233bf298 --- /dev/null +++ b/ts/fixtures/lang/zeros/expected/core/option.ts @@ -0,0 +1,56 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import type * as Loud from "../zeros.Loud.ts"; +import * as Tagged from "../zeros.Tagged.ts"; + +export function unwrapOr$1la41a6(self: Uint8Array | undefined, default_: Uint8Array): Uint8Array { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u8 { + if (self === undefined) { + return default_; + } + return self; +} + +export function unwrapOrDefault$1b97y1a(self: Tagged.Tagged | undefined): Tagged.Tagged { + if (self === undefined) { + return Tagged.default$Default_String(); + } + return self; +} + +export function map$0po44cb(self: undefined[] | undefined, f: (a0: undefined[]) => Uint8Array): Uint8Array | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$1qp1ym6(self: rt.u8 | undefined, f: (a0: rt.u8) => rt.u32): rt.u32 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$1ibcmaa(self: rt.u8 | undefined, f: (a0: rt.u8) => Loud.Loud): Loud.Loud | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$1iwwjee(self: rt.u8 | undefined, f: (a0: rt.u8) => Uint8Array): Uint8Array | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +//# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/zeros/expected/harness.ts b/ts/fixtures/lang/zeros/expected/harness.ts new file mode 100644 index 000000000..58ec1cf62 --- /dev/null +++ b/ts/fixtures/lang/zeros/expected/harness.ts @@ -0,0 +1,40 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { cases } from "./lib.ts"; + +/** Run one case. */ +export function run(input: rt.ByteSlice): rt.ByteVec { + const out: rt.ByteVec = new rt.ByteVec(); + if (!(input.length >= 3)) { + return out; + } + const cases_: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] = cases(); + cases_[rt.idx(cases_, rt.usizeRem(((input.data[input.start] << 8) | input.data[input.start + 1]) as rt.usize, cases_.length))][1](input.data[input.start + 2], new rt.ByteSlice(input.data, input.start + 3, input.length - 3), out); + return out; +} + +/** + * The first two bytes, as one big-endian number, that pick the case named `name`, which + * `lang.ts` targets by. + */ +export function op(name: string): rt.u16 { + const _11: rt.usize | undefined = rt.iterPosition(rt.iterSlice(cases()), (_2: [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]): boolean => { + return _2[0] === name; + }); + if (_11 !== undefined) { + const _20: rt.Result = rt.u16TryFrom(_11); + if (_20.ok) { + if ((_20.value >> 8) !== 255) { + return _20.value; + } + } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["case ", args4[0], " is past what two bytes pick"]); + } else { + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, name)]; + rt.panicFmt(["no case ", args2[0]]); + } +} + +//# sourceMappingURL=harness.ts.map diff --git a/ts/fixtures/lang/zeros/expected/lib.ts b/ts/fixtures/lang/zeros/expected/lib.ts new file mode 100644 index 000000000..04b8fae62 --- /dev/null +++ b/ts/fixtures/lang/zeros/expected/lib.ts @@ -0,0 +1,26 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { zeros, impls, keys, unread, writes } from "./zeros.ts"; +import * as Lock from "./zeros.Lock.ts"; +import type * as Loud from "./zeros.Loud.ts"; + +export function drop$zeros_Lock_u32(_1: Lock.Lock): void { + Lock.drop$ops_Drop_u32(_1); +} + +export function drop$zeros_Lock_zeros_Loud(_1: Lock.Lock): void { + Lock.drop$ops_Drop_zeros_Loud(_1); +} + +/** + * Each case's name and what it runs. The first two bytes, big-endian, pick one modulo + * their count, so a case added at the end moves no other. + */ +export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { + return [["zeros::zeros", zeros as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::impls", impls as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::keys", keys as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::unread", unread as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::writes", (a05: rt.u8, a15: rt.ByteSlice, a25: rt.ByteVec): undefined => { + writes(a05, a15.data, a15.start, a15.length, a25); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; +} + +//# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/lang/expected/zeros.Both.ts b/ts/fixtures/lang/zeros/expected/zeros.Both.ts similarity index 89% rename from ts/fixtures/lang/expected/zeros.Both.ts rename to ts/fixtures/lang/zeros/expected/zeros.Both.ts index 21481fd4a..304d67fb5 100644 --- a/ts/fixtures/lang/expected/zeros.Both.ts +++ b/ts/fixtures/lang/zeros/expected/zeros.Both.ts @@ -1,6 +1,6 @@ // Generated by rust2-ts. Do not edit. -import { log as zeros_log } from "./zeros.ts"; +import { log } from "./zeros.ts"; import type * as Loud from "./zeros.Loud.ts"; import type * as Quiet from "./zeros.Quiet.ts"; @@ -22,7 +22,7 @@ export class Both { } export function drop$ops_Drop(_self: Both): void { - zeros_log(3); + log(3); } //# sourceMappingURL=zeros.Both.ts.map diff --git a/ts/fixtures/lang/expected/zeros.Defaulted.ts b/ts/fixtures/lang/zeros/expected/zeros.Defaulted.ts similarity index 84% rename from ts/fixtures/lang/expected/zeros.Defaulted.ts rename to ts/fixtures/lang/zeros/expected/zeros.Defaulted.ts index 1205493cb..579fdb4f4 100644 --- a/ts/fixtures/lang/expected/zeros.Defaulted.ts +++ b/ts/fixtures/lang/zeros/expected/zeros.Defaulted.ts @@ -1,6 +1,6 @@ // Generated by rust2-ts. Do not edit. -import { log as zeros_log } from "./zeros.ts"; +import { log } from "./zeros.ts"; export function eq$cmp_PartialEq(_self: Defaulted, _other: Defaulted): boolean { return true; @@ -11,7 +11,7 @@ export interface Defaulted { } export function default$Default(): Defaulted { - zeros_log(5); + log(5); return {}; } diff --git a/ts/fixtures/lang/expected/zeros.Holds.ts b/ts/fixtures/lang/zeros/expected/zeros.Holds.ts similarity index 100% rename from ts/fixtures/lang/expected/zeros.Holds.ts rename to ts/fixtures/lang/zeros/expected/zeros.Holds.ts diff --git a/ts/fixtures/lang/expected/zeros.Lock.ts b/ts/fixtures/lang/zeros/expected/zeros.Lock.ts similarity index 100% rename from ts/fixtures/lang/expected/zeros.Lock.ts rename to ts/fixtures/lang/zeros/expected/zeros.Lock.ts diff --git a/ts/fixtures/lang/expected/zeros.Loud.ts b/ts/fixtures/lang/zeros/expected/zeros.Loud.ts similarity index 77% rename from ts/fixtures/lang/expected/zeros.Loud.ts rename to ts/fixtures/lang/zeros/expected/zeros.Loud.ts index c0ea58461..ebc02e4bc 100644 --- a/ts/fixtures/lang/expected/zeros.Loud.ts +++ b/ts/fixtures/lang/zeros/expected/zeros.Loud.ts @@ -1,6 +1,6 @@ // Generated by rust2-ts. Do not edit. -import { log as zeros_log } from "./zeros.ts"; +import { log } from "./zeros.ts"; export class Loud { @@ -10,7 +10,7 @@ export class Loud { } export function drop$ops_Drop(_self: Loud): void { - zeros_log(1); + log(1); } //# sourceMappingURL=zeros.Loud.ts.map diff --git a/ts/fixtures/lang/expected/zeros.Names.ts b/ts/fixtures/lang/zeros/expected/zeros.Names.ts similarity index 94% rename from ts/fixtures/lang/expected/zeros.Names.ts rename to ts/fixtures/lang/zeros/expected/zeros.Names.ts index a2a8462cd..61662ea5b 100644 --- a/ts/fixtures/lang/expected/zeros.Names.ts +++ b/ts/fixtures/lang/zeros/expected/zeros.Names.ts @@ -17,7 +17,7 @@ export function clone$Clone(self: Names): Names { } export function fmt$fmt_Debug(_self: Names, f: rt.Formatter): rt.Result { - const values: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<(i64, bool)>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<&str>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<[u16; 3]>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData>>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData u8>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<()>")]; + const values: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<(i64, bool)>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<&str>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<[u16; 3]>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData>>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData u8>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<()>")]; return rt.fmtDebugTupleFields(f, "Names", values); } diff --git a/ts/fixtures/lang/expected/zeros.One.ts b/ts/fixtures/lang/zeros/expected/zeros.One.ts similarity index 100% rename from ts/fixtures/lang/expected/zeros.One.ts rename to ts/fixtures/lang/zeros/expected/zeros.One.ts diff --git a/ts/fixtures/lang/expected/zeros.Pair.ts b/ts/fixtures/lang/zeros/expected/zeros.Pair.ts similarity index 77% rename from ts/fixtures/lang/expected/zeros.Pair.ts rename to ts/fixtures/lang/zeros/expected/zeros.Pair.ts index 2ad0ba3ea..11f6dfc91 100644 --- a/ts/fixtures/lang/expected/zeros.Pair.ts +++ b/ts/fixtures/lang/zeros/expected/zeros.Pair.ts @@ -1,6 +1,6 @@ // Generated by rust2-ts. Do not edit. -import type * as zeros_Unit from "./zeros.Unit.ts"; +import type * as Unit from "./zeros.Unit.ts"; export function clone$Clone(_self: Pair): Pair { return { _0: {}, _1: undefined }; @@ -8,7 +8,7 @@ export function clone$Clone(_self: Pair): Pair { /** Of zero-sized fields, so zero-sized too. */ export interface Pair { - _0: zeros_Unit.Unit; + _0: Unit.Unit; _1: undefined; } diff --git a/ts/fixtures/lang/expected/zeros.Quiet.ts b/ts/fixtures/lang/zeros/expected/zeros.Quiet.ts similarity index 77% rename from ts/fixtures/lang/expected/zeros.Quiet.ts rename to ts/fixtures/lang/zeros/expected/zeros.Quiet.ts index 93de4651e..8b26473c1 100644 --- a/ts/fixtures/lang/expected/zeros.Quiet.ts +++ b/ts/fixtures/lang/zeros/expected/zeros.Quiet.ts @@ -1,6 +1,6 @@ // Generated by rust2-ts. Do not edit. -import { log as zeros_log } from "./zeros.ts"; +import { log } from "./zeros.ts"; export class Quiet { @@ -10,7 +10,7 @@ export class Quiet { } export function drop$ops_Drop(_self: Quiet): void { - zeros_log(2); + log(2); } //# sourceMappingURL=zeros.Quiet.ts.map diff --git a/ts/fixtures/lang/expected/zeros.Rest.ts b/ts/fixtures/lang/zeros/expected/zeros.Rest.ts similarity index 100% rename from ts/fixtures/lang/expected/zeros.Rest.ts rename to ts/fixtures/lang/zeros/expected/zeros.Rest.ts diff --git a/ts/fixtures/lang/expected/zeros.Tagged.ts b/ts/fixtures/lang/zeros/expected/zeros.Tagged.ts similarity index 100% rename from ts/fixtures/lang/expected/zeros.Tagged.ts rename to ts/fixtures/lang/zeros/expected/zeros.Tagged.ts diff --git a/ts/fixtures/lang/expected/zeros.Unit.ts b/ts/fixtures/lang/zeros/expected/zeros.Unit.ts similarity index 100% rename from ts/fixtures/lang/expected/zeros.Unit.ts rename to ts/fixtures/lang/zeros/expected/zeros.Unit.ts diff --git a/ts/fixtures/lang/expected/zeros.ts b/ts/fixtures/lang/zeros/expected/zeros.ts similarity index 79% rename from ts/fixtures/lang/expected/zeros.ts rename to ts/fixtures/lang/zeros/expected/zeros.ts index eb671db5e..4885d84e4 100644 --- a/ts/fixtures/lang/expected/zeros.ts +++ b/ts/fixtures/lang/zeros/expected/zeros.ts @@ -7,15 +7,15 @@ import { unwrapOr$1la41a6 as option_unwrapOr$1la41a6, unwrapOr$0r2bmpr as option import * as Both from "./zeros.Both.ts"; import * as Defaulted from "./zeros.Defaulted.ts"; import * as Holds from "./zeros.Holds.ts"; -import * as zeros_Lock from "./zeros.Lock.ts"; +import * as Lock from "./zeros.Lock.ts"; import * as Loud from "./zeros.Loud.ts"; import * as Names from "./zeros.Names.ts"; import * as One from "./zeros.One.ts"; -import * as zeros_Pair from "./zeros.Pair.ts"; +import * as Pair from "./zeros.Pair.ts"; import * as Quiet from "./zeros.Quiet.ts"; import * as Rest from "./zeros.Rest.ts"; -import * as zeros_Tagged from "./zeros.Tagged.ts"; -import * as zeros_Unit from "./zeros.Unit.ts"; +import * as Tagged from "./zeros.Tagged.ts"; +import * as Unit from "./zeros.Unit.ts"; export const LOG: rt.Atomic = /* @__PURE__ */ new rt.Atomic(0); @@ -23,11 +23,11 @@ export function log(tag: rt.u32): void { rt.atomicStore(LOG, (((rt.atomicLoad(LOG, 0) << 4) >>> 0) | tag) >>> 0, 0); } -export function unit(): zeros_Unit.Unit { +export function unit(): Unit.Unit { return {}; } -export function pair(): zeros_Pair.Pair { +export function pair(): Pair.Pair { return { _0: {}, _1: undefined }; } @@ -35,7 +35,7 @@ export function none$String(): string[] { return []; } -export function units(): zeros_Unit.Unit[] { +export function units(): Unit.Unit[] { return [{}, {}, {}]; } @@ -43,8 +43,8 @@ export function one(): One.One { return "Only" as One.One; } -export function tuple(): [undefined, zeros_Unit.Unit, Uint8Array] { - return [undefined, {}, Uint8Array.of()] as [undefined, zeros_Unit.Unit, Uint8Array]; +export function tuple(): [undefined, Unit.Unit, Uint8Array] { + return [undefined, {}, Uint8Array.of()] as [undefined, Unit.Unit, Uint8Array]; } export function phantom$u8(): undefined { @@ -61,8 +61,8 @@ export function loud(): Loud.Loud { return new Loud.Loud(); } -export function made$zeros_Unit(): zeros_Unit.Unit { - return zeros_Unit.default$Default(); +export function made$zeros_Unit(): Unit.Unit { + return Unit.default$Default(); } /** The case `kind` picks, on `data`; each puts what it read. */ @@ -74,37 +74,37 @@ export function zeros(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const n: rt.usize = data.length; const _8: rt.u8 = rt.u8Rem(kind, 7); if (_8 === 0) { - const _11: zeros_Unit.Unit = zeros_Unit.clone$Clone({}); - const _13: zeros_Pair.Pair = zeros_Pair.clone$Clone(pair()); - const _16: zeros_Unit.Unit = made$zeros_Unit(); + const _11: Unit.Unit = Unit.clone$Clone({}); + const _13: Pair.Pair = Pair.clone$Clone(pair()); + const _16: Unit.Unit = made$zeros_Unit(); phantom$u8(); - rt.byteVecPush(out, ((zeros_Unit.eq$cmp_PartialEq(_11, {}) ? 1 : 0)) | ((((zeros_Unit.eq$cmp_PartialEq(_13._0, _16) ? 1 : 0)) << 1) & 0xff)); + rt.byteVecPush(out, ((Unit.eq$cmp_PartialEq(_11, {}) ? 1 : 0)) | ((((Unit.eq$cmp_PartialEq(_13._0, _16) ? 1 : 0)) << 1) & 0xff)); const _40: One.One = One.clone$Clone("Only" as One.One); - const args2: rt.Fmt[] = [(f: rt.Formatter) => zeros_Unit.fmt$fmt_Debug(_11, f), (f: rt.Formatter) => One.fmt$fmt_Debug(_40, f)]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => Unit.fmt$fmt_Debug(_11, f), (f: rt.Formatter) => One.fmt$fmt_Debug(_40, f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1]])), undefined, true); } else if (_8 === 1) { rt.byteVecPush(out, rt.iterCount(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_213: rt.u8): Uint8Array => { return Uint8Array.of(); })) & 0xff); - rt.byteVecPush(out, rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_214: rt.u8): zeros_Unit.Unit => { + rt.byteVecPush(out, rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_214: rt.u8): Unit.Unit => { return {}; }), undefined, 0, true).length & 0xff); - rt.byteVecPush(out, rt.iterCount(rt.iterFlatten(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_215: rt.u8): zeros_Unit.Unit[] => { + rt.byteVecPush(out, rt.iterCount(rt.iterFlatten(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_215: rt.u8): Unit.Unit[] => { return [{}, {}, {}]; - }), (value: zeros_Unit.Unit[]) => rt.iterSlice(value), false, 3)) & 0xff); - rt.byteVecPush(out, rt.iterCount(rt.iterFilter(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_216: rt.u8): zeros_Pair.Pair => { + }), (value: Unit.Unit[]) => rt.iterSlice(value), false, 3)) & 0xff); + rt.byteVecPush(out, rt.iterCount(rt.iterFilter(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_216: rt.u8): Pair.Pair => { return pair(); - }), (p: zeros_Pair.Pair): boolean => { - return zeros_Unit.eq$cmp_PartialEq(p._0, { _0: {}, _1: undefined }._0); + }), (p: Pair.Pair): boolean => { + return Unit.eq$cmp_PartialEq(p._0, { _0: {}, _1: undefined }._0); })) & 0xff); rt.byteVecPush(out, One.eq$cmp_PartialEq(_72(1), one()) ? 1 : 0); } else if (_8 === 2) { - const _87: zeros_Unit.Unit = unit(); + const _87: Unit.Unit = unit(); const _89: string[] = none$String(); - const _91: zeros_Unit.Unit[] = units(); + const _91: Unit.Unit[] = units(); const _93: One.One = one(); - const _95: [undefined, zeros_Unit.Unit, Uint8Array] = tuple(); - const args4: rt.Fmt[] = [(f: rt.Formatter) => zeros_Unit.fmt$fmt_Debug(_87, f), (f: rt.Formatter) => rt.fmtList(_89, f, rt.fmtStr), (f: rt.Formatter) => rt.fmtList(_91, f, (value: zeros_Unit.Unit, f: rt.Formatter) => zeros_Unit.fmt$fmt_Debug(value, f)), (f: rt.Formatter) => One.fmt$fmt_Debug(_93, f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtUnit(_95[0], f), (f: rt.Formatter) => zeros_Unit.fmt$fmt_Debug(_95[1], f), (f: rt.Formatter) => rt.fmtList(_95[2], f, rt.u8Debug)], f)]; + const _95: [undefined, Unit.Unit, Uint8Array] = tuple(); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Unit.fmt$fmt_Debug(_87, f), (f: rt.Formatter) => rt.fmtList(_89, f, rt.fmtStr), (f: rt.Formatter) => rt.fmtList(_91, f, (value: Unit.Unit, f: rt.Formatter) => Unit.fmt$fmt_Debug(value, f)), (f: rt.Formatter) => One.fmt$fmt_Debug(_93, f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtUnit(_95[0], f), (f: rt.Formatter) => Unit.fmt$fmt_Debug(_95[1], f), (f: rt.Formatter) => rt.fmtList(_95[2], f, rt.u8Debug)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args4[0], " ", args4[1], " ", args4[2], " ", args4[3], " ", args4[4]])), undefined, true); } else if (_8 === 3) { const _108: (a0: rt.u8) => rt.u8 = adder(); @@ -152,10 +152,10 @@ export function zeros(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, rt.iterCount(rt.iterFromFn((): rt.u8 | undefined => { return undefined; })) & 0xff); - rt.iterFromFn((): zeros_Unit.Unit | undefined => { + rt.iterFromFn((): Unit.Unit | undefined => { return {}; }); - rt.byteVecPush(out, rt.iterCount(rt.iterTake(rt.iterFromFn((): zeros_Unit.Unit | undefined => { + rt.byteVecPush(out, rt.iterCount(rt.iterTake(rt.iterFromFn((): Unit.Unit | undefined => { return {}; }), n)) & 0xff); let captured = n; @@ -229,9 +229,9 @@ export function hash$zeros_Names(value: Names.Names): rt.u64 { } /** `DefaultHasher::new`'s hash of `value`. */ -export function hash$zeros_Tagged_String(value: zeros_Tagged.Tagged): rt.u64 { +export function hash$zeros_Tagged_String(value: Tagged.Tagged): rt.u64 { const h: rt.Hasher = rt.hasher(); - zeros_Tagged.hash$Hash_String_hash_DefaultHasher(value, h); + Tagged.hash$Hash_String_hash_DefaultHasher(value, h); return rt.hashFinish(h); } @@ -266,41 +266,41 @@ export function digest$zeros_Names(value: Names.Names, out: rt.ByteVec): void { } /** [`hash`] of `value`, little-endian. */ -export function digest$zeros_Tagged_String(value: zeros_Tagged.Tagged, out: rt.ByteVec): void { +export function digest$zeros_Tagged_String(value: Tagged.Tagged, out: rt.ByteVec): void { rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(rt.u64ToBeBytes(hash$zeros_Tagged_String(value)).reverse())); } /** The impls `#[derive]` calls on `PhantomData`, `PhantomPinned`, and `()` fields. */ export function impls(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { - const tags: zeros_Tagged.Tagged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): zeros_Tagged.Tagged => { + const tags: Tagged.Tagged[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): Tagged.Tagged => { const n: rt.u8 = _2; - zeros_Tagged.default$Default_String(); + Tagged.default$Default_String(); return { n, of: undefined, pin: undefined, unit: undefined }; }), undefined, 1, true); const _7: rt.u8 = rt.u8Rem(kind, 4); if (_7 === 0) { - const _11: zeros_Tagged.Tagged | undefined = rt.sliceFirst(tags); - const t: zeros_Tagged.Tagged = option_unwrapOrDefault$1b97y1a(_11 === undefined ? undefined : zeros_Tagged.clone$Clone_String(_11)); + const _11: Tagged.Tagged | undefined = rt.sliceFirst(tags); + const t: Tagged.Tagged = option_unwrapOrDefault$1b97y1a(_11 === undefined ? undefined : Tagged.clone$Clone_String(_11)); const _15: rt.u8 = t.n; - zeros_Tagged.default$Default_u8(); - const copied: zeros_Tagged.Tagged = { n: _15, of: undefined, pin: undefined, unit: undefined }; - const again: zeros_Tagged.Tagged = copied; + Tagged.default$Default_u8(); + const copied: Tagged.Tagged = { n: _15, of: undefined, pin: undefined, unit: undefined }; + const again: Tagged.Tagged = copied; const _27: Names.Names = Names.default$Default(); - const args2: rt.Fmt[] = [(f: rt.Formatter) => zeros_Tagged.fmt$fmt_Debug_String(t, f), (f: rt.Formatter) => zeros_Tagged.fmt$fmt_Debug_u8(copied, f), (f: rt.Formatter) => zeros_Tagged.fmt$fmt_Debug_u8(again, f), (f: rt.Formatter) => Names.fmt$fmt_Debug(_27, f)]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => Tagged.fmt$fmt_Debug_String(t, f), (f: rt.Formatter) => Tagged.fmt$fmt_Debug_u8(copied, f), (f: rt.Formatter) => Tagged.fmt$fmt_Debug_u8(again, f), (f: rt.Formatter) => Names.fmt$fmt_Debug(_27, f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", rt.fmtSpec({ alternate: true }, args2[2]), " ", rt.fmtSpec({ alternate: true }, args2[3])])), undefined, true); const _38: Rest.Rest = Rest.clone$Clone(Rest.default$Default()); const args4: rt.Fmt[] = [(f: rt.Formatter) => Rest.fmt$fmt_Debug(_38, f), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomPinned"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData")]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args4[0], " ", rt.fmtSpec({ alternate: true }, args4[0]), " ", rt.fmtSpec({ align: ">", width: 9 }, args4[1]), "|", rt.fmtSpec({ align: "<", width: 9 }, args4[2]), "|"])), undefined, true); rt.byteVecPush(out, rt.iterCount(rt.iterEmpty() as rt.Iter) & 0xff); } else if (_7 === 1) { - const sorted: zeros_Tagged.Tagged[] = rt.vecExact(tags.map(zeros_Tagged.clone$Clone_String), 1); - rt.sliceSort(sorted, rt.cmpLt(zeros_Tagged.partialCmp$cmp_PartialOrd_String), 1, true); - rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(sorted), (t3: zeros_Tagged.Tagged): rt.u8 => { + const sorted: Tagged.Tagged[] = rt.vecExact(tags.map(Tagged.clone$Clone_String), 1); + rt.sliceSort(sorted, rt.cmpLt(Tagged.partialCmp$cmp_PartialOrd_String), 1, true); + rt.iterExtendBytes(out, rt.iterMap(rt.iterSlice(sorted), (t3: Tagged.Tagged): rt.u8 => { return t3.n; }), undefined, true); - const iter: rt.Iter[]> = rt.sliceWindows(tags, 2); + const iter: rt.Iter[]> = rt.sliceWindows(tags, 2); while (true) { - const _76: zeros_Tagged.Tagged[] | rt.Done = iter.next(); + const _76: Tagged.Tagged[] | rt.Done = iter.next(); if (_76 === rt.DONE) { break; } @@ -308,10 +308,10 @@ export function impls(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.idx(_76, 1); const part = _76[0]; const part2 = _76[1]; - const a: zeros_Tagged.Tagged = part; - const b: zeros_Tagged.Tagged = part2; - rt.byteVecPush(out, (zeros_Tagged.cmp$cmp_Ord_String(a, b) & 0xff) | ((((zeros_Tagged.eq$cmp_PartialEq_String(a, b) ? 1 : 0)) << 2) & 0xff) | ((((zeros_Tagged.partialCmp$cmp_PartialOrd_String(a, b) === zeros_Tagged.cmp$cmp_Ord_String(a, b) as rt.Ordering | undefined ? 1 : 0)) << 3) & 0xff)); - rt.byteVecPush(out, zeros_Tagged.cmp$cmp_Ord_String(a, b) === 0 === rt.u64Eq(hash$zeros_Tagged_String(a), hash$zeros_Tagged_String(b)) ? 1 : 0); + const a: Tagged.Tagged = part; + const b: Tagged.Tagged = part2; + rt.byteVecPush(out, (Tagged.cmp$cmp_Ord_String(a, b) & 0xff) | ((((Tagged.eq$cmp_PartialEq_String(a, b) ? 1 : 0)) << 2) & 0xff) | ((((Tagged.partialCmp$cmp_PartialOrd_String(a, b) === Tagged.cmp$cmp_Ord_String(a, b) as rt.Ordering | undefined ? 1 : 0)) << 3) & 0xff)); + rt.byteVecPush(out, Tagged.cmp$cmp_Ord_String(a, b) === 0 === rt.u64Eq(hash$zeros_Tagged_String(a), hash$zeros_Tagged_String(b)) ? 1 : 0); } rt.byteVecPush(out, ((true ? 1 : 0)) | ((((true ? 1 : 0)) << 1) & 0xff)); rt.byteVecPush(out, rt.cmpNothing(undefined, undefined) & 0xff); @@ -332,8 +332,8 @@ export function impls(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, Names.eq$cmp_PartialEq(_168, _176) ? 1 : 0); const _183: Names.Names = Names.default$Default(); rt.byteVecPush(out, Names.cmp$cmp_Ord(_168, _183) === 0 ? 1 : 0); - rt.byteVecPush(out, rt.iterAll(rt.iterSlice(tags), (t2: zeros_Tagged.Tagged): boolean => { - return zeros_Tagged.eq$cmp_PartialEq_String(zeros_Tagged.clone$Clone_String(t2), t2); + rt.byteVecPush(out, rt.iterAll(rt.iterSlice(tags), (t2: Tagged.Tagged): boolean => { + return Tagged.eq$cmp_PartialEq_String(Tagged.clone$Clone_String(t2), t2); }) ? 1 : 0); Rest.default$Default(); rt.byteVecPush(out, true ? 1 : 0); @@ -463,14 +463,14 @@ export function unread(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const n: rt.u8 = data.length & 0xff; const _9: rt.u8 = rt.u8Rem(kind, 3); if (_9 === 0) { - drop$zeros_Lock_u32(zeros_Lock.new$u32(option_map$1qp1ym6(rt.byteSliceFirst(data), (_210: rt.u8): rt.u32 => { + drop$zeros_Lock_u32(Lock.new$u32(option_map$1qp1ym6(rt.byteSliceFirst(data), (_210: rt.u8): rt.u32 => { return _210 as rt.u32; }))); - drop$zeros_Lock_u32(zeros_Lock.new$u32(undefined)); - drop$zeros_Lock_zeros_Loud(zeros_Lock.new$zeros_Loud(option_map$1ibcmaa(rt.byteSliceFirst(data), (_211: rt.u8): Loud.Loud => { + drop$zeros_Lock_u32(Lock.new$u32(undefined)); + drop$zeros_Lock_zeros_Loud(Lock.new$zeros_Loud(option_map$1ibcmaa(rt.byteSliceFirst(data), (_211: rt.u8): Loud.Loud => { return new Loud.Loud(); }))); - drop$zeros_Lock_zeros_Loud(zeros_Lock.new$zeros_Loud(undefined)); + drop$zeros_Lock_zeros_Loud(Lock.new$zeros_Loud(undefined)); rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(rt.atomicLoad(LOG, 0))), undefined, true); } else if (_9 === 1) { rt.byteVecPush(out, rt.iterCount(rt.iterFilter(rt.iterSlice(rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_25: rt.u8): undefined => {}), undefined, 0, true)), (_u: undefined): boolean => { @@ -481,7 +481,7 @@ export function unread(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, rewritten(undefined, n)); rt.byteVecPush(out, flattened(undefined, [rt.byteSliceToByteVec(data), rt.byteSliceToByteVec(data)])); } else { - const lock: zeros_Lock.Lock = zeros_Lock.new$u32(option_map$1qp1ym6(rt.byteSliceFirst(data), (_2: rt.u8): rt.u32 => { + const lock: Lock.Lock = Lock.new$u32(option_map$1qp1ym6(rt.byteSliceFirst(data), (_2: rt.u8): rt.u32 => { return _2 as rt.u32; })); rt.byteVecPush(out, ((((_22: undefined): boolean => { @@ -523,25 +523,25 @@ export function writes(kind: rt.u8, _dataData: Uint8Array, _dataStart: number, d } else if (_9 === 1) { rt.byteVecPush(out, true ? 1 : 0); unit(); - zeros_Unit.default$Default(); - rt.byteVecPush(out, ((zeros_Unit.eq$cmp_PartialEq({}, zeros_Unit.default$Default()) ? 1 : 0)) | ((n << 1) & 0xff)); + Unit.default$Default(); + rt.byteVecPush(out, ((Unit.eq$cmp_PartialEq({}, Unit.default$Default()) ? 1 : 0)) | ((n << 1) & 0xff)); rt.byteVecPush(out, Defaulted.eq$cmp_PartialEq({}, Defaulted.default$Default()) ? 1 : 0); } else if (_9 === 2) { raw(1); raw(2); raw(3); raw(4); - const q: zeros_Unit.Unit = {}; + const q: Unit.Unit = {}; unit(); - const _96: zeros_Unit.Unit = {}; - rt.byteVecPush(out, ((zeros_Unit.eq$cmp_PartialEq(q, _96) ? 1 : 0)) | ((n << 1) & 0xff)); + const _96: Unit.Unit = {}; + rt.byteVecPush(out, ((Unit.eq$cmp_PartialEq(q, _96) ? 1 : 0)) | ((n << 1) & 0xff)); } else if (_9 === 3) { const _113: rt.Cell = new rt.Cell(undefined); rt.cellReplace(_113, undefined); rt.cellReplace(_113, undefined); rt.cellSet(_113, undefined); rt.sliceSwap([undefined, undefined, undefined], 0, n as rt.usize); - const v: zeros_Unit.Unit[] = rt.vecFromElem({}, 2, undefined); + const v: Unit.Unit[] = rt.vecFromElem({}, 2, undefined); rt.sliceSwap(v, 0, 1); rt.byteVecPush(out, ([undefined, undefined, undefined].length & 0xff) | (((v.length & 0xff) << 4) & 0xff)); const _141: rt.Cell = new rt.Cell(undefined); diff --git a/ts/fixtures/lang/zeros/src/lib.rs b/ts/fixtures/lang/zeros/src/lib.rs new file mode 100644 index 000000000..c06dd7ec8 --- /dev/null +++ b/ts/fixtures/lang/zeros/src/lib.rs @@ -0,0 +1,25 @@ +//! A part of the language the driver translates, exercised against native Rust: what +//! each of its modules says. + +#[path = "../../harness.rs"] +pub mod harness; +#[cfg(target_arch = "wasm32")] +#[path = "../../../wasm.rs"] +mod wasm; +mod zeros; +#[cfg(target_arch = "wasm32")] +use harness::run as entry; + +use harness::Case; + +/// Each case's name and what it runs. The first two bytes, big-endian, pick one modulo +/// their count, so a case added at the end moves no other. +fn cases() -> Vec<(&'static str, Case)> { + vec![ + ("zeros::zeros", zeros::zeros), + ("zeros::impls", zeros::impls), + ("zeros::keys", zeros::keys), + ("zeros::unread", zeros::unread), + ("zeros::writes", zeros::writes), + ] +} diff --git a/ts/fixtures/lang/src/zeros.rs b/ts/fixtures/lang/zeros/src/zeros.rs similarity index 100% rename from ts/fixtures/lang/src/zeros.rs rename to ts/fixtures/lang/zeros/src/zeros.rs diff --git a/ts/fixtures/lang/zeros/ts.toml b/ts/fixtures/lang/zeros/ts.toml new file mode 100644 index 000000000..03a708abd --- /dev/null +++ b/ts/fixtures/lang/zeros/ts.toml @@ -0,0 +1,2 @@ +package = "lang-zeros-fixture" +roots = ["harness::run", "harness::op"] diff --git a/ts/fixtures/reject/census.md b/ts/fixtures/reject/census.md deleted file mode 100644 index 44c86885f..000000000 --- a/ts/fixtures/reject/census.md +++ /dev/null @@ -1,1143 +0,0 @@ -# Census of `reject-fixture` - -- Refusals: 257 -- Function instances: 293 -- Generic functions no instance reached, lowered over their type parameters: 13 - -## By construct - -| Count | Construct | First | -| ---: | --- | --- | -| 50 | a raw pointer to `_` in `_`, which the crate may put another object in place of | fixtures/reject/src/lib.rs:536:10 | -| 23 | a raw pointer to `_` in a variable assigned again while it may point there | fixtures/reject/src/lib.rs:544:10 | -| 20 | unsupported call to `_` | fixtures/reject/src/lib.rs:164:8 | -| 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:1259: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:1577:18 | -| 6 | a cast from a pointer to `_` to one to `_`, which reads the bytes of one type as another | fixtures/reject/src/lib.rs:483:27 | -| 5 | `_` with a mutable reference to a value JS copies, which its mapping would copy | fixtures/reject/src/lib.rs:1157: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:607:10 | -| 5 | memory from `alloc` cast to pointers to `_` and to `_`, which reads the bytes of one type as another | fixtures/reject/src/lib.rs:2268:7 | -| 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:260: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 byte of memory from `alloc`, which JS keeps as the values a cast of its pointer types it as | fixtures/reject/src/lib.rs:496:3 | -| 3 | a copy between pointers to `_`, which JS keeps as an object that knows no array it is in | fixtures/reject/src/lib.rs:1632:3 | -| 3 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:182:14 | -| 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:2188:2 | -| 3 | an offset of a pointer to `_`, which JS keeps as an object that knows no array it is in | fixtures/reject/src/lib.rs:1635:56 | -| 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 | `_`, 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:386:23 | -| 2 | `offset_from` between a pointer into a value in no array and one into a value in no array, which JS keeps in different arrays | fixtures/reject/src/lib.rs:2147:5 | -| 2 | `offset_from` between a pointer into an array of this body's own and one into an array of this body's own, which JS keeps in different arrays | fixtures/reject/src/lib.rs:2149:24 | -| 2 | a pointer reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust | fixtures/reject/src/lib.rs:2172:18 | -| 2 | a raw or mutable slice of a byte in no array of bytes | fixtures/reject/src/lib.rs:2158:12 | -| 2 | a raw pointer to a place of `()`, which has no address of its own | fixtures/reject/src/lib.rs:656:15 | -| 2 | an upcast from `_` to `_`, which is not supported yet | fixtures/reject/src/lib.rs:454:32 | -| 2 | comparing pointers to `_`, each a place JS makes of its own | fixtures/reject/src/lib.rs:524:2 | -| 2 | overriding `_`, which std's adaptors call in place of `next` or beside it | fixtures/reject/src/lib.rs:125:2 | -| 2 | unsupported type `_` from another crate | fixtures/reject/src/lib.rs:367:32 | -| 1 | `Buf::copy_to_bytes` of `_`, a value JS copies, which is not supported | fixtures/reject/src/lib.rs:689:2 | -| 1 | `BufMut::put` of `_` into a `BytesMut`, which advances it by the room left in a capacity that depends on whether the other handles of its storage dropped, which is not supported | fixtures/reject/src/lib.rs:323:2 | -| 1 | `BufMut::put` of `_` into a `BytesMut`, which picks the methods it calls by a capacity that depends on whether the other handles of its storage dropped, which is not supported | fixtures/reject/src/lib.rs:318:2 | -| 1 | `Bytes::from_owner` of `_`, which would drop with the last clone of what it makes, which is not supported | fixtures/reject/src/lib.rs:303:2 | -| 1 | `Extend` of `_` by `_`, whose `_` of `_` is not supported yet | fixtures/reject/src/lib.rs:1194:31 | -| 1 | `Pointer` formatting, as in `{:p}`, is not supported | fixtures/reject/src/lib.rs:49:2 | -| 1 | `_` is not supported: its `Pending` and `Ready` would both be `rt.OuterPending` | fixtures/reject/src/lib.rs:72:20 | -| 1 | `_` is not supported: its field `_` is `_`, typed `_`, whose `None` would be `rt.None` as `_` | fixtures/reject/src/lib.rs:31:2 | -| 1 | `_` is not supported: its field `_` is `_`, typed `_`, whose `Pending` would be `rt.OuterPending` as `_` | fixtures/reject/src/lib.rs:424:2 | -| 1 | `_` of `_` by `_`, which is not supported yet | fixtures/reject/src/lib.rs:211:6 | -| 1 | `_` of `_`, which is not supported yet | fixtures/reject/src/lib.rs:466:4 | -| 1 | `_`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported | fixtures/reject/src/lib.rs:312:6 | -| 1 | `clone_from` of `_`, whose items' `clone_from` is their own, which is not supported yet | fixtures/reject/src/lib.rs:2040:4 | -| 1 | `collect` of `_`, which sorts by `_`'s own `Ord`, of entries that drop, which is not supported yet | fixtures/reject/src/lib.rs:877:22 | -| 1 | `fmt::Arguments` with a placeholder, or not made in place, written to `_`'s own `fmt::Write`, which is not supported yet: std splits what a placeholder writes into `write_str` calls the runtime does not make | fixtures/reject/src/lib.rs:55:10 | -| 1 | `offset_from` between a pointer into a shared slice JS copies and one into a value in no array, which JS keeps in different arrays | fixtures/reject/src/lib.rs:2152:21 | -| 1 | `offset_from` between a pointer into a shared slice JS copies and one into an array of this body's own, which JS keeps in different arrays | fixtures/reject/src/lib.rs:2151:20 | -| 1 | `offset_from` of pointers to `()`, which has no bytes | fixtures/reject/src/lib.rs:2094:13 | -| 1 | `offset_from` of pointers to `_`, which JS keeps as an object that knows no array it is in | fixtures/reject/src/lib.rs:2087:36 | -| 1 | a cast from `_` to `_` | fixtures/reject/src/lib.rs:68:2 | -| 1 | a coercion of `_` to `_`, which is not supported yet | fixtures/reject/src/lib.rs:2388:40 | -| 1 | a coercion to `_` | fixtures/reject/src/lib.rs:234:2 | -| 1 | a coercion to `_`, which is not supported yet | fixtures/reject/src/lib.rs:413:30 | -| 1 | a constant of type `_` | fixtures/reject/src/lib.rs:2288:34 | -| 1 | a constant of type `_`, a pointer into memory translation can't name | fixtures/reject/src/lib.rs:706:3 | -| 1 | a copy reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust | fixtures/reject/src/lib.rs:2170:3 | -| 1 | a dangling pointer to `_`, a value of no bytes made of more than structs and tuples | fixtures/reject/src/lib.rs:665:11 | -| 1 | a future of `_`, which can be `rt.Pending`, as the future's own `Pending` is | fixtures/reject/src/lib.rs:77:34 | -| 1 | a mapped guard of `_`, which JS can't write in place | fixtures/reject/src/lib.rs:2074:10 | -| 1 | a mutable reference into a `Result`'s payload, passed on or kept | fixtures/reject/src/lib.rs:291:12 | -| 1 | a mutable static, which any code may write | fixtures/reject/src/lib.rs:61:11 | -| 1 | a pointer into `_`, which JS keeps as an object that knows no array it is in | fixtures/reject/src/lib.rs:2081:12 | -| 1 | a pointer into an array of `_`, which JS keeps as an object that knows no array it is in | fixtures/reject/src/lib.rs:2086:30 | -| 1 | a pointer reaching past a value in no array, which JS keeps apart from what holds it in Rust | fixtures/reject/src/lib.rs:2174:27 | -| 1 | a pointer's address, which JS has no counterpart of | fixtures/reject/src/lib.rs:488:17 | -| 1 | a printable type must implement `Display` or `Debug` | fixtures/reject/src/lib.rs:64:1 | -| 1 | a raw pointer to `_` behind a reference, which is the object and not where it is kept | fixtures/reject/src/lib.rs:505: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:1286:11 | -| 1 | a scalar constant of type `_` | fixtures/reject/src/lib.rs:8:2 | -| 1 | a slice from a pointer to `_`, which JS keeps as an object that knows no array it is in | fixtures/reject/src/lib.rs:2085:11 | -| 1 | a slice of `()`, which has no bytes, from a pointer | fixtures/reject/src/lib.rs:2094:39 | -| 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:2182:2 | -| 1 | a slice reaching past a value in no array, which JS keeps apart from what holds it in Rust | fixtures/reject/src/lib.rs:2173:6 | -| 1 | a trait object of `_`, which is not supported yet | fixtures/reject/src/lib.rs:403:26 | -| 1 | arithmetic on `_` | fixtures/reject/src/lib.rs:8:2 | -| 1 | comparing `_` | fixtures/reject/src/lib.rs:1634:41 | -| 1 | comparing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:193:75 | -| 1 | comparing pointers to `_` in an atomic, which JS has no address of | fixtures/reject/src/lib.rs:705:15 | -| 1 | comparing pointers to `_`, which has no bytes and so no address of its own | fixtures/reject/src/lib.rs:656:70 | -| 1 | const generic types are not supported: `_` | fixtures/reject/src/lib.rs:2019:1 | -| 1 | constructing `_` | fixtures/reject/src/lib.rs:278:53 | -| 1 | hashing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:193:75 | -| 1 | hashing `_` by its address, which JS has no counterpart of | fixtures/reject/src/lib.rs:1638:5 | -| 1 | hashing `_` through `_`'s own `Hash::hash_slice`, which is not supported yet | fixtures/reject/src/lib.rs:253:16 | -| 1 | union `_`, whose fields overlap in `_` and `f64`, which JS keeps apart | fixtures/reject/src/lib.rs:510:1 | - -## By API - -The type or module each refused type or path belongs to. - -| Count | API | First | -| ---: | --- | --- | -| 39 | `std::cell::UnsafeCell` | fixtures/reject/src/lib.rs:615:15 | -| 27 | `(u32, u32)` | fixtures/reject/src/lib.rs:536:10 | -| 15 | `u32` | fixtures/reject/src/lib.rs:483:27 | -| 11 | `(u8, u8)` | fixtures/reject/src/lib.rs:1194:31 | -| 9 | `[u8; 4]` | fixtures/reject/src/lib.rs:403:26 | -| 8 | `u8` | fixtures/reject/src/lib.rs:211:6 | -| 6 | `f16` | fixtures/reject/src/lib.rs:7:14 | -| 6 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:260:2 | -| 5 | `Gap` | fixtures/reject/src/lib.rs:830:10 | -| 5 | `Option` | fixtures/reject/src/lib.rs:16:15 | -| 5 | `i32` | fixtures/reject/src/lib.rs:2268:7 | -| 4 | `std::pin::Pin` | fixtures/reject/src/lib.rs:91:2 | -| 4 | `std::str` | fixtures/reject/src/lib.rs:368:4 | -| 3 | `Iterator` | fixtures/reject/src/lib.rs:37:4 | -| 3 | `Mid` | fixtures/reject/src/lib.rs:1277:34 | -| 3 | `Outer` | fixtures/reject/src/lib.rs:1277:34 | -| 3 | `Reused` | fixtures/reject/src/lib.rs:21:4 | -| 3 | `dyn std::any::Any` | fixtures/reject/src/lib.rs:454:32 | -| 3 | `std::mem::ManuallyDrop` | fixtures/reject/src/lib.rs:2288:2 | -| 3 | `std::vec::Vec` | fixtures/reject/src/lib.rs:253:16 | -| 2 | `(u16, u16)` | fixtures/reject/src/lib.rs:1098:31 | -| 2 | `Counted` | fixtures/reject/src/lib.rs:318:2 | -| 2 | `InArray` | fixtures/reject/src/lib.rs:1224:9 | -| 2 | `InPayload` | fixtures/reject/src/lib.rs:1236:9 | -| 2 | `InTuple` | fixtures/reject/src/lib.rs:1228:9 | -| 2 | `InWritten` | fixtures/reject/src/lib.rs:1248:9 | -| 2 | `Inside` | fixtures/reject/src/lib.rs:1767:20 | -| 2 | `Poll` | fixtures/reject/src/lib.rs:72:20 | -| 2 | `Scaled` | fixtures/reject/src/lib.rs:386:23 | -| 2 | `[u32; 3]` | fixtures/reject/src/lib.rs:2112:10 | -| 2 | `[u8; 2]` | fixtures/reject/src/lib.rs:1648:37 | -| 2 | `[u8; 3]` | fixtures/reject/src/lib.rs:1648:15 | -| 2 | `dyn Keyed` | fixtures/reject/src/lib.rs:454:32 | -| 2 | `dyn Scaled` | fixtures/reject/src/lib.rs:386:23 | -| 2 | `dyn std::hash::Hasher` | fixtures/reject/src/lib.rs:11:16 | -| 2 | `slice` | fixtures/reject/src/lib.rs:21:4 | -| 2 | `std::any::TypeId` | fixtures/reject/src/lib.rs:466:2 | -| 2 | `std::collections::BTreeSet` | fixtures/reject/src/lib.rs:193:75 | -| 2 | `std::collections::LinkedList` | fixtures/reject/src/lib.rs:2039:4 | -| 2 | `std::mem::MaybeUninit` | fixtures/reject/src/lib.rs:844:19 | -| 2 | `std::ops::Range` | fixtures/reject/src/lib.rs:164:8 | -| 2 | `std::option::Option` | fixtures/reject/src/lib.rs:298:2 | -| 2 | `std::sync::Arc` | fixtures/reject/src/lib.rs:234:2 | -| 2 | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:83:2 | -| 2 | `std::vec::IntoIter` | fixtures/reject/src/lib.rs:363:17 | -| 1 | `(Dropped, (u8, u8))` | fixtures/reject/src/lib.rs:2333:2 | -| 1 | `([Cloned; 2], (u8, u8))` | fixtures/reject/src/lib.rs:2317:2 | -| 1 | `([Greatest; 2], (u8, u8))` | fixtures/reject/src/lib.rs:2351:13 | -| 1 | `([Touched; 2], (u8, u8))` | fixtures/reject/src/lib.rs:2382:2 | -| 1 | `(std::vec::Vec, Tens)` | fixtures/reject/src/lib.rs:1194:31 | -| 1 | `(u16, ByKeyReplace)` | fixtures/reject/src/lib.rs:1543:55 | -| 1 | `(u16, ByKeySet)` | fixtures/reject/src/lib.rs:1535:51 | -| 1 | `(u16, ByKeyTake)` | fixtures/reject/src/lib.rs:1550:52 | -| 1 | `(u16, ByRefReplace)` | fixtures/reject/src/lib.rs:1519:32 | -| 1 | `(u16, ByRefTake)` | fixtures/reject/src/lib.rs:1527:32 | -| 1 | `(u16, InTuple)` | fixtures/reject/src/lib.rs:1268:33 | -| 1 | `*const [u8; 4]` | fixtures/reject/src/lib.rs:1638:5 | -| 1 | `*mut [u8; 4]` | fixtures/reject/src/lib.rs:1634:41 | -| 1 | `*mut dyn std::iter::Iterator` | fixtures/reject/src/lib.rs:2388:40 | -| 1 | `*mut std::ops::Range` | fixtures/reject/src/lib.rs:2388:40 | -| 1 | `Aliased` | fixtures/reject/src/lib.rs:1042:29 | -| 1 | `Assigned` | fixtures/reject/src/lib.rs:1934:20 | -| 1 | `Bare` | fixtures/reject/src/lib.rs:656:70 | -| 1 | `Batched` | fixtures/reject/src/lib.rs:253:16 | -| 1 | `Behind` | fixtures/reject/src/lib.rs:1673:22 | -| 1 | `Bits` | fixtures/reject/src/lib.rs:510:1 | -| 1 | `Blank` | fixtures/reject/src/lib.rs:689:2 | -| 1 | `Block` | fixtures/reject/src/lib.rs:2019:1 | -| 1 | `ByBox` | fixtures/reject/src/lib.rs:1426:35 | -| 1 | `ByClosure` | fixtures/reject/src/lib.rs:1441:35 | -| 1 | `ByExchanged` | fixtures/reject/src/lib.rs:1487:30 | -| 1 | `ByInstance` | fixtures/reject/src/lib.rs:1467:35 | -| 1 | `ByKeyReplace` | fixtures/reject/src/lib.rs:1543:55 | -| 1 | `ByKeySet` | fixtures/reject/src/lib.rs:1535:51 | -| 1 | `ByKeyTake` | fixtures/reject/src/lib.rs:1550:52 | -| 1 | `ByObject` | fixtures/reject/src/lib.rs:1454:35 | -| 1 | `ByRead` | fixtures/reject/src/lib.rs:1377:35 | -| 1 | `ByRefReplace` | fixtures/reject/src/lib.rs:1519:32 | -| 1 | `ByRefTake` | fixtures/reject/src/lib.rs:1527:32 | -| 1 | `ByReplace` | fixtures/reject/src/lib.rs:1415:35 | -| 1 | `BySwap` | fixtures/reject/src/lib.rs:1403:35 | -| 1 | `BySwapped` | fixtures/reject/src/lib.rs:1476:76 | -| 1 | `ByWrite` | fixtures/reject/src/lib.rs:1390:35 | -| 1 | `BytesMut` | fixtures/reject/src/lib.rs:312:6 | -| 1 | `Called` | fixtures/reject/src/lib.rs:1008:28 | -| 1 | `Chosen` | fixtures/reject/src/lib.rs:1828:17 | -| 1 | `Clone` | fixtures/reject/src/lib.rs:2193:4 | -| 1 | `Closed` | fixtures/reject/src/lib.rs:2000:15 | -| 1 | `Compared` | fixtures/reject/src/lib.rs:1795:22 | -| 1 | `Copied` | fixtures/reject/src/lib.rs:1098:31 | -| 1 | `Deep` | fixtures/reject/src/lib.rs:1709:18 | -| 1 | `Deeper` | fixtures/reject/src/lib.rs:1960:22 | -| 1 | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:150:2 | -| 1 | `Dynamic` | fixtures/reject/src/lib.rs:1984:20 | -| 1 | `Enclosing` | fixtures/reject/src/lib.rs:1812:22 | -| 1 | `Escaped` | fixtures/reject/src/lib.rs:994:43 | -| 1 | `Halves` | fixtures/reject/src/lib.rs:2255:16 | -| 1 | `HashMap` | fixtures/reject/src/lib.rs:211:6 | -| 1 | `Hits` | fixtures/reject/src/lib.rs:648:21 | -| 1 | `InField` | fixtures/reject/src/lib.rs:1240:9 | -| 1 | `InGeneric` | fixtures/reject/src/lib.rs:1244:9 | -| 1 | `InNested` | fixtures/reject/src/lib.rs:1232:9 | -| 1 | `Lane` | fixtures/reject/src/lib.rs:794:19 | -| 1 | `Lanes` | fixtures/reject/src/lib.rs:2114:10 | -| 1 | `Loaded` | fixtures/reject/src/lib.rs:1064:29 | -| 1 | `Looped` | fixtures/reject/src/lib.rs:1032:26 | -| 1 | `Mapped` | fixtures/reject/src/lib.rs:1109:39 | -| 1 | `Maybe` | fixtures/reject/src/lib.rs:31:2 | -| 1 | `Onced` | fixtures/reject/src/lib.rs:1155:46 | -| 1 | `Only` | fixtures/reject/src/lib.rs:665:11 | -| 1 | `Parked` | fixtures/reject/src/lib.rs:2059:20 | -| 1 | `Parking` | fixtures/reject/src/lib.rs:2059:20 | -| 1 | `Plain` | fixtures/reject/src/lib.rs:748:10 | -| 1 | `Pushed` | fixtures/reject/src/lib.rs:1170:22 | -| 1 | `Repeated` | fixtures/reject/src/lib.rs:1143:18 | -| 1 | `Replaced` | fixtures/reject/src/lib.rs:1879:20 | -| 1 | `Rewritten` | fixtures/reject/src/lib.rs:1052:47 | -| 1 | `Shared` | fixtures/reject/src/lib.rs:1750:20 | -| 1 | `Sink` | fixtures/reject/src/lib.rs:55:10 | -| 1 | `Slotted` | fixtures/reject/src/lib.rs:1731:21 | -| 1 | `Span2` | fixtures/reject/src/lib.rs:536:10 | -| 1 | `Swapped` | fixtures/reject/src/lib.rs:1897:20 | -| 1 | `T \| undefined` | fixtures/reject/src/lib.rs:31:2 | -| 1 | `Tail` | fixtures/reject/src/lib.rs:413:30 | -| 1 | `Taken` | fixtures/reject/src/lib.rs:1915:20 | -| 1 | `Target` | fixtures/reject/src/lib.rs:1591:10 | -| 1 | `Tens` | fixtures/reject/src/lib.rs:1194:31 | -| 1 | `Track` | fixtures/reject/src/lib.rs:774:19 | -| 1 | `Unboxed` | fixtures/reject/src/lib.rs:1688:16 | -| 1 | `Waiting` | fixtures/reject/src/lib.rs:424:2 | -| 1 | `Window` | fixtures/reject/src/lib.rs:597:2 | -| 1 | `Wrapped` | fixtures/reject/src/lib.rs:1856:21 | -| 1 | `[InArray; 2]` | fixtures/reject/src/lib.rs:1259:33 | -| 1 | `[InWritten; 1]` | fixtures/reject/src/lib.rs:1320:35 | -| 1 | `[std::cell::UnsafeCell; 2]` | fixtures/reject/src/lib.rs:2013:20 | -| 1 | `[u32; 2]` | fixtures/reject/src/lib.rs:2099:13 | -| 1 | `poll` | fixtures/reject/src/lib.rs:424:2 | -| 1 | `rt.Poll` | fixtures/reject/src/lib.rs:424:2 | -| 1 | `std::any::Any` | fixtures/reject/src/lib.rs:466:4 | -| 1 | `std::cell::Cell` | fixtures/reject/src/lib.rs:877:22 | -| 1 | `std::cell::LazyCell` | fixtures/reject/src/lib.rs:2230:3 | -| 1 | `std::collections::BTreeMap` | fixtures/reject/src/lib.rs:877:22 | -| 1 | `std::collections::HashMap` | fixtures/reject/src/lib.rs:211:6 | -| 1 | `std::default::Default` | fixtures/reject/src/lib.rs:2041:2 | -| 1 | `std::iter` | fixtures/reject/src/lib.rs:1157:22 | -| 1 | `std::mem` | fixtures/reject/src/lib.rs:2198:2 | -| 1 | `std::net::AddrParseError` | fixtures/reject/src/lib.rs:367:32 | -| 1 | `std::net::Ipv4Addr` | fixtures/reject/src/lib.rs:367:32 | -| 1 | `std::num` | fixtures/reject/src/lib.rs:1199:4 | -| 1 | `std::ops::RangeFrom` | fixtures/reject/src/lib.rs:906:32 | -| 1 | `std::ops::RangeTo` | fixtures/reject/src/lib.rs:906:11 | -| 1 | `std::ptr` | fixtures/reject/src/lib.rs:1634:14 | -| 1 | `std::slice::IterMut` | fixtures/reject/src/lib.rs:694:15 | -| 1 | `std::std` | fixtures/reject/src/lib.rs:2282:13 | -| 1 | `std::sync::LazyLock` | fixtures/reject/src/lib.rs:2235:2 | -| 1 | `std::task::Poll` | fixtures/reject/src/lib.rs:77:34 | -| 1 | `std::thread::LocalKey` | fixtures/reject/src/lib.rs:2241:2 | -| 1 | `u64` | fixtures/reject/src/lib.rs:68:2 | -| 1 | `value` | fixtures/reject/src/lib.rs:31:2 | -| 1 | `{closure}` | fixtures/reject/src/lib.rs:2074:10 | - -## By type or path - -| Count | Construct | Type or path | First | -| ---: | --- | --- | --- | -| 17 | a raw pointer to `_` in a variable assigned again while it may point there | `(u32, u32)` | fixtures/reject/src/lib.rs:544:10 | -| 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:260: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:830: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:1277:34 | -| 3 | memory from `alloc` cast to pointers to `_` and to `_`, which reads the bytes of one type as another | `i32`, `u32` | fixtures/reject/src/lib.rs:2269:11 | -| 3 | unsupported type `_` | `f16` | fixtures/reject/src/lib.rs:7:14 | -| 2 | `_` is not supported: its `None` and `Some` would both be `rt.None` | `Option` | fixtures/reject/src/lib.rs:16:15 | -| 2 | `_` of `_`, whose `None` is `rt.None`, which is not supported yet | `Iterator::scan`, `Option` | fixtures/reject/src/lib.rs:37:4 | -| 2 | `_`, a trait object of another crate's trait, which is not supported yet | `dyn std::hash::Hasher` | fixtures/reject/src/lib.rs:11:16 | -| 2 | `_`, a trait object of the generic trait `_`, which is not supported yet | `dyn Scaled`, `Scaled` | fixtures/reject/src/lib.rs:386:23 | -| 2 | a cast from a pointer to `_` to one to `_`, which reads the bytes of one type as another | `u32`, `u8` | fixtures/reject/src/lib.rs:483:27 | -| 2 | a cast from a pointer to `_` to one to `_`, which reads the bytes of one type as another | `u8`, `u32` | fixtures/reject/src/lib.rs:2254:15 | -| 2 | a copy between pointers to `_`, which JS keeps as an object that knows no array it is in | `[u8; 4]` | fixtures/reject/src/lib.rs:1632:3 | -| 2 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::mem::MaybeUninit`, `Gap` | fixtures/reject/src/lib.rs:844:19 | -| 2 | a raw pointer to `_` in a variable assigned again while it may point there | `[u8; 4]` | fixtures/reject/src/lib.rs:1655:26 | -| 2 | a raw pointer to `_` in a variable assigned again while it may point there | `std::cell::UnsafeCell` | fixtures/reject/src/lib.rs:624:15 | -| 2 | a raw pointer to `_` in an element, a payload, or a union field, which is not supported yet | `[u8; 2]` | fixtures/reject/src/lib.rs:1648:37 | -| 2 | a raw pointer to `_` in an element, a payload, or a union field, which is not supported yet | `[u8; 3]` | fixtures/reject/src/lib.rs:1648:15 | -| 2 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | `Inside` | fixtures/reject/src/lib.rs:1767:20 | -| 2 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | `[u8; 4]` | fixtures/reject/src/lib.rs:1655:26 | -| 2 | an assignment through a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:107:2 | -| 2 | an offset of a pointer to `_`, which JS keeps as an object that knows no array it is in | `[u8; 4]` | fixtures/reject/src/lib.rs:1635:56 | -| 2 | an upcast from `_` to `_`, which is not supported yet | `dyn Keyed`, `dyn std::any::Any` | fixtures/reject/src/lib.rs:454:32 | -| 2 | comparing pointers to `_`, each a place JS makes of its own | `u32` | fixtures/reject/src/lib.rs:524:2 | -| 2 | memory from `alloc` cast to pointers to `_` and to `_`, which reads the bytes of one type as another | `u32`, `i32` | fixtures/reject/src/lib.rs:2268:7 | -| 2 | replacing the value behind a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:91:2 | -| 2 | unsupported call to `_` | `::sum` | fixtures/reject/src/lib.rs:363:17 | -| 1 | `Buf::copy_to_bytes` of `_`, a value JS copies, which is not supported | `Blank` | fixtures/reject/src/lib.rs:689:2 | -| 1 | `BufMut::put` of `_` into a `BytesMut`, which advances it by the room left in a capacity that depends on whether the other handles of its storage dropped, which is not supported | `Counted` | fixtures/reject/src/lib.rs:323:2 | -| 1 | `BufMut::put` of `_` into a `BytesMut`, which picks the methods it calls by a capacity that depends on whether the other handles of its storage dropped, which is not supported | `Counted` | fixtures/reject/src/lib.rs:318:2 | -| 1 | `Bytes::from_owner` of `_`, which would drop with the last clone of what it makes, which is not supported | `std::sync::Arc` | fixtures/reject/src/lib.rs:303:2 | -| 1 | `Extend` of `_` by `_`, whose `_` of `_` is not supported yet | `(std::vec::Vec, Tens)`, `(u8, u8)`, `Tens`, `u8` | fixtures/reject/src/lib.rs:1194:31 | -| 1 | `_` is not supported: its `Pending` and `Ready` would both be `rt.OuterPending` | `Poll` | fixtures/reject/src/lib.rs:72:20 | -| 1 | `_` is not supported: its field `_` is `_`, typed `_`, whose `None` would be `rt.None` as `_` | `Maybe`, `value`, `Option`, `T \| undefined`, `Option` | fixtures/reject/src/lib.rs:31:2 | -| 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:424:2 | -| 1 | `_` of `_` by `_`, which is not supported yet | `HashMap::contains_key`, `std::collections::HashMap`, `u8` | fixtures/reject/src/lib.rs:211:6 | -| 1 | `_` of `_`, which is not supported yet | `std::any::Any::type_id`, `dyn std::any::Any` | fixtures/reject/src/lib.rs:466: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:2193:4 | -| 1 | `_` of `_`, whose `clone_from` is its own, which is not supported yet | `slice::clone_from_slice`, `Reused` | fixtures/reject/src/lib.rs:229: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:2039:4 | -| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::default::Default::default` | fixtures/reject/src/lib.rs:2041:2 | -| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::iter::once` | fixtures/reject/src/lib.rs:1157:22 | -| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::str::from_utf8_mut` | fixtures/reject/src/lib.rs:1564:20 | -| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::str::get_unchecked_mut` | fixtures/reject/src/lib.rs:1559:13 | -| 1 | `_`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported | `BytesMut::capacity` | fixtures/reject/src/lib.rs:312:6 | -| 1 | `clone_from` of `_`, whose items' `clone_from` is their own, which is not supported yet | `std::collections::LinkedList` | fixtures/reject/src/lib.rs:2040:4 | -| 1 | `collect` of `_`, which sorts by `_`'s own `Ord`, of entries that drop, which is not supported yet | `std::collections::BTreeMap`, `std::cell::Cell` | fixtures/reject/src/lib.rs:877:22 | -| 1 | `fmt::Arguments` with a placeholder, or not made in place, written to `_`'s own `fmt::Write`, which is not supported yet: std splits what a placeholder writes into `write_str` calls the runtime does not make | `Sink` | fixtures/reject/src/lib.rs:55:10 | -| 1 | `offset_from` of pointers to `_`, which JS keeps as an object that knows no array it is in | `(u8, u8)` | fixtures/reject/src/lib.rs:2087:36 | -| 1 | a cast from `_` to `_` | `u64`, `f16` | fixtures/reject/src/lib.rs:68:2 | -| 1 | a cast from a pointer to `_` to one to `_`, which reads the bytes of one type as another | `u32`, `[u32; 2]` | fixtures/reject/src/lib.rs:2099:13 | -| 1 | a cast from a pointer to `_` to one to `_`, which reads the bytes of one type as another | `u8`, `Halves` | fixtures/reject/src/lib.rs:2255:16 | -| 1 | a coercion of `_` to `_`, which is not supported yet | `*mut std::ops::Range`, `*mut dyn std::iter::Iterator` | fixtures/reject/src/lib.rs:2388:40 | -| 1 | a coercion to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:234:2 | -| 1 | a coercion to `_`, which is not supported yet | `&Tail` | fixtures/reject/src/lib.rs:413:30 | -| 1 | a constant of type `_` | `std::mem::ManuallyDrop` | fixtures/reject/src/lib.rs:2288:34 | -| 1 | a constant of type `_`, a pointer into memory translation can't name | `&u32` | fixtures/reject/src/lib.rs:706:3 | -| 1 | a copy between pointers to `_`, which JS keeps as an object that knows no array it is in | `(u8, u8)` | fixtures/reject/src/lib.rs:2084:3 | -| 1 | a dangling pointer to `_`, a value of no bytes made of more than structs and tuples | `Only` | fixtures/reject/src/lib.rs:665:11 | -| 1 | a future of `_`, which can be `rt.Pending`, as the future's own `Pending` is | `std::task::Poll` | fixtures/reject/src/lib.rs:77:34 | -| 1 | a mapped guard of `_`, which JS can't write in place | `{closure}` | fixtures/reject/src/lib.rs:2074:10 | -| 1 | a pointer into `_`, which JS keeps as an object that knows no array it is in | `(u8, u8)` | fixtures/reject/src/lib.rs:2081:12 | -| 1 | a pointer into an array of `_`, which JS keeps as an object that knows no array it is in | `(u8, u8)` | fixtures/reject/src/lib.rs:2086:30 | -| 1 | a raw pointer to `_` behind a reference, which is the object and not where it is kept | `std::vec::Vec` | fixtures/reject/src/lib.rs:505:10 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u16, u16)`, `Copied` | fixtures/reject/src/lib.rs:1098:31 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u16, u16)`, `Pushed` | fixtures/reject/src/lib.rs:1170:22 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u32, u32)`, `Lane` | fixtures/reject/src/lib.rs:794:19 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u32, u32)`, `Plain` | fixtures/reject/src/lib.rs:748:10 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u32, u32)`, `Span2` | fixtures/reject/src/lib.rs:536:10 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u32, u32)`, `Track` | fixtures/reject/src/lib.rs:774:19 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u32, u32)`, `Window` | fixtures/reject/src/lib.rs:597:2 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u32, u32)`, `std::cell::UnsafeCell` | fixtures/reject/src/lib.rs:615:15 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u8, u8)`, `(Dropped, (u8, u8))` | fixtures/reject/src/lib.rs:2333:2 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u8, u8)`, `([Cloned; 2], (u8, u8))` | fixtures/reject/src/lib.rs:2317:2 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u8, u8)`, `([Greatest; 2], (u8, u8))` | fixtures/reject/src/lib.rs:2351:13 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u8, u8)`, `([Touched; 2], (u8, u8))` | fixtures/reject/src/lib.rs:2382:2 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `ByKeyReplace`, `(u16, ByKeyReplace)` | fixtures/reject/src/lib.rs:1543:55 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `ByKeySet`, `(u16, ByKeySet)` | fixtures/reject/src/lib.rs:1535:51 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `ByKeyTake`, `(u16, ByKeyTake)` | fixtures/reject/src/lib.rs:1550:52 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `ByRefReplace`, `(u16, ByRefReplace)` | fixtures/reject/src/lib.rs:1519:32 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `ByRefTake`, `(u16, ByRefTake)` | fixtures/reject/src/lib.rs:1527:32 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `[u32; 3]`, `Lanes` | fixtures/reject/src/lib.rs:2114:10 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Aliased` | fixtures/reject/src/lib.rs:1042:29 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `ByBox` | fixtures/reject/src/lib.rs:1426:35 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `ByClosure` | fixtures/reject/src/lib.rs:1441:35 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `ByExchanged` | fixtures/reject/src/lib.rs:1487:30 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `ByInstance` | fixtures/reject/src/lib.rs:1467:35 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `ByObject` | fixtures/reject/src/lib.rs:1454:35 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `ByRead` | fixtures/reject/src/lib.rs:1377:35 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `ByReplace` | fixtures/reject/src/lib.rs:1415:35 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `BySwap` | fixtures/reject/src/lib.rs:1403:35 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `BySwapped` | fixtures/reject/src/lib.rs:1476:76 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `ByWrite` | fixtures/reject/src/lib.rs:1390:35 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Called` | fixtures/reject/src/lib.rs:1008:28 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Escaped` | fixtures/reject/src/lib.rs:994:43 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Hits` | fixtures/reject/src/lib.rs:648:21 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `InArray` | fixtures/reject/src/lib.rs:1224:9 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `InField` | fixtures/reject/src/lib.rs:1240:9 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `InGeneric` | fixtures/reject/src/lib.rs:1244:9 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `InNested` | fixtures/reject/src/lib.rs:1232:9 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `InPayload` | fixtures/reject/src/lib.rs:1236:9 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `InTuple` | fixtures/reject/src/lib.rs:1228:9 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `InWritten` | fixtures/reject/src/lib.rs:1248:9 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Loaded` | fixtures/reject/src/lib.rs:1064:29 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Looped` | fixtures/reject/src/lib.rs:1032:26 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Mapped` | fixtures/reject/src/lib.rs:1109:39 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Onced` | fixtures/reject/src/lib.rs:1155:46 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Repeated` | fixtures/reject/src/lib.rs:1143:18 | -| 1 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Rewritten` | fixtures/reject/src/lib.rs:1052:47 | -| 1 | a raw pointer to `_` in a variable assigned again while it may point there | `Target` | fixtures/reject/src/lib.rs:1591:10 | -| 1 | a raw pointer to `_` in a variable assigned again while it may point there | `[u32; 3]` | fixtures/reject/src/lib.rs:2112:10 | -| 1 | a raw pointer to `_` in an element, a payload, or a union field, which is not supported yet | `(u32, u32)` | fixtures/reject/src/lib.rs:607:10 | -| 1 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | `InArray`, `[InArray; 2]` | fixtures/reject/src/lib.rs:1259:33 | -| 1 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | `InTuple`, `(u16, InTuple)` | fixtures/reject/src/lib.rs:1268:33 | -| 1 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | `InWritten`, `[InWritten; 1]` | fixtures/reject/src/lib.rs:1320:35 | -| 1 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | `Parked`, `Parking` | fixtures/reject/src/lib.rs:2059:20 | -| 1 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Assigned` | fixtures/reject/src/lib.rs:1934:20 | -| 1 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Closed` | fixtures/reject/src/lib.rs:2000:15 | -| 1 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Deeper` | fixtures/reject/src/lib.rs:1960:22 | -| 1 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Dynamic` | fixtures/reject/src/lib.rs:1984:20 | -| 1 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Replaced` | fixtures/reject/src/lib.rs:1879:20 | -| 1 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Swapped` | fixtures/reject/src/lib.rs:1897:20 | -| 1 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `Taken` | fixtures/reject/src/lib.rs:1915:20 | -| 1 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | `std::cell::UnsafeCell`, `[std::cell::UnsafeCell; 2]` | fixtures/reject/src/lib.rs:2013:20 | -| 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 | `InPayload` | fixtures/reject/src/lib.rs:1286:11 | -| 1 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | `Behind` | fixtures/reject/src/lib.rs:1673:22 | -| 1 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | `Chosen` | fixtures/reject/src/lib.rs:1828:17 | -| 1 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | `Compared` | fixtures/reject/src/lib.rs:1795:22 | -| 1 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | `Deep` | fixtures/reject/src/lib.rs:1709:18 | -| 1 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | `Enclosing` | fixtures/reject/src/lib.rs:1812:22 | -| 1 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | `Shared` | fixtures/reject/src/lib.rs:1750:20 | -| 1 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | `Slotted` | fixtures/reject/src/lib.rs:1731:21 | -| 1 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | `Unboxed` | fixtures/reject/src/lib.rs:1688:16 | -| 1 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | `Wrapped` | fixtures/reject/src/lib.rs:1856:21 | -| 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:1577: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:2030:13 | -| 1 | a scalar constant of type `_` | `f16` | fixtures/reject/src/lib.rs:8:2 | -| 1 | a slice from a pointer to `_`, which JS keeps as an object that knows no array it is in | `(u8, u8)` | fixtures/reject/src/lib.rs:2085:11 | -| 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:2188: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:2230: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:2241:2 | -| 1 | a trait object of `_`, which is not supported yet | `[u8; 4]` | fixtures/reject/src/lib.rs:403:26 | -| 1 | an assignment through a reference to `_` | `std::sync::LazyLock` | fixtures/reject/src/lib.rs:2235:2 | -| 1 | an assignment through a reference to `_` | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:83:2 | -| 1 | an offset of a pointer to `_`, which JS keeps as an object that knows no array it is in | `(u8, u8)` | fixtures/reject/src/lib.rs:2083:13 | -| 1 | arithmetic on `_` | `f16` | fixtures/reject/src/lib.rs:8:2 | -| 1 | comparing `_` | `*mut [u8; 4]` | fixtures/reject/src/lib.rs:1634:41 | -| 1 | comparing `_` as a key, which is not supported yet | `std::collections::BTreeSet` | fixtures/reject/src/lib.rs:193:75 | -| 1 | comparing pointers to `_` in an atomic, which JS has no address of | `u32` | fixtures/reject/src/lib.rs:705:15 | -| 1 | comparing pointers to `_`, which has no bytes and so no address of its own | `Bare` | fixtures/reject/src/lib.rs:656:70 | -| 1 | const generic types are not supported: `_` | `Block` | fixtures/reject/src/lib.rs:2019:1 | -| 1 | constructing `_` | `std::borrow::Cow` | fixtures/reject/src/lib.rs:278:53 | -| 1 | hashing `_` as a key, which is not supported yet | `std::collections::BTreeSet` | fixtures/reject/src/lib.rs:193:75 | -| 1 | hashing `_` by its address, which JS has no counterpart of | `*const [u8; 4]` | fixtures/reject/src/lib.rs:1638:5 | -| 1 | hashing `_` through `_`'s own `Hash::hash_slice`, which is not supported yet | `std::vec::Vec`, `Batched` | fixtures/reject/src/lib.rs:253:16 | -| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `DoubleEndedIterator::nth_back` | fixtures/reject/src/lib.rs:150:2 | -| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::fold` | fixtures/reject/src/lib.rs:125:2 | -| 1 | replacing the value behind a reference to `_` | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:112:2 | -| 1 | union `_`, whose fields overlap in `_` and `f64`, which JS keeps apart | `Bits`, `u32` | fixtures/reject/src/lib.rs:510:1 | -| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:466:2 | -| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:2288:25 | -| 1 | unsupported call to `_` | `::fmt` | fixtures/reject/src/lib.rs:2288:2 | -| 1 | unsupported call to `_` | `::contains` | fixtures/reject/src/lib.rs:906:32 | -| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:298:2 | -| 1 | unsupported call to `_` | `::is_sorted` | fixtures/reject/src/lib.rs:694:15 | -| 1 | unsupported call to `_` | `::hash` | fixtures/reject/src/lib.rs:244:10 | -| 1 | unsupported call to `_` | `std::any::TypeId::of` | fixtures/reject/src/lib.rs:466:17 | -| 1 | unsupported call to `_` | `std::borrow::Cow::is_borrowed` | fixtures/reject/src/lib.rs:272:2 | -| 1 | unsupported call to `_` | `std::mem::size_of_val` | fixtures/reject/src/lib.rs:2198:2 | -| 1 | unsupported call to `_` | `std::num::is_ascii_octdigit` | fixtures/reject/src/lib.rs:1199:4 | -| 1 | unsupported call to `_` | `std::ops::Range::contains` | fixtures/reject/src/lib.rs:164:8 | -| 1 | unsupported call to `_` | `std::ops::Range::is_empty` | fixtures/reject/src/lib.rs:911:9 | -| 1 | unsupported call to `_` | `std::ops::RangeTo::contains` | fixtures/reject/src/lib.rs:906:11 | -| 1 | unsupported call to `_` | `std::ptr::addr_eq` | fixtures/reject/src/lib.rs:1634:14 | -| 1 | unsupported call to `_` | `std::std::alloc_zeroed` | fixtures/reject/src/lib.rs:2282:13 | -| 1 | unsupported call to `_` | `std::str::as_bytes_mut` | fixtures/reject/src/lib.rs:1558:13 | -| 1 | unsupported call to `_` | `std::str::parse` | fixtures/reject/src/lib.rs:368:4 | -| 1 | unsupported type `_` from another crate | `std::net::AddrParseError` | fixtures/reject/src/lib.rs:367:32 | -| 1 | unsupported type `_` from another crate | `std::net::Ipv4Addr` | fixtures/reject/src/lib.rs:367:32 | - -## Spans - -

a raw pointer to `_` in `_`, which the crate may put another object in place of (50) - -- fixtures/reject/src/lib.rs:536:10: a raw pointer to `(u32, u32)` in `Span2`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:597:2: a raw pointer to `(u32, u32)` in `Window`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:615:15: a raw pointer to `(u32, u32)` in `std::cell::UnsafeCell<(u32, u32)>`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:648:21: a raw pointer to `std::cell::UnsafeCell` in `Hits`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:748:10: a raw pointer to `(u32, u32)` in `Plain`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:774:19: a raw pointer to `(u32, u32)` in `Track`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:794:19: a raw pointer to `(u32, u32)` in `Lane`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:830:10: a raw pointer to `(u32, u32)` in `Gap`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:831:10: a raw pointer to `(u32, u32)` in `Gap`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:832:58: a raw pointer to `(u32, u32)` in `Gap`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:844:19: a raw pointer to `std::mem::MaybeUninit<(u32, u32)>` in `Gap`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:845:19: a raw pointer to `std::mem::MaybeUninit<(u32, u32)>` in `Gap`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:994:43: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Escaped`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1008:28: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Called`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1032:26: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Looped`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1042:29: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Aliased`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1052:47: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Rewritten`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1064:29: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Loaded`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1098:31: a raw pointer to `(u16, u16)` in `Copied`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1109:39: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Mapped`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1143:18: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Repeated`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1155:46: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Onced`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1170:22: a raw pointer to `(u16, u16)` in `Pushed`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1224:9: a raw pointer to `std::cell::UnsafeCell` in `InArray`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1228:9: a raw pointer to `std::cell::UnsafeCell` in `InTuple`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1232:9: a raw pointer to `std::cell::UnsafeCell` in `InNested`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1236:9: a raw pointer to `std::cell::UnsafeCell` in `InPayload`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1240:9: a raw pointer to `std::cell::UnsafeCell` in `InField`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1244:9: a raw pointer to `std::cell::UnsafeCell` in `InGeneric`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1248:9: a raw pointer to `std::cell::UnsafeCell` in `InWritten`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1377:35: a raw pointer to `std::cell::UnsafeCell` in `ByRead`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1390:35: a raw pointer to `std::cell::UnsafeCell` in `ByWrite`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1403:35: a raw pointer to `std::cell::UnsafeCell` in `BySwap`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1415:35: a raw pointer to `std::cell::UnsafeCell` in `ByReplace`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1426:35: a raw pointer to `std::cell::UnsafeCell` in `ByBox`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1441:35: a raw pointer to `std::cell::UnsafeCell` in `ByClosure`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1454:35: a raw pointer to `std::cell::UnsafeCell` in `ByObject`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1467:35: a raw pointer to `std::cell::UnsafeCell` in `ByInstance`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1476:76: a raw pointer to `std::cell::UnsafeCell` in `BySwapped`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1487:30: a raw pointer to `std::cell::UnsafeCell` in `ByExchanged`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1519:32: a raw pointer to `ByRefReplace` in `(u16, ByRefReplace)`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1527:32: a raw pointer to `ByRefTake` in `(u16, ByRefTake)`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1535:51: a raw pointer to `ByKeySet` in `(u16, ByKeySet)`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1543:55: a raw pointer to `ByKeyReplace` in `(u16, ByKeyReplace)`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1550:52: a raw pointer to `ByKeyTake` in `(u16, ByKeyTake)`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:2114:10: a raw pointer to `[u32; 3]` in `Lanes`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:2317:2: a raw pointer to `(u8, u8)` in `([Cloned; 2], (u8, u8))`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:2333:2: a raw pointer to `(u8, u8)` in `(Dropped, (u8, u8))`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:2351:13: a raw pointer to `(u8, u8)` in `([Greatest; 2], (u8, u8))`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:2382:2: a raw pointer to `(u8, u8)` in `([Touched; 2], (u8, u8))`, which the crate may put another object in place of - -
- -
a raw pointer to `_` in a variable assigned again while it may point there (23) - -- fixtures/reject/src/lib.rs:544:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:552:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:561:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:569:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:578:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:586:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:624:15: a raw pointer to `std::cell::UnsafeCell` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:637:15: a raw pointer to `std::cell::UnsafeCell` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:923:26: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:936:22: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:946:12: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:955:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:965:17: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:970:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:1591:10: a raw pointer to `Target` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:1604:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:1619:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:1655:26: a raw pointer to `[u8; 4]` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:1656:10: a raw pointer to `[u8; 4]` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:2112:10: a raw pointer to `[u32; 3]` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:2204:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:2212:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there -- fixtures/reject/src/lib.rs:2220:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there - -
- -
unsupported call to `_` (20) - -- fixtures/reject/src/lib.rs:164:8: unsupported call to `std::ops::Range::::contains::` -- fixtures/reject/src/lib.rs:244:10: unsupported call to `::hash::` -- fixtures/reject/src/lib.rs:272:2: unsupported call to `std::borrow::Cow::<'_, [u8]>::is_borrowed` -- fixtures/reject/src/lib.rs:298:2: unsupported call to ` as std::cmp::PartialEq>::eq` -- fixtures/reject/src/lib.rs:363:17: unsupported call to ` as std::iter::Iterator>::sum::` -- fixtures/reject/src/lib.rs:363:38: unsupported call to ` as std::iter::Iterator>::sum::` -- fixtures/reject/src/lib.rs:368:4: unsupported call to `core::str::::parse::` -- fixtures/reject/src/lib.rs:466:2: unsupported call to `::eq` -- fixtures/reject/src/lib.rs:466:17: unsupported call to `std::any::TypeId::of::` -- fixtures/reject/src/lib.rs:694:15: unsupported call to ` as std::iter::Iterator>::is_sorted` -- fixtures/reject/src/lib.rs:906:11: unsupported call to `std::ops::RangeTo::::contains::` -- fixtures/reject/src/lib.rs:906:32: unsupported call to ` as std::ops::RangeBounds>::contains::` -- fixtures/reject/src/lib.rs:911:9: unsupported call to `std::ops::Range::<&mut u8>::is_empty` -- fixtures/reject/src/lib.rs:1199:4: unsupported call to `core::num::::is_ascii_octdigit` -- fixtures/reject/src/lib.rs:1558:13: unsupported call to `core::str::::as_bytes_mut` -- fixtures/reject/src/lib.rs:1634:14: unsupported call to `std::ptr::addr_eq::<[u8; 4], [u8; 4]>` -- fixtures/reject/src/lib.rs:2198:2: unsupported call to `std::mem::size_of_val::` -- fixtures/reject/src/lib.rs:2282:13: unsupported call to `std::alloc::alloc_zeroed` -- fixtures/reject/src/lib.rs:2288:2: unsupported call to ` as std::fmt::Debug>::fmt` -- fixtures/reject/src/lib.rs:2288:25: unsupported call to ` as std::cmp::PartialEq>::eq` - -
- -
a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of (15) - -- fixtures/reject/src/lib.rs:1259:33: a reference through which a raw pointer may be made into `InArray` in `[InArray; 2]`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1268:33: a reference through which a raw pointer may be made into `InTuple` in `(u16, InTuple)`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1277:34: a reference through which a raw pointer may be made into `Mid` in `Outer`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1298:33: a reference through which a raw pointer may be made into `Mid` in `Outer`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1311:35: a reference through which a raw pointer may be made into `Mid` in `Outer`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1320:35: a reference through which a raw pointer may be made into `InWritten` in `[InWritten; 1]`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1879:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `Replaced`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1897:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `Swapped`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1915:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `Taken`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1934:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `Assigned`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1960:22: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `Deeper`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:1984:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `Dynamic`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:2000:15: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `Closed`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:2013:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `[std::cell::UnsafeCell; 2]`, which the crate may put another object in place of -- fixtures/reject/src/lib.rs:2059:20: a reference through which a raw pointer may be made into `Parked` in `Parking`, which the crate may put another object in place of - -
- -
a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there (15) - -- fixtures/reject/src/lib.rs:1577:18: a reference to `std::cell::UnsafeCell`, 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:26: a reference to `[u8; 4]`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there -- fixtures/reject/src/lib.rs:1673:22: a reference to `Behind`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there -- fixtures/reject/src/lib.rs:1688:16: a reference to `Unboxed`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there -- fixtures/reject/src/lib.rs:1709:18: a reference to `Deep`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there -- fixtures/reject/src/lib.rs:1731:21: a reference to `Slotted`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there -- fixtures/reject/src/lib.rs:1750:20: a reference to `Shared`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there -- fixtures/reject/src/lib.rs:1767:20: a reference to `Inside`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there -- fixtures/reject/src/lib.rs:1780:26: a reference to `Inside`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there -- fixtures/reject/src/lib.rs:1795:22: a reference to `Compared`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there -- fixtures/reject/src/lib.rs:1812:22: a reference to `Enclosing`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there -- fixtures/reject/src/lib.rs:1828:17: a reference to `Chosen`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there -- fixtures/reject/src/lib.rs:1841:19: a reference to `[u8; 4]`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there -- fixtures/reject/src/lib.rs:1856:21: a reference to `Wrapped>`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there -- fixtures/reject/src/lib.rs:2030:13: a reference to `std::option::Option>`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there - -
- -
a cast from a pointer to `_` to one to `_`, which reads the bytes of one type as another (6) - -- fixtures/reject/src/lib.rs:483:27: a cast from a pointer to `u32` to one to `u8`, which reads the bytes of one type as another -- fixtures/reject/src/lib.rs:2099:13: a cast from a pointer to `u32` to one to `[u32; 2]`, which reads the bytes of one type as another -- fixtures/reject/src/lib.rs:2254:15: a cast from a pointer to `u8` to one to `u32`, which reads the bytes of one type as another -- fixtures/reject/src/lib.rs:2255:16: a cast from a pointer to `u8` to one to `Halves`, which reads the bytes of one type as another -- fixtures/reject/src/lib.rs:2257:15: a cast from a pointer to `u32` to one to `u8`, which reads the bytes of one type as another -- fixtures/reject/src/lib.rs:2282:12: a cast from a pointer to `u8` to one to `u32`, which reads the bytes of one type as another - -
- -
`_` with a mutable reference to a value JS copies, which its mapping would copy (5) - -- fixtures/reject/src/lib.rs:1157:22: `std::iter::once` with a mutable reference to a value JS copies, which its mapping would copy -- fixtures/reject/src/lib.rs:1559:13: `core::str::::get_unchecked_mut` with a mutable reference to a value JS copies, which its mapping would copy -- fixtures/reject/src/lib.rs:1564:20: `std::str::from_utf8_mut` with a mutable reference to a value JS copies, which its mapping would copy -- fixtures/reject/src/lib.rs:2039:4: `std::collections::LinkedList::::retain` with a mutable reference to a value JS copies, which its mapping would copy -- fixtures/reject/src/lib.rs:2041:2: `std::default::Default::default` with a mutable reference to a value JS copies, which its mapping would copy - -
- -
a raw pointer to `_` in an element, a payload, or a union field, which is not supported yet (5) - -- fixtures/reject/src/lib.rs:607:10: a raw pointer to `(u32, u32)` in an element, a payload, or a union field, which is not supported yet -- fixtures/reject/src/lib.rs:1648:15: a raw pointer to `[u8; 3]` in an element, a payload, or a union field, which is not supported yet -- fixtures/reject/src/lib.rs:1648:18: a raw pointer to `[u8; 3]` in an element, a payload, or a union field, which is not supported yet -- fixtures/reject/src/lib.rs:1648:37: a raw pointer to `[u8; 2]` in an element, a payload, or a union field, which is not supported yet -- fixtures/reject/src/lib.rs:1648:44: a raw pointer to `[u8; 2]` in an element, a payload, or a union field, which is not supported yet - -
- -
memory from `alloc` cast to pointers to `_` and to `_`, which reads the bytes of one type as another (5) - -- fixtures/reject/src/lib.rs:2268:7: memory from `alloc` cast to pointers to `u32` and to `i32`, which reads the bytes of one type as another -- fixtures/reject/src/lib.rs:2269:11: memory from `alloc` cast to pointers to `i32` and to `u32`, which reads the bytes of one type as another -- fixtures/reject/src/lib.rs:2271:17: memory from `alloc` cast to pointers to `i32` and to `u32`, which reads the bytes of one type as another -- fixtures/reject/src/lib.rs:2272:21: memory from `alloc` cast to pointers to `u32` and to `i32`, which reads the bytes of one type as another -- fixtures/reject/src/lib.rs:2274:17: memory from `alloc` cast to pointers to `i32` and to `u32`, which reads the bytes of one type as another - -
- -
a variant of `_`, which is not supported: either is the same JS string (4) - -- fixtures/reject/src/lib.rs:260:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:261:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:262:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:267:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string - -
- -
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:172:2: an assignment through a reference to `std::pin::Pin<&mut Noisy>` -- fixtures/reject/src/lib.rs:2235: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:229:4: `slice::clone_from_slice` of `Reused`, whose `clone_from` is its own, which is not supported yet -- fixtures/reject/src/lib.rs:2193:4: `Clone::clone_from` of `std::vec::Vec`, whose `clone_from` is its own, which is not supported yet - -
- -
a byte of memory from `alloc`, which JS keeps as the values a cast of its pointer types it as (3) - -- fixtures/reject/src/lib.rs:496:3: a byte of memory from `alloc`, which JS keeps as the values a cast of its pointer types it as -- fixtures/reject/src/lib.rs:497:11: a byte of memory from `alloc`, which JS keeps as the values a cast of its pointer types it as -- fixtures/reject/src/lib.rs:2253:3: a byte of memory from `alloc`, which JS keeps as the values a cast of its pointer types it as - -
- -
a copy between pointers to `_`, which JS keeps as an object that knows no array it is in (3) - -- fixtures/reject/src/lib.rs:1632:3: a copy between pointers to `[u8; 4]`, which JS keeps as an object that knows no array it is in -- fixtures/reject/src/lib.rs:1633:3: a copy between pointers to `[u8; 4]`, which JS keeps as an object that knows no array it is in -- fixtures/reject/src/lib.rs:2084:3: a copy between pointers to `(u8, u8)`, which JS keeps as an object that knows no array it is in - -
- -
a copy of a closure that changes what it captured (3) - -- fixtures/reject/src/lib.rs:182:14: a copy of a closure that changes what it captured -- fixtures/reject/src/lib.rs:436:14: a copy of a closure that changes what it captured -- fixtures/reject/src/lib.rs:437:14: a copy of a closure that changes what it captured - -
- -
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:2188: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:2230: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:2241: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 - -
- -
an offset of a pointer to `_`, which JS keeps as an object that knows no array it is in (3) - -- fixtures/reject/src/lib.rs:1635:56: an offset of a pointer to `[u8; 4]`, which JS keeps as an object that knows no array it is in -- fixtures/reject/src/lib.rs:1635:73: an offset of a pointer to `[u8; 4]`, which JS keeps as an object that knows no array it is in -- fixtures/reject/src/lib.rs:2083:13: an offset of a pointer to `(u8, u8)`, which JS keeps as an object that knows no array it is in - -
- -
replacing the value behind a reference to `_` (3) - -- fixtures/reject/src/lib.rs:91:2: replacing the value behind a reference to `std::pin::Pin fn(&'a mut std::task::Context<'b>) -> std::task::Poll>>>` -- fixtures/reject/src/lib.rs:99:2: replacing the value behind a reference to `std::pin::Pin>` -- fixtures/reject/src/lib.rs:112:2: replacing the value behind a reference to `std::sync::MutexGuard<'_, u8>` - -
- -
unsupported type `_` (3) - -- fixtures/reject/src/lib.rs:7:14: unsupported type `f16` -- fixtures/reject/src/lib.rs:7:25: unsupported type `f16` -- fixtures/reject/src/lib.rs:66:51: unsupported type `f16` - -
- -
`_` is not supported: its `None` and `Some` would both be `rt.None` (2) - -- fixtures/reject/src/lib.rs:16:15: `Option>>` is not supported: its `None` and `Some` would both be `rt.None` -- fixtures/reject/src/lib.rs:17:2: `Option>>` is not supported: its `None` and `Some` would both be `rt.None` - -
- -
`_` of `_`, whose `None` is `rt.None`, which is not supported yet (2) - -- fixtures/reject/src/lib.rs:37:4: `Iterator::scan` of `Option>`, whose `None` is `rt.None`, which is not supported yet -- fixtures/reject/src/lib.rs:188:11: `Iterator::scan` of `Option<()>`, whose `None` is `rt.None`, 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::hash::Hasher`, a trait object of another crate's trait, which is not supported yet -- fixtures/reject/src/lib.rs:12:4: `dyn std::hash::Hasher`, a trait object of another crate's trait, which is not supported yet - -
- -
`_`, a trait object of the generic trait `_`, which is not supported yet (2) - -- fixtures/reject/src/lib.rs:386:23: `dyn Scaled`, a trait object of the generic trait `Scaled`, which is not supported yet -- fixtures/reject/src/lib.rs:387:4: `dyn Scaled`, a trait object of the generic trait `Scaled`, which is not supported yet - -
- -
`offset_from` between a pointer into a value in no array and one into a value in no array, which JS keeps in different arrays (2) - -- fixtures/reject/src/lib.rs:2147:5: `offset_from` between a pointer into a value in no array and one into a value in no array, which JS keeps in different arrays -- fixtures/reject/src/lib.rs:2148:26: `offset_from` between a pointer into a value in no array and one into a value in no array, which JS keeps in different arrays - -
- -
`offset_from` between a pointer into an array of this body's own and one into an array of this body's own, which JS keeps in different arrays (2) - -- fixtures/reject/src/lib.rs:2149:24: `offset_from` between a pointer into an array of this body's own and one into an array of this body's own, which JS keeps in different arrays -- fixtures/reject/src/lib.rs:2150:23: `offset_from` between a pointer into an array of this body's own and one into an array of this body's own, which JS keeps in different arrays - -
- -
a pointer reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust (2) - -- fixtures/reject/src/lib.rs:2172:18: a pointer reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust -- fixtures/reject/src/lib.rs:2175:21: a pointer reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust - -
- -
a raw or mutable slice of a byte in no array of bytes (2) - -- fixtures/reject/src/lib.rs:2158:12: a raw or mutable slice of a byte in no array of bytes -- fixtures/reject/src/lib.rs:2159:19: a raw or mutable slice of a byte in no array of bytes - -
- -
a raw pointer to a place of `()`, which has no address of its own (2) - -- fixtures/reject/src/lib.rs:656:15: a raw pointer to a place of `()`, which has no address of its own -- fixtures/reject/src/lib.rs:656:29: a raw pointer to a place of `()`, which has no address of its own - -
- -
an upcast from `_` to `_`, which is not supported yet (2) - -- fixtures/reject/src/lib.rs:454:32: an upcast from `dyn Keyed` to `dyn std::any::Any`, which is not supported yet -- fixtures/reject/src/lib.rs:460:46: an upcast from `dyn Keyed` to `dyn std::any::Any`, which is not supported yet - -
- -
comparing pointers to `_`, each a place JS makes of its own (2) - -- fixtures/reject/src/lib.rs:524:2: comparing pointers to `u32`, each a place JS makes of its own -- fixtures/reject/src/lib.rs:2067:2: comparing pointers to `u32`, each a place JS makes of its own - -
- -
overriding `_`, which std's adaptors call in place of `next` or beside it (2) - -- fixtures/reject/src/lib.rs:125:2: overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it -- fixtures/reject/src/lib.rs:150:2: overriding `DoubleEndedIterator::nth_back`, which std's adaptors call in place of `next` or beside it - -
- -
unsupported type `_` from another crate (2) - -- fixtures/reject/src/lib.rs:367:32: unsupported type `std::net::AddrParseError` from another crate -- fixtures/reject/src/lib.rs:367:32: unsupported type `std::net::Ipv4Addr` from another crate - -
- -
`Buf::copy_to_bytes` of `_`, a value JS copies, which is not supported (1) - -- fixtures/reject/src/lib.rs:689:2: `Buf::copy_to_bytes` of `Blank`, a value JS copies, which is not supported - -
- -
`BufMut::put` of `_` into a `BytesMut`, which advances it by the room left in a capacity that depends on whether the other handles of its storage dropped, which is not supported (1) - -- fixtures/reject/src/lib.rs:323:2: `BufMut::put` of `Counted` into a `BytesMut`, which advances it by the room left in a capacity that depends on whether the other handles of its storage dropped, which is not supported - -
- -
`BufMut::put` of `_` into a `BytesMut`, which picks the methods it calls by a capacity that depends on whether the other handles of its storage dropped, which is not supported (1) - -- fixtures/reject/src/lib.rs:318:2: `BufMut::put` of `Counted` into a `BytesMut`, which picks the methods it calls by a capacity that depends on whether the other handles of its storage dropped, which is not supported - -
- -
`Bytes::from_owner` of `_`, which would drop with the last clone of what it makes, which is not supported (1) - -- fixtures/reject/src/lib.rs:303:2: `Bytes::from_owner` of `std::sync::Arc<[u8]>`, which would drop with the last clone of what it makes, which is not supported - -
- -
`Extend` of `_` by `_`, whose `_` of `_` is not supported yet (1) - -- fixtures/reject/src/lib.rs:1194:31: `Extend` of `(std::vec::Vec, Tens)` by `(u8, u8)`, whose `Tens` of `u8` is not supported yet - -
- -
`Pointer` formatting, as in `{:p}`, is not supported (1) - -- fixtures/reject/src/lib.rs:49:2: `Pointer` formatting, as in `{:p}`, is not supported - -
- -
`_` is not supported: its `Pending` and `Ready` would both be `rt.OuterPending` (1) - -- fixtures/reject/src/lib.rs:72:20: `Poll>>>` is not supported: its `Pending` and `Ready` would both be `rt.OuterPending` - -
- -
`_` is not supported: its field `_` is `_`, typed `_`, whose `None` would be `rt.None` as `_` (1) - -- fixtures/reject/src/lib.rs:31:2: `Maybe<()>` is not supported: its field `value` is `Option`, typed `T | undefined`, whose `None` would be `rt.None` as `Option<()>` - -
- -
`_` is not supported: its field `_` is `_`, typed `_`, whose `Pending` would be `rt.OuterPending` as `_` (1) - -- fixtures/reject/src/lib.rs:424:2: `Waiting>` is not supported: its field `poll` is `Poll`, typed `rt.Poll`, whose `Pending` would be `rt.OuterPending` as `Poll>` - -
- -
`_` of `_` by `_`, which is not supported yet (1) - -- fixtures/reject/src/lib.rs:211:6: `HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet - -
- -
`_` of `_`, which is not supported yet (1) - -- fixtures/reject/src/lib.rs:466:4: `std::any::Any::type_id` of `dyn std::any::Any`, which is not supported yet - -
- -
`_`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported (1) - -- fixtures/reject/src/lib.rs:312:6: `BytesMut::capacity`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported - -
- -
`clone_from` of `_`, whose items' `clone_from` is their own, which is not supported yet (1) - -- fixtures/reject/src/lib.rs:2040:4: `clone_from` of `std::collections::LinkedList`, whose items' `clone_from` is their own, which is not supported yet - -
- -
`collect` of `_`, which sorts by `_`'s own `Ord`, of entries that drop, which is not supported yet (1) - -- fixtures/reject/src/lib.rs:877:22: `collect` of `std::collections::BTreeMap, Noisy>`, which sorts by `std::cell::Cell`'s own `Ord`, of entries that drop, which is not supported yet - -
- -
`fmt::Arguments` with a placeholder, or not made in place, written to `_`'s own `fmt::Write`, which is not supported yet: std splits what a placeholder writes into `write_str` calls the runtime does not make (1) - -- fixtures/reject/src/lib.rs:55:10: `fmt::Arguments` with a placeholder, or not made in place, written to `Sink`'s own `fmt::Write`, which is not supported yet: std splits what a placeholder writes into `write_str` calls the runtime does not make - -
- -
`offset_from` between a pointer into a shared slice JS copies and one into a value in no array, which JS keeps in different arrays (1) - -- fixtures/reject/src/lib.rs:2152:21: `offset_from` between a pointer into a shared slice JS copies and one into a value in no array, which JS keeps in different arrays - -
- -
`offset_from` between a pointer into a shared slice JS copies and one into an array of this body's own, which JS keeps in different arrays (1) - -- fixtures/reject/src/lib.rs:2151:20: `offset_from` between a pointer into a shared slice JS copies and one into an array of this body's own, which JS keeps in different arrays - -
- -
`offset_from` of pointers to `()`, which has no bytes (1) - -- fixtures/reject/src/lib.rs:2094:13: `offset_from` of pointers to `()`, which has no bytes - -
- -
`offset_from` of pointers to `_`, which JS keeps as an object that knows no array it is in (1) - -- fixtures/reject/src/lib.rs:2087:36: `offset_from` of pointers to `(u8, u8)`, which JS keeps as an object that knows no array it is in - -
- -
a cast from `_` to `_` (1) - -- fixtures/reject/src/lib.rs:68:2: a cast from `u64` to `f16` - -
- -
a coercion of `_` to `_`, which is not supported yet (1) - -- fixtures/reject/src/lib.rs:2388:40: a coercion of `*mut std::ops::Range` to `*mut dyn std::iter::Iterator`, which is not supported yet - -
- -
a coercion to `_` (1) - -- fixtures/reject/src/lib.rs:234:2: a coercion to `std::sync::Arc<[u8]>` - -
- -
a coercion to `_`, which is not supported yet (1) - -- fixtures/reject/src/lib.rs:413:30: a coercion to `&Tail`, which is not supported yet - -
- -
a constant of type `_` (1) - -- fixtures/reject/src/lib.rs:2288:34: a constant of type `std::mem::ManuallyDrop` - -
- -
a constant of type `_`, a pointer into memory translation can't name (1) - -- fixtures/reject/src/lib.rs:706:3: a constant of type `&u32`, a pointer into memory translation can't name - -
- -
a copy reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust (1) - -- fixtures/reject/src/lib.rs:2170:3: a copy reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust - -
- -
a dangling pointer to `_`, a value of no bytes made of more than structs and tuples (1) - -- fixtures/reject/src/lib.rs:665:11: a dangling pointer to `Only`, a value of no bytes made of more than structs and tuples - -
- -
a future of `_`, which can be `rt.Pending`, as the future's own `Pending` is (1) - -- fixtures/reject/src/lib.rs:77:34: a future of `std::task::Poll`, which can be `rt.Pending`, as the future's own `Pending` is - -
- -
a mapped guard of `_`, which JS can't write in place (1) - -- fixtures/reject/src/lib.rs:2074:10: a mapped guard of `{closure@fixtures/reject/src/lib.rs:2073:38: 2073:50}`, which JS can't write in place - -
- -
a mutable reference into a `Result`'s payload, passed on or kept (1) - -- fixtures/reject/src/lib.rs:291:12: a mutable reference into a `Result`'s payload, passed on or kept - -
- -
a mutable static, which any code may write (1) - -- fixtures/reject/src/lib.rs:61:11: a mutable static, which any code may write - -
- -
a pointer into `_`, which JS keeps as an object that knows no array it is in (1) - -- fixtures/reject/src/lib.rs:2081:12: a pointer into `(u8, u8)`, which JS keeps as an object that knows no array it is in - -
- -
a pointer into an array of `_`, which JS keeps as an object that knows no array it is in (1) - -- fixtures/reject/src/lib.rs:2086:30: a pointer into an array of `(u8, u8)`, which JS keeps as an object that knows no array it is in - -
- -
a pointer reaching past a value in no array, which JS keeps apart from what holds it in Rust (1) - -- fixtures/reject/src/lib.rs:2174:27: a pointer reaching past a value in no array, which JS keeps apart from what holds it in Rust - -
- -
a pointer's address, which JS has no counterpart of (1) - -- fixtures/reject/src/lib.rs:488:17: a pointer's address, which JS has no counterpart of - -
- -
a printable type must implement `Display` or `Debug` (1) - -- fixtures/reject/src/lib.rs:64:1: a printable type must implement `Display` or `Debug` - -
- -
a raw pointer to `_` behind a reference, which is the object and not where it is kept (1) - -- fixtures/reject/src/lib.rs:505:10: a raw pointer to `std::vec::Vec` behind a reference, which is the object and not where it is kept - -
- -
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 (1) - -- fixtures/reject/src/lib.rs:1286:11: a reference through which a raw pointer may be made into `InPayload` in an element, a payload, or a union field, which is not supported yet - -
- -
a scalar constant of type `_` (1) - -- fixtures/reject/src/lib.rs:8:2: a scalar constant of type `f16` - -
- -
a slice from a pointer to `_`, which JS keeps as an object that knows no array it is in (1) - -- fixtures/reject/src/lib.rs:2085:11: a slice from a pointer to `(u8, u8)`, which JS keeps as an object that knows no array it is in - -
- -
a slice of `()`, which has no bytes, from a pointer (1) - -- fixtures/reject/src/lib.rs:2094:39: a slice of `()`, which has no bytes, from a pointer - -
- -
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:2182:2: a slice of one byte's place, which a byte slice can view only in an array of bytes - -
- -
a slice reaching past a value in no array, which JS keeps apart from what holds it in Rust (1) - -- fixtures/reject/src/lib.rs:2173:6: a slice reaching past a value in no array, which JS keeps apart from what holds it in Rust - -
- -
a trait object of `_`, which is not supported yet (1) - -- fixtures/reject/src/lib.rs:403:26: a trait object of `[u8; 4]`, which is not supported yet - -
- -
arithmetic on `_` (1) - -- fixtures/reject/src/lib.rs:8:2: arithmetic on `f16` - -
- -
comparing `_` (1) - -- fixtures/reject/src/lib.rs:1634:41: comparing `*mut [u8; 4]` - -
- -
comparing `_` as a key, which is not supported yet (1) - -- fixtures/reject/src/lib.rs:193:75: comparing `std::collections::BTreeSet` as a key, which is not supported yet - -
- -
comparing pointers to `_` in an atomic, which JS has no address of (1) - -- fixtures/reject/src/lib.rs:705:15: comparing pointers to `u32` in an atomic, which JS has no address of - -
- -
comparing pointers to `_`, which has no bytes and so no address of its own (1) - -- fixtures/reject/src/lib.rs:656:70: comparing pointers to `Bare`, which has no bytes and so no address of its own - -
- -
const generic types are not supported: `_` (1) - -- fixtures/reject/src/lib.rs:2019:1: const generic types are not supported: `Block` - -
- -
constructing `_` (1) - -- fixtures/reject/src/lib.rs:278:53: constructing `std::borrow::Cow<'_, std::sync::Arc>` - -
- -
hashing `_` as a key, which is not supported yet (1) - -- fixtures/reject/src/lib.rs:193:75: hashing `std::collections::BTreeSet` as a key, which is not supported yet - -
- -
hashing `_` by its address, which JS has no counterpart of (1) - -- fixtures/reject/src/lib.rs:1638:5: hashing `*const [u8; 4]` by its address, which JS has no counterpart of - -
- -
hashing `_` through `_`'s own `Hash::hash_slice`, which is not supported yet (1) - -- fixtures/reject/src/lib.rs:253:16: hashing `std::vec::Vec` through `Batched`'s own `Hash::hash_slice`, which is not supported yet - -
- -
union `_`, whose fields overlap in `_` and `f64`, which JS keeps apart (1) - -- fixtures/reject/src/lib.rs:510:1: union `Bits`, whose fields overlap in `u32` and `f64`, which JS keeps apart - -
diff --git a/ts/fixtures/reject/census.toml b/ts/fixtures/reject/census.toml index 53df8b231..3e5e525cd 100644 --- a/ts/fixtures/reject/census.toml +++ b/ts/fixtures/reject/census.toml @@ -1,4 +1,4 @@ # The census's: no roots, so every item is one. package = "reject-fixture" roots = [] -printable = ["Meters"] +printable = ["config::Meters"] diff --git a/ts/fixtures/reject/census.txt b/ts/fixtures/reject/census.txt new file mode 100644 index 000000000..2c2e5dced --- /dev/null +++ b/ts/fixtures/reject/census.txt @@ -0,0 +1,257 @@ +fixtures/reject/src/alloc.rs:addressed+1:17: a pointer's address, which JS has no counterpart of +fixtures/reject/src/alloc.rs:alloc_retyped+4:7: memory from `alloc` cast to pointers to `u32` and to `i32`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:alloc_retyped+5:11: memory from `alloc` cast to pointers to `i32` and to `u32`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:alloc_retyped+7:17: memory from `alloc` cast to pointers to `i32` and to `u32`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:alloc_retyped+8:21: memory from `alloc` cast to pointers to `u32` and to `i32`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:alloc_retyped+10:17: memory from `alloc` cast to pointers to `i32` and to `u32`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:allocated+4:3: a byte of memory from `alloc`, which JS keeps as the values a cast of its pointer types it as +fixtures/reject/src/alloc.rs:allocated+5:11: a byte of memory from `alloc`, which JS keeps as the values a cast of its pointer types it as +fixtures/reject/src/alloc.rs:bytes_as_values+3:3: a byte of memory from `alloc`, which JS keeps as the values a cast of its pointer types it as +fixtures/reject/src/alloc.rs:bytes_as_values+4:15: a cast from a pointer to `u8` to one to `u32`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:bytes_as_values+5:16: a cast from a pointer to `u8` to one to `pointers::Halves`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:bytes_as_values+7:15: a cast from a pointer to `u32` to one to `u8`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:reinterpreted+1:27: a cast from a pointer to `u32` to one to `u8`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:vec_pointer+1:10: a raw pointer to `std::vec::Vec` behind a reference, which is the object and not where it is kept +fixtures/reject/src/alloc.rs:zeroed+1:12: a cast from a pointer to `u8` to one to `u32`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:zeroed+1:13: unsupported call to `std::alloc::alloc_zeroed` +fixtures/reject/src/buffers.rs:blank_bytes+1:2: `Buf::copy_to_bytes` of `buffers::Blank`, a value JS copies, which is not supported +fixtures/reject/src/buffers.rs:bytes_mut_capacity+5:6: `BytesMut::capacity`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported +fixtures/reject/src/buffers.rs:bytes_mut_put+1:2: `BufMut::put` of `buffers::Counted` into a `BytesMut`, which picks the methods it calls by a capacity that depends on whether the other handles of its storage dropped, which is not supported +fixtures/reject/src/buffers.rs:bytes_mut_put_through+1:2: `BufMut::put` of `buffers::Counted` into a `BytesMut`, which advances it by the room left in a capacity that depends on whether the other handles of its storage dropped, which is not supported +fixtures/reject/src/buffers.rs:owned_bytes+1:2: `Bytes::from_owner` of `std::sync::Arc<[u8]>`, which would drop with the last clone of what it makes, which is not supported +fixtures/reject/src/buffers.rs:shared+1:2: a coercion to `std::sync::Arc<[u8]>` +fixtures/reject/src/clones.rs:given_slots+6:2: a raw pointer to `(u8, u8)` in `([clones::Touched; 2], (u8, u8))`, which the crate may put another object in place of +fixtures/reject/src/clones.rs:greatest_slot+6:13: a raw pointer to `(u8, u8)` in `([clones::Greatest; 2], (u8, u8))`, which the crate may put another object in place of +fixtures/reject/src/clones.rs:kept_slots+5:2: a raw pointer to `(u8, u8)` in `([clones::Cloned; 2], (u8, u8))`, which the crate may put another object in place of +fixtures/reject/src/clones.rs:moved_slots+5:2: a raw pointer to `(u8, u8)` in `(clones::Dropped, (u8, u8))`, which the crate may put another object in place of +fixtures/reject/src/clones.rs:recloned+1:4: `slice::clone_from_slice` of `clones::Reused`, whose `clone_from` is its own, which is not supported yet +fixtures/reject/src/clones.rs:refilled+1:4: `slice::fill` of `clones::Reused`, whose `clone_from` is its own, which is not supported yet +fixtures/reject/src/clones.rs:slice_of_object+1:2: a slice or a cell of a mutable reference to `clones::Reused` that names no place, which a whole write would replace only there +fixtures/reject/src/clones.rs:vec_clone_from+1:4: `Clone::clone_from` of `std::vec::Vec`, whose `clone_from` is its own, which is not supported yet +fixtures/reject/src/config.rs:Meters+0:1: a printable type must implement `Display` or `Debug` +fixtures/reject/src/config.rs:generic+0:51: unsupported type `f16` +fixtures/reject/src/config.rs:generic+2:2: a cast from `u64` to `f16` +fixtures/reject/src/fmt.rs:pointer+1:2: `Pointer` formatting, as in `{:p}`, is not supported +fixtures/reject/src/fmt.rs:written+2:10: `fmt::Arguments` with a placeholder, or not made in place, written to `fmt::Sink`'s own `fmt::Write`, which is not supported yet: std splits what a placeholder writes into `write_str` calls the runtime does not make +fixtures/reject/src/futures.rs:generic_pending+1:2: `futures::Waiting>` is not supported: its field `poll` is `Poll`, typed `rt.Poll`, whose `Pending` would be `rt.OuterPending` as `Poll>` +fixtures/reject/src/futures.rs:nested_poll+0:20: `Poll>>>` is not supported: its `Pending` and `Ready` would both be `rt.OuterPending` +fixtures/reject/src/futures.rs:pending_output+0:34: a future of `std::task::Poll`, which can be `rt.Pending`, as the future's own `Pending` is +fixtures/reject/src/iters.rs:impl DoubleEndedIterator for Backs+5:2: overriding `DoubleEndedIterator::nth_back`, which std's adaptors call in place of `next` or beside it +fixtures/reject/src/iters.rs:impl Iterator for Folds+7:2: overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it +fixtures/reject/src/iters.rs:parts_summed+1:17: unsupported call to ` as std::iter::Iterator>::sum::` +fixtures/reject/src/iters.rs:parts_summed+1:38: unsupported call to ` as std::iter::Iterator>::sum::` +fixtures/reject/src/iters.rs:scanned+2:4: `Iterator::scan` of `Option>`, whose `None` is `rt.None`, which is not supported yet +fixtures/reject/src/iters.rs:scanned_unit+1:11: `Iterator::scan` of `Option<()>`, whose `None` is `rt.None`, which is not supported yet +fixtures/reject/src/iters.rs:tens+1:31: `Extend` of `(std::vec::Vec, iters::Tens)` by `(u8, u8)`, whose `iters::Tens` of `u8` is not supported yet +fixtures/reject/src/kept.rs:atomic_exchanged+4:30: a raw pointer to `std::cell::UnsafeCell` in `kept::ByExchanged`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:atomic_swapped+3:76: a raw pointer to `std::cell::UnsafeCell` in `kept::BySwapped`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:impl Clone for Copied+2:31: a raw pointer to `(u16, u16)` in `kept::Copied`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:keep_part+1:43: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Escaped`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_across_iterations+10:18: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Repeated`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_across_writes+9:26: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Looped`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_boxed+5:35: a raw pointer to `std::cell::UnsafeCell` in `kept::ByBox`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_called+6:35: a raw pointer to `std::cell::UnsafeCell` in `kept::ByClosure`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_instance+6:35: a raw pointer to `std::cell::UnsafeCell` in `kept::ByInstance`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_object+6:35: a raw pointer to `std::cell::UnsafeCell` in `kept::ByObject`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_part+1:28: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Called`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_read+6:35: a raw pointer to `std::cell::UnsafeCell` in `kept::ByRead`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_replaced+6:35: a raw pointer to `std::cell::UnsafeCell` in `kept::ByReplace`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_swapped+7:35: a raw pointer to `std::cell::UnsafeCell` in `kept::BySwap`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_written+6:35: a raw pointer to `std::cell::UnsafeCell` in `kept::ByWrite`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:key_replaced+2:55: a raw pointer to `kept::ByKeyReplace` in `(u16, kept::ByKeyReplace)`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:key_set+2:51: a raw pointer to `kept::ByKeySet` in `(u16, kept::ByKeySet)`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:key_taken+1:52: a raw pointer to `kept::ByKeyTake` in `(u16, kept::ByKeyTake)`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:lent_kept+4:46: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Onced`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:lent_kept+6:22: `std::iter::once` with a mutable reference to a value JS copies, which its mapping would copy +fixtures/reject/src/kept.rs:mapped_kept+4:39: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Mapped`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:pushed_part_kept+4:22: a raw pointer to `(u16, u16)` in `kept::Pushed`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:ref_replaced+2:32: a raw pointer to `kept::ByRefReplace` in `(u16, kept::ByRefReplace)`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:ref_taken+2:32: a raw pointer to `kept::ByRefTake` in `(u16, kept::ByRefTake)`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:uninit_rewritten+3:47: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Rewritten`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:written_through_alias+3:29: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Aliased`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:written_through_loaded+3:29: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Loaded`, which the crate may put another object in place of +fixtures/reject/src/keys.rs:batched+1:16: hashing `std::vec::Vec` through `keys::Batched`'s own `Hash::hash_slice`, which is not supported yet +fixtures/reject/src/keys.rs:borrowed+1:6: `HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet +fixtures/reject/src/keys.rs:impl std::hash::Hash for Batched+2:10: unsupported call to `::hash::` +fixtures/reject/src/keys.rs:keyed+1:8: unsupported call to `std::ops::Range::::contains::` +fixtures/reject/src/keys.rs:keyed_across+1:11: unsupported call to `std::ops::RangeTo::::contains::` +fixtures/reject/src/keys.rs:keyed_across+1:32: unsupported call to ` as std::ops::RangeBounds>::contains::` +fixtures/reject/src/keys.rs:place_bounds+1:9: unsupported call to `std::ops::Range::<&mut u8>::is_empty` +fixtures/reject/src/keys.rs:places_sorted+1:15: unsupported call to ` as std::iter::Iterator>::is_sorted` +fixtures/reject/src/keys.rs:ranked_cells+1:22: `collect` of `std::collections::BTreeMap, places::Noisy>`, which sorts by `std::cell::Cell`'s own `Ord`, of entries that drop, which is not supported yet +fixtures/reject/src/keys.rs:set_keys+1:75: comparing `std::collections::BTreeSet` as a key, which is not supported yet +fixtures/reject/src/keys.rs:set_keys+1:75: hashing `std::collections::BTreeSet` as a key, which is not supported yet +fixtures/reject/src/objects.rs:any_type_id+1:2: unsupported call to `::eq` +fixtures/reject/src/objects.rs:any_type_id+1:4: `std::any::Any::type_id` of `dyn std::any::Any`, which is not supported yet +fixtures/reject/src/objects.rs:any_type_id+1:17: unsupported call to `std::any::TypeId::of::` +fixtures/reject/src/objects.rs:any_upcast+1:32: an upcast from `dyn objects::Keyed` to `dyn std::any::Any`, which is not supported yet +fixtures/reject/src/objects.rs:dyn_size+1:2: unsupported call to `std::mem::size_of_val::` +fixtures/reject/src/objects.rs:dynamic+0:16: `dyn std::hash::Hasher`, a trait object of another crate's trait, which is not supported yet +fixtures/reject/src/objects.rs:dynamic+1:4: `dyn std::hash::Hasher`, a trait object of another crate's trait, which is not supported yet +fixtures/reject/src/objects.rs:first_of+1:26: a trait object of `[u8; 4]`, which is not supported yet +fixtures/reject/src/objects.rs:generic_object+0:23: `dyn objects::Scaled`, a trait object of the generic trait `objects::Scaled`, which is not supported yet +fixtures/reject/src/objects.rs:generic_object+1:4: `dyn objects::Scaled`, a trait object of the generic trait `objects::Scaled`, which is not supported yet +fixtures/reject/src/objects.rs:raw_dyn_iter+2:40: a coercion of `*mut std::ops::Range` to `*mut dyn std::iter::Iterator`, which is not supported yet +fixtures/reject/src/objects.rs:weak_any_upcast+1:46: an upcast from `dyn objects::Keyed` to `dyn std::any::Any`, which is not supported yet +fixtures/reject/src/parts.rs:array_part+1:9: a raw pointer to `std::cell::UnsafeCell` in `parts::InArray`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:array_part_replaced+3:33: a reference through which a raw pointer may be made into `parts::InArray` in `[parts::InArray; 2]`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:element_replaced+2:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `[std::cell::UnsafeCell; 2]`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:field_part+1:9: a raw pointer to `std::cell::UnsafeCell` in `parts::InField`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:field_part_replaced+3:33: a reference through which a raw pointer may be made into `parts::Mid` in `parts::Outer`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:generic_part+1:9: a raw pointer to `std::cell::UnsafeCell` in `parts::InGeneric`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:generic_part_replaced+3:35: a reference through which a raw pointer may be made into `parts::Mid` in `parts::Outer`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:nested_part+1:9: a raw pointer to `std::cell::UnsafeCell` in `parts::InNested`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:nested_part_replaced+3:34: a reference through which a raw pointer may be made into `parts::Mid` in `parts::Outer`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:part_assigned+4:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `parts::Assigned`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:part_mem_replaced+4:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `parts::Replaced`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:part_replaced_closure+5:15: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `parts::Closed`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:part_replaced_deep+4:22: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `parts::Deeper`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:part_replaced_dyn+4:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `parts::Dynamic`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:part_swapped+4:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `parts::Swapped`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:part_taken+4:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `parts::Taken`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:payload_part+1:9: a raw pointer to `std::cell::UnsafeCell` in `parts::InPayload`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:payload_part_replaced+3:11: a reference through which a raw pointer may be made into `parts::InPayload` in an element, a payload, or a union field, which is not supported yet +fixtures/reject/src/parts.rs:tuple_part+1:9: a raw pointer to `std::cell::UnsafeCell` in `parts::InTuple`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:tuple_part_replaced+3:33: a reference through which a raw pointer may be made into `parts::InTuple` in `(u16, parts::InTuple)`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:written_part+1:9: a raw pointer to `std::cell::UnsafeCell` in `parts::InWritten`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:written_part_replaced+3:35: a reference through which a raw pointer may be made into `parts::InWritten` in `[parts::InWritten; 1]`, which the crate may put another object in place of +fixtures/reject/src/places.rs:copied_closure+6:14: a copy of a closure that changes what it captured +fixtures/reject/src/places.rs:mapped_closure+2:10: a mapped guard of `{closure@fixtures/reject/src/places.rs:mapped_closure+1:38: +1:50}`, which JS can't write in place +fixtures/reject/src/places.rs:ok_passed+1:12: a mutable reference into a `Result`'s payload, passed on or kept +fixtures/reject/src/places.rs:optional_places_compared+2:2: comparing pointers to `u32`, each a place JS makes of its own +fixtures/reject/src/places.rs:places_compared+3:2: comparing pointers to `u32`, each a place JS makes of its own +fixtures/reject/src/places.rs:places_equal+1:2: unsupported call to ` as std::cmp::PartialEq>::eq` +fixtures/reject/src/places.rs:rebound_reference+7:14: a copy of a closure that changes what it captured +fixtures/reject/src/places.rs:rebound_reference+8:14: a copy of a closure that changes what it captured +fixtures/reject/src/places.rs:replace_boxed_bytes+4:2: replacing the value behind a reference to `std::pin::Pin>` +fixtures/reject/src/places.rs:replace_boxed_future+4:2: an assignment through a reference to `std::pin::Pin>>` +fixtures/reject/src/places.rs:replace_boxed_poll_fn+4:2: replacing the value behind a reference to `std::pin::Pin fn(&'a mut std::task::Context<'b>) -> std::task::Poll>>>` +fixtures/reject/src/places.rs:replace_guard+1:2: an assignment through a reference to `std::sync::MutexGuard<'_, u8>` +fixtures/reject/src/places.rs:replace_pinned_ref+1:2: an assignment through a reference to `std::pin::Pin<&mut places::Noisy>` +fixtures/reject/src/places.rs:swap_guards+1:2: replacing the value behind a reference to `std::sync::MutexGuard<'_, u8>` +fixtures/reject/src/pointers.rs:assigned_through+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:byte_pointer_ops+5:3: a copy between pointers to `[u8; 4]`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:byte_pointer_ops+6:3: a copy between pointers to `[u8; 4]`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:byte_pointer_ops+7:14: unsupported call to `std::ptr::addr_eq::<[u8; 4], [u8; 4]>` +fixtures/reject/src/pointers.rs:byte_pointer_ops+7:41: comparing `*mut [u8; 4]` +fixtures/reject/src/pointers.rs:byte_pointer_ops+8:56: an offset of a pointer to `[u8; 4]`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:byte_pointer_ops+8:73: an offset of a pointer to `[u8; 4]`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:byte_pointer_ops+11:5: hashing `*const [u8; 4]` by its address, which JS has no counterpart of +fixtures/reject/src/pointers.rs:byte_pointer_parts+3:15: a raw pointer to `[u8; 3]` in an element, a payload, or a union field, which is not supported yet +fixtures/reject/src/pointers.rs:byte_pointer_parts+3:18: a raw pointer to `[u8; 3]` in an element, a payload, or a union field, which is not supported yet +fixtures/reject/src/pointers.rs:byte_pointer_parts+3:37: a raw pointer to `[u8; 2]` in an element, a payload, or a union field, which is not supported yet +fixtures/reject/src/pointers.rs:byte_pointer_parts+3:44: a raw pointer to `[u8; 2]` in an element, a payload, or a union field, which is not supported yet +fixtures/reject/src/pointers.rs:byte_pointer_rebound+2:26: a raw pointer to `[u8; 4]` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:byte_pointer_rebound+2:26: a reference to `[u8; 4]`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/pointers.rs:byte_pointer_rebound+3:10: a raw pointer to `[u8; 4]` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:byte_slice_of_place+1:2: a slice of one byte's place, which a byte slice can view only in an array of bytes +fixtures/reject/src/pointers.rs:cast_reassigned+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:cell_field_replaced+4:21: a raw pointer to `std::cell::UnsafeCell` in `pointers::Hits`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:cell_reassigned+2:15: a raw pointer to `std::cell::UnsafeCell` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:cell_replaced+2:15: a raw pointer to `(u32, u32)` in `std::cell::UnsafeCell<(u32, u32)>`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:cell_taken+2:15: a raw pointer to `std::cell::UnsafeCell` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:closure_replaced+3:19: a raw pointer to `(u32, u32)` in `pointers::Lane`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:element_pointer+2:10: a raw pointer to `(u32, u32)` in an element, a payload, or a union field, which is not supported yet +fixtures/reject/src/pointers.rs:element_to_array+1:13: a cast from a pointer to `u32` to one to `[u32; 2]`, which reads the bytes of one type as another +fixtures/reject/src/pointers.rs:elements_replaced+2:10: a raw pointer to `[u32; 3]` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:elements_replaced+4:10: a raw pointer to `[u32; 3]` in `pointers::Lanes`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:lone_byte_slices+1:12: a raw or mutable slice of a byte in no array of bytes +fixtures/reject/src/pointers.rs:lone_byte_slices+2:19: a raw or mutable slice of a byte in no array of bytes +fixtures/reject/src/pointers.rs:made_part_replaced+5:10: a raw pointer to `(u32, u32)` in `pointers::Gap`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:made_part_replaced+6:10: a raw pointer to `(u32, u32)` in `pointers::Gap`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:made_part_replaced+7:58: a raw pointer to `(u32, u32)` in `pointers::Gap`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:nonnull_reassigned+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:object_elements+1:12: a pointer into `(u8, u8)`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:object_elements+3:13: an offset of a pointer to `(u8, u8)`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:object_elements+4:3: a copy between pointers to `(u8, u8)`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:object_elements+5:11: a slice from a pointer to `(u8, u8)`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:object_elements+6:30: a pointer into an array of `(u8, u8)`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:object_elements+7:36: `offset_from` of pointers to `(u8, u8)`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:object_replaced+2:19: a raw pointer to `(u32, u32)` in `pointers::Track`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:part_replaced+2:10: a raw pointer to `(u32, u32)` in `pointers::Span2`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:pointer_captured+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:pointer_in_struct+2:26: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:pointer_kept_across+2:17: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:pointer_kept_across+7:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:pointer_pushed+3:12: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:pointer_returned+2:22: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:pointers_apart+9:5: `offset_from` between a pointer into a value in no array and one into a value in no array, which JS keeps in different arrays +fixtures/reject/src/pointers.rs:pointers_apart+10:26: `offset_from` between a pointer into a value in no array and one into a value in no array, which JS keeps in different arrays +fixtures/reject/src/pointers.rs:pointers_apart+11:24: `offset_from` between a pointer into an array of this body's own and one into an array of this body's own, which JS keeps in different arrays +fixtures/reject/src/pointers.rs:pointers_apart+12:23: `offset_from` between a pointer into an array of this body's own and one into an array of this body's own, which JS keeps in different arrays +fixtures/reject/src/pointers.rs:pointers_apart+13:20: `offset_from` between a pointer into a shared slice JS copies and one into an array of this body's own, which JS keeps in different arrays +fixtures/reject/src/pointers.rs:pointers_apart+14:21: `offset_from` between a pointer into a shared slice JS copies and one into a value in no array, which JS keeps in different arrays +fixtures/reject/src/pointers.rs:put_replaced+2:10: a raw pointer to `(u32, u32)` in `pointers::Plain`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:range_of+1:2: a raw pointer to `(u32, u32)` in `pointers::Window`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:reached_out+4:3: a copy reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust +fixtures/reject/src/pointers.rs:reached_out+6:18: a pointer reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust +fixtures/reject/src/pointers.rs:reached_out+7:6: a slice reaching past a value in no array, which JS keeps apart from what holds it in Rust +fixtures/reject/src/pointers.rs:reached_out+8:27: a pointer reaching past a value in no array, which JS keeps apart from what holds it in Rust +fixtures/reject/src/pointers.rs:reached_out+9:21: a pointer reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust +fixtures/reject/src/pointers.rs:uninit_part_replaced+5:19: a raw pointer to `std::mem::MaybeUninit<(u32, u32)>` in `pointers::Gap`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:uninit_part_replaced+6:19: a raw pointer to `std::mem::MaybeUninit<(u32, u32)>` in `pointers::Gap`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:unit_elements+1:13: `offset_from` of pointers to `()`, which has no bytes +fixtures/reject/src/pointers.rs:unit_elements+1:39: a slice of `()`, which has no bytes, from a pointer +fixtures/reject/src/pointers.rs:variable_celled+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:variable_cloned_from+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:variable_cloned_into+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:variable_reassigned+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:variable_replaced+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:variable_swapped+3:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/rebound.rs:bytes_compared_rebound+2:19: a reference to `[u8; 4]`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:cell_rebound+2:18: a reference to `std::cell::UnsafeCell`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:chosen_compared_rebound+3:17: a reference to `rebound::Chosen`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:compared_rebound+2:22: a reference to `rebound::Compared`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:deep_cell_rebound+4:18: a reference to `rebound::Deep`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:enclosed_compared_rebound+2:22: a reference to `rebound::Enclosing`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:generic_cell_rebound+2:21: a reference to `rebound::Wrapped>`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:generic_park_rebound+1:20: a reference through which a raw pointer may be made into `rebound::Parked` in `rebound::Parking`, which the crate may put another object in place of +fixtures/reject/src/rebound.rs:inside_cell_rebound+2:20: a reference to `rebound::Inside`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:inside_field_rebound+2:26: a reference to `rebound::Inside`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:payload_cell_rebound+2:21: a reference to `rebound::Slotted`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:read_behind_rebound+2:22: a reference to `rebound::Behind`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:ref_cell_rebound+2:20: a reference to `rebound::Shared`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:retargeted+5:10: a raw pointer to `rebound::Target` in a variable assigned again while it may point there +fixtures/reject/src/rebound.rs:swap_retargeted+6:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/rebound.rs:swapped_in_loop+8:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/rebound.rs:unboxed_rebound+2:16: a reference to `rebound::Unboxed`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/statics.rs:key_celled+1: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 +fixtures/reject/src/statics.rs:lazy_assigned+1:2: an assignment through a reference to `std::sync::LazyLock` +fixtures/reject/src/statics.rs:lazy_celled+1: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/statics.rs:pointer_statics+3:15: comparing pointers to `u32` in an atomic, which JS has no address of +fixtures/reject/src/statics.rs:pointer_statics+4:3: a constant of type `&u32`, a pointer into memory translation can't name +fixtures/reject/src/statics.rs:statics+1:11: a mutable static, which any code may write +fixtures/reject/src/strs.rs:cow_borrowed+1:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +fixtures/reject/src/strs.rs:cow_bytes+1:2: unsupported call to `std::borrow::Cow::<'_, [u8]>::is_borrowed` +fixtures/reject/src/strs.rs:cow_made+2:53: constructing `std::borrow::Cow<'_, std::sync::Arc>` +fixtures/reject/src/strs.rs:cow_matched+1:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +fixtures/reject/src/strs.rs:cow_matched+2:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +fixtures/reject/src/strs.rs:cow_matched+3:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +fixtures/reject/src/strs.rs:str_bytes_mut+1:13: unsupported call to `core::str::::as_bytes_mut` +fixtures/reject/src/strs.rs:str_bytes_mut+2:13: `core::str::::get_unchecked_mut` with a mutable reference to a value JS copies, which its mapping would copy +fixtures/reject/src/strs.rs:str_from_bytes_mut+1:20: `std::str::from_utf8_mut` with a mutable reference to a value JS copies, which its mapping would copy +fixtures/reject/src/values.rs:Bits+0:1: union `values::Bits`, whose fields overlap in `u32` and `f64`, which JS keeps apart +fixtures/reject/src/values.rs:Block+0:1: const generic types are not supported: `values::Block` +fixtures/reject/src/values.rs:addr_parsed+0:32: unsupported type `std::net::AddrParseError` from another crate +fixtures/reject/src/values.rs:addr_parsed+0:32: unsupported type `std::net::Ipv4Addr` from another crate +fixtures/reject/src/values.rs:addr_parsed+1:4: unsupported call to `core::str::::parse::` +fixtures/reject/src/values.rs:ascii_octal+1:4: unsupported call to `core::num::::is_ascii_octdigit` +fixtures/reject/src/values.rs:dangling_enum+1:11: a dangling pointer to `values::Only`, a value of no bytes made of more than structs and tuples +fixtures/reject/src/values.rs:float+0:14: unsupported type `f16` +fixtures/reject/src/values.rs:float+0:25: unsupported type `f16` +fixtures/reject/src/values.rs:float+1:2: a scalar constant of type `f16` +fixtures/reject/src/values.rs:float+1:2: arithmetic on `f16` +fixtures/reject/src/values.rs:generic_unit+1:2: `values::Maybe<()>` is not supported: its field `value` is `Option`, typed `T | undefined`, whose `None` would be `rt.None` as `Option<()>` +fixtures/reject/src/values.rs:lists+1:4: `std::collections::LinkedList::::retain` with a mutable reference to a value JS copies, which its mapping would copy +fixtures/reject/src/values.rs:lists+2:4: `clone_from` of `std::collections::LinkedList`, whose items' `clone_from` is their own, which is not supported yet +fixtures/reject/src/values.rs:lists+3:2: `std::default::Default::default` with a mutable reference to a value JS copies, which its mapping would copy +fixtures/reject/src/values.rs:manual_impls+2:2: unsupported call to ` as std::fmt::Debug>::fmt` +fixtures/reject/src/values.rs:manual_impls+2:25: unsupported call to ` as std::cmp::PartialEq>::eq` +fixtures/reject/src/values.rs:manual_impls+2:34: a constant of type `std::mem::ManuallyDrop` +fixtures/reject/src/values.rs:nested+0:15: `Option>>` is not supported: its `None` and `Some` would both be `rt.None` +fixtures/reject/src/values.rs:nested+1:2: `Option>>` is not supported: its `None` and `Some` would both be `rt.None` +fixtures/reject/src/values.rs:reclone+3:13: a reference to `std::option::Option>`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/values.rs:tail_read+1:30: a coercion to `&values::Tail`, which is not supported yet +fixtures/reject/src/values.rs:units_compared+2:15: a raw pointer to a place of `()`, which has no address of its own +fixtures/reject/src/values.rs:units_compared+2:29: a raw pointer to a place of `()`, which has no address of its own +fixtures/reject/src/values.rs:units_compared+2:70: comparing pointers to `places::Bare`, which has no bytes and so no address of its own diff --git a/ts/fixtures/reject/expected.txt b/ts/fixtures/reject/expected.txt index 4903dbb75..d425670c9 100644 --- a/ts/fixtures/reject/expected.txt +++ b/ts/fixtures/reject/expected.txt @@ -1,257 +1,257 @@ +no item `bound_ranges` in the crate no item `lopsided` in the crate no item `missing` in the crate -no item `bound_ranges` in the crate -a root must not be generic at fixtures/reject/src/lib.rs:66:1 -a printable type must implement `Display` or `Debug` at fixtures/reject/src/lib.rs:64:1 -unsupported type `f16` at fixtures/reject/src/lib.rs:7:14 -a scalar constant of type `f16` at fixtures/reject/src/lib.rs:8:2 -arithmetic on `f16` at fixtures/reject/src/lib.rs:8:2 -unsupported type `f16` at fixtures/reject/src/lib.rs:7:25 -`dyn std::hash::Hasher`, a trait object of another crate's trait, which is not supported yet at fixtures/reject/src/lib.rs:11:16 -`dyn std::hash::Hasher`, a trait object of another crate's trait, which is not supported yet at fixtures/reject/src/lib.rs:12:4 -`Option>>` is not supported: its `None` and `Some` would both be `rt.None` at fixtures/reject/src/lib.rs:17:2 -`Option>>` is not supported: its `None` and `Some` would both be `rt.None` at fixtures/reject/src/lib.rs:16:15 -`slice::fill` of `Reused`, whose `clone_from` is its own, which is not supported yet at fixtures/reject/src/lib.rs:21:4 -`Iterator::scan` of `Option>`, whose `None` is `rt.None`, which is not supported yet at fixtures/reject/src/lib.rs:37:4 -`Maybe<()>` is not supported: its field `value` is `Option`, typed `T | undefined`, whose `None` would be `rt.None` as `Option<()>` at fixtures/reject/src/lib.rs:31:2 -`Pointer` formatting, as in `{:p}`, is not supported at fixtures/reject/src/lib.rs:49:11 -`fmt::Arguments` with a placeholder, or not made in place, written to `Sink`'s own `fmt::Write`, which is not supported yet: std splits what a placeholder writes into `write_str` calls the runtime does not make at fixtures/reject/src/lib.rs:55:10 -a mutable static, which any code may write at fixtures/reject/src/lib.rs:61:11 -`Poll>>>` is not supported: its `Pending` and `Ready` would both be `rt.OuterPending` at fixtures/reject/src/lib.rs:72:20 -a future of `std::task::Poll`, which can be `rt.Pending`, as the future's own `Pending` is at fixtures/reject/src/lib.rs:77:34 -an assignment through a reference to `std::sync::MutexGuard<'_, u8>` at fixtures/reject/src/lib.rs:83:2 -replacing the value behind a reference to `std::sync::MutexGuard<'_, u8>` at fixtures/reject/src/lib.rs:112:2 -replacing the value behind a reference to `std::pin::Pin fn(&'a mut std::task::Context<'b>) -> std::task::Poll>>>` at fixtures/reject/src/lib.rs:91:2 -an assignment through a reference to `std::pin::Pin>>` at fixtures/reject/src/lib.rs:107:2 -replacing the value behind a reference to `std::pin::Pin>` at fixtures/reject/src/lib.rs:99:2 -unsupported call to `std::ops::Range::::contains::` at fixtures/reject/src/lib.rs:164:8 -unsupported call to `std::ops::RangeTo::::contains::` at fixtures/reject/src/lib.rs:906:11 -unsupported call to ` as std::ops::RangeBounds>::contains::` at fixtures/reject/src/lib.rs:906:32 -unsupported call to `std::ops::Range::<&mut u8>::is_empty` at fixtures/reject/src/lib.rs:911:9 -an assignment through a reference to `std::pin::Pin<&mut Noisy>` at fixtures/reject/src/lib.rs:172:2 -a copy of a closure that changes what it captured at fixtures/reject/src/lib.rs:182:14 -`Iterator::scan` of `Option<()>`, whose `None` is `rt.None`, which is not supported yet at fixtures/reject/src/lib.rs:188:11 -hashing `std::collections::BTreeSet` as a key, which is not supported yet at fixtures/reject/src/lib.rs:193:75 -comparing `std::collections::BTreeSet` as a key, which is not supported yet at fixtures/reject/src/lib.rs:193:75 -`HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet at fixtures/reject/src/lib.rs:211:6 -`slice::clone_from_slice` of `Reused`, whose `clone_from` is its own, which is not supported yet at fixtures/reject/src/lib.rs:229:4 -a coercion to `std::sync::Arc<[u8]>` at fixtures/reject/src/lib.rs:234:2 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:260:2 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:262:27 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:261:30 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:267:2 -unsupported call to `std::borrow::Cow::<'_, [u8]>::is_borrowed` at fixtures/reject/src/lib.rs:272:2 -constructing `std::borrow::Cow<'_, std::sync::Arc>` at fixtures/reject/src/lib.rs:278:53 -hashing `std::vec::Vec` through `Batched`'s own `Hash::hash_slice`, which is not supported yet at fixtures/reject/src/lib.rs:253:16 -unsupported call to ` as std::iter::Iterator>::sum::` at fixtures/reject/src/lib.rs:363:17 -unsupported call to ` as std::iter::Iterator>::sum::` at fixtures/reject/src/lib.rs:363:38 -a mutable reference into a `Result`'s payload, passed on or kept at fixtures/reject/src/lib.rs:291:12 -unsupported call to ` as std::cmp::PartialEq>::eq` at fixtures/reject/src/lib.rs:298:2 -`Bytes::from_owner` of `std::sync::Arc<[u8]>`, which would drop with the last clone of what it makes, which is not supported at fixtures/reject/src/lib.rs:303:2 -`BytesMut::capacity`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported at fixtures/reject/src/lib.rs:312:6 -`BufMut::put` of `Counted` into a `BytesMut`, which picks the methods it calls by a capacity that depends on whether the other handles of its storage dropped, which is not supported at fixtures/reject/src/lib.rs:318:2 -`BufMut::put` of `Counted` into a `BytesMut`, which advances it by the room left in a capacity that depends on whether the other handles of its storage dropped, which is not supported at fixtures/reject/src/lib.rs:323:2 -unsupported call to `core::str::::parse::` at fixtures/reject/src/lib.rs:368:4 -unsupported type `std::net::Ipv4Addr` from another crate at fixtures/reject/src/lib.rs:367:32 -unsupported type `std::net::AddrParseError` from another crate at fixtures/reject/src/lib.rs:367:32 -`dyn Scaled`, a trait object of the generic trait `Scaled`, which is not supported yet at fixtures/reject/src/lib.rs:386:23 -`dyn Scaled`, a trait object of the generic trait `Scaled`, which is not supported yet at fixtures/reject/src/lib.rs:387:4 -a trait object of `[u8; 4]`, which is not supported yet at fixtures/reject/src/lib.rs:403:26 -a coercion to `&Tail`, which is not supported yet at fixtures/reject/src/lib.rs:413:30 -`Waiting>` is not supported: its field `poll` is `Poll`, typed `rt.Poll`, whose `Pending` would be `rt.OuterPending` as `Poll>` at fixtures/reject/src/lib.rs:424:2 -a copy of a closure that changes what it captured at fixtures/reject/src/lib.rs:436:14 -a copy of a closure that changes what it captured at fixtures/reject/src/lib.rs:437:14 -an upcast from `dyn Keyed` to `dyn std::any::Any`, which is not supported yet at fixtures/reject/src/lib.rs:454:32 -an upcast from `dyn Keyed` to `dyn std::any::Any`, which is not supported yet at fixtures/reject/src/lib.rs:460:46 -`std::any::Any::type_id` of `dyn std::any::Any`, which is not supported yet at fixtures/reject/src/lib.rs:466:4 -unsupported call to `std::any::TypeId::of::` at fixtures/reject/src/lib.rs:466:17 -unsupported call to `::eq` at fixtures/reject/src/lib.rs:466:2 -a cast from a pointer to `u32` to one to `u8`, which reads the bytes of one type as another at fixtures/reject/src/lib.rs:483:27 -a pointer's address, which JS has no counterpart of at fixtures/reject/src/lib.rs:488:17 -a byte of memory from `alloc`, which JS keeps as the values a cast of its pointer types it as at fixtures/reject/src/lib.rs:496:3 -a byte of memory from `alloc`, which JS keeps as the values a cast of its pointer types it as at fixtures/reject/src/lib.rs:497:11 -a raw pointer to `std::vec::Vec` behind a reference, which is the object and not where it is kept at fixtures/reject/src/lib.rs:505:10 -union `Bits`, whose fields overlap in `u32` and `f64`, which JS keeps apart at fixtures/reject/src/lib.rs:516:10 -comparing pointers to `u32`, each a place JS makes of its own at fixtures/reject/src/lib.rs:524:2 -comparing pointers to `u32`, each a place JS makes of its own at fixtures/reject/src/lib.rs:2067:2 -a raw pointer to `(u32, u32)` in `Span2`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:536:10 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:544:10 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:552:10 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:561:10 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:569:10 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:578:10 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:586:10 -a reference to `std::cell::UnsafeCell`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:1577:18 -a raw pointer to `Target` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:1591:10 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:1604:10 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:1619:10 -a reference to `Behind`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:1673:22 -a reference to `Unboxed`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:1688:16 -a reference to `Deep`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:1709:18 -a reference to `Slotted`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:1731:21 -a reference to `Shared`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:1750:20 -a reference to `Inside`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:1767:20 -a reference to `Inside`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:1780:26 -a reference to `Wrapped>`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:1856:21 -a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `Replaced`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1879:20 -a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `Swapped`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1897:20 -a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `Taken`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1915:20 -a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `Assigned`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1934:20 -a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `Deeper`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1960:22 -a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `Dynamic`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1984:20 -a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `Closed`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:2000:15 -a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `[std::cell::UnsafeCell; 2]`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:2013:20 -a reference to `Compared`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:1795:22 -a reference to `Enclosing`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:1812:22 -a reference to `Chosen`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:1828:17 -a reference to `[u8; 4]`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:1841:19 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:923:26 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:936:22 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:946:12 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:955:10 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:965:17 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:970:10 -a raw pointer to `(u32, u32)` in `Window`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:597:2 -a raw pointer to `(u32, u32)` in an element, a payload, or a union field, which is not supported yet at fixtures/reject/src/lib.rs:607:10 -a raw pointer to `(u32, u32)` in `std::cell::UnsafeCell<(u32, u32)>`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:615:15 -a raw pointer to `std::cell::UnsafeCell` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:624:15 -a raw pointer to `std::cell::UnsafeCell` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:637:15 -a raw pointer to `std::cell::UnsafeCell` in `Hits`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:648:21 -a raw pointer to a place of `()`, which has no address of its own at fixtures/reject/src/lib.rs:656:15 -a raw pointer to a place of `()`, which has no address of its own at fixtures/reject/src/lib.rs:656:29 -comparing pointers to `Bare`, which has no bytes and so no address of its own at fixtures/reject/src/lib.rs:656:70 -a dangling pointer to `Only`, a value of no bytes made of more than structs and tuples at fixtures/reject/src/lib.rs:665:11 -`Buf::copy_to_bytes` of `Blank`, a value JS copies, which is not supported at fixtures/reject/src/lib.rs:689:2 -unsupported call to ` as std::iter::Iterator>::is_sorted` at fixtures/reject/src/lib.rs:694:15 -comparing pointers to `u32` in an atomic, which JS has no address of at fixtures/reject/src/lib.rs:705:15 -a constant of type `&u32`, a pointer into memory translation can't name at fixtures/reject/src/lib.rs:706:3 -a raw pointer to `(u32, u32)` in `Plain`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:748:10 -a raw pointer to `(u32, u32)` in `Track`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:774:19 -a raw pointer to `(u32, u32)` in `Lane`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:794:19 -a raw pointer to `(u32, u32)` in `Gap`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:830:10 -a raw pointer to `(u32, u32)` in `Gap`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:831:10 -a raw pointer to `(u32, u32)` in `Gap`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:832:58 -a raw pointer to `std::mem::MaybeUninit<(u32, u32)>` in `Gap`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:844:19 -a raw pointer to `std::mem::MaybeUninit<(u32, u32)>` in `Gap`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:845:19 -`collect` of `std::collections::BTreeMap, Noisy>`, which sorts by `std::cell::Cell`'s own `Ord`, of entries that drop, which is not supported yet at fixtures/reject/src/lib.rs:877:22 -a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Looped`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1032:26 -a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Aliased`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1042:29 -a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Rewritten`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1052:47 -a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Loaded`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1064:29 -a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Mapped`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1109:39 -a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Repeated`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1143:18 -a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Onced`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1155:46 -`std::iter::once` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:1157:22 -a raw pointer to `(u16, u16)` in `Pushed`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1170:22 -`Extend` of `(std::vec::Vec, Tens)` by `(u8, u8)`, whose `Tens` of `u8` is not supported yet at fixtures/reject/src/lib.rs:1194:31 -unsupported call to `core::num::::is_ascii_octdigit` at fixtures/reject/src/lib.rs:1199:4 -a reference through which a raw pointer may be made into `InArray` in `[InArray; 2]`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1259:33 -a reference through which a raw pointer may be made into `InTuple` in `(u16, InTuple)`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1268:33 -a reference through which a raw pointer may be made into `Mid` in `Outer`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1277:34 -a reference through which a raw pointer may be made into `InPayload` in an element, a payload, or a union field, which is not supported yet at fixtures/reject/src/lib.rs:1286:11 -a reference through which a raw pointer may be made into `Mid` in `Outer`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1298:33 -a reference through which a raw pointer may be made into `Mid` in `Outer`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1311:35 -a reference through which a raw pointer may be made into `InWritten` in `[InWritten; 1]`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1320:35 -a raw pointer to `std::cell::UnsafeCell` in `ByRead`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1377:35 -a raw pointer to `std::cell::UnsafeCell` in `ByWrite`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1390:35 -a raw pointer to `std::cell::UnsafeCell` in `BySwap`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1403:35 -a raw pointer to `std::cell::UnsafeCell` in `ByReplace`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1415:35 -a raw pointer to `std::cell::UnsafeCell` in `ByBox`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1426:35 -a raw pointer to `std::cell::UnsafeCell` in `ByClosure`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1441:35 -a raw pointer to `std::cell::UnsafeCell` in `ByObject`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1454:35 -a raw pointer to `std::cell::UnsafeCell` in `ByInstance`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1467:35 -a raw pointer to `std::cell::UnsafeCell` in `BySwapped`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1476:76 -a raw pointer to `std::cell::UnsafeCell` in `ByExchanged`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1487:30 -a raw pointer to `ByRefReplace` in `(u16, ByRefReplace)`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1519:32 -a raw pointer to `ByRefTake` in `(u16, ByRefTake)`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1527:32 -a raw pointer to `ByKeySet` in `(u16, ByKeySet)`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1535:51 -a raw pointer to `ByKeyReplace` in `(u16, ByKeyReplace)`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1543:55 -a raw pointer to `ByKeyTake` in `(u16, ByKeyTake)`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1550:52 -unsupported call to `core::str::::as_bytes_mut` at fixtures/reject/src/lib.rs:1558:13 -`core::str::::get_unchecked_mut` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:1559:13 -`std::str::from_utf8_mut` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:1564:20 -a copy between pointers to `[u8; 4]`, which JS keeps as an object that knows no array it is in at fixtures/reject/src/lib.rs:1632:3 -a copy between pointers to `[u8; 4]`, which JS keeps as an object that knows no array it is in at fixtures/reject/src/lib.rs:1633:3 -unsupported call to `std::ptr::addr_eq::<[u8; 4], [u8; 4]>` at fixtures/reject/src/lib.rs:1634:14 -comparing `*mut [u8; 4]` at fixtures/reject/src/lib.rs:1634:41 -an offset of a pointer to `[u8; 4]`, which JS keeps as an object that knows no array it is in at fixtures/reject/src/lib.rs:1635:56 -an offset of a pointer to `[u8; 4]`, which JS keeps as an object that knows no array it is in at fixtures/reject/src/lib.rs:1635:73 -hashing `*const [u8; 4]` by its address, which JS has no counterpart of at fixtures/reject/src/lib.rs:1638:5 -a raw pointer to `[u8; 3]` in an element, a payload, or a union field, which is not supported yet at fixtures/reject/src/lib.rs:1648:15 -a raw pointer to `[u8; 3]` in an element, a payload, or a union field, which is not supported yet at fixtures/reject/src/lib.rs:1648:18 -a raw pointer to `[u8; 2]` in an element, a payload, or a union field, which is not supported yet at fixtures/reject/src/lib.rs:1648:37 -a raw pointer to `[u8; 2]` in an element, a payload, or a union field, which is not supported yet at fixtures/reject/src/lib.rs:1648:44 -a reference to `[u8; 4]`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:1655:26 -a raw pointer to `[u8; 4]` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:1655:26 -a raw pointer to `[u8; 4]` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:1656:10 -const generic types are not supported: `Block` at fixtures/reject/src/lib.rs:2023:21 -`std::collections::LinkedList::::retain` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:2039:4 -`clone_from` of `std::collections::LinkedList`, whose items' `clone_from` is their own, which is not supported yet at fixtures/reject/src/lib.rs:2040: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:2041:2 -a mapped guard of `{closure@fixtures/reject/src/lib.rs:2073:38: 2073:50}`, which JS can't write in place at fixtures/reject/src/lib.rs:2074:10 -a pointer into `(u8, u8)`, which JS keeps as an object that knows no array it is in at fixtures/reject/src/lib.rs:2081:12 -an offset of a pointer to `(u8, u8)`, which JS keeps as an object that knows no array it is in at fixtures/reject/src/lib.rs:2083:13 -a copy between pointers to `(u8, u8)`, which JS keeps as an object that knows no array it is in at fixtures/reject/src/lib.rs:2084:3 -a slice from a pointer to `(u8, u8)`, which JS keeps as an object that knows no array it is in at fixtures/reject/src/lib.rs:2085:11 -a pointer into an array of `(u8, u8)`, which JS keeps as an object that knows no array it is in at fixtures/reject/src/lib.rs:2086:30 -`offset_from` of pointers to `(u8, u8)`, which JS keeps as an object that knows no array it is in at fixtures/reject/src/lib.rs:2087:36 -`offset_from` of pointers to `()`, which has no bytes at fixtures/reject/src/lib.rs:2094:13 -a slice of `()`, which has no bytes, from a pointer at fixtures/reject/src/lib.rs:2094:39 -a cast from a pointer to `u32` to one to `[u32; 2]`, which reads the bytes of one type as another at fixtures/reject/src/lib.rs:2099:13 -a raw pointer to `[u32; 3]` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:2112:10 -a raw pointer to `[u32; 3]` in `Lanes`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:2114:10 -`offset_from` between a pointer into a value in no array and one into a value in no array, which JS keeps in different arrays at fixtures/reject/src/lib.rs:2147:5 -`offset_from` between a pointer into a value in no array and one into a value in no array, which JS keeps in different arrays at fixtures/reject/src/lib.rs:2148:26 -`offset_from` between a pointer into an array of this body's own and one into an array of this body's own, which JS keeps in different arrays at fixtures/reject/src/lib.rs:2149:24 -`offset_from` between a pointer into an array of this body's own and one into an array of this body's own, which JS keeps in different arrays at fixtures/reject/src/lib.rs:2150:23 -`offset_from` between a pointer into a shared slice JS copies and one into an array of this body's own, which JS keeps in different arrays at fixtures/reject/src/lib.rs:2151:20 -`offset_from` between a pointer into a shared slice JS copies and one into a value in no array, which JS keeps in different arrays at fixtures/reject/src/lib.rs:2152:21 -a raw or mutable slice of a byte in no array of bytes at fixtures/reject/src/lib.rs:2158:12 -a raw or mutable slice of a byte in no array of bytes at fixtures/reject/src/lib.rs:2159:19 -a copy reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust at fixtures/reject/src/lib.rs:2170:3 -a pointer reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust at fixtures/reject/src/lib.rs:2172:18 -a slice reaching past a value in no array, which JS keeps apart from what holds it in Rust at fixtures/reject/src/lib.rs:2173:6 -a pointer reaching past a value in no array, which JS keeps apart from what holds it in Rust at fixtures/reject/src/lib.rs:2174:27 -a pointer reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust at fixtures/reject/src/lib.rs:2175:21 -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:2182: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:2188: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:2193:4 -unsupported call to `std::mem::size_of_val::` at fixtures/reject/src/lib.rs:2198:2 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:2204:10 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:2212:10 -a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:2220: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:2230:3 -an assignment through a reference to `std::sync::LazyLock` at fixtures/reject/src/lib.rs:2235: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:2241:2 -a byte of memory from `alloc`, which JS keeps as the values a cast of its pointer types it as at fixtures/reject/src/lib.rs:2253:3 -a cast from a pointer to `u8` to one to `u32`, which reads the bytes of one type as another at fixtures/reject/src/lib.rs:2254:15 -a cast from a pointer to `u8` to one to `Halves`, which reads the bytes of one type as another at fixtures/reject/src/lib.rs:2255:16 -a cast from a pointer to `u32` to one to `u8`, which reads the bytes of one type as another at fixtures/reject/src/lib.rs:2257:15 -unsupported call to `std::alloc::alloc_zeroed` at fixtures/reject/src/lib.rs:2282:13 -a cast from a pointer to `u8` to one to `u32`, which reads the bytes of one type as another at fixtures/reject/src/lib.rs:2282:12 -unsupported call to ` as std::cmp::PartialEq>::eq` at fixtures/reject/src/lib.rs:2288:25 -a constant of type `std::mem::ManuallyDrop` at fixtures/reject/src/lib.rs:2288:34 -unsupported call to ` as std::fmt::Debug>::fmt` at fixtures/reject/src/lib.rs:2288:11 -memory from `alloc` cast to pointers to `u32` and to `i32`, which reads the bytes of one type as another at fixtures/reject/src/lib.rs:2268:7 -memory from `alloc` cast to pointers to `i32` and to `u32`, which reads the bytes of one type as another at fixtures/reject/src/lib.rs:2269:11 -memory from `alloc` cast to pointers to `i32` and to `u32`, which reads the bytes of one type as another at fixtures/reject/src/lib.rs:2271:17 -memory from `alloc` cast to pointers to `u32` and to `i32`, which reads the bytes of one type as another at fixtures/reject/src/lib.rs:2272:21 -memory from `alloc` cast to pointers to `i32` and to `u32`, which reads the bytes of one type as another at fixtures/reject/src/lib.rs:2274:17 -a coercion of `*mut std::ops::Range` to `*mut dyn std::iter::Iterator`, which is not supported yet at fixtures/reject/src/lib.rs:2388:40 -overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:125:2 -overriding `DoubleEndedIterator::nth_back`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:150:2 -a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Escaped`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:994:43 -a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `Called`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1008:28 -a raw pointer to `(u16, u16)` in `Copied`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1098:31 -a raw pointer to `std::cell::UnsafeCell` in `InArray`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1224:9 -a raw pointer to `std::cell::UnsafeCell` in `InTuple`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1228:9 -a raw pointer to `std::cell::UnsafeCell` in `InNested`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1232:9 -a raw pointer to `std::cell::UnsafeCell` in `InPayload`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1236:9 -a raw pointer to `std::cell::UnsafeCell` in `InField`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1240:9 -a raw pointer to `std::cell::UnsafeCell` in `InGeneric`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1244:9 -a raw pointer to `std::cell::UnsafeCell` in `InWritten`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1248:9 -a reference to `std::option::Option>`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there at fixtures/reject/src/lib.rs:2030:13 -a raw pointer to `(u8, u8)` in `([Cloned; 2], (u8, u8))`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:2295:23 -a raw pointer to `(u8, u8)` in `(Dropped, (u8, u8))`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:2295:23 -a raw pointer to `(u8, u8)` in `([Greatest; 2], (u8, u8))`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:2351:13 -a raw pointer to `(u8, u8)` in `([Touched; 2], (u8, u8))`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:2295:23 +fixtures/reject/src/alloc.rs:addressed+1:17: a pointer's address, which JS has no counterpart of +fixtures/reject/src/alloc.rs:alloc_retyped+4:7: memory from `alloc` cast to pointers to `u32` and to `i32`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:alloc_retyped+5:11: memory from `alloc` cast to pointers to `i32` and to `u32`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:alloc_retyped+7:17: memory from `alloc` cast to pointers to `i32` and to `u32`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:alloc_retyped+8:21: memory from `alloc` cast to pointers to `u32` and to `i32`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:alloc_retyped+10:17: memory from `alloc` cast to pointers to `i32` and to `u32`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:allocated+4:3: a byte of memory from `alloc`, which JS keeps as the values a cast of its pointer types it as +fixtures/reject/src/alloc.rs:allocated+5:11: a byte of memory from `alloc`, which JS keeps as the values a cast of its pointer types it as +fixtures/reject/src/alloc.rs:bytes_as_values+3:3: a byte of memory from `alloc`, which JS keeps as the values a cast of its pointer types it as +fixtures/reject/src/alloc.rs:bytes_as_values+4:15: a cast from a pointer to `u8` to one to `u32`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:bytes_as_values+5:16: a cast from a pointer to `u8` to one to `pointers::Halves`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:bytes_as_values+7:15: a cast from a pointer to `u32` to one to `u8`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:reinterpreted+1:27: a cast from a pointer to `u32` to one to `u8`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:vec_pointer+1:10: a raw pointer to `std::vec::Vec` behind a reference, which is the object and not where it is kept +fixtures/reject/src/alloc.rs:zeroed+1:12: a cast from a pointer to `u8` to one to `u32`, which reads the bytes of one type as another +fixtures/reject/src/alloc.rs:zeroed+1:13: unsupported call to `std::alloc::alloc_zeroed` +fixtures/reject/src/buffers.rs:blank_bytes+1:2: `Buf::copy_to_bytes` of `buffers::Blank`, a value JS copies, which is not supported +fixtures/reject/src/buffers.rs:bytes_mut_capacity+5:6: `BytesMut::capacity`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported +fixtures/reject/src/buffers.rs:bytes_mut_put+1:2: `BufMut::put` of `buffers::Counted` into a `BytesMut`, which picks the methods it calls by a capacity that depends on whether the other handles of its storage dropped, which is not supported +fixtures/reject/src/buffers.rs:bytes_mut_put_through+1:2: `BufMut::put` of `buffers::Counted` into a `BytesMut`, which advances it by the room left in a capacity that depends on whether the other handles of its storage dropped, which is not supported +fixtures/reject/src/buffers.rs:owned_bytes+1:2: `Bytes::from_owner` of `std::sync::Arc<[u8]>`, which would drop with the last clone of what it makes, which is not supported +fixtures/reject/src/buffers.rs:shared+1:2: a coercion to `std::sync::Arc<[u8]>` +fixtures/reject/src/clones.rs:greatest_slot+6:13: a raw pointer to `(u8, u8)` in `([clones::Greatest; 2], (u8, u8))`, which the crate may put another object in place of +fixtures/reject/src/clones.rs:recloned+1:4: `slice::clone_from_slice` of `clones::Reused`, whose `clone_from` is its own, which is not supported yet +fixtures/reject/src/clones.rs:refilled+1:4: `slice::fill` of `clones::Reused`, whose `clone_from` is its own, which is not supported yet +fixtures/reject/src/clones.rs:slice_of_object+1:2: a slice or a cell of a mutable reference to `clones::Reused` that names no place, which a whole write would replace only there +fixtures/reject/src/clones.rs:tagged_slots!+2:23: a raw pointer to `(u8, u8)` in `([clones::Cloned; 2], (u8, u8))`, which the crate may put another object in place of +fixtures/reject/src/clones.rs:tagged_slots!+2:23: a raw pointer to `(u8, u8)` in `([clones::Touched; 2], (u8, u8))`, which the crate may put another object in place of +fixtures/reject/src/clones.rs:tagged_slots!+2:23: a raw pointer to `(u8, u8)` in `(clones::Dropped, (u8, u8))`, which the crate may put another object in place of +fixtures/reject/src/clones.rs:vec_clone_from+1:4: `Clone::clone_from` of `std::vec::Vec`, whose `clone_from` is its own, which is not supported yet +fixtures/reject/src/config.rs:Meters+0:1: a printable type must implement `Display` or `Debug` +fixtures/reject/src/config.rs:generic+0:1: a root must not be generic +fixtures/reject/src/fmt.rs:pointer+1:11: `Pointer` formatting, as in `{:p}`, is not supported +fixtures/reject/src/fmt.rs:written+2:10: `fmt::Arguments` with a placeholder, or not made in place, written to `fmt::Sink`'s own `fmt::Write`, which is not supported yet: std splits what a placeholder writes into `write_str` calls the runtime does not make +fixtures/reject/src/futures.rs:generic_pending+1:2: `futures::Waiting>` is not supported: its field `poll` is `Poll`, typed `rt.Poll`, whose `Pending` would be `rt.OuterPending` as `Poll>` +fixtures/reject/src/futures.rs:nested_poll+0:20: `Poll>>>` is not supported: its `Pending` and `Ready` would both be `rt.OuterPending` +fixtures/reject/src/futures.rs:pending_output+0:34: a future of `std::task::Poll`, which can be `rt.Pending`, as the future's own `Pending` is +fixtures/reject/src/iters.rs:impl DoubleEndedIterator for Backs+5:2: overriding `DoubleEndedIterator::nth_back`, which std's adaptors call in place of `next` or beside it +fixtures/reject/src/iters.rs:impl Iterator for Folds+7:2: overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it +fixtures/reject/src/iters.rs:parts_summed+1:17: unsupported call to ` as std::iter::Iterator>::sum::` +fixtures/reject/src/iters.rs:parts_summed+1:38: unsupported call to ` as std::iter::Iterator>::sum::` +fixtures/reject/src/iters.rs:scanned+2:4: `Iterator::scan` of `Option>`, whose `None` is `rt.None`, which is not supported yet +fixtures/reject/src/iters.rs:scanned_unit+1:11: `Iterator::scan` of `Option<()>`, whose `None` is `rt.None`, which is not supported yet +fixtures/reject/src/iters.rs:tens+1:31: `Extend` of `(std::vec::Vec, iters::Tens)` by `(u8, u8)`, whose `iters::Tens` of `u8` is not supported yet +fixtures/reject/src/kept.rs:atomic_exchanged+4:30: a raw pointer to `std::cell::UnsafeCell` in `kept::ByExchanged`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:atomic_swapped+3:76: a raw pointer to `std::cell::UnsafeCell` in `kept::BySwapped`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:impl Clone for Copied+2:31: a raw pointer to `(u16, u16)` in `kept::Copied`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:keep_part+1:43: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Escaped`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_across_iterations+10:18: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Repeated`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_across_writes+9:26: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Looped`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_boxed+5:35: a raw pointer to `std::cell::UnsafeCell` in `kept::ByBox`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_called+6:35: a raw pointer to `std::cell::UnsafeCell` in `kept::ByClosure`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_instance+6:35: a raw pointer to `std::cell::UnsafeCell` in `kept::ByInstance`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_object+6:35: a raw pointer to `std::cell::UnsafeCell` in `kept::ByObject`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_part+1:28: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Called`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_read+6:35: a raw pointer to `std::cell::UnsafeCell` in `kept::ByRead`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_replaced+6:35: a raw pointer to `std::cell::UnsafeCell` in `kept::ByReplace`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_swapped+7:35: a raw pointer to `std::cell::UnsafeCell` in `kept::BySwap`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:kept_written+6:35: a raw pointer to `std::cell::UnsafeCell` in `kept::ByWrite`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:key_replaced+2:55: a raw pointer to `kept::ByKeyReplace` in `(u16, kept::ByKeyReplace)`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:key_set+2:51: a raw pointer to `kept::ByKeySet` in `(u16, kept::ByKeySet)`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:key_taken+1:52: a raw pointer to `kept::ByKeyTake` in `(u16, kept::ByKeyTake)`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:lent_kept+4:46: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Onced`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:lent_kept+6:22: `std::iter::once` with a mutable reference to a value JS copies, which its mapping would copy +fixtures/reject/src/kept.rs:mapped_kept+4:39: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Mapped`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:pushed_part_kept+4:22: a raw pointer to `(u16, u16)` in `kept::Pushed`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:ref_replaced+2:32: a raw pointer to `kept::ByRefReplace` in `(u16, kept::ByRefReplace)`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:ref_taken+2:32: a raw pointer to `kept::ByRefTake` in `(u16, kept::ByRefTake)`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:uninit_rewritten+3:47: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Rewritten`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:written_through_alias+3:29: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Aliased`, which the crate may put another object in place of +fixtures/reject/src/kept.rs:written_through_loaded+3:29: a raw pointer to `std::cell::UnsafeCell<(u16, u16)>` in `kept::Loaded`, which the crate may put another object in place of +fixtures/reject/src/keys.rs:batched+1:16: hashing `std::vec::Vec` through `keys::Batched`'s own `Hash::hash_slice`, which is not supported yet +fixtures/reject/src/keys.rs:borrowed+1:6: `HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet +fixtures/reject/src/keys.rs:keyed+1:8: unsupported call to `std::ops::Range::::contains::` +fixtures/reject/src/keys.rs:keyed_across+1:11: unsupported call to `std::ops::RangeTo::::contains::` +fixtures/reject/src/keys.rs:keyed_across+1:32: unsupported call to ` as std::ops::RangeBounds>::contains::` +fixtures/reject/src/keys.rs:place_bounds+1:9: unsupported call to `std::ops::Range::<&mut u8>::is_empty` +fixtures/reject/src/keys.rs:places_sorted+1:15: unsupported call to ` as std::iter::Iterator>::is_sorted` +fixtures/reject/src/keys.rs:ranked_cells+1:22: `collect` of `std::collections::BTreeMap, places::Noisy>`, which sorts by `std::cell::Cell`'s own `Ord`, of entries that drop, which is not supported yet +fixtures/reject/src/keys.rs:set_keys+1:75: comparing `std::collections::BTreeSet` as a key, which is not supported yet +fixtures/reject/src/keys.rs:set_keys+1:75: hashing `std::collections::BTreeSet` as a key, which is not supported yet +fixtures/reject/src/objects.rs:any_type_id+1:2: unsupported call to `::eq` +fixtures/reject/src/objects.rs:any_type_id+1:4: `std::any::Any::type_id` of `dyn std::any::Any`, which is not supported yet +fixtures/reject/src/objects.rs:any_type_id+1:17: unsupported call to `std::any::TypeId::of::` +fixtures/reject/src/objects.rs:any_upcast+1:32: an upcast from `dyn objects::Keyed` to `dyn std::any::Any`, which is not supported yet +fixtures/reject/src/objects.rs:dyn_size+1:2: unsupported call to `std::mem::size_of_val::` +fixtures/reject/src/objects.rs:dynamic+0:16: `dyn std::hash::Hasher`, a trait object of another crate's trait, which is not supported yet +fixtures/reject/src/objects.rs:dynamic+1:4: `dyn std::hash::Hasher`, a trait object of another crate's trait, which is not supported yet +fixtures/reject/src/objects.rs:first_of+1:26: a trait object of `[u8; 4]`, which is not supported yet +fixtures/reject/src/objects.rs:generic_object+0:23: `dyn objects::Scaled`, a trait object of the generic trait `objects::Scaled`, which is not supported yet +fixtures/reject/src/objects.rs:generic_object+1:4: `dyn objects::Scaled`, a trait object of the generic trait `objects::Scaled`, which is not supported yet +fixtures/reject/src/objects.rs:raw_dyn_iter+2:40: a coercion of `*mut std::ops::Range` to `*mut dyn std::iter::Iterator`, which is not supported yet +fixtures/reject/src/objects.rs:weak_any_upcast+1:46: an upcast from `dyn objects::Keyed` to `dyn std::any::Any`, which is not supported yet +fixtures/reject/src/parts.rs:array_part+1:9: a raw pointer to `std::cell::UnsafeCell` in `parts::InArray`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:array_part_replaced+3:33: a reference through which a raw pointer may be made into `parts::InArray` in `[parts::InArray; 2]`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:element_replaced+2:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `[std::cell::UnsafeCell; 2]`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:field_part+1:9: a raw pointer to `std::cell::UnsafeCell` in `parts::InField`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:field_part_replaced+3:33: a reference through which a raw pointer may be made into `parts::Mid` in `parts::Outer`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:generic_part+1:9: a raw pointer to `std::cell::UnsafeCell` in `parts::InGeneric`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:generic_part_replaced+3:35: a reference through which a raw pointer may be made into `parts::Mid` in `parts::Outer`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:nested_part+1:9: a raw pointer to `std::cell::UnsafeCell` in `parts::InNested`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:nested_part_replaced+3:34: a reference through which a raw pointer may be made into `parts::Mid` in `parts::Outer`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:part_assigned+4:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `parts::Assigned`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:part_mem_replaced+4:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `parts::Replaced`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:part_replaced_closure+5:15: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `parts::Closed`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:part_replaced_deep+4:22: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `parts::Deeper`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:part_replaced_dyn+4:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `parts::Dynamic`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:part_swapped+4:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `parts::Swapped`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:part_taken+4:20: a reference through which a raw pointer may be made into `std::cell::UnsafeCell` in `parts::Taken`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:payload_part+1:9: a raw pointer to `std::cell::UnsafeCell` in `parts::InPayload`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:payload_part_replaced+3:11: a reference through which a raw pointer may be made into `parts::InPayload` in an element, a payload, or a union field, which is not supported yet +fixtures/reject/src/parts.rs:tuple_part+1:9: a raw pointer to `std::cell::UnsafeCell` in `parts::InTuple`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:tuple_part_replaced+3:33: a reference through which a raw pointer may be made into `parts::InTuple` in `(u16, parts::InTuple)`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:written_part+1:9: a raw pointer to `std::cell::UnsafeCell` in `parts::InWritten`, which the crate may put another object in place of +fixtures/reject/src/parts.rs:written_part_replaced+3:35: a reference through which a raw pointer may be made into `parts::InWritten` in `[parts::InWritten; 1]`, which the crate may put another object in place of +fixtures/reject/src/places.rs:copied_closure+6:14: a copy of a closure that changes what it captured +fixtures/reject/src/places.rs:mapped_closure+2:10: a mapped guard of `{closure@fixtures/reject/src/places.rs:mapped_closure+1:38: +1:50}`, which JS can't write in place +fixtures/reject/src/places.rs:ok_passed+1:12: a mutable reference into a `Result`'s payload, passed on or kept +fixtures/reject/src/places.rs:optional_places_compared+2:2: comparing pointers to `u32`, each a place JS makes of its own +fixtures/reject/src/places.rs:places_compared+3:2: comparing pointers to `u32`, each a place JS makes of its own +fixtures/reject/src/places.rs:places_equal+1:2: unsupported call to ` as std::cmp::PartialEq>::eq` +fixtures/reject/src/places.rs:rebound_reference+7:14: a copy of a closure that changes what it captured +fixtures/reject/src/places.rs:rebound_reference+8:14: a copy of a closure that changes what it captured +fixtures/reject/src/places.rs:replace_boxed_bytes+4:2: replacing the value behind a reference to `std::pin::Pin>` +fixtures/reject/src/places.rs:replace_boxed_future+4:2: an assignment through a reference to `std::pin::Pin>>` +fixtures/reject/src/places.rs:replace_boxed_poll_fn+4:2: replacing the value behind a reference to `std::pin::Pin fn(&'a mut std::task::Context<'b>) -> std::task::Poll>>>` +fixtures/reject/src/places.rs:replace_guard+1:2: an assignment through a reference to `std::sync::MutexGuard<'_, u8>` +fixtures/reject/src/places.rs:replace_pinned_ref+1:2: an assignment through a reference to `std::pin::Pin<&mut places::Noisy>` +fixtures/reject/src/places.rs:swap_guards+1:2: replacing the value behind a reference to `std::sync::MutexGuard<'_, u8>` +fixtures/reject/src/pointers.rs:assigned_through+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:byte_pointer_ops+5:3: a copy between pointers to `[u8; 4]`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:byte_pointer_ops+6:3: a copy between pointers to `[u8; 4]`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:byte_pointer_ops+7:14: unsupported call to `std::ptr::addr_eq::<[u8; 4], [u8; 4]>` +fixtures/reject/src/pointers.rs:byte_pointer_ops+7:41: comparing `*mut [u8; 4]` +fixtures/reject/src/pointers.rs:byte_pointer_ops+8:56: an offset of a pointer to `[u8; 4]`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:byte_pointer_ops+8:73: an offset of a pointer to `[u8; 4]`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:byte_pointer_ops+11:5: hashing `*const [u8; 4]` by its address, which JS has no counterpart of +fixtures/reject/src/pointers.rs:byte_pointer_parts+3:15: a raw pointer to `[u8; 3]` in an element, a payload, or a union field, which is not supported yet +fixtures/reject/src/pointers.rs:byte_pointer_parts+3:18: a raw pointer to `[u8; 3]` in an element, a payload, or a union field, which is not supported yet +fixtures/reject/src/pointers.rs:byte_pointer_parts+3:37: a raw pointer to `[u8; 2]` in an element, a payload, or a union field, which is not supported yet +fixtures/reject/src/pointers.rs:byte_pointer_parts+3:44: a raw pointer to `[u8; 2]` in an element, a payload, or a union field, which is not supported yet +fixtures/reject/src/pointers.rs:byte_pointer_rebound+2:26: a raw pointer to `[u8; 4]` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:byte_pointer_rebound+2:26: a reference to `[u8; 4]`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/pointers.rs:byte_pointer_rebound+3:10: a raw pointer to `[u8; 4]` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:byte_slice_of_place+1:2: a slice of one byte's place, which a byte slice can view only in an array of bytes +fixtures/reject/src/pointers.rs:cast_reassigned+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:cell_field_replaced+4:21: a raw pointer to `std::cell::UnsafeCell` in `pointers::Hits`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:cell_reassigned+2:15: a raw pointer to `std::cell::UnsafeCell` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:cell_replaced+2:15: a raw pointer to `(u32, u32)` in `std::cell::UnsafeCell<(u32, u32)>`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:cell_taken+2:15: a raw pointer to `std::cell::UnsafeCell` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:closure_replaced+3:19: a raw pointer to `(u32, u32)` in `pointers::Lane`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:element_pointer+2:10: a raw pointer to `(u32, u32)` in an element, a payload, or a union field, which is not supported yet +fixtures/reject/src/pointers.rs:element_to_array+1:13: a cast from a pointer to `u32` to one to `[u32; 2]`, which reads the bytes of one type as another +fixtures/reject/src/pointers.rs:elements_replaced+2:10: a raw pointer to `[u32; 3]` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:elements_replaced+4:10: a raw pointer to `[u32; 3]` in `pointers::Lanes`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:lone_byte_slices+1:12: a raw or mutable slice of a byte in no array of bytes +fixtures/reject/src/pointers.rs:lone_byte_slices+2:19: a raw or mutable slice of a byte in no array of bytes +fixtures/reject/src/pointers.rs:made_part_replaced+5:10: a raw pointer to `(u32, u32)` in `pointers::Gap`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:made_part_replaced+6:10: a raw pointer to `(u32, u32)` in `pointers::Gap`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:made_part_replaced+7:58: a raw pointer to `(u32, u32)` in `pointers::Gap`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:nonnull_reassigned+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:object_elements+1:12: a pointer into `(u8, u8)`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:object_elements+3:13: an offset of a pointer to `(u8, u8)`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:object_elements+4:3: a copy between pointers to `(u8, u8)`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:object_elements+5:11: a slice from a pointer to `(u8, u8)`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:object_elements+6:30: a pointer into an array of `(u8, u8)`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:object_elements+7:36: `offset_from` of pointers to `(u8, u8)`, which JS keeps as an object that knows no array it is in +fixtures/reject/src/pointers.rs:object_replaced+2:19: a raw pointer to `(u32, u32)` in `pointers::Track`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:part_replaced+2:10: a raw pointer to `(u32, u32)` in `pointers::Span2`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:pointer_captured+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:pointer_in_struct+2:26: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:pointer_kept_across+2:17: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:pointer_kept_across+7:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:pointer_pushed+3:12: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:pointer_returned+2:22: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:pointers_apart+9:5: `offset_from` between a pointer into a value in no array and one into a value in no array, which JS keeps in different arrays +fixtures/reject/src/pointers.rs:pointers_apart+10:26: `offset_from` between a pointer into a value in no array and one into a value in no array, which JS keeps in different arrays +fixtures/reject/src/pointers.rs:pointers_apart+11:24: `offset_from` between a pointer into an array of this body's own and one into an array of this body's own, which JS keeps in different arrays +fixtures/reject/src/pointers.rs:pointers_apart+12:23: `offset_from` between a pointer into an array of this body's own and one into an array of this body's own, which JS keeps in different arrays +fixtures/reject/src/pointers.rs:pointers_apart+13:20: `offset_from` between a pointer into a shared slice JS copies and one into an array of this body's own, which JS keeps in different arrays +fixtures/reject/src/pointers.rs:pointers_apart+14:21: `offset_from` between a pointer into a shared slice JS copies and one into a value in no array, which JS keeps in different arrays +fixtures/reject/src/pointers.rs:put_replaced+2:10: a raw pointer to `(u32, u32)` in `pointers::Plain`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:range_of+1:2: a raw pointer to `(u32, u32)` in `pointers::Window`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:reached_out+4:3: a copy reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust +fixtures/reject/src/pointers.rs:reached_out+6:18: a pointer reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust +fixtures/reject/src/pointers.rs:reached_out+7:6: a slice reaching past a value in no array, which JS keeps apart from what holds it in Rust +fixtures/reject/src/pointers.rs:reached_out+8:27: a pointer reaching past a value in no array, which JS keeps apart from what holds it in Rust +fixtures/reject/src/pointers.rs:reached_out+9:21: a pointer reaching past a shared slice JS copies, which JS keeps apart from what holds it in Rust +fixtures/reject/src/pointers.rs:uninit_part_replaced+5:19: a raw pointer to `std::mem::MaybeUninit<(u32, u32)>` in `pointers::Gap`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:uninit_part_replaced+6:19: a raw pointer to `std::mem::MaybeUninit<(u32, u32)>` in `pointers::Gap`, which the crate may put another object in place of +fixtures/reject/src/pointers.rs:unit_elements+1:13: `offset_from` of pointers to `()`, which has no bytes +fixtures/reject/src/pointers.rs:unit_elements+1:39: a slice of `()`, which has no bytes, from a pointer +fixtures/reject/src/pointers.rs:variable_celled+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:variable_cloned_from+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:variable_cloned_into+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:variable_reassigned+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:variable_replaced+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:variable_swapped+3:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/rebound.rs:bytes_compared_rebound+2:19: a reference to `[u8; 4]`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:cell_rebound+2:18: a reference to `std::cell::UnsafeCell`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:chosen_compared_rebound+3:17: a reference to `rebound::Chosen`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:compared_rebound+2:22: a reference to `rebound::Compared`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:deep_cell_rebound+4:18: a reference to `rebound::Deep`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:enclosed_compared_rebound+2:22: a reference to `rebound::Enclosing`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:generic_cell_rebound+2:21: a reference to `rebound::Wrapped>`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:inside_cell_rebound+2:20: a reference to `rebound::Inside`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:inside_field_rebound+2:26: a reference to `rebound::Inside`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:payload_cell_rebound+2:21: a reference to `rebound::Slotted`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:read_behind_rebound+2:22: a reference to `rebound::Behind`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:ref_cell_rebound+2:20: a reference to `rebound::Shared`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/rebound.rs:retargeted+5:10: a raw pointer to `rebound::Target` in a variable assigned again while it may point there +fixtures/reject/src/rebound.rs:swap_retargeted+6:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/rebound.rs:swapped_in_loop+8:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/rebound.rs:unboxed_rebound+2:16: a reference to `rebound::Unboxed`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/statics.rs:key_celled+1: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 +fixtures/reject/src/statics.rs:lazy_assigned+1:2: an assignment through a reference to `std::sync::LazyLock` +fixtures/reject/src/statics.rs:lazy_celled+1: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/statics.rs:pointer_statics+3:15: comparing pointers to `u32` in an atomic, which JS has no address of +fixtures/reject/src/statics.rs:pointer_statics+4:3: a constant of type `&u32`, a pointer into memory translation can't name +fixtures/reject/src/statics.rs:statics+1:11: a mutable static, which any code may write +fixtures/reject/src/strs.rs:cow_borrowed+1:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +fixtures/reject/src/strs.rs:cow_bytes+1:2: unsupported call to `std::borrow::Cow::<'_, [u8]>::is_borrowed` +fixtures/reject/src/strs.rs:cow_made+2:53: constructing `std::borrow::Cow<'_, std::sync::Arc>` +fixtures/reject/src/strs.rs:cow_matched+1:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +fixtures/reject/src/strs.rs:cow_matched+2:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +fixtures/reject/src/strs.rs:cow_matched+3:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +fixtures/reject/src/strs.rs:str_bytes_mut+1:13: unsupported call to `core::str::::as_bytes_mut` +fixtures/reject/src/strs.rs:str_bytes_mut+2:13: `core::str::::get_unchecked_mut` with a mutable reference to a value JS copies, which its mapping would copy +fixtures/reject/src/strs.rs:str_from_bytes_mut+1:20: `std::str::from_utf8_mut` with a mutable reference to a value JS copies, which its mapping would copy +fixtures/reject/src/values.rs:addr_parsed+0:32: unsupported type `std::net::AddrParseError` from another crate +fixtures/reject/src/values.rs:addr_parsed+0:32: unsupported type `std::net::Ipv4Addr` from another crate +fixtures/reject/src/values.rs:addr_parsed+1:4: unsupported call to `core::str::::parse::` +fixtures/reject/src/values.rs:ascii_octal+1:4: unsupported call to `core::num::::is_ascii_octdigit` +fixtures/reject/src/values.rs:bits+1:10: union `values::Bits`, whose fields overlap in `u32` and `f64`, which JS keeps apart +fixtures/reject/src/values.rs:block_cloned+0:21: const generic types are not supported: `values::Block` +fixtures/reject/src/values.rs:dangling_enum+1:11: a dangling pointer to `values::Only`, a value of no bytes made of more than structs and tuples +fixtures/reject/src/values.rs:float+0:14: unsupported type `f16` +fixtures/reject/src/values.rs:float+0:25: unsupported type `f16` +fixtures/reject/src/values.rs:float+1:2: a scalar constant of type `f16` +fixtures/reject/src/values.rs:float+1:2: arithmetic on `f16` +fixtures/reject/src/values.rs:generic_unit+1:2: `values::Maybe<()>` is not supported: its field `value` is `Option`, typed `T | undefined`, whose `None` would be `rt.None` as `Option<()>` +fixtures/reject/src/values.rs:lists+1:4: `std::collections::LinkedList::::retain` with a mutable reference to a value JS copies, which its mapping would copy +fixtures/reject/src/values.rs:lists+2:4: `clone_from` of `std::collections::LinkedList`, whose items' `clone_from` is their own, which is not supported yet +fixtures/reject/src/values.rs:lists+3:2: `std::default::Default::default` with a mutable reference to a value JS copies, which its mapping would copy +fixtures/reject/src/values.rs:manual_impls+2:11: unsupported call to ` as std::fmt::Debug>::fmt` +fixtures/reject/src/values.rs:manual_impls+2:25: unsupported call to ` as std::cmp::PartialEq>::eq` +fixtures/reject/src/values.rs:manual_impls+2:34: a constant of type `std::mem::ManuallyDrop` +fixtures/reject/src/values.rs:nested+0:15: `Option>>` is not supported: its `None` and `Some` would both be `rt.None` +fixtures/reject/src/values.rs:nested+1:2: `Option>>` is not supported: its `None` and `Some` would both be `rt.None` +fixtures/reject/src/values.rs:reclone+3:13: a reference to `std::option::Option>`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there +fixtures/reject/src/values.rs:tail_read+1:30: a coercion to `&values::Tail`, which is not supported yet +fixtures/reject/src/values.rs:units_compared+2:15: a raw pointer to a place of `()`, which has no address of its own +fixtures/reject/src/values.rs:units_compared+2:29: a raw pointer to a place of `()`, which has no address of its own +fixtures/reject/src/values.rs:units_compared+2:70: comparing pointers to `places::Bare`, which has no bytes and so no address of its own diff --git a/ts/fixtures/reject/src/alloc.rs b/ts/fixtures/reject/src/alloc.rs new file mode 100644 index 000000000..dd4e03d8b --- /dev/null +++ b/ts/fixtures/reject/src/alloc.rs @@ -0,0 +1,71 @@ +//! Memory from `alloc` and raw pointers read as other types' bytes or as addresses. + +use crate::pointers::Halves; + +/// A pointer read as another type's bytes. +pub fn reinterpreted(n: u32) -> u8 { + unsafe { *(&raw const n).cast::() } +} + +/// A pointer's address, as an integer. +pub fn addressed(n: u32) -> usize { + (&raw const n).addr() +} + +/// Memory from the allocator as bytes, which JS keeps only as values a cast types it as. +pub fn allocated() -> u8 { + let layout = std::alloc::Layout::new::(); + unsafe { + let p = std::alloc::alloc(layout); + *p = 1; + let n = *p; + std::alloc::dealloc(p, layout); + n + } +} + +/// A pointer to a `Vec`, whose JS array is its heap, not where Rust keeps the `Vec`. +pub fn vec_pointer(v: &mut Vec) -> usize { + let p = &raw const *v; + unsafe { (*p).len() } +} + +/// Casts between pointers to bytes and to values outside memory from `alloc`, which read +/// the bytes of one type as another: of an array's bytes to `u32`s, of memory from +/// `alloc` to the crate's struct, which JS keeps as an object, and of a pointer to values +/// to one to their bytes, read rather than freed; and a byte of memory from `alloc` written +/// by `ptr::write`. +pub fn bytes_as_values(bytes: [u8; 4]) -> u32 { + let layout = std::alloc::Layout::new::(); + unsafe { + std::ptr::write(std::alloc::alloc(layout), 2); + let words = bytes.as_ptr() as *const u32; + let halves = std::alloc::alloc(layout) as *mut Halves; + let n = 7u32; + let byte = *((&raw const n) as *const u8); + *words + (*halves).low + u32::from(byte) + } +} + +/// Memory from `alloc` cast to pointers to two types, which reads one's bytes as the +/// other's, also once `realloc` grows it. +pub fn alloc_retyped() -> i32 { + let layout = std::alloc::Layout::new::(); + unsafe { + let raw = std::alloc::alloc(layout); + raw.cast::().write(u32::MAX); + let n = (raw as *mut i32).read(); + let grown = std::alloc::realloc(raw, layout, 8); + let m = grown.cast::().read(); + let words = grown.cast::(); + let again = std::alloc::realloc(words.cast::(), std::alloc::Layout::array::(2).unwrap(), 12); + let k = again.cast::().read(); + std::alloc::dealloc(again, std::alloc::Layout::array::(3).unwrap()); + n + m + k + } +} + +/// Memory from `alloc_zeroed`, whose zeroed bytes JS can't type. +pub fn zeroed() -> u32 { + unsafe { *(std::alloc::alloc_zeroed(std::alloc::Layout::new::()) as *mut u32) } +} diff --git a/ts/fixtures/reject/src/buffers.rs b/ts/fixtures/reject/src/buffers.rs new file mode 100644 index 000000000..7b2452488 --- /dev/null +++ b/ts/fixtures/reject/src/buffers.rs @@ -0,0 +1,76 @@ +//! `bytes`' buffers, and buffers of the crate's own, where JS's storage would tell apart what Rust's doesn't. + +/// An `Arc`'s bytes would need a `ByteSlice` made inside it. +pub fn shared(b: std::sync::Arc<[u8; 2]>) -> std::sync::Arc<[u8]> { + b +} + +/// An owner that drops, which would drop with the last clone of the `Bytes`. +pub fn owned_bytes(owner: std::sync::Arc<[u8]>) -> usize { + bytes::Bytes::from_owner(owner).len() +} + +/// A `BytesMut`'s capacity, which `bytes` reclaims only once the `Bytes` it froze drops. +pub fn bytes_mut_capacity(n: usize) -> usize { + let mut buf = bytes::BytesMut::with_capacity(n); + buf.extend_from_slice(b"frame"); + drop(buf.split_to(2).freeze()); + buf.reserve(n); + buf.capacity() +} + +/// `bytes` reads a `Buf` of the crate's own into a `BytesMut` by its `copy_to_bytes` only +/// at zero capacity. +pub fn bytes_mut_put(buf: &mut bytes::BytesMut, src: Counted) { + bytes::BufMut::put(buf, src); +} + +/// Through a `&mut`, `bytes` advances it by the room left in the `BytesMut`'s capacity. +pub fn bytes_mut_put_through(mut buf: &mut bytes::BytesMut, src: Counted) { + bytes::BufMut::put(&mut buf, src); +} + +/// A `Buf` whose `copy_to_bytes` differs from its `chunk` and `advance`. +pub struct Counted(pub bytes::Bytes); + +impl bytes::Buf for Counted { + fn remaining(&self) -> usize { + self.0.remaining() + } + + fn chunk(&self) -> &[u8] { + self.0.chunk() + } + + fn advance(&mut self, cnt: usize) { + self.0.advance(cnt); + } + + fn copy_to_bytes(&mut self, len: usize) -> bytes::Bytes { + bytes::Bytes::from(vec![0; len]) + } +} + +/// A buffer of the crate's own that JS copies, so `&mut` to it is an `rt.Place`, which the +/// provided `copy_to_bytes` doesn't read through. +pub enum Blank { + Empty, +} + +impl bytes::Buf for Blank { + fn remaining(&self) -> usize { + 0 + } + + fn chunk(&self) -> &[u8] { + &[] + } + + fn advance(&mut self, cnt: usize) { + assert_eq!(cnt, 0); + } +} + +pub fn blank_bytes(len: usize) -> usize { + bytes::Buf::copy_to_bytes(&mut Blank::Empty, len).len() +} diff --git a/ts/fixtures/reject/src/clones.rs b/ts/fixtures/reject/src/clones.rs new file mode 100644 index 000000000..0bcd596de --- /dev/null +++ b/ts/fixtures/reject/src/clones.rs @@ -0,0 +1,130 @@ +//! `clone_from` and `Clone` of the crate's own, which std calls where the translation would not. + +use crate::places::Noisy; + +pub fn refilled(v: &mut [Reused], r: Reused) { + v.fill(r); +} + +/// `clone_from_slice` calls `Reused`'s own `clone_from` for each element. +pub fn recloned(v: &mut [Reused], w: &[Reused]) { + v.clone_from_slice(w); +} + +/// A `clone_from` of its own, which `fill` calls for each slot but the last. +pub struct Reused(Vec); + +impl Clone for Reused { + fn clone(&self) -> Self { + Reused(self.0.clone()) + } + + fn clone_from(&mut self, source: &Self) { + self.0.clone_from(&source.0); + } +} + +/// 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); +} + +/// The tags of the first of two slots, each written whole as `fill` beside a pair of +/// tags, then changed through a pointer to them. +macro_rules! tagged_slots { + ($slots:ident) => {{ + let tags = unsafe { &raw mut $slots[0].assume_init_mut().1 }; + unsafe { + (*tags).0 ^= 1; + (*tags).0 + } + }}; +} + +#[derive(Clone, Copy)] +pub struct Cloned(pub u8); + +/// Slots of a type parameter's values written whole through an iterator zipped with +/// clones of them: std's code calls the crate's `Clone`, so the writes fill nothing fresh. +pub fn cloned_slots(fill: [Cloned; 2]) -> u8 { + kept_slots(fill) +} + +fn kept_slots(fill: [T; 2]) -> u8 { + let mut slots: [std::mem::MaybeUninit<([T; 2], (u8, u8))>; 2] = [const { std::mem::MaybeUninit::uninit() }; 2]; + for (slot, value) in slots.iter_mut().zip(fill.iter().cloned()) { + slot.write(([value.clone(), value], (0, 1))); + } + tagged_slots!(slots) +} + +pub struct Dropped(pub Noisy); + +/// [`cloned_slots`] zipped with a vector's values, which std's iterator drops through +/// the crate's `Drop` of a field. +pub fn dropped_slots(fill: Vec) -> u8 { + moved_slots(fill) +} + +fn moved_slots(fill: Vec) -> u8 { + let mut slots: [std::mem::MaybeUninit<(T, (u8, u8))>; 2] = [const { std::mem::MaybeUninit::uninit() }; 2]; + for (slot, value) in slots.iter_mut().zip(fill) { + slot.write((value, (0, 1))); + } + tagged_slots!(slots) +} + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +pub struct Greatest(pub u8); + +/// A slot written whole through the greatest of a type parameter's values, which std +/// finds through the crate's `Ord`. +pub fn ranked_slots(fill: [Greatest; 2]) -> u8 { + greatest_slot(fill) +} + +fn greatest_slot(fill: [T; 2]) -> u8 { + let mut slots: [([T; 2], (u8, u8)); 2] = [(fill, (0, 0)); 2]; + let Some(top) = slots.iter_mut().max() else { + return 0; + }; + *top = (fill, (1, 2)); + let tags = &raw mut top.1; + unsafe { + (*tags).0 ^= 1; + (*tags).0 + } +} + +/// What a type parameter's value does to a slot of it. +pub trait Touch: Sized { + fn touch(&self, slot: &mut std::mem::MaybeUninit<([Self; 2], (u8, u8))>); +} + +#[derive(Clone, Copy)] +pub struct Touched(pub u8); + +impl Touch for Touched { + fn touch(&self, _: &mut std::mem::MaybeUninit<([Self; 2], (u8, u8))>) {} +} + +/// [`cloned_slots`] where each slot is first given to the crate's own trait, through +/// the type parameter's bound. +pub fn touched_slots(fill: [Touched; 2]) -> u8 { + given_slots(fill) +} + +fn given_slots(fill: [T; 2]) -> u8 { + let mut slots: [std::mem::MaybeUninit<([T; 2], (u8, u8))>; 2] = [const { std::mem::MaybeUninit::uninit() }; 2]; + for (slot, at) in slots.iter_mut().zip(0u8..) { + fill[0].touch(slot); + slot.write((fill, (at, !at))); + } + tagged_slots!(slots) +} diff --git a/ts/fixtures/reject/src/config.rs b/ts/fixtures/reject/src/config.rs new file mode 100644 index 000000000..03339b2fd --- /dev/null +++ b/ts/fixtures/reject/src/config.rs @@ -0,0 +1,8 @@ +//! What the config names that translation can't take as a root or a printable type. + +pub struct Meters(pub u64); + +pub fn generic>(t: &mut T) -> f16 { + // A census lowers this over `T`: what hinges on `T` waits for an instance, the float does not. + (*t).into() as f16 +} diff --git a/ts/fixtures/reject/src/fmt.rs b/ts/fixtures/reject/src/fmt.rs new file mode 100644 index 000000000..1e8b23741 --- /dev/null +++ b/ts/fixtures/reject/src/fmt.rs @@ -0,0 +1,21 @@ +//! Formatting the runtime doesn't do as std does. + +/// A pointer's address, which JS has no counterpart of. +pub fn pointer(n: u8) -> String { + format!("{:p}", &n) +} + +/// A placeholder written to the crate's own `fmt::Write`, which sees each call std makes. +pub fn written(w: &mut Sink, n: u8) { + use std::fmt::Write; + let _ = write!(w, "{n}"); +} + +pub struct Sink(u8); + +impl std::fmt::Write for Sink { + fn write_str(&mut self, s: &str) -> std::fmt::Result { + self.0 = self.0.wrapping_add(s.len() as u8); + Ok(()) + } +} diff --git a/ts/fixtures/reject/src/futures.rs b/ts/fixtures/reject/src/futures.rs new file mode 100644 index 000000000..269566cf7 --- /dev/null +++ b/ts/fixtures/reject/src/futures.rs @@ -0,0 +1,39 @@ +//! Futures and polls whose `Pending`s JS can't tell apart. + +/// `Ready(Some(Ready(Pending)))` would be `rt.OuterPending`, as the outer `Pending` is. +pub fn nested_poll(p: std::task::Poll>>>) -> bool { + matches!(p, std::task::Poll::Pending) +} + +/// A future's `Ready(Pending)` would be `rt.Pending`, as its own pending is. +pub async fn pending_output() -> std::task::Poll { + std::task::Poll::Pending +} + +/// A generic type's `Poll` is `rt.Poll`, which can't hold `rt.OuterPending`, the +/// `Pending` of a `Poll>`. +pub struct Waiting { + pub poll: std::task::Poll, +} + +pub fn generic_pending(poll: std::task::Poll>) -> bool { + Waiting { poll }.poll.is_pending() +} + +/// A census lowers this over `F` and `O`, and `awaited`'s body with it, whose closure names +/// `O` as this function's second type parameter: that refuses nothing. +pub async fn generic_awaited u8, O: std::future::Future>(f: F, o: O) -> u8 { + f() + awaited(o).await +} + +async fn awaited>(o: O) -> u8 { + let mut o = std::pin::pin!(o); + std::future::poll_fn(|cx| poll_pinned(o.as_mut(), cx)).await +} + +fn poll_pinned( + o: std::pin::Pin<&mut O>, + cx: &mut std::task::Context<'_>, +) -> std::task::Poll { + o.poll(cx) +} diff --git a/ts/fixtures/reject/src/iters.rs b/ts/fixtures/reject/src/iters.rs new file mode 100644 index 000000000..76620466b --- /dev/null +++ b/ts/fixtures/reject/src/iters.rs @@ -0,0 +1,98 @@ +//! Iterators and collections of the crate's own that override what std's adaptors call. + +/// `scan` of items that can be `undefined`: its closure's `None` and `Some(None)` would both be. +pub fn scanned(v: &[u8]) -> usize { + v.iter() + .scan(Vec::::new(), |_, &b| Some((b > 1).then_some(b))) + .count() +} + +/// An iterator whose `fold` std's adaptors would call in place of its `next`. +pub struct Folds; + +impl Iterator for Folds { + type Item = u8; + + fn next(&mut self) -> Option { + None + } + + fn fold B>(self, init: B, _f: F) -> B { + init + } +} + +pub fn folds() -> usize { + Folds.map(|b| b + 1).count() +} + +/// An iterator whose `nth_back` std's adaptors would call in place of its `next_back`. +pub struct Backs; + +impl Iterator for Backs { + type Item = u8; + + fn next(&mut self) -> Option { + None + } +} + +impl DoubleEndedIterator for Backs { + fn next_back(&mut self) -> Option { + None + } + + fn nth_back(&mut self, _n: usize) -> Option { + Some(0) + } +} + +pub fn backs() -> usize { + Backs.rev().skip(1).count() +} + +/// `scan` of `()`s: its closure's `None` and `Some(())` would both be `undefined`. +pub fn scanned_unit(v: &[u8]) -> usize { + v.iter().scan(Vec::::new(), |_, _| Some(())).count() +} + +pub struct Part(pub u64); + +impl std::iter::Sum for std::time::Duration { + fn sum>(parts: I) -> Self { + std::time::Duration::from_secs(parts.map(|p| p.0 * 2).sum()) + } +} + +impl std::iter::Sum for u64 { + fn sum>(parts: I) -> Self { + parts.map(|p| p.0 * 2).sum() + } +} + +/// A `Sum` of the crate's into a std type, which std's `Sum` mapping would bypass. +pub fn parts_summed(a: Vec, b: Vec) -> (std::time::Duration, u64) { + (a.into_iter().sum(), b.into_iter().sum()) +} + +/// A collection of the crate's own that overrides `extend_one`, which a tuple's `Extend` +/// calls, as only a nightly crate can. +#[derive(Default)] +pub struct Tens(pub u8); + +impl Extend for Tens { + fn extend>(&mut self, iter: I) { + for b in iter { + self.0 = self.0.wrapping_add(b); + } + } + + fn extend_one(&mut self, item: u8) { + self.0 = self.0.wrapping_add(item).wrapping_mul(10); + } +} + +/// A tuple of collections, one of them the crate's own that overrides `extend_one`. +pub fn tens(data: &[u8]) -> (Vec, Tens) { + data.iter().map(|&b| (b, b)).collect() +} diff --git a/ts/fixtures/reject/src/kept.rs b/ts/fixtures/reject/src/kept.rs new file mode 100644 index 000000000..ab0d31891 --- /dev/null +++ b/ts/fixtures/reject/src/kept.rs @@ -0,0 +1,434 @@ +//! Pointers kept in memory, structs, and slots, read after a whole write replaced what they point at. + +use crate::parts::cell; + +/// Structs JS keeps as objects, each holding an `rt.Cell` of an object, one for each write +/// of fresh memory made while a pointer into it may still be read, which gives the cell +/// another object. +pub struct Escaped(pub std::cell::UnsafeCell<(u16, u16)>); + +pub struct Called(pub std::cell::UnsafeCell<(u16, u16)>); + +pub struct Looped(pub std::cell::UnsafeCell<(u16, u16)>); + +pub struct Aliased(pub std::cell::UnsafeCell<(u16, u16)>); + +pub struct Rewritten(pub std::cell::UnsafeCell<(u16, u16)>); + +pub struct Keeper { + pub whole: *mut Escaped, + pub part: *mut (u16, u16), +} + +fn keep_part(keeper: &mut Keeper) { + keeper.part = unsafe { (*keeper.whole).0.get() }; +} + +/// A fresh allocation written whole again after its pointer escaped into a struct. +pub fn escaped_into_struct(n: u16, keeper: &mut Keeper) -> u16 { + let p = Box::into_raw(Box::new(std::mem::MaybeUninit::::uninit())).cast::(); + unsafe { p.write(Escaped(std::cell::UnsafeCell::new((n, n)))) }; + keeper.whole = p; + keep_part(keeper); + unsafe { p.write(Escaped(std::cell::UnsafeCell::new((0, 0)))) }; + unsafe { (*keeper.part).0 } +} + +fn kept_part(p: *mut Called, kept: &mut Vec<*mut (u16, u16)>) { + kept.push(unsafe { (*p).0.get() }); +} + +/// A fresh allocation written whole again after its pointer escaped into a call. +pub fn escaped_into_call(n: u16) -> u16 { + let p = Box::into_raw(Box::new(std::mem::MaybeUninit::::uninit())).cast::(); + unsafe { p.write(Called(std::cell::UnsafeCell::new((n, n)))) }; + let mut kept = Vec::new(); + kept_part(p, &mut kept); + unsafe { p.write(Called(std::cell::UnsafeCell::new((0, 0)))) }; + unsafe { (*kept[0]).0 } +} + +/// A fresh allocation written whole in each iteration, read after through the pointer an +/// earlier iteration took into it. +pub fn kept_across_writes(data: &[u16]) -> u16 { + let p = Box::into_raw(Box::new(std::mem::MaybeUninit::::uninit())).cast::(); + let mut kept: *mut (u16, u16) = std::ptr::null_mut(); + let mut sum = 0; + for &n in data { + unsafe { p.write(Looped(std::cell::UnsafeCell::new((n, n)))) }; + if !kept.is_null() { + sum += unsafe { (*kept).0 }; + } + kept = unsafe { (*p).0.get() }; + } + sum +} + +/// A fresh allocation written whole through an alias of its pointer while a pointer into it +/// may still be read. +pub fn written_through_alias(n: u16) -> u16 { + let p = Box::into_raw(Box::new(std::mem::MaybeUninit::::uninit())).cast::(); + unsafe { p.write(Aliased(std::cell::UnsafeCell::new((n, n)))) }; + let part = unsafe { (*p).0.get() }; + let alias = p; + unsafe { alias.write(Aliased(std::cell::UnsafeCell::new((0, 0)))) }; + unsafe { (*part).0 } +} + +/// A `MaybeUninit` written whole again while a pointer into it may still be read. +pub fn uninit_rewritten(n: u16) -> u16 { + let mut slot = std::mem::MaybeUninit::::uninit(); + slot.write(Rewritten(std::cell::UnsafeCell::new((n, n)))); + let part = unsafe { slot.assume_init_ref().0.get() }; + slot.write(Rewritten(std::cell::UnsafeCell::new((0, 0)))); + unsafe { (*part).0 } +} + +pub struct Loaded(pub std::cell::UnsafeCell<(u16, u16)>); + +/// A fresh allocation written whole again through a pointer to it read out of another +/// allocation, while a pointer into it may still be read. +pub fn written_through_loaded(n: u16) -> u16 { + let p = Box::into_raw(Box::new(std::mem::MaybeUninit::::uninit())).cast::(); + unsafe { p.write(Loaded(std::cell::UnsafeCell::new((n, n)))) }; + let part = unsafe { (*p).0.get() }; + let container = Box::into_raw(Box::new(p.cast_const())); + unsafe { + container + .read() + .cast_mut() + .write(Loaded(std::cell::UnsafeCell::new((0, 0)))) + }; + unsafe { (*part).0 } +} + +/// Structs JS keeps as objects, each written whole into slots through std's iterators +/// while a pointer into one may still be read, which gives what holds it another object. +pub struct Mapped(pub std::cell::UnsafeCell<(u16, u16)>); + +pub struct Repeated(pub std::cell::UnsafeCell<(u16, u16)>); + +pub struct Onced(pub std::cell::UnsafeCell<(u16, u16)>); + +pub struct Pushed { + pub part: (u16, u16), +} + +pub struct Copied { + pub span: (u16, u16), +} + +std::thread_local! { + static COPIED: std::cell::Cell<*const (u16, u16)> = const { std::cell::Cell::new(std::ptr::null()) }; +} + +/// A clone that keeps a pointer into what it copies. +impl Clone for Copied { + fn clone(&self) -> Self { + COPIED.with(|kept| kept.set(&raw const self.span)); + Copied { span: self.span } + } +} + +/// Slots written through an iterator whose closure keeps a pointer into each before it is +/// written. +pub fn mapped_kept(n: u16) -> u16 { + let mut slots = [const { std::mem::MaybeUninit::::uninit() }; 2]; + let mut kept: *mut (u16, u16) = std::ptr::null_mut(); + for slot in slots.iter_mut().map(|s| { + kept = unsafe { (*s.as_mut_ptr()).0.get() }; + s + }) { + slot.write(Mapped(std::cell::UnsafeCell::new((n, n)))); + } + unsafe { (*kept).0 } +} + +/// A slot written whole again after `cloned` handed it to the crate's `Clone`, which kept +/// a pointer into it. +pub fn cloned_kept(n: u16) -> u16 { + let mut slots = [const { std::mem::MaybeUninit::::uninit() }; 1]; + for slot in &mut slots { + slot.write(Copied { span: (n, n) }); + } + let copies: Vec = std::iter::once(unsafe { slots[0].assume_init_ref() }) + .cloned() + .collect(); + slots[0].write(Copied { span: (0, 0) }); + COPIED.with(|kept| unsafe { (*kept.get()).0 }) + copies.len() as u16 +} + +/// Slots written whole on each pass, read after through the pointer a write on the pass +/// before took into the same slot. +pub fn kept_across_iterations(data: &[u16]) -> u16 { + let mut slots = [const { std::mem::MaybeUninit::::uninit() }; 1]; + let mut kept: *mut (u16, u16) = std::ptr::null_mut(); + let mut sum = 0; + for &n in data { + for slot in slots.iter_mut() { + let made = slot.write(Repeated(std::cell::UnsafeCell::new((n, n)))); + if !kept.is_null() { + sum += unsafe { (*kept).0 }; + } + kept = made.0.get(); + } + } + sum +} + +/// A slot written whole through a borrow that std's `once` handed the crate a mutable +/// borrow of, which pointed it at memory a pointer into may still be read. +pub fn lent_kept(n: u16) -> u16 { + let mut slots = [const { std::mem::MaybeUninit::::uninit() }; 1]; + let mut old = std::mem::MaybeUninit::::uninit(); + old.write(Onced(std::cell::UnsafeCell::new((n, n)))); + let part = unsafe { old.assume_init_ref().0.get() }; + let mut slot: &mut std::mem::MaybeUninit = &mut slots[0]; + if let Some(lent) = std::iter::once(&mut slot).next() { + *lent = &mut old; + } + slot.write(Onced(std::cell::UnsafeCell::new((0, 0)))); + unsafe { (*part).0 } +} + +/// An element of memory `Vec::push` allocated, written whole while a pointer into it may +/// still be read. +pub fn pushed_part_kept(n: u16) -> u16 { + let mut v = Vec::new(); + v.push(Pushed { part: (n, n) }); + let p = &raw mut v[0]; + let part = unsafe { &raw mut (*p).part }; + unsafe { p.write(Pushed { part: (0, 0) }) }; + unsafe { (*part).0 } +} + +/// Structs JS keeps as objects, each holding an `rt.Cell`, one for each path by which a +/// pointer kept in memory reaches a whole write of what it points at, which gives it +/// another cell, while a pointer to the cell, taken through a reference to the struct, +/// may still be read. +pub struct ByRead(pub std::cell::UnsafeCell); + +pub struct ByWrite(pub std::cell::UnsafeCell); + +pub struct BySwap(pub std::cell::UnsafeCell); + +pub struct ByReplace(pub std::cell::UnsafeCell); + +pub struct ByBox(pub std::cell::UnsafeCell); + +pub struct ByClosure(pub std::cell::UnsafeCell); + +pub struct ByObject(pub std::cell::UnsafeCell); + +pub struct ByInstance(pub std::cell::UnsafeCell); + +pub struct BySwapped(pub std::cell::UnsafeCell); + +pub struct ByExchanged(pub std::cell::UnsafeCell); + +/// A pointer kept in memory, which only the crate's own code reads back. +pub struct Kept { + pub at: *mut T, +} + +impl Kept { + fn put(&self, value: T) { + unsafe { *self.at = value } + } +} + +pub trait Put { + fn put(&self); +} + +impl Put for Kept { + fn put(&self) { + unsafe { *self.at = ByObject(cell(0)) } + } +} + +/// Read back from memory, then written whole through. +pub fn kept_read(n: u16) -> u16 { + let mut whole = ByRead(cell(n)); + let mut kept = Kept { + at: std::ptr::null_mut(), + }; + kept.at = &raw mut whole; + let part = unsafe { (*kept.at).0.get() }; + let at = kept.at; + unsafe { *at = ByRead(cell(0)) }; + unsafe { *part } +} + +/// Read back from memory, then written whole by `ptr::write`. +pub fn kept_written(n: u16) -> u16 { + let mut whole = ByWrite(cell(n)); + let mut kept = Kept { + at: std::ptr::null_mut(), + }; + kept.at = &raw mut whole; + let part = unsafe { (*kept.at).0.get() }; + unsafe { kept.at.write(ByWrite(cell(0))) }; + unsafe { *part } +} + +/// Read back from memory, then swapped whole by `ptr::swap`. +pub fn kept_swapped(n: u16) -> u16 { + let mut whole = BySwap(cell(n)); + let mut other = BySwap(cell(0)); + let mut kept = Kept { + at: std::ptr::null_mut(), + }; + kept.at = &raw mut whole; + let part = unsafe { (*kept.at).0.get() }; + unsafe { std::ptr::swap(kept.at, &raw mut other) }; + unsafe { *part } +} + +/// Read back from memory, then replaced whole by `mem::replace` through a `&mut`. +pub fn kept_replaced(n: u16) -> u16 { + let mut whole = ByReplace(cell(n)); + let mut kept = Kept { + at: std::ptr::null_mut(), + }; + kept.at = &raw mut whole; + let part = unsafe { (*kept.at).0.get() }; + drop(std::mem::replace(unsafe { &mut *kept.at }, ByReplace(cell(0)))); + unsafe { *part } +} + +/// Read back from memory into `Box::from_raw`, then written whole through the box. +pub fn kept_boxed(n: u16) -> u16 { + let mut kept = Kept { + at: std::ptr::null_mut(), + }; + kept.at = Box::into_raw(Box::new(ByBox(cell(n)))); + let part = unsafe { (*kept.at).0.get() }; + let mut boxed = unsafe { Box::from_raw(kept.at) }; + *boxed = ByBox(cell(0)); + let read = unsafe { *part }; + drop(boxed); + read +} + +/// Read back from memory by a closure, which writes whole through it. +pub fn kept_called(n: u16) -> u16 { + let mut whole = ByClosure(cell(n)); + let mut kept = Kept { + at: std::ptr::null_mut(), + }; + kept.at = &raw mut whole; + let part = unsafe { (*kept.at).0.get() }; + let put: Box = Box::new(|| unsafe { *kept.at = ByClosure(cell(0)) }); + put(); + unsafe { *part } +} + +/// Read back from memory by a trait object's method, which writes whole through it. +pub fn kept_object(n: u16) -> u16 { + let mut whole = ByObject(cell(n)); + let mut kept = Kept { + at: std::ptr::null_mut(), + }; + kept.at = &raw mut whole; + let part = unsafe { (*kept.at).0.get() }; + let put: &dyn Put = &kept; + put.put(); + unsafe { *part } +} + +/// Read back from memory by a generic method, which writes whole through it. +pub fn kept_instance(n: u16) -> u16 { + let mut whole = ByInstance(cell(n)); + let mut kept = Kept { + at: std::ptr::null_mut(), + }; + kept.at = &raw mut whole; + let part = unsafe { (*kept.at).0.get() }; + kept.put(ByInstance(cell(0))); + unsafe { *part } +} + +/// Given to an atomic, handed back by its `swap`, then written whole through. +pub fn atomic_swapped(n: u16) -> u16 { + let mut whole = BySwapped(cell(n)); + let atomic = std::sync::atomic::AtomicPtr::new(&raw mut whole); + let part = unsafe { (*atomic.load(std::sync::atomic::Ordering::SeqCst)).0.get() }; + let at = atomic.swap(std::ptr::null_mut(), std::sync::atomic::Ordering::SeqCst); + unsafe { *at = BySwapped(cell(0)) }; + unsafe { *part } +} + +/// Given to an atomic, handed back by its `compare_exchange`, then written whole through. +pub fn atomic_exchanged(n: u16) -> u16 { + let mut whole = ByExchanged(cell(n)); + let at = &raw mut whole; + let atomic = std::sync::atomic::AtomicPtr::new(at); + let part = unsafe { (*at).0.get() }; + let order = std::sync::atomic::Ordering::SeqCst; + if let Ok(at) = atomic.compare_exchange(at, std::ptr::null_mut(), order, order) { + unsafe { *at = ByExchanged(cell(0)) }; + } + unsafe { *part } +} + +/// Structs JS keeps as objects, each holding an `rt.Cell`, one for each std function that +/// puts another object in place of a `RefCell`'s value through a shared reference, while a +/// pointer to the cell, taken through a borrow of that value, may still be read. +pub struct ByRefReplace(pub std::cell::UnsafeCell); + +#[derive(Default)] +pub struct ByRefTake(pub std::cell::UnsafeCell); + +pub struct ByKeySet(pub std::cell::UnsafeCell); + +pub struct ByKeyReplace(pub std::cell::UnsafeCell); + +#[derive(Default)] +pub struct ByKeyTake(pub std::cell::UnsafeCell); + +std::thread_local! { + static KEY_SET: std::cell::RefCell<(u16, ByKeySet)> = const { std::cell::RefCell::new((0, ByKeySet(std::cell::UnsafeCell::new(0)))) }; + static KEY_REPLACE: std::cell::RefCell<(u16, ByKeyReplace)> = const { std::cell::RefCell::new((0, ByKeyReplace(std::cell::UnsafeCell::new(0)))) }; + static KEY_TAKE: std::cell::RefCell<(u16, ByKeyTake)> = const { std::cell::RefCell::new((0, ByKeyTake(std::cell::UnsafeCell::new(0)))) }; +} + +/// Replaced by `RefCell::replace`. +pub fn ref_replaced(n: u16) -> u16 { + let whole = std::cell::RefCell::new((n, ByRefReplace(cell(n)))); + let part = whole.borrow().1.0.get(); + drop(whole.replace((0, ByRefReplace(cell(0))))); + unsafe { *part } +} + +/// Replaced by `RefCell::take`. +pub fn ref_taken(n: u16) -> u16 { + let whole = std::cell::RefCell::new((n, ByRefTake(cell(n)))); + let part = whole.borrow().1.0.get(); + drop(whole.take()); + unsafe { *part } +} + +/// Replaced by a thread-local `RefCell`'s `set`. +pub fn key_set(n: u16) -> u16 { + KEY_SET.set((n, ByKeySet(cell(n)))); + let part = KEY_SET.with_borrow(|whole| whole.1.0.get()); + KEY_SET.set((0, ByKeySet(cell(0)))); + unsafe { *part } +} + +/// Replaced by a thread-local `RefCell`'s `replace`. +pub fn key_replaced(n: u16) -> u16 { + drop(KEY_REPLACE.replace((n, ByKeyReplace(cell(n))))); + let part = KEY_REPLACE.with_borrow(|whole| whole.1.0.get()); + drop(KEY_REPLACE.replace((0, ByKeyReplace(cell(0))))); + unsafe { *part } +} + +/// Replaced by a thread-local `RefCell`'s `take`. +pub fn key_taken(n: u16) -> u16 { + let part = KEY_TAKE.with_borrow(|whole| whole.1.0.get()); + unsafe { *part = n }; + drop(KEY_TAKE.take()); + unsafe { *part } +} diff --git a/ts/fixtures/reject/src/keys.rs b/ts/fixtures/reject/src/keys.rs new file mode 100644 index 000000000..7948d4664 --- /dev/null +++ b/ts/fixtures/reject/src/keys.rs @@ -0,0 +1,137 @@ +//! Keys and orders of the crate's own, which the runtime's collections and comparisons don't call. + +use crate::places::Noisy; + +/// JS compares objects by identity, not by `PartialOrd`. +#[derive(PartialEq, PartialOrd)] +pub struct Key(pub u8); + +pub fn keyed(range: std::ops::Range) -> bool { + range.contains(&Key(2)) +} + +/// A key the runtime has no `Hash` and `Eq` of. +pub fn set_keys() -> usize { + let map: std::collections::HashMap, u8> = std::collections::HashMap::new(); + map.len() +} + +/// A key whose `Hash` and `Eq` agree with a `u8`'s, but which is a JS object. +#[derive(PartialEq, Eq, Hash)] +pub struct Id { + pub n: u8, +} + +impl std::borrow::Borrow for Id { + fn borrow(&self) -> &u8 { + &self.n + } +} + +/// Looked up by a `u8`, which the map would look for among its primitive keys. +pub fn borrowed(map: &std::collections::HashMap) -> bool { + map.contains_key(&1) +} + +/// `max` drops the operand it doesn't return, which the runtime's leaves undropped. +pub fn widest(a: std::sync::Arc, b: std::sync::Arc) -> std::sync::Arc { + a.max(b) +} + +/// std hands its closure a `&mut` to a value JS copies, which its mapping has as the value. +pub fn passed(map: &mut std::collections::HashMap) -> u8 { + map.get_mut(&1).map_or(0, |v| { + *v += 1; + *v + }) +} + +/// A `hash_slice` of its own, which a `Vec`'s `Hash` calls where the translation hashes each +/// element. +#[derive(PartialEq, Eq)] +pub struct Batched(u8); + +impl std::hash::Hash for Batched { + fn hash(&self, state: &mut H) { + self.0.hash(state); + } + + fn hash_slice(data: &[Self], state: &mut H) { + state.write_usize(data.len()); + } +} + +pub fn batched(v: Vec) -> usize { + let mut set = std::collections::HashSet::new(); + set.insert(v); + set.len() +} + +/// The places `iter_mut` lends, which the runtime would compare as the objects they are. +pub fn places_sorted(v: &mut [u8]) -> bool { + v.iter_mut().is_sorted() +} + +/// A key ordered by its own `Ord`. +#[derive(Clone, Copy)] +pub struct Ranked(pub u8); + +impl PartialEq for Ranked { + fn eq(&self, other: &Self) -> bool { + self.0 % 4 == other.0 % 4 + } +} + +impl Eq for Ranked {} + +impl PartialOrd for Ranked { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for Ranked { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + (self.0 % 4).cmp(&(other.0 % 4)) + } +} + +/// Entries that drop, sorted by what a cell holds, whose own `Ord` the runtime's sort +/// calls where std's does not. +pub fn ranked_cells(entries: Vec<(std::cell::Cell, Noisy)>) -> usize { + entries.into_iter().collect::>().len() +} + +impl PartialEq for u8 { + fn eq(&self, other: &Key) -> bool { + *self == other.0 + } +} + +impl PartialEq for Key { + fn eq(&self, other: &u8) -> bool { + self.0 == *other + } +} + +impl PartialOrd for u8 { + fn partial_cmp(&self, other: &Key) -> Option { + self.partial_cmp(&other.0) + } +} + +impl PartialOrd for Key { + fn partial_cmp(&self, other: &u8) -> Option { + self.0.partial_cmp(other) + } +} + +/// Integer bounds against the crate's item, which compares by its own `PartialOrd`. +pub fn keyed_across(n: u8) -> bool { + (..10u8).contains(&Key(n)) || std::ops::RangeBounds::contains(&(1u8..), &Key(n)) +} + +/// Bounds behind `&mut`s, which JS may keep as places rather than the integers. +pub fn place_bounds(a: &mut u8, b: &mut u8) -> bool { + (a..b).is_empty() +} diff --git a/ts/fixtures/reject/src/lib.rs b/ts/fixtures/reject/src/lib.rs index cf6911c2f..c607cb1e6 100644 --- a/ts/fixtures/reject/src/lib.rs +++ b/ts/fixtures/reject/src/lib.rs @@ -1,2390 +1,23 @@ //! Constructs outside the subset: each root fails translation with a span, and no -//! output is written. +//! output is written. Each module holds the cases of one kind of construct. #![allow(dead_code, reason = "each item is a translation root, not called from Rust")] #![feature(cow_is_borrowed, extend_one, f16, is_ascii_octdigit, linked_list_retain)] -pub fn float(a: f16) -> f16 { - a * 2.0 -} - -pub fn dynamic(h: &mut dyn std::hash::Hasher) -> u64 { - h.finish() -} - -/// `None` and `Some(None)` would both be `rt.None`, as `Some(Some(None))` is `undefined`. -pub fn nested(x: Option>>) -> bool { - x.is_some() -} - -pub fn refilled(v: &mut [Reused], r: Reused) { - v.fill(r); -} - -/// A generic type's `Option` is `T | undefined`, which can't hold `rt.None`, the `None` -/// of an `Option<()>`. -pub struct Maybe { - pub value: Option, -} - -pub fn generic_unit(value: Option<()>) -> bool { - Maybe { value }.value.is_some() -} - -/// `scan` of items that can be `undefined`: its closure's `None` and `Some(None)` would both be. -pub fn scanned(v: &[u8]) -> usize { - v.iter() - .scan(Vec::::new(), |_, &b| Some((b > 1).then_some(b))) - .count() -} - -pub struct Noisy(pub u8); - -impl Drop for Noisy { - fn drop(&mut self) {} -} - -/// A pointer's address, which JS has no counterpart of. -pub fn pointer(n: u8) -> String { - format!("{:p}", &n) -} - -/// A placeholder written to the crate's own `fmt::Write`, which sees each call std makes. -pub fn written(w: &mut Sink, n: u8) { - use std::fmt::Write; - let _ = write!(w, "{n}"); -} - -static mut COUNT: u8 = 0; - -pub fn statics() -> u8 { - unsafe { COUNT } -} - -pub struct Meters(pub u64); - -pub fn generic>(t: &mut T) -> f16 { - // A census lowers this over `T`: what hinges on `T` waits for an instance, the float does not. - (*t).into() as f16 -} - -/// `Ready(Some(Ready(Pending)))` would be `rt.OuterPending`, as the outer `Pending` is. -pub fn nested_poll(p: std::task::Poll>>>) -> bool { - matches!(p, std::task::Poll::Pending) -} - -/// A future's `Ready(Pending)` would be `rt.Pending`, as its own pending is. -pub async fn pending_output() -> std::task::Poll { - std::task::Poll::Pending -} - -/// A guard is its mutex in JS: replacing it would copy the other mutex's value in. -pub fn replace_guard<'a>(dst: &mut std::sync::MutexGuard<'a, u8>, src: std::sync::MutexGuard<'a, u8>) { - *dst = src; -} - -/// A boxed `PollFn` is the `rt.PollFn`, whose callback is private where a copy can't reach. -pub fn replace_boxed_poll_fn( - dst: &mut std::pin::Pin) -> std::task::Poll>>>, - src: std::pin::Pin) -> std::task::Poll>>>, -) -> std::pin::Pin) -> std::task::Poll>>> { - std::mem::replace(dst, src) -} - -/// A boxed byte array is a `Uint8Array`, which a replacement can't copy out as an object. -pub fn replace_boxed_bytes( - dst: &mut std::pin::Pin>, - src: std::pin::Pin>, -) -> std::pin::Pin> { - std::mem::replace(dst, src) -} - -/// A boxed future is whatever class its value's type is. -pub fn replace_boxed_future( - dst: &mut std::pin::Pin>>, - src: std::pin::Pin>>, -) { - *dst = src; -} - -/// Swapping two guards would swap their mutexes' values instead. -pub fn swap_guards<'a>(a: &mut std::sync::MutexGuard<'a, u8>, b: &mut std::sync::MutexGuard<'a, u8>) { - std::mem::swap(a, b); -} - -/// An iterator whose `fold` std's adaptors would call in place of its `next`. -pub struct Folds; - -impl Iterator for Folds { - type Item = u8; - - fn next(&mut self) -> Option { - None - } - - fn fold B>(self, init: B, _f: F) -> B { - init - } -} - -pub fn folds() -> usize { - Folds.map(|b| b + 1).count() -} - -/// An iterator whose `nth_back` std's adaptors would call in place of its `next_back`. -pub struct Backs; - -impl Iterator for Backs { - type Item = u8; - - fn next(&mut self) -> Option { - None - } -} - -impl DoubleEndedIterator for Backs { - fn next_back(&mut self) -> Option { - None - } - - fn nth_back(&mut self, _n: usize) -> Option { - Some(0) - } -} - -pub fn backs() -> usize { - Backs.rev().skip(1).count() -} - -/// JS compares objects by identity, not by `PartialOrd`. -#[derive(PartialEq, PartialOrd)] -pub struct Key(pub u8); - -pub fn keyed(range: std::ops::Range) -> bool { - range.contains(&Key(2)) -} - -/// A type of no bytes. -pub struct Bare; - -/// A pinned reference is its referent in JS: replacing it would change what it points at. -pub fn replace_pinned_ref<'a>(dst: &mut std::pin::Pin<&'a mut Noisy>, src: std::pin::Pin<&'a mut Noisy>) { - *dst = src; -} - -/// Each copy of a closure has its own captures, which copies of an arrow function share. -pub fn copied_closure(n: u8) -> u8 { - let mut a = [n]; - let mut g = move || { - a[0] = a[0].wrapping_add(1); - a[0] - }; - let mut h = g; - g().wrapping_add(h()) -} - -/// `scan` of `()`s: its closure's `None` and `Some(())` would both be `undefined`. -pub fn scanned_unit(v: &[u8]) -> usize { - v.iter().scan(Vec::::new(), |_, _| Some(())).count() -} - -/// A key the runtime has no `Hash` and `Eq` of. -pub fn set_keys() -> usize { - let map: std::collections::HashMap, u8> = std::collections::HashMap::new(); - map.len() -} - -/// A key whose `Hash` and `Eq` agree with a `u8`'s, but which is a JS object. -#[derive(PartialEq, Eq, Hash)] -pub struct Id { - pub n: u8, -} - -impl std::borrow::Borrow for Id { - fn borrow(&self) -> &u8 { - &self.n - } -} - -/// Looked up by a `u8`, which the map would look for among its primitive keys. -pub fn borrowed(map: &std::collections::HashMap) -> bool { - map.contains_key(&1) -} - -/// `max` drops the operand it doesn't return, which the runtime's leaves undropped. -pub fn widest(a: std::sync::Arc, b: std::sync::Arc) -> std::sync::Arc { - a.max(b) -} - -/// std hands its closure a `&mut` to a value JS copies, which its mapping has as the value. -pub fn passed(map: &mut std::collections::HashMap) -> u8 { - map.get_mut(&1).map_or(0, |v| { - *v += 1; - *v - }) -} - -/// `clone_from_slice` calls `Reused`'s own `clone_from` for each element. -pub fn recloned(v: &mut [Reused], w: &[Reused]) { - v.clone_from_slice(w); -} - -/// An `Arc`'s bytes would need a `ByteSlice` made inside it. -pub fn shared(b: std::sync::Arc<[u8; 2]>) -> std::sync::Arc<[u8]> { - b -} - -/// A `hash_slice` of its own, which a `Vec`'s `Hash` calls where the translation hashes each -/// element. -#[derive(PartialEq, Eq)] -pub struct Batched(u8); - -impl std::hash::Hash for Batched { - fn hash(&self, state: &mut H) { - self.0.hash(state); - } - - fn hash_slice(data: &[Self], state: &mut H) { - state.write_usize(data.len()); - } -} - -pub fn batched(v: Vec) -> usize { - let mut set = std::collections::HashSet::new(); - set.insert(v); - set.len() -} - -/// A `Cow` is a JS string, which keeps no variant to match on or ask about. -pub fn cow_matched(c: std::borrow::Cow<'_, str>) -> String { - match c { - std::borrow::Cow::Borrowed(s) => s.to_string(), - std::borrow::Cow::Owned(s) => s, - } -} - -pub fn cow_borrowed(c: &std::borrow::Cow<'_, str>) -> bool { - std::borrow::Cow::is_borrowed(c) -} - -/// A slice's tells its variants apart, but asking is unstable. -pub fn cow_bytes(c: &std::borrow::Cow<'_, [u8]>) -> bool { - std::borrow::Cow::is_borrowed(c) -} - -/// Made where its type goes unchecked, as a local's, it is refused where it is made. -pub fn cow_made(a: &std::sync::Arc) -> usize { - { - let c: std::borrow::Cow<'_, std::sync::Arc> = std::borrow::Cow::Owned(a.clone()); - drop(c); - } - std::sync::Arc::strong_count(a) -} - -fn bumped(x: &mut u8) { - *x += 1; -} - -/// A `Result`'s value passed on: a store through it makes the `Result` again, which no -/// `rt.Place` of a path does. -pub fn ok_passed(r: &mut Result) { - if let Ok(v) = r { - bumped(v); - } -} - -/// `Option`s holding `rt.Place`s, which std's runtime would compare as the Places. -pub fn places_equal(a: &mut u32, b: &mut u32) -> bool { - Some(a) == Some(b) -} - -/// An owner that drops, which would drop with the last clone of the `Bytes`. -pub fn owned_bytes(owner: std::sync::Arc<[u8]>) -> usize { - bytes::Bytes::from_owner(owner).len() -} - -/// A `BytesMut`'s capacity, which `bytes` reclaims only once the `Bytes` it froze drops. -pub fn bytes_mut_capacity(n: usize) -> usize { - let mut buf = bytes::BytesMut::with_capacity(n); - buf.extend_from_slice(b"frame"); - drop(buf.split_to(2).freeze()); - buf.reserve(n); - buf.capacity() -} - -/// `bytes` reads a `Buf` of the crate's own into a `BytesMut` by its `copy_to_bytes` only -/// at zero capacity. -pub fn bytes_mut_put(buf: &mut bytes::BytesMut, src: Counted) { - bytes::BufMut::put(buf, src); -} - -/// Through a `&mut`, `bytes` advances it by the room left in the `BytesMut`'s capacity. -pub fn bytes_mut_put_through(mut buf: &mut bytes::BytesMut, src: Counted) { - bytes::BufMut::put(&mut buf, src); -} - -/// A `Buf` whose `copy_to_bytes` differs from its `chunk` and `advance`. -pub struct Counted(pub bytes::Bytes); - -impl bytes::Buf for Counted { - fn remaining(&self) -> usize { - self.0.remaining() - } - - fn chunk(&self) -> &[u8] { - self.0.chunk() - } - - fn advance(&mut self, cnt: usize) { - self.0.advance(cnt); - } - - fn copy_to_bytes(&mut self, len: usize) -> bytes::Bytes { - bytes::Bytes::from(vec![0; len]) - } -} - -pub struct Part(pub u64); - -impl std::iter::Sum for std::time::Duration { - fn sum>(parts: I) -> Self { - std::time::Duration::from_secs(parts.map(|p| p.0 * 2).sum()) - } -} - -impl std::iter::Sum for u64 { - fn sum>(parts: I) -> Self { - parts.map(|p| p.0 * 2).sum() - } -} - -/// A `Sum` of the crate's into a std type, which std's `Sum` mapping would bypass. -pub fn parts_summed(a: Vec, b: Vec) -> (std::time::Duration, u64) { - (a.into_iter().sum(), b.into_iter().sum()) -} - -/// Parsing an address is not translated yet. -pub fn addr_parsed(s: &str) -> Result { - s.parse() -} - -pub trait Reading { - fn read(&self) -> u8; -} - -impl Reading for u8 { - fn read(&self) -> u8 { - *self - } -} - -pub trait Scaled { - fn scale(&self, by: T) -> T; -} - -/// A trait object of a generic trait. -pub fn generic_object(s: &dyn Scaled) -> u8 { - s.scale(2) -} - -pub trait First { - fn first(&self) -> u8; -} - -impl First for [u8; 4] { - fn first(&self) -> u8 { - self[0] - } -} - -/// A trait object of a byte array, which a box holds as a `Uint8Array` and a reference as -/// an `rt.ByteSlice`. -pub fn first_of(n: u8) -> u8 { - let b: Box = Box::new([n, 8, 9, 10]); - b.first() -} - -pub struct Tail { - pub value: T, -} - -/// A struct whose last field unsizes to a trait object. -pub fn tail_read(t: &Tail) -> u8 { - let r: &Tail = t; - r.value.read() -} - -/// A generic type's `Poll` is `rt.Poll`, which can't hold `rt.OuterPending`, the -/// `Pending` of a `Poll>`. -pub struct Waiting { - pub poll: std::task::Poll, -} - -pub fn generic_pending(poll: std::task::Poll>) -> bool { - Waiting { poll }.poll.is_pending() -} - -/// A copy of a closure that rebinds a shared reference it captured: each Rust copy has -/// its own, where JS would share one binding. -pub fn rebound_reference(a: &u32, b: &u32) -> (u32, u32) { - let mut r = a; - let c = move || { - let old = *r; - r = b; - old - }; - let mut x = c; - let mut y = c; - (x(), y()) -} - -pub trait Keyed: std::any::Any { - fn key(&self) -> u8; -} - -impl Keyed for u8 { - fn key(&self) -> u8 { - *self - } -} - -/// An upcast to `dyn Any`, whose downcast checks for the class of the value's own type, -/// not the object of another trait. -pub fn any_upcast(k: &dyn Keyed) -> bool { - let any: &dyn std::any::Any = k; - any.is::() -} - -/// The same upcast of a `Weak`. -pub fn weak_any_upcast(k: std::rc::Weak) -> bool { - let any: std::rc::Weak = k; - any.upgrade().is_some_and(|a| a.is::()) -} - -/// A `TypeId`, which no value stands for yet. -pub fn any_type_id(a: &dyn std::any::Any) -> bool { - a.type_id() == std::any::TypeId::of::() -} - -pub trait Source { - type Item: Reading; - fn item(&self) -> &Self::Item; -} - -/// A trait object of a type only an instance decides, which a census lowering this over -/// its type parameter can't make. -pub fn source_reading(s: &S) -> u8 { - let r: &dyn Reading = s.item(); - r.read() -} - -/// A pointer read as another type's bytes. -pub fn reinterpreted(n: u32) -> u8 { - unsafe { *(&raw const n).cast::() } -} - -/// A pointer's address, as an integer. -pub fn addressed(n: u32) -> usize { - (&raw const n).addr() -} - -/// Memory from the allocator as bytes, which JS keeps only as values a cast types it as. -pub fn allocated() -> u8 { - let layout = std::alloc::Layout::new::(); - unsafe { - let p = std::alloc::alloc(layout); - *p = 1; - let n = *p; - std::alloc::dealloc(p, layout); - n - } -} - -/// A pointer to a `Vec`, whose JS array is its heap, not where Rust keeps the `Vec`. -pub fn vec_pointer(v: &mut Vec) -> usize { - let p = &raw const *v; - unsafe { (*p).len() } -} - -/// A union whose fields overlap in values JS keeps apart. -pub union Bits { - pub int: u32, - pub float: f64, -} - -pub fn bits(n: u32) -> u32 { - let b = Bits { int: n }; - unsafe { b.int } -} - -/// Two `rt.Place`s of one number, which are two objects. -pub fn places_compared(n: &mut u32) -> bool { - let a = &raw mut *n; - let b = &raw mut *n; - a == b -} - -pub struct Span2 { - pub start: (u32, u32), - pub len: u32, -} - -/// A pointer to a part kept as an object, which a write of the whole part elsewhere -/// replaces with another object. -pub fn part_replaced(n: u32) -> u32 { - let mut s = Span2 { start: (n, n), len: n }; - let p = &raw mut s.start; - s.start = (0, 0); - unsafe { (*p).0 + s.len } -} - -/// A pointer to a variable's object, which an assignment of the whole variable replaces. -pub fn variable_reassigned(n: u32) -> u32 { - let mut pair = (n, n); - let p = &raw mut pair; - pair = (0, 0); - unsafe { (*p).0 + pair.1 } -} - -/// A pointer to a variable's object, which `mem::replace` of the whole variable replaces. -pub fn variable_replaced(n: u32) -> u32 { - let mut pair = (n, n); - let p = &raw mut pair; - let old = std::mem::replace(&mut pair, (0, 0)); - unsafe { (*p).0 + old.1 } -} - -/// A pointer to a variable's object, which `mem::swap` replaces. -pub fn variable_swapped(n: u32) -> u32 { - let mut a = (n, n); - let mut b = (0, 0); - let p = &raw mut a; - std::mem::swap(&mut a, &mut b); - unsafe { (*p).0 + b.1 } -} - -/// A pointer to a variable's object, which a whole write through a `&mut` to it replaces. -pub fn assigned_through(n: u32) -> u32 { - let mut pair = (n, n); - let p = &raw mut pair; - let r = &mut pair; - *r = (0, 0); - unsafe { (*p).0 } -} - -/// A pointer `NonNull::from` makes of a `&mut` to a variable, which an assignment replaces. -pub fn nonnull_reassigned(n: u32) -> u32 { - let mut pair = (n, n); - let p = std::ptr::NonNull::from(&mut pair); - pair = (0, 0); - unsafe { p.as_ref().0 + pair.1 } -} - -/// A pointer cast from a `&mut` to a variable, which an assignment replaces. -pub fn cast_reassigned(n: u32) -> u32 { - let mut pair = (n, n); - let p = &mut pair as *mut (u32, u32); - pair = (0, 0); - unsafe { (*p).0 + pair.1 } -} - -pub struct Window { - pub range: (u32, u32), -} - -/// A pointer to a part kept as an object, which `mem::replace` of the part elsewhere replaces. -pub fn range_of(w: &mut Window) -> *mut (u32, u32) { - &raw mut w.range -} - -pub fn range_replaced(w: &mut Window) -> (u32, u32) { - std::mem::replace(&mut w.range, (0, 0)) -} - -/// A pointer to an element kept as an object. -pub fn element_pointer(n: u32) -> u32 { - let mut pairs = [(n, n); 2]; - let p = &raw mut pairs[1]; - unsafe { (*p).0 } -} - -/// The pointer `UnsafeCell::get` gives to the object its `rt.Cell` holds, which a whole -/// write of the cell elsewhere replaces with another object. -pub fn cell_replaced(n: u32) -> u32 { - let mut cell = std::cell::UnsafeCell::new((n, n)); - let p = cell.get(); - let old = std::mem::replace(&mut cell, std::cell::UnsafeCell::new((0, 0))); - unsafe { (*p).0 + old.into_inner().1 } -} - -/// The pointer `UnsafeCell::get` gives to a number, the `rt.Cell` itself, which an -/// assignment of the whole variable replaces. -pub fn cell_reassigned(n: u32) -> u32 { - let mut cell = std::cell::UnsafeCell::new(n); - let p = cell.get(); - cell = std::cell::UnsafeCell::new(0); - unsafe { *p + cell.into_inner() } -} - -pub struct Hits { - pub count: std::cell::UnsafeCell, -} - -/// The pointer `UnsafeCell::get` gives to a number, the `rt.Cell` itself, which -/// `mem::take` of the whole variable replaces. -pub fn cell_taken(n: u32) -> u32 { - let mut cell = std::cell::UnsafeCell::new(n); - let p = cell.get(); - let old = std::mem::take(&mut cell); - unsafe { *p + old.into_inner() } -} - -/// The pointer `UnsafeCell::get` gives to a number, the `rt.Cell` in a struct, which a -/// write of the whole field replaces. -pub fn cell_field_replaced(n: u32) -> u32 { - let mut hits = Hits { - count: std::cell::UnsafeCell::new(n), - }; - let p = hits.count.get(); - hits.count = std::cell::UnsafeCell::new(0); - unsafe { *p + *hits.count.get_mut() } -} - -/// Pointers to places of no bytes, which Rust may put anywhere, `()`'s refused as made. -pub fn units_compared() -> bool { - let (a, b, c, d) = ((), (), Bare, Bare); - std::ptr::eq(&raw const a, std::ptr::NonNull::from(&b).as_ptr()) && std::ptr::eq(&raw const c, &raw const d) -} - -pub enum Only { - One, -} - -/// A dangling pointer to an enum of no bytes, whose value is its variant's tag. -pub fn dangling_enum() -> bool { - unsafe { std::ptr::NonNull::::dangling().as_ptr().as_ref().is_some() } -} - -/// A buffer of the crate's own that JS copies, so `&mut` to it is an `rt.Place`, which the -/// provided `copy_to_bytes` doesn't read through. -pub enum Blank { - Empty, -} - -impl bytes::Buf for Blank { - fn remaining(&self) -> usize { - 0 - } - - fn chunk(&self) -> &[u8] { - &[] - } - - fn advance(&mut self, cnt: usize) { - assert_eq!(cnt, 0); - } -} - -pub fn blank_bytes(len: usize) -> usize { - bytes::Buf::copy_to_bytes(&mut Blank::Empty, len).len() -} - -/// The places `iter_mut` lends, which the runtime would compare as the objects they are. -pub fn places_sorted(v: &mut [u8]) -> bool { - v.iter_mut().is_sorted() -} - -/// A pointer into memory the translation can't name. -static NAMED: &u32 = &5; - -static SLOT: std::sync::atomic::AtomicPtr = std::sync::atomic::AtomicPtr::new(std::ptr::null_mut()); - -pub fn pointer_statics(p: *mut u32) -> u32 { - use std::sync::atomic::Ordering::Relaxed; - // Two `rt.Place`s of one place are two objects, which `===` can't tell are one. - let _ = SLOT.compare_exchange(p, std::ptr::null_mut(), Relaxed, Relaxed); - *NAMED -} - -/// A census lowers this over `F` and `O`, and `awaited`'s body with it, whose closure names -/// `O` as this function's second type parameter: that refuses nothing. -pub async fn generic_awaited u8, O: std::future::Future>(f: F, o: O) -> u8 { - f() + awaited(o).await -} - -async fn awaited>(o: O) -> u8 { - let mut o = std::pin::pin!(o); - std::future::poll_fn(|cx| poll_pinned(o.as_mut(), cx)).await -} - -fn poll_pinned( - o: std::pin::Pin<&mut O>, - cx: &mut std::task::Context<'_>, -) -> std::task::Poll { - o.poll(cx) -} - -pub struct Sink(u8); - -impl std::fmt::Write for Sink { - fn write_str(&mut self, s: &str) -> std::fmt::Result { - self.0 = self.0.wrapping_add(s.len() as u8); - Ok(()) - } -} - -pub struct Plain { - pub at: (u32, u32), -} - -fn put(slot: &mut T, value: T) { - *slot = value; -} - -/// A pointer to a part kept as an object, which a generic body reached at its struct -/// replaces with another object. -pub fn put_replaced(n: u32) -> u32 { - let mut plain = Plain { at: (n, n) }; - let p = &raw mut plain.at; - put(&mut plain, Plain { at: (0, 0) }); - unsafe { (*p).0 } -} - -#[derive(Default)] -pub struct Track { - pub at: (u32, u32), -} - -pub struct Bin(std::cell::UnsafeCell); - -pub trait Reset { - fn reset(&self); -} - -impl Reset for Bin { - fn reset(&self) { - unsafe { *self.0.get() = T::default() }; - } -} - -/// A pointer to a part kept as an object, which a generic body reached only through a trait -/// object replaces with another object. -pub fn object_replaced(n: u32) -> u32 { - let bin = Bin(std::cell::UnsafeCell::new(Track { at: (n, n) })); - let p = unsafe { &raw mut (*bin.0.get()).at }; - let object: &dyn Reset = &bin; - object.reset(); - unsafe { (*p).0 } -} - -#[derive(Default)] -pub struct Lane { - pub at: (u32, u32), -} - -fn resetter(slot: *mut T) -> impl FnOnce() { - move || unsafe { *slot = T::default() } -} - -/// A pointer to a part kept as an object, which a generic closure reached at its struct -/// replaces with another object. -pub fn closure_replaced(n: u32) -> u32 { - let mut lane = Lane { at: (n, n) }; - let whole = &raw mut lane; - let p = unsafe { &raw mut (*whole).at }; - resetter(whole)(); - unsafe { (*p).0 } -} - -/// A `clone_from` of its own, which `fill` calls for each slot but the last. -pub struct Reused(Vec); - -impl Clone for Reused { - fn clone(&self) -> Self { - Reused(self.0.clone()) - } - - fn clone_from(&mut self, source: &Self) { - self.0.clone_from(&source.0); - } -} - -pub struct Gap { - pub range: (u32, u32), - pub slot: std::mem::MaybeUninit<(u32, u32)>, -} - -fn reset_gap(gap: &mut Gap) { - gap.range = (0, 0); - gap.slot = std::mem::MaybeUninit::new((0, 0)); -} - -/// The pointers `NonNull::from` makes of a `&mut` and of a `&` to a part kept as an object, -/// and `into` of a `&mut`, which a write of the whole part elsewhere replaces with another -/// object. -pub fn made_part_replaced(n: u32) -> u32 { - let mut gap = Gap { - range: (n, n), - slot: std::mem::MaybeUninit::new((n, n)), - }; - let p = std::ptr::NonNull::from(&mut gap.range); - let q = std::ptr::NonNull::from(&gap.range); - let r: std::ptr::NonNull<(u32, u32)> = (&mut gap.range).into(); - reset_gap(&mut gap); - unsafe { p.as_ref().0 + q.as_ref().1 + r.as_ref().0 } -} - -/// The pointers `MaybeUninit::as_ptr` and `as_mut_ptr` make to a part kept as an object, -/// which a write of the whole part elsewhere replaces with another object. -pub fn uninit_part_replaced(n: u32) -> u32 { - let mut gap = Gap { - range: (n, n), - slot: std::mem::MaybeUninit::new((n, n)), - }; - let p = gap.slot.as_ptr(); - let q = gap.slot.as_mut_ptr(); - reset_gap(&mut gap); - unsafe { (*p).0 + (*q).1 } -} - -/// A key ordered by its own `Ord`. -#[derive(Clone, Copy)] -pub struct Ranked(pub u8); - -impl PartialEq for Ranked { - fn eq(&self, other: &Self) -> bool { - self.0 % 4 == other.0 % 4 - } -} - -impl Eq for Ranked {} - -impl PartialOrd for Ranked { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -impl Ord for Ranked { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - (self.0 % 4).cmp(&(other.0 % 4)) - } -} - -/// Entries that drop, sorted by what a cell holds, whose own `Ord` the runtime's sort -/// calls where std's does not. -pub fn ranked_cells(entries: Vec<(std::cell::Cell, Noisy)>) -> usize { - entries.into_iter().collect::>().len() -} - -impl PartialEq for u8 { - fn eq(&self, other: &Key) -> bool { - *self == other.0 - } -} - -impl PartialEq for Key { - fn eq(&self, other: &u8) -> bool { - self.0 == *other - } -} - -impl PartialOrd for u8 { - fn partial_cmp(&self, other: &Key) -> Option { - self.partial_cmp(&other.0) - } -} - -impl PartialOrd for Key { - fn partial_cmp(&self, other: &u8) -> Option { - self.0.partial_cmp(other) - } -} - -/// Integer bounds against the crate's item, which compares by its own `PartialOrd`. -pub fn keyed_across(n: u8) -> bool { - (..10u8).contains(&Key(n)) || std::ops::RangeBounds::contains(&(1u8..), &Key(n)) -} - -/// Bounds behind `&mut`s, which JS may keep as places rather than the integers. -pub fn place_bounds(a: &mut u8, b: &mut u8) -> bool { - (a..b).is_empty() -} - -/// A struct holding a pointer. -pub struct Aimed { - pub at: *mut (u32, u32), -} - -/// A pointer to a variable's object, copied into a struct read after an assignment of -/// the whole variable replaces the object. -pub fn pointer_in_struct(n: u32) -> u32 { - let mut pair = (n, n); - let aimed = Aimed { at: &raw mut pair }; - pair = (0, 0); - unsafe { (*aimed.at).0 + pair.1 } -} - -fn handed_back(p: *mut T) -> *mut T { - p -} - -/// A pointer to a variable's object, which a call returns, read after an assignment of -/// the whole variable replaces the object. -pub fn pointer_returned(n: u32) -> u32 { - let mut pair = (n, n); - let p = handed_back(&raw mut pair); - pair = (0, 0); - unsafe { (*p).0 + pair.1 } -} - -/// A pointer to a variable's object, kept in a `Vec` and read after an assignment of the -/// whole variable replaces the object. -pub fn pointer_pushed(n: u32) -> u32 { - let mut pair = (n, n); - let mut kept = Vec::new(); - kept.push(&raw mut pair); - pair = (0, 0); - unsafe { (*kept[0]).0 + pair.1 } -} - -/// A pointer to a variable's object, which a closure captures and reads after an -/// assignment of the whole variable replaces the object. -pub fn pointer_captured(n: u32) -> u32 { - let mut pair = (n, n); - let p = &raw mut pair; - let read = move || unsafe { (*p).0 }; - pair = (0, 0); - read() + pair.1 -} - -/// A pointer an earlier iteration made to a variable's object, read after the next -/// iteration's assignment of the whole variable replaces the object. -pub fn pointer_kept_across(data: &[u32]) -> u32 { - let mut pair = (0, 0); - let mut last = &raw mut pair; - let mut sum = 0; - for &n in data { - pair = (n, n); - sum += unsafe { (*last).0 }; - last = &raw mut pair; - } - sum -} - -/// Structs JS keeps as objects, each holding an `rt.Cell` of an object, one for each write -/// of fresh memory made while a pointer into it may still be read, which gives the cell -/// another object. -pub struct Escaped(pub std::cell::UnsafeCell<(u16, u16)>); - -pub struct Called(pub std::cell::UnsafeCell<(u16, u16)>); - -pub struct Looped(pub std::cell::UnsafeCell<(u16, u16)>); - -pub struct Aliased(pub std::cell::UnsafeCell<(u16, u16)>); - -pub struct Rewritten(pub std::cell::UnsafeCell<(u16, u16)>); - -pub struct Keeper { - pub whole: *mut Escaped, - pub part: *mut (u16, u16), -} - -fn keep_part(keeper: &mut Keeper) { - keeper.part = unsafe { (*keeper.whole).0.get() }; -} - -/// A fresh allocation written whole again after its pointer escaped into a struct. -pub fn escaped_into_struct(n: u16, keeper: &mut Keeper) -> u16 { - let p = Box::into_raw(Box::new(std::mem::MaybeUninit::::uninit())).cast::(); - unsafe { p.write(Escaped(std::cell::UnsafeCell::new((n, n)))) }; - keeper.whole = p; - keep_part(keeper); - unsafe { p.write(Escaped(std::cell::UnsafeCell::new((0, 0)))) }; - unsafe { (*keeper.part).0 } -} - -fn kept_part(p: *mut Called, kept: &mut Vec<*mut (u16, u16)>) { - kept.push(unsafe { (*p).0.get() }); -} - -/// A fresh allocation written whole again after its pointer escaped into a call. -pub fn escaped_into_call(n: u16) -> u16 { - let p = Box::into_raw(Box::new(std::mem::MaybeUninit::::uninit())).cast::(); - unsafe { p.write(Called(std::cell::UnsafeCell::new((n, n)))) }; - let mut kept = Vec::new(); - kept_part(p, &mut kept); - unsafe { p.write(Called(std::cell::UnsafeCell::new((0, 0)))) }; - unsafe { (*kept[0]).0 } -} - -/// A fresh allocation written whole in each iteration, read after through the pointer an -/// earlier iteration took into it. -pub fn kept_across_writes(data: &[u16]) -> u16 { - let p = Box::into_raw(Box::new(std::mem::MaybeUninit::::uninit())).cast::(); - let mut kept: *mut (u16, u16) = std::ptr::null_mut(); - let mut sum = 0; - for &n in data { - unsafe { p.write(Looped(std::cell::UnsafeCell::new((n, n)))) }; - if !kept.is_null() { - sum += unsafe { (*kept).0 }; - } - kept = unsafe { (*p).0.get() }; - } - sum -} - -/// A fresh allocation written whole through an alias of its pointer while a pointer into it -/// may still be read. -pub fn written_through_alias(n: u16) -> u16 { - let p = Box::into_raw(Box::new(std::mem::MaybeUninit::::uninit())).cast::(); - unsafe { p.write(Aliased(std::cell::UnsafeCell::new((n, n)))) }; - let part = unsafe { (*p).0.get() }; - let alias = p; - unsafe { alias.write(Aliased(std::cell::UnsafeCell::new((0, 0)))) }; - unsafe { (*part).0 } -} - -/// A `MaybeUninit` written whole again while a pointer into it may still be read. -pub fn uninit_rewritten(n: u16) -> u16 { - let mut slot = std::mem::MaybeUninit::::uninit(); - slot.write(Rewritten(std::cell::UnsafeCell::new((n, n)))); - let part = unsafe { slot.assume_init_ref().0.get() }; - slot.write(Rewritten(std::cell::UnsafeCell::new((0, 0)))); - unsafe { (*part).0 } -} - -pub struct Loaded(pub std::cell::UnsafeCell<(u16, u16)>); - -/// A fresh allocation written whole again through a pointer to it read out of another -/// allocation, while a pointer into it may still be read. -pub fn written_through_loaded(n: u16) -> u16 { - let p = Box::into_raw(Box::new(std::mem::MaybeUninit::::uninit())).cast::(); - unsafe { p.write(Loaded(std::cell::UnsafeCell::new((n, n)))) }; - let part = unsafe { (*p).0.get() }; - let container = Box::into_raw(Box::new(p.cast_const())); - unsafe { - container - .read() - .cast_mut() - .write(Loaded(std::cell::UnsafeCell::new((0, 0)))) - }; - unsafe { (*part).0 } -} - -/// Structs JS keeps as objects, each written whole into slots through std's iterators -/// while a pointer into one may still be read, which gives what holds it another object. -pub struct Mapped(pub std::cell::UnsafeCell<(u16, u16)>); - -pub struct Repeated(pub std::cell::UnsafeCell<(u16, u16)>); - -pub struct Onced(pub std::cell::UnsafeCell<(u16, u16)>); - -pub struct Pushed { - pub part: (u16, u16), -} - -pub struct Copied { - pub span: (u16, u16), -} - -std::thread_local! { - static COPIED: std::cell::Cell<*const (u16, u16)> = const { std::cell::Cell::new(std::ptr::null()) }; -} - -/// A clone that keeps a pointer into what it copies. -impl Clone for Copied { - fn clone(&self) -> Self { - COPIED.with(|kept| kept.set(&raw const self.span)); - Copied { span: self.span } - } -} - -/// Slots written through an iterator whose closure keeps a pointer into each before it is -/// written. -pub fn mapped_kept(n: u16) -> u16 { - let mut slots = [const { std::mem::MaybeUninit::::uninit() }; 2]; - let mut kept: *mut (u16, u16) = std::ptr::null_mut(); - for slot in slots.iter_mut().map(|s| { - kept = unsafe { (*s.as_mut_ptr()).0.get() }; - s - }) { - slot.write(Mapped(std::cell::UnsafeCell::new((n, n)))); - } - unsafe { (*kept).0 } -} - -/// A slot written whole again after `cloned` handed it to the crate's `Clone`, which kept -/// a pointer into it. -pub fn cloned_kept(n: u16) -> u16 { - let mut slots = [const { std::mem::MaybeUninit::::uninit() }; 1]; - for slot in &mut slots { - slot.write(Copied { span: (n, n) }); - } - let copies: Vec = std::iter::once(unsafe { slots[0].assume_init_ref() }) - .cloned() - .collect(); - slots[0].write(Copied { span: (0, 0) }); - COPIED.with(|kept| unsafe { (*kept.get()).0 }) + copies.len() as u16 -} - -/// Slots written whole on each pass, read after through the pointer a write on the pass -/// before took into the same slot. -pub fn kept_across_iterations(data: &[u16]) -> u16 { - let mut slots = [const { std::mem::MaybeUninit::::uninit() }; 1]; - let mut kept: *mut (u16, u16) = std::ptr::null_mut(); - let mut sum = 0; - for &n in data { - for slot in slots.iter_mut() { - let made = slot.write(Repeated(std::cell::UnsafeCell::new((n, n)))); - if !kept.is_null() { - sum += unsafe { (*kept).0 }; - } - kept = made.0.get(); - } - } - sum -} - -/// A slot written whole through a borrow that std's `once` handed the crate a mutable -/// borrow of, which pointed it at memory a pointer into may still be read. -pub fn lent_kept(n: u16) -> u16 { - let mut slots = [const { std::mem::MaybeUninit::::uninit() }; 1]; - let mut old = std::mem::MaybeUninit::::uninit(); - old.write(Onced(std::cell::UnsafeCell::new((n, n)))); - let part = unsafe { old.assume_init_ref().0.get() }; - let mut slot: &mut std::mem::MaybeUninit = &mut slots[0]; - if let Some(lent) = std::iter::once(&mut slot).next() { - *lent = &mut old; - } - slot.write(Onced(std::cell::UnsafeCell::new((0, 0)))); - unsafe { (*part).0 } -} - -/// An element of memory `Vec::push` allocated, written whole while a pointer into it may -/// still be read. -pub fn pushed_part_kept(n: u16) -> u16 { - let mut v = Vec::new(); - v.push(Pushed { part: (n, n) }); - let p = &raw mut v[0]; - let part = unsafe { &raw mut (*p).part }; - unsafe { p.write(Pushed { part: (0, 0) }) }; - unsafe { (*part).0 } -} - -/// A collection of the crate's own that overrides `extend_one`, which a tuple's `Extend` -/// calls, as only a nightly crate can. -#[derive(Default)] -pub struct Tens(pub u8); - -impl Extend for Tens { - fn extend>(&mut self, iter: I) { - for b in iter { - self.0 = self.0.wrapping_add(b); - } - } - - fn extend_one(&mut self, item: u8) { - self.0 = self.0.wrapping_add(item).wrapping_mul(10); - } -} - -/// A tuple of collections, one of them the crate's own that overrides `extend_one`. -pub fn tens(data: &[u8]) -> (Vec, Tens) { - data.iter().map(|&b| (b, b)).collect() -} - -/// `u8`'s unstable ASCII methods are not translated. -pub fn ascii_octal(a: u8) -> bool { - a.is_ascii_octdigit() -} - -/// Structs JS keeps as objects, each holding an `rt.Cell`, one for each kind of whole -/// write of a value that holds one, which gives it another cell, while a pointer to the -/// cell, taken through a reference to the struct, may still be read. -pub struct InArray(pub std::cell::UnsafeCell); - -pub struct InTuple(pub std::cell::UnsafeCell); - -pub struct InNested(pub std::cell::UnsafeCell); - -pub struct InPayload(pub std::cell::UnsafeCell); - -pub struct InField(pub std::cell::UnsafeCell); - -pub struct InGeneric(pub std::cell::UnsafeCell); - -pub struct InWritten(pub std::cell::UnsafeCell); - -pub struct Mid(pub u16, pub T); - -pub struct Outer(pub Mid); - -fn array_part(held: &InArray) -> *mut u16 { - held.0.get() -} - -fn tuple_part(held: &InTuple) -> *mut u16 { - held.0.get() -} - -fn nested_part(held: &InNested) -> *mut u16 { - held.0.get() -} - -fn payload_part(held: &InPayload) -> *mut u16 { - held.0.get() -} - -fn field_part(held: &InField) -> *mut u16 { - held.0.get() -} - -fn generic_part(held: &InGeneric) -> *mut u16 { - held.0.get() -} - -fn written_part(held: &InWritten) -> *mut u16 { - held.0.get() -} - -fn cell(n: u16) -> std::cell::UnsafeCell { - std::cell::UnsafeCell::new(n) -} - -/// A whole array written, then a pointer into its element read. -pub fn array_part_replaced(n: u16) -> u16 { - let mut whole = [InArray(cell(n)), InArray(cell(n))]; - let p = &raw mut whole; - let part = array_part(unsafe { &(*p)[1] }); - unsafe { *p = [InArray(cell(0)), InArray(cell(0))] }; - unsafe { *part } -} - -/// A whole tuple written, then a pointer into its element read. -pub fn tuple_part_replaced(n: u16) -> u16 { - let mut whole = (n, InTuple(cell(n))); - let p = &raw mut whole; - let part = tuple_part(unsafe { &(*p).1 }); - unsafe { *p = (0, InTuple(cell(0))) }; - unsafe { *part } -} - -/// A whole struct written, then a pointer into a struct its field holds read. -pub fn nested_part_replaced(n: u16) -> u16 { - let mut whole = Outer(Mid(n, InNested(cell(n)))); - let p = &raw mut whole; - let part = nested_part(unsafe { &(*p).0.1 }); - unsafe { *p = Outer(Mid(0, InNested(cell(0)))) }; - unsafe { *part } -} - -/// A whole `Option` written, then a pointer into its payload read. -pub fn payload_part_replaced(n: u16) -> u16 { - let mut whole = Some(InPayload(cell(n))); - let p = &raw mut whole; - let Some(held) = (unsafe { &*p }) else { - return 0; - }; - let part = payload_part(held); - unsafe { *p = Some(InPayload(cell(0))) }; - unsafe { *part } -} - -/// A whole field written, then a pointer into a struct it holds read. -pub fn field_part_replaced(n: u16) -> u16 { - let mut whole = Outer(Mid(n, InField(cell(n)))); - let p = &raw mut whole; - let part = field_part(unsafe { &(*p).0.1 }); - unsafe { (*p).0 = Mid(0, InField(cell(0))) }; - unsafe { *part } -} - -fn set(slot: *mut T, value: T) { - unsafe { *slot = value } -} - -/// A whole struct written by a generic body, then a pointer into a struct it holds read. -pub fn generic_part_replaced(n: u16) -> u16 { - let mut whole = Outer(Mid(n, InGeneric(cell(n)))); - let p = &raw mut whole; - let part = generic_part(unsafe { &(*p).0.1 }); - set(p, Outer(Mid(0, InGeneric(cell(0))))); - unsafe { *part } -} - -/// A whole array written by std, then a pointer into its element read. -pub fn written_part_replaced(n: u16) -> u16 { - let mut whole = [InWritten(cell(n))]; - let p = &raw mut whole; - let part = written_part(unsafe { &(*p)[0] }); - unsafe { p.write([InWritten(cell(0))]) }; - unsafe { *part } -} - -/// Structs JS keeps as objects, each holding an `rt.Cell`, one for each path by which a -/// pointer kept in memory reaches a whole write of what it points at, which gives it -/// another cell, while a pointer to the cell, taken through a reference to the struct, -/// may still be read. -pub struct ByRead(pub std::cell::UnsafeCell); - -pub struct ByWrite(pub std::cell::UnsafeCell); - -pub struct BySwap(pub std::cell::UnsafeCell); - -pub struct ByReplace(pub std::cell::UnsafeCell); - -pub struct ByBox(pub std::cell::UnsafeCell); - -pub struct ByClosure(pub std::cell::UnsafeCell); - -pub struct ByObject(pub std::cell::UnsafeCell); - -pub struct ByInstance(pub std::cell::UnsafeCell); - -pub struct BySwapped(pub std::cell::UnsafeCell); - -pub struct ByExchanged(pub std::cell::UnsafeCell); - -/// A pointer kept in memory, which only the crate's own code reads back. -pub struct Kept { - pub at: *mut T, -} - -impl Kept { - fn put(&self, value: T) { - unsafe { *self.at = value } - } -} - -pub trait Put { - fn put(&self); -} - -impl Put for Kept { - fn put(&self) { - unsafe { *self.at = ByObject(cell(0)) } - } -} - -/// Read back from memory, then written whole through. -pub fn kept_read(n: u16) -> u16 { - let mut whole = ByRead(cell(n)); - let mut kept = Kept { - at: std::ptr::null_mut(), - }; - kept.at = &raw mut whole; - let part = unsafe { (*kept.at).0.get() }; - let at = kept.at; - unsafe { *at = ByRead(cell(0)) }; - unsafe { *part } -} - -/// Read back from memory, then written whole by `ptr::write`. -pub fn kept_written(n: u16) -> u16 { - let mut whole = ByWrite(cell(n)); - let mut kept = Kept { - at: std::ptr::null_mut(), - }; - kept.at = &raw mut whole; - let part = unsafe { (*kept.at).0.get() }; - unsafe { kept.at.write(ByWrite(cell(0))) }; - unsafe { *part } -} - -/// Read back from memory, then swapped whole by `ptr::swap`. -pub fn kept_swapped(n: u16) -> u16 { - let mut whole = BySwap(cell(n)); - let mut other = BySwap(cell(0)); - let mut kept = Kept { - at: std::ptr::null_mut(), - }; - kept.at = &raw mut whole; - let part = unsafe { (*kept.at).0.get() }; - unsafe { std::ptr::swap(kept.at, &raw mut other) }; - unsafe { *part } -} - -/// Read back from memory, then replaced whole by `mem::replace` through a `&mut`. -pub fn kept_replaced(n: u16) -> u16 { - let mut whole = ByReplace(cell(n)); - let mut kept = Kept { - at: std::ptr::null_mut(), - }; - kept.at = &raw mut whole; - let part = unsafe { (*kept.at).0.get() }; - drop(std::mem::replace(unsafe { &mut *kept.at }, ByReplace(cell(0)))); - unsafe { *part } -} - -/// Read back from memory into `Box::from_raw`, then written whole through the box. -pub fn kept_boxed(n: u16) -> u16 { - let mut kept = Kept { - at: std::ptr::null_mut(), - }; - kept.at = Box::into_raw(Box::new(ByBox(cell(n)))); - let part = unsafe { (*kept.at).0.get() }; - let mut boxed = unsafe { Box::from_raw(kept.at) }; - *boxed = ByBox(cell(0)); - let read = unsafe { *part }; - drop(boxed); - read -} - -/// Read back from memory by a closure, which writes whole through it. -pub fn kept_called(n: u16) -> u16 { - let mut whole = ByClosure(cell(n)); - let mut kept = Kept { - at: std::ptr::null_mut(), - }; - kept.at = &raw mut whole; - let part = unsafe { (*kept.at).0.get() }; - let put: Box = Box::new(|| unsafe { *kept.at = ByClosure(cell(0)) }); - put(); - unsafe { *part } -} - -/// Read back from memory by a trait object's method, which writes whole through it. -pub fn kept_object(n: u16) -> u16 { - let mut whole = ByObject(cell(n)); - let mut kept = Kept { - at: std::ptr::null_mut(), - }; - kept.at = &raw mut whole; - let part = unsafe { (*kept.at).0.get() }; - let put: &dyn Put = &kept; - put.put(); - unsafe { *part } -} - -/// Read back from memory by a generic method, which writes whole through it. -pub fn kept_instance(n: u16) -> u16 { - let mut whole = ByInstance(cell(n)); - let mut kept = Kept { - at: std::ptr::null_mut(), - }; - kept.at = &raw mut whole; - let part = unsafe { (*kept.at).0.get() }; - kept.put(ByInstance(cell(0))); - unsafe { *part } -} - -/// Given to an atomic, handed back by its `swap`, then written whole through. -pub fn atomic_swapped(n: u16) -> u16 { - let mut whole = BySwapped(cell(n)); - let atomic = std::sync::atomic::AtomicPtr::new(&raw mut whole); - let part = unsafe { (*atomic.load(std::sync::atomic::Ordering::SeqCst)).0.get() }; - let at = atomic.swap(std::ptr::null_mut(), std::sync::atomic::Ordering::SeqCst); - unsafe { *at = BySwapped(cell(0)) }; - unsafe { *part } -} - -/// Given to an atomic, handed back by its `compare_exchange`, then written whole through. -pub fn atomic_exchanged(n: u16) -> u16 { - let mut whole = ByExchanged(cell(n)); - let at = &raw mut whole; - let atomic = std::sync::atomic::AtomicPtr::new(at); - let part = unsafe { (*at).0.get() }; - let order = std::sync::atomic::Ordering::SeqCst; - if let Ok(at) = atomic.compare_exchange(at, std::ptr::null_mut(), order, order) { - unsafe { *at = ByExchanged(cell(0)) }; - } - unsafe { *part } -} - -/// Structs JS keeps as objects, each holding an `rt.Cell`, one for each std function that -/// puts another object in place of a `RefCell`'s value through a shared reference, while a -/// pointer to the cell, taken through a borrow of that value, may still be read. -pub struct ByRefReplace(pub std::cell::UnsafeCell); - -#[derive(Default)] -pub struct ByRefTake(pub std::cell::UnsafeCell); - -pub struct ByKeySet(pub std::cell::UnsafeCell); - -pub struct ByKeyReplace(pub std::cell::UnsafeCell); - -#[derive(Default)] -pub struct ByKeyTake(pub std::cell::UnsafeCell); - -std::thread_local! { - static KEY_SET: std::cell::RefCell<(u16, ByKeySet)> = const { std::cell::RefCell::new((0, ByKeySet(std::cell::UnsafeCell::new(0)))) }; - static KEY_REPLACE: std::cell::RefCell<(u16, ByKeyReplace)> = const { std::cell::RefCell::new((0, ByKeyReplace(std::cell::UnsafeCell::new(0)))) }; - static KEY_TAKE: std::cell::RefCell<(u16, ByKeyTake)> = const { std::cell::RefCell::new((0, ByKeyTake(std::cell::UnsafeCell::new(0)))) }; -} - -/// Replaced by `RefCell::replace`. -pub fn ref_replaced(n: u16) -> u16 { - let whole = std::cell::RefCell::new((n, ByRefReplace(cell(n)))); - let part = whole.borrow().1.0.get(); - drop(whole.replace((0, ByRefReplace(cell(0))))); - unsafe { *part } -} - -/// Replaced by `RefCell::take`. -pub fn ref_taken(n: u16) -> u16 { - let whole = std::cell::RefCell::new((n, ByRefTake(cell(n)))); - let part = whole.borrow().1.0.get(); - drop(whole.take()); - unsafe { *part } -} - -/// Replaced by a thread-local `RefCell`'s `set`. -pub fn key_set(n: u16) -> u16 { - KEY_SET.set((n, ByKeySet(cell(n)))); - let part = KEY_SET.with_borrow(|whole| whole.1.0.get()); - KEY_SET.set((0, ByKeySet(cell(0)))); - unsafe { *part } -} - -/// Replaced by a thread-local `RefCell`'s `replace`. -pub fn key_replaced(n: u16) -> u16 { - drop(KEY_REPLACE.replace((n, ByKeyReplace(cell(n))))); - let part = KEY_REPLACE.with_borrow(|whole| whole.1.0.get()); - drop(KEY_REPLACE.replace((0, ByKeyReplace(cell(0))))); - unsafe { *part } -} - -/// Replaced by a thread-local `RefCell`'s `take`. -pub fn key_taken(n: u16) -> u16 { - let part = KEY_TAKE.with_borrow(|whole| whole.1.0.get()); - unsafe { *part = n }; - drop(KEY_TAKE.take()); - unsafe { *part } -} - -/// A `str`'s UTF-8 written as bytes, or a part of it unchecked. -pub fn str_bytes_mut(s: &mut str) { - unsafe { s.as_bytes_mut()[0] = b'a' }; - unsafe { s.get_unchecked_mut(..1) }.make_ascii_uppercase(); -} - -/// Bytes written through a `&mut str` to them, which no JS string is. -pub fn str_from_bytes_mut(bytes: &mut [u8]) { - if let Ok(text) = std::str::from_utf8_mut(bytes) { - text.make_ascii_uppercase(); - } -} - -fn cell_of(c: &std::cell::UnsafeCell) -> *mut u64 { - c.get() -} - -/// The pointer `UnsafeCell::get` gives a callee, the `rt.Cell` itself, which the caller's -/// assignment of the variable replaces. -pub fn cell_rebound(n: u64) -> u64 { - let mut cell = std::cell::UnsafeCell::new(n); - let p = cell_of(&cell); - cell = std::cell::UnsafeCell::new(0); - unsafe { *p + cell.into_inner() } -} - -pub struct Target(pub u32); - -/// A pointer through a reference that `mem::replace` points at another variable, which an -/// assignment of that variable replaces. -pub fn retargeted(n: u32) -> u32 { - let mut a = Target(n); - let mut b = Target(n); - let mut r = &mut a; - let _ = std::mem::replace(&mut r, &mut b); - let p = &raw mut *r; - b = Target(0); - unsafe { (*p).0 + b.0 + a.0 } -} - -/// A pointer through a reference that `mem::swap` points at another variable, which an -/// assignment of that variable replaces. -pub fn swap_retargeted(n: u32) -> u32 { - let mut a = (n, n); - let mut b = (n, n); - let mut r = &mut a; - let mut s = &mut b; - std::mem::swap(&mut r, &mut s); - let p = &raw mut *r; - b = (0, 0); - unsafe { (*p).0 + b.0 + a.0 } -} - -/// A pointer through a reference a loop's `mem::swap`s may point at either variable, one -/// of which an assignment then replaces. -pub fn swapped_in_loop(n: u32) -> u32 { - let mut a = (n, n); - let mut b = (n, 1); - let mut r = &mut a; - let mut s = &mut b; - for _ in 0..n { - std::mem::swap(&mut r, &mut s); - } - let p = &raw mut *r; - a = (0, 0); - unsafe { (*p).0 + a.0 } -} - -/// Pointer operations on arrays of bytes that read the address or other bytes than the -/// array's: comparing addresses only, copying, offsetting, hashing, and ordering, beside -/// pointers to their first bytes. -pub fn byte_pointer_ops(mut a: [u8; 4], b: [u8; 4]) -> u64 { - use std::hash::{Hash, Hasher}; - let p: *mut [u8; 4] = &mut a; - let q: *const [u8; 4] = &b; - unsafe { - std::ptr::copy(q, p, 1); - std::ptr::copy_nonoverlapping(q, p, 1); - let same = std::ptr::addr_eq(p, q) || p < q.cast_mut(); - let byte = *p.cast::() + *(q as *const u8) + (*p.add(0))[0] + (*q.offset(0))[1]; - let slice: *const [u8] = q; - let mut h = std::collections::hash_map::DefaultHasher::new(); - q.hash(&mut h); - h.finish() + u64::from(same) + u64::from(byte) + slice.len() as u64 - } -} - -/// Pointers to arrays of bytes that are parts of an array kept apart from it: a slice -/// pattern's rest and an array's element. -pub fn byte_pointer_parts(a: [u8; 4], b: [[u8; 2]; 3]) -> bool { - let [_, ref x @ ..] = a; - let [_, ref y @ ..] = a; - std::ptr::eq(x, y) || std::ptr::eq(&b[0], &b[1]) -} - -/// Pointers to an array of bytes in a variable assigned again while they point there, -/// made of a reference and as a raw borrow. -pub fn byte_pointer_rebound(n: u8) -> u8 { - let mut a = [n; 4]; - let p: *const [u8; 4] = &a; - let q = &raw const a; - a = [n ^ 1; 4]; - unsafe { (*p)[0] + (*q)[1] + a[2] } -} - -pub struct Behind(pub std::cell::Cell); - -fn read_behind(b: &Behind) -> *const Behind { - let p = &raw const *b; - let held = (p,); - unsafe { std::ptr::read(&raw const held).0 } -} - -/// A pointer a callee reads back through a pointer to where it put it, which the read -/// holds, and returns, to a cell the caller's assignment replaces. -pub fn read_behind_rebound(n: u32) -> u32 { - let mut b = Behind(std::cell::Cell::new(n)); - let p = read_behind(&b); - b = Behind(std::cell::Cell::new(0)); - unsafe { (*p).0.get() + b.0.get() } -} - -pub struct Unboxed(pub std::cell::Cell); - -fn unbox(u: &Unboxed) -> *const Unboxed { - *Box::leak(Box::new(&raw const *u)) -} - -/// A pointer a callee reads back out of a box it put it in, and returns, to a cell the -/// caller's assignment replaces. -pub fn unboxed_rebound(n: u32) -> u32 { - let mut u = Unboxed(std::cell::Cell::new(n)); - let p = unbox(&u); - u = Unboxed(std::cell::Cell::new(0)); - unsafe { (*p).0.get() + u.0.get() } -} - -pub struct Deep { - pub mid: DeepMid, -} - -pub struct DeepMid(pub u8, pub std::cell::UnsafeCell); - -fn deep_of(d: &Deep) -> *mut u32 { - d.mid.1.get() -} - -/// A pointer a callee makes into a cell two structs deep, which the caller's assignment -/// of the outer one replaces. -pub fn deep_cell_rebound(n: u32) -> u32 { - let mut d = Deep { - mid: DeepMid(1, std::cell::UnsafeCell::new(n)), - }; - let p = deep_of(&d); - d = Deep { - mid: DeepMid(2, std::cell::UnsafeCell::new(0)), - }; - unsafe { *p + d.mid.0 as u32 } -} - -pub enum Slot { - Empty, - Full(std::cell::Cell), -} - -pub struct Slotted(pub Slot); - -fn slotted_of(s: &Slotted) -> *const Slotted { - &raw const *s -} - -/// A pointer a callee makes to a struct whose only cell is in an enum's payload, which -/// the caller's assignment replaces. -pub fn payload_cell_rebound(n: u32) -> u32 { - let mut s = Slotted(Slot::Full(std::cell::Cell::new(n))); - let p = slotted_of(&s); - s = Slotted(Slot::Empty); - let rest = matches!(s.0, Slot::Empty) as u32; - match unsafe { &(*p).0 } { - Slot::Full(c) => c.get() + rest, - Slot::Empty => rest, - } -} - -pub struct Shared(pub std::cell::RefCell); - -fn shared_of(s: &Shared) -> *const Shared { - s -} - -/// A pointer a callee makes to a `RefCell`'s holder, which the caller's assignment -/// replaces. A `usize` leaves no padding, which is not in the cell. -pub fn ref_cell_rebound(n: usize) -> usize { - let mut s = Shared(std::cell::RefCell::new(n)); - let p = shared_of(&s); - s = Shared(std::cell::RefCell::new(0)); - unsafe { *(*p).0.borrow() + *s.0.borrow() } -} - -pub struct Duo(pub u32, pub u32); - -pub struct Inside(pub std::cell::UnsafeCell); - -fn inside_of(i: &Inside) -> *mut Duo { - i.0.get() -} - -/// A pointer a callee makes through a cell to the object it holds, which the caller's -/// assignment of the cell's holder replaces. -pub fn inside_cell_rebound(n: u32) -> u32 { - let mut i = Inside(std::cell::UnsafeCell::new(Duo(n, n))); - let p = inside_of(&i); - i = Inside(std::cell::UnsafeCell::new(Duo(0, 0))); - unsafe { (*p).0 + (*i.0.get()).1 } -} - -fn inside_field_of(i: &Inside) -> *mut u32 { - unsafe { &raw mut (*i.0.get()).1 } -} - -/// A pointer a callee makes through a cell to a field of the object it holds, which the -/// caller's assignment of the cell's holder replaces. -pub fn inside_field_rebound(n: u32) -> u32 { - let mut i = Inside(std::cell::UnsafeCell::new(Duo(n, n))); - let p = inside_field_of(&i); - i = Inside(std::cell::UnsafeCell::new(Duo(0, 0))); - unsafe { *p + (*i.0.get()).0 } -} - -pub struct Compared(pub u32); - -fn compared_of(c: &Compared) -> *const Compared { - c -} - -/// A pointer a callee makes to a struct with no cell, compared after the caller's -/// assignment, which Rust defines as its address and JS as the object it replaced. -pub fn compared_rebound(n: u32) -> bool { - let mut c = Compared(n); - let p = compared_of(&c); - c = Compared(n + 1); - p == compared_of(&c) && c.0 > 0 -} - -pub struct Enclosed(pub u32); - -pub struct Enclosing(pub Enclosed); - -fn enclosed_of(e: &Enclosing) -> *const Enclosed { - &e.0 -} - -/// A pointer a callee makes to a part of a struct with no cell, compared after the -/// caller's assignment of the whole. -pub fn enclosed_compared_rebound(n: u32) -> bool { - let mut e = Enclosing(Enclosed(n)); - let p = enclosed_of(&e); - e = Enclosing(Enclosed(n + 1)); - p == enclosed_of(&e) && (e.0).0 > 0 -} - -pub struct Chosen(pub u32); - -fn choose<'a>(a: &'a mut Chosen, b: &'a mut Chosen, first: bool) -> &'a mut Chosen { - if first { a } else { b } -} - -/// A pointer made of a reference a callee picks between two variables, compared after -/// the caller's assignment of one of them. -pub fn chosen_compared_rebound(n: u32, first: bool) -> bool { - let mut a = Chosen(n); - let mut b = Chosen(n + 1); - let r = choose(&mut a, &mut b, first); - let p = &raw const *r; - a = Chosen(n + 2); - p == &raw const a && a.0 > b.0 -} - -fn bytes_of(b: &[u8; 4]) -> *const [u8; 4] { - b -} - -/// A pointer a callee makes to an array of bytes, compared after the caller's assignment. -pub fn bytes_compared_rebound(n: u8) -> bool { - let mut b = [n; 4]; - let p = bytes_of(&b); - b = [n ^ 1; 4]; - std::ptr::eq(p, bytes_of(&b)) && b[0] > 0 -} - -pub struct Wrapped(pub u8, pub T); - -fn wrapped_of(w: &Wrapped) -> *const Wrapped { - w -} - -/// A pointer a generic callee makes, instantiated with a cell, which the caller's -/// assignment replaces. -pub fn generic_cell_rebound(n: u32) -> u32 { - let mut w = Wrapped(1, std::cell::Cell::new(n)); - let p = wrapped_of(&w); - w = Wrapped(2, std::cell::Cell::new(0)); - unsafe { (*p).1.get() + w.0 as u32 } -} - -fn part_cell(c: &std::cell::UnsafeCell) -> *mut u16 { - c.get() -} - -pub struct Replaced { - pub cell: std::cell::UnsafeCell, -} - -fn replace_part(r: &mut Replaced) { - drop(std::mem::replace(&mut r.cell, std::cell::UnsafeCell::new(0))); -} - -/// A pointer a callee takes through a reference to a cell in a struct, which another -/// function's `mem::replace` gives another object. -pub fn part_mem_replaced(n: u16) -> u16 { - let mut r = Replaced { - cell: std::cell::UnsafeCell::new(n), - }; - let p = part_cell(&r.cell); - replace_part(&mut r); - unsafe { *p } -} - -pub struct Swapped { - pub cell: std::cell::UnsafeCell, -} - -fn swap_part(s: &mut Swapped) { - std::mem::swap(&mut s.cell, &mut std::cell::UnsafeCell::new(0)); -} - -/// As `part_replaced`, by another function's `mem::swap`. -pub fn part_swapped(n: u16) -> u16 { - let mut s = Swapped { - cell: std::cell::UnsafeCell::new(n), - }; - let p = part_cell(&s.cell); - swap_part(&mut s); - unsafe { *p } -} - -pub struct Taken { - pub cell: std::cell::UnsafeCell, -} - -fn take_part(t: &mut Taken) { - drop(std::mem::take(&mut t.cell)); -} - -/// As `part_replaced`, by another function's `mem::take`. -pub fn part_taken(n: u16) -> u16 { - let mut t = Taken { - cell: std::cell::UnsafeCell::new(n), - }; - let p = part_cell(&t.cell); - take_part(&mut t); - unsafe { *p } -} - -pub struct Assigned { - pub cell: std::cell::UnsafeCell, -} - -fn assign_part(a: &mut Assigned) { - a.cell = std::cell::UnsafeCell::new(0); -} - -/// As `part_replaced`, by another function's assignment of the part through a `&mut` to -/// its holder. -pub fn part_assigned(n: u16) -> u16 { - let mut a = Assigned { - cell: std::cell::UnsafeCell::new(n), - }; - let p = part_cell(&a.cell); - assign_part(&mut a); - unsafe { *p } -} - -pub struct Deeper { - pub cell: std::cell::UnsafeCell, -} - -fn deeper_cell(c: &std::cell::UnsafeCell) -> *mut u16 { - part_cell(c) -} - -fn assign_deeper(d: &mut Deeper) { - d.cell = std::cell::UnsafeCell::new(0); -} - -fn reset_deeper(d: &mut Deeper) { - assign_deeper(d); -} - -/// As `part_assigned`, with the pointer taken and the part assigned each two calls deep. -pub fn part_replaced_deep(n: u16) -> u16 { - let mut d = Deeper { - cell: std::cell::UnsafeCell::new(n), - }; - let p = deeper_cell(&d.cell); - reset_deeper(&mut d); - unsafe { *p } -} - -pub trait Clear { - fn clear(&mut self); -} - -pub struct Dynamic { - pub cell: std::cell::UnsafeCell, -} - -impl Clear for Dynamic { - fn clear(&mut self) { - self.cell = std::cell::UnsafeCell::new(0); - } -} - -/// As `part_assigned`, through a trait object's method. -pub fn part_replaced_dyn(n: u16) -> u16 { - let mut d = Dynamic { - cell: std::cell::UnsafeCell::new(n), - }; - let p = part_cell(&d.cell); - let clear: &mut dyn Clear = &mut d; - clear.clear(); - unsafe { *p } -} - -pub struct Closed { - pub cell: std::cell::UnsafeCell, -} - -/// As `part_assigned`, by a closure, which also takes the pointer. -pub fn part_replaced_closure(n: u16) -> u16 { - let mut e = Closed { - cell: std::cell::UnsafeCell::new(n), - }; - let take = |c: &std::cell::UnsafeCell| c.get(); - let p = take(&e.cell); - let reset = |e: &mut Closed| e.cell = std::cell::UnsafeCell::new(0); - reset(&mut e); - unsafe { *p } -} - -fn replace_element(cells: &mut [std::cell::UnsafeCell; 2]) { - cells[1] = std::cell::UnsafeCell::new(0); -} - -/// As `part_assigned`, with the cell an array's element, which another function assigns. -pub fn element_replaced(n: u16) -> u16 { - let mut cells = [std::cell::UnsafeCell::new(n), std::cell::UnsafeCell::new(n)]; - let p = part_cell(&cells[1]); - replace_element(&mut cells); - unsafe { *p } -} - -#[derive(Clone, Copy)] -pub struct Block([u8; N]); - -/// A struct generic over a length, which no class is, cloned out of an `Option` a pair -/// holds and written back whole in a body generic over that length. -pub fn block_cloned(a: Option>) -> Option> { - reclone(a) -} - -fn reclone(a: Option>) -> Option> { - let mut pair = (a, 0u8); - #[allow(clippy::clone_on_copy, reason = "the clone `Option`'s `Clone` makes")] - let copy = pair.0.clone(); - pair.0 = copy; - pair.0 -} - -/// `LinkedList`'s unstable `retain`, which no mapping covers, as none does its other -/// unstable methods; its `clone_from` of items whose own `clone_from` it would call; and -/// an empty `IterMut` of bytes, whose places nothing makes. -pub fn lists(l: &mut std::collections::LinkedList, r: &mut std::collections::LinkedList) -> usize { - l.retain(|x| *x > 1); - r.clone_from(&std::collections::LinkedList::new()); - std::collections::linked_list::IterMut::::default().count() -} - -pub struct Parking { - pub task: T, - pub park: Parked, -} - -pub struct Parked(pub std::cell::Cell); - -fn parked_of(a: &A) -> *const A { - a -} - -/// A pointer a callee generic over what it points at makes into a cell, which the -/// caller's assignment replaces, in a body that the census lowers over its own type -/// parameter: the callee's instance for the cell's holder takes it. -pub fn generic_park_rebound(mut w: Parking, next: Parking) -> i16 { - let p = parked_of(&w.park); - w = next; - unsafe { (*p).0.get() + w.park.0.get() } -} - -/// An `Option` of pointers to a number, each an `rt.Place` JS makes of its own. -pub fn optional_places_compared(n: &mut u32) -> bool { - let p = std::ptr::NonNull::from(&mut *n); - Some(p) == std::ptr::NonNull::new(&raw mut *n) -} - -/// A `RefMut` mapped to a closure, which a write through the guard would put in place of -/// the cell's, though JS can't write one closure's captures into another. -pub fn mapped_closure(add: u8) -> u8 { - let cell = std::cell::RefCell::new((move |x: u8| x + add, 0u8)); - let f = std::cell::RefMut::map(cell.borrow_mut(), |pair| &mut pair.0); - f(1) -} - -/// Pointers into arrays whose elements JS keeps as objects: a pointer to one is the -/// object, which knows no array it is in. -pub fn object_elements(v: &mut Vec<(u8, u8)>, a: [(u8, u8); 2]) -> u8 { - let p = v.as_mut_ptr(); - unsafe { - let q = p.add(1); - std::ptr::copy(p, q, 1); - let s = std::slice::from_raw_parts(p, 2); - let first = (&raw const a).cast::<(u8, u8)>(); - (*q).0 + s[1].1 + (*first).0 + q.offset_from(p) as u8 - } -} - -/// Pointers to values of no bytes, which std's `offset_from` panics on, and a slice of -/// them from one, which has no array to be a view of. -pub fn unit_elements(p: *const ()) -> usize { - unsafe { p.offset_from(p) as usize + std::slice::from_raw_parts(p, 3).len() } -} - -/// A pointer to an element cast to one to an array of elements from it. -pub fn element_to_array(v: &[u32]) -> u32 { - unsafe { (*(v.as_ptr() as *const [u32; 2]))[1] } -} - -/// A struct holding an array. -pub struct Lanes { - /// The array a pointer points into. - pub lanes: [u32; 3], -} - -/// Pointers to elements of arrays that a later assignment gives another JS array, which a -/// pointer into the first would not see: a variable's, and a struct's field. -pub fn elements_replaced(n: u32, l: &mut Lanes) -> u32 { - let mut a = [n; 3]; - let p = &raw mut a[1]; - a = [0; 3]; - let q = &raw mut l.lanes[2]; - l.lanes = [1; 3]; - unsafe { *p + *q + a[0] } -} - -#[repr(C)] -pub struct Halves { - pub low: u32, - pub high: u32, -} - -/// Two arrays in one allocation, which JS keeps apart. -#[repr(C)] -pub struct Rows { - /// The first. - pub top: [u32; 2], - /// The second. - pub bottom: [u32; 2], -} - -/// `offset_from` of pointers the body shows JS keeps in different arrays: two made apart -/// of one variable, two of a struct's fields, into two of its array fields, into two rows -/// of a nested array, one into a shared subslice, a copy, against one into what it was -/// taken of, and one into a shared slice of a byte, also a copy, against the byte's. -pub fn pointers_apart(n: u32, h: Halves, r: Rows, byte: u8) -> isize { - let a = &raw const n; - let b = &raw const n; - let grid = [[n; 2]; 2]; - let lanes = [n; 4]; - let part = &lanes[1..3]; - let at = &raw const byte; - unsafe { - let bytes = std::slice::from_raw_parts(at, 1); - a.offset_from(b) - + (&raw const h.high).offset_from(&raw const h.low) - + r.bottom.as_ptr().offset_from(r.top.as_ptr()) - + grid[1].as_ptr().offset_from(grid[0].as_ptr()) - + part.as_ptr().offset_from(lanes.as_ptr()) - + bytes.as_ptr().offset_from(at) - } -} - -/// A raw and a mutable slice of a byte in no array, which no `Uint8Array` can share. -pub fn lone_byte_slices(mut b: u8) -> u8 { - let raw = std::ptr::slice_from_raw_parts_mut(&raw mut b, 1); - let s = unsafe { std::slice::from_raw_parts_mut(&raw mut b, 1) }; - s[0] = 1; - unsafe { (*raw)[0] } -} - -/// Pointers, slices, and copies the body shows reach out of an array of one or a copied -/// subslice, where Rust's reach the rest of what holds them. -pub fn reached_out(h: Halves, lanes: [u32; 4]) -> u32 { - let part = &lanes[1..3]; - let mut to = [0u32; 3]; - unsafe { - std::ptr::copy_nonoverlapping(part.as_ptr(), to.as_mut_ptr(), 3); - let tail = lanes.get_unchecked(2..); - *part.as_ptr().sub(1) - + std::slice::from_raw_parts(&raw const h.low, 2)[1] - + *(&raw const h.high).sub(1) - + *tail.as_ptr().offset(-2) - + to[0] - } -} - -/// 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) -} - -/// Casts between pointers to bytes and to values outside memory from `alloc`, which read -/// the bytes of one type as another: of an array's bytes to `u32`s, of memory from -/// `alloc` to the crate's struct, which JS keeps as an object, and of a pointer to values -/// to one to their bytes, read rather than freed; and a byte of memory from `alloc` written -/// by `ptr::write`. -pub fn bytes_as_values(bytes: [u8; 4]) -> u32 { - let layout = std::alloc::Layout::new::(); - unsafe { - std::ptr::write(std::alloc::alloc(layout), 2); - let words = bytes.as_ptr() as *const u32; - let halves = std::alloc::alloc(layout) as *mut Halves; - let n = 7u32; - let byte = *((&raw const n) as *const u8); - *words + (*halves).low + u32::from(byte) - } -} - -/// Memory from `alloc` cast to pointers to two types, which reads one's bytes as the -/// other's, also once `realloc` grows it. -pub fn alloc_retyped() -> i32 { - let layout = std::alloc::Layout::new::(); - unsafe { - let raw = std::alloc::alloc(layout); - raw.cast::().write(u32::MAX); - let n = (raw as *mut i32).read(); - let grown = std::alloc::realloc(raw, layout, 8); - let m = grown.cast::().read(); - let words = grown.cast::(); - let again = std::alloc::realloc(words.cast::(), std::alloc::Layout::array::(2).unwrap(), 12); - let k = again.cast::().read(); - std::alloc::dealloc(again, std::alloc::Layout::array::(3).unwrap()); - n + m + k - } -} - -/// Memory from `alloc_zeroed`, whose zeroed bytes JS can't type. -pub fn zeroed() -> u32 { - unsafe { *(std::alloc::alloc_zeroed(std::alloc::Layout::new::()) as *mut u32) } -} - -/// `ManuallyDrop`'s impls beyond holding a value: compared, formatted, and a constant. -pub fn manual_impls(a: std::mem::ManuallyDrop, b: std::mem::ManuallyDrop) -> String { - const HELD: std::mem::ManuallyDrop = std::mem::ManuallyDrop::new(3); - format!("{a:?} {} {}", a == b, *HELD) -} - -/// The tags of the first of two slots, each written whole as `fill` beside a pair of -/// tags, then changed through a pointer to them. -macro_rules! tagged_slots { - ($slots:ident) => {{ - let tags = unsafe { &raw mut $slots[0].assume_init_mut().1 }; - unsafe { - (*tags).0 ^= 1; - (*tags).0 - } - }}; -} - -#[derive(Clone, Copy)] -pub struct Cloned(pub u8); - -/// Slots of a type parameter's values written whole through an iterator zipped with -/// clones of them: std's code calls the crate's `Clone`, so the writes fill nothing fresh. -pub fn cloned_slots(fill: [Cloned; 2]) -> u8 { - kept_slots(fill) -} - -fn kept_slots(fill: [T; 2]) -> u8 { - let mut slots: [std::mem::MaybeUninit<([T; 2], (u8, u8))>; 2] = [const { std::mem::MaybeUninit::uninit() }; 2]; - for (slot, value) in slots.iter_mut().zip(fill.iter().cloned()) { - slot.write(([value.clone(), value], (0, 1))); - } - tagged_slots!(slots) -} - -pub struct Dropped(pub Noisy); - -/// [`cloned_slots`] zipped with a vector's values, which std's iterator drops through -/// the crate's `Drop` of a field. -pub fn dropped_slots(fill: Vec) -> u8 { - moved_slots(fill) -} - -fn moved_slots(fill: Vec) -> u8 { - let mut slots: [std::mem::MaybeUninit<(T, (u8, u8))>; 2] = [const { std::mem::MaybeUninit::uninit() }; 2]; - for (slot, value) in slots.iter_mut().zip(fill) { - slot.write((value, (0, 1))); - } - tagged_slots!(slots) -} - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] -pub struct Greatest(pub u8); - -/// A slot written whole through the greatest of a type parameter's values, which std -/// finds through the crate's `Ord`. -pub fn ranked_slots(fill: [Greatest; 2]) -> u8 { - greatest_slot(fill) -} - -fn greatest_slot(fill: [T; 2]) -> u8 { - let mut slots: [([T; 2], (u8, u8)); 2] = [(fill, (0, 0)); 2]; - let Some(top) = slots.iter_mut().max() else { - return 0; - }; - *top = (fill, (1, 2)); - let tags = &raw mut top.1; - unsafe { - (*tags).0 ^= 1; - (*tags).0 - } -} - -/// What a type parameter's value does to a slot of it. -pub trait Touch: Sized { - fn touch(&self, slot: &mut std::mem::MaybeUninit<([Self; 2], (u8, u8))>); -} - -#[derive(Clone, Copy)] -pub struct Touched(pub u8); - -impl Touch for Touched { - fn touch(&self, _: &mut std::mem::MaybeUninit<([Self; 2], (u8, u8))>) {} -} - -/// [`cloned_slots`] where each slot is first given to the crate's own trait, through -/// the type parameter's bound. -pub fn touched_slots(fill: [Touched; 2]) -> u8 { - given_slots(fill) -} - -fn given_slots(fill: [T; 2]) -> u8 { - let mut slots: [std::mem::MaybeUninit<([T; 2], (u8, u8))>; 2] = [const { std::mem::MaybeUninit::uninit() }; 2]; - for (slot, at) in slots.iter_mut().zip(0u8..) { - fill[0].touch(slot); - slot.write((fill, (at, !at))); - } - tagged_slots!(slots) -} - -/// A raw pointer to an iterator as one to a trait object, whose `rt.Place` no `rt.Iter` is. -pub fn raw_dyn_iter(n: u8) -> Option { - let mut range = 0..n; - let p: *mut dyn Iterator = &raw mut range; - unsafe { (&mut *p).next() } -} +mod alloc; +mod buffers; +mod clones; +mod config; +mod fmt; +mod futures; +mod iters; +mod kept; +mod keys; +mod objects; +mod parts; +mod places; +mod pointers; +mod rebound; +mod statics; +mod strs; +mod values; diff --git a/ts/fixtures/reject/src/objects.rs b/ts/fixtures/reject/src/objects.rs new file mode 100644 index 000000000..7a6f5a1a2 --- /dev/null +++ b/ts/fixtures/reject/src/objects.rs @@ -0,0 +1,93 @@ +//! Trait objects the translation doesn't make. + +pub fn dynamic(h: &mut dyn std::hash::Hasher) -> u64 { + h.finish() +} + +pub trait Reading { + fn read(&self) -> u8; +} + +impl Reading for u8 { + fn read(&self) -> u8 { + *self + } +} + +pub trait Scaled { + fn scale(&self, by: T) -> T; +} + +/// A trait object of a generic trait. +pub fn generic_object(s: &dyn Scaled) -> u8 { + s.scale(2) +} + +pub trait First { + fn first(&self) -> u8; +} + +impl First for [u8; 4] { + fn first(&self) -> u8 { + self[0] + } +} + +/// A trait object of a byte array, which a box holds as a `Uint8Array` and a reference as +/// an `rt.ByteSlice`. +pub fn first_of(n: u8) -> u8 { + let b: Box = Box::new([n, 8, 9, 10]); + b.first() +} + +pub trait Keyed: std::any::Any { + fn key(&self) -> u8; +} + +impl Keyed for u8 { + fn key(&self) -> u8 { + *self + } +} + +/// An upcast to `dyn Any`, whose downcast checks for the class of the value's own type, +/// not the object of another trait. +pub fn any_upcast(k: &dyn Keyed) -> bool { + let any: &dyn std::any::Any = k; + any.is::() +} + +/// The same upcast of a `Weak`. +pub fn weak_any_upcast(k: std::rc::Weak) -> bool { + let any: std::rc::Weak = k; + any.upgrade().is_some_and(|a| a.is::()) +} + +/// A `TypeId`, which no value stands for yet. +pub fn any_type_id(a: &dyn std::any::Any) -> bool { + a.type_id() == std::any::TypeId::of::() +} + +pub trait Source { + type Item: Reading; + fn item(&self) -> &Self::Item; +} + +/// A trait object of a type only an instance decides, which a census lowering this over +/// its type parameter can't make. +pub fn source_reading(s: &S) -> u8 { + let r: &dyn Reading = s.item(); + r.read() +} + +/// `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 raw pointer to an iterator as one to a trait object, whose `rt.Place` no `rt.Iter` is. +pub fn raw_dyn_iter(n: u8) -> Option { + let mut range = 0..n; + let p: *mut dyn Iterator = &raw mut range; + unsafe { (&mut *p).next() } +} diff --git a/ts/fixtures/reject/src/parts.rs b/ts/fixtures/reject/src/parts.rs new file mode 100644 index 000000000..ee481eb43 --- /dev/null +++ b/ts/fixtures/reject/src/parts.rs @@ -0,0 +1,279 @@ +//! Pointers into parts of objects that a whole write of the part replaces. + +use crate::rebound::part_cell; + +/// Structs JS keeps as objects, each holding an `rt.Cell`, one for each kind of whole +/// write of a value that holds one, which gives it another cell, while a pointer to the +/// cell, taken through a reference to the struct, may still be read. +pub struct InArray(pub std::cell::UnsafeCell); + +pub struct InTuple(pub std::cell::UnsafeCell); + +pub struct InNested(pub std::cell::UnsafeCell); + +pub struct InPayload(pub std::cell::UnsafeCell); + +pub struct InField(pub std::cell::UnsafeCell); + +pub struct InGeneric(pub std::cell::UnsafeCell); + +pub struct InWritten(pub std::cell::UnsafeCell); + +pub struct Mid(pub u16, pub T); + +pub struct Outer(pub Mid); + +fn array_part(held: &InArray) -> *mut u16 { + held.0.get() +} + +fn tuple_part(held: &InTuple) -> *mut u16 { + held.0.get() +} + +fn nested_part(held: &InNested) -> *mut u16 { + held.0.get() +} + +fn payload_part(held: &InPayload) -> *mut u16 { + held.0.get() +} + +fn field_part(held: &InField) -> *mut u16 { + held.0.get() +} + +fn generic_part(held: &InGeneric) -> *mut u16 { + held.0.get() +} + +fn written_part(held: &InWritten) -> *mut u16 { + held.0.get() +} + +pub fn cell(n: u16) -> std::cell::UnsafeCell { + std::cell::UnsafeCell::new(n) +} + +/// A whole array written, then a pointer into its element read. +pub fn array_part_replaced(n: u16) -> u16 { + let mut whole = [InArray(cell(n)), InArray(cell(n))]; + let p = &raw mut whole; + let part = array_part(unsafe { &(*p)[1] }); + unsafe { *p = [InArray(cell(0)), InArray(cell(0))] }; + unsafe { *part } +} + +/// A whole tuple written, then a pointer into its element read. +pub fn tuple_part_replaced(n: u16) -> u16 { + let mut whole = (n, InTuple(cell(n))); + let p = &raw mut whole; + let part = tuple_part(unsafe { &(*p).1 }); + unsafe { *p = (0, InTuple(cell(0))) }; + unsafe { *part } +} + +/// A whole struct written, then a pointer into a struct its field holds read. +pub fn nested_part_replaced(n: u16) -> u16 { + let mut whole = Outer(Mid(n, InNested(cell(n)))); + let p = &raw mut whole; + let part = nested_part(unsafe { &(*p).0.1 }); + unsafe { *p = Outer(Mid(0, InNested(cell(0)))) }; + unsafe { *part } +} + +/// A whole `Option` written, then a pointer into its payload read. +pub fn payload_part_replaced(n: u16) -> u16 { + let mut whole = Some(InPayload(cell(n))); + let p = &raw mut whole; + let Some(held) = (unsafe { &*p }) else { + return 0; + }; + let part = payload_part(held); + unsafe { *p = Some(InPayload(cell(0))) }; + unsafe { *part } +} + +/// A whole field written, then a pointer into a struct it holds read. +pub fn field_part_replaced(n: u16) -> u16 { + let mut whole = Outer(Mid(n, InField(cell(n)))); + let p = &raw mut whole; + let part = field_part(unsafe { &(*p).0.1 }); + unsafe { (*p).0 = Mid(0, InField(cell(0))) }; + unsafe { *part } +} + +fn set(slot: *mut T, value: T) { + unsafe { *slot = value } +} + +/// A whole struct written by a generic body, then a pointer into a struct it holds read. +pub fn generic_part_replaced(n: u16) -> u16 { + let mut whole = Outer(Mid(n, InGeneric(cell(n)))); + let p = &raw mut whole; + let part = generic_part(unsafe { &(*p).0.1 }); + set(p, Outer(Mid(0, InGeneric(cell(0))))); + unsafe { *part } +} + +/// A whole array written by std, then a pointer into its element read. +pub fn written_part_replaced(n: u16) -> u16 { + let mut whole = [InWritten(cell(n))]; + let p = &raw mut whole; + let part = written_part(unsafe { &(*p)[0] }); + unsafe { p.write([InWritten(cell(0))]) }; + unsafe { *part } +} + +pub struct Replaced { + pub cell: std::cell::UnsafeCell, +} + +fn replace_part(r: &mut Replaced) { + drop(std::mem::replace(&mut r.cell, std::cell::UnsafeCell::new(0))); +} + +/// A pointer a callee takes through a reference to a cell in a struct, which another +/// function's `mem::replace` gives another object. +pub fn part_mem_replaced(n: u16) -> u16 { + let mut r = Replaced { + cell: std::cell::UnsafeCell::new(n), + }; + let p = part_cell(&r.cell); + replace_part(&mut r); + unsafe { *p } +} + +pub struct Swapped { + pub cell: std::cell::UnsafeCell, +} + +fn swap_part(s: &mut Swapped) { + std::mem::swap(&mut s.cell, &mut std::cell::UnsafeCell::new(0)); +} + +/// As `part_replaced`, by another function's `mem::swap`. +pub fn part_swapped(n: u16) -> u16 { + let mut s = Swapped { + cell: std::cell::UnsafeCell::new(n), + }; + let p = part_cell(&s.cell); + swap_part(&mut s); + unsafe { *p } +} + +pub struct Taken { + pub cell: std::cell::UnsafeCell, +} + +fn take_part(t: &mut Taken) { + drop(std::mem::take(&mut t.cell)); +} + +/// As `part_replaced`, by another function's `mem::take`. +pub fn part_taken(n: u16) -> u16 { + let mut t = Taken { + cell: std::cell::UnsafeCell::new(n), + }; + let p = part_cell(&t.cell); + take_part(&mut t); + unsafe { *p } +} + +pub struct Assigned { + pub cell: std::cell::UnsafeCell, +} + +fn assign_part(a: &mut Assigned) { + a.cell = std::cell::UnsafeCell::new(0); +} + +/// As `part_replaced`, by another function's assignment of the part through a `&mut` to +/// its holder. +pub fn part_assigned(n: u16) -> u16 { + let mut a = Assigned { + cell: std::cell::UnsafeCell::new(n), + }; + let p = part_cell(&a.cell); + assign_part(&mut a); + unsafe { *p } +} + +pub struct Deeper { + pub cell: std::cell::UnsafeCell, +} + +fn deeper_cell(c: &std::cell::UnsafeCell) -> *mut u16 { + part_cell(c) +} + +fn assign_deeper(d: &mut Deeper) { + d.cell = std::cell::UnsafeCell::new(0); +} + +fn reset_deeper(d: &mut Deeper) { + assign_deeper(d); +} + +/// As `part_assigned`, with the pointer taken and the part assigned each two calls deep. +pub fn part_replaced_deep(n: u16) -> u16 { + let mut d = Deeper { + cell: std::cell::UnsafeCell::new(n), + }; + let p = deeper_cell(&d.cell); + reset_deeper(&mut d); + unsafe { *p } +} + +pub trait Clear { + fn clear(&mut self); +} + +pub struct Dynamic { + pub cell: std::cell::UnsafeCell, +} + +impl Clear for Dynamic { + fn clear(&mut self) { + self.cell = std::cell::UnsafeCell::new(0); + } +} + +/// As `part_assigned`, through a trait object's method. +pub fn part_replaced_dyn(n: u16) -> u16 { + let mut d = Dynamic { + cell: std::cell::UnsafeCell::new(n), + }; + let p = part_cell(&d.cell); + let clear: &mut dyn Clear = &mut d; + clear.clear(); + unsafe { *p } +} + +pub struct Closed { + pub cell: std::cell::UnsafeCell, +} + +/// As `part_assigned`, by a closure, which also takes the pointer. +pub fn part_replaced_closure(n: u16) -> u16 { + let mut e = Closed { + cell: std::cell::UnsafeCell::new(n), + }; + let take = |c: &std::cell::UnsafeCell| c.get(); + let p = take(&e.cell); + let reset = |e: &mut Closed| e.cell = std::cell::UnsafeCell::new(0); + reset(&mut e); + unsafe { *p } +} + +fn replace_element(cells: &mut [std::cell::UnsafeCell; 2]) { + cells[1] = std::cell::UnsafeCell::new(0); +} + +/// As `part_assigned`, with the cell an array's element, which another function assigns. +pub fn element_replaced(n: u16) -> u16 { + let mut cells = [std::cell::UnsafeCell::new(n), std::cell::UnsafeCell::new(n)]; + let p = part_cell(&cells[1]); + replace_element(&mut cells); + unsafe { *p } +} diff --git a/ts/fixtures/reject/src/places.rs b/ts/fixtures/reject/src/places.rs new file mode 100644 index 000000000..2bf5e4533 --- /dev/null +++ b/ts/fixtures/reject/src/places.rs @@ -0,0 +1,112 @@ +//! Writes through references whose referent JS keeps as the place, or as another object. + +pub struct Noisy(pub u8); + +impl Drop for Noisy { + fn drop(&mut self) {} +} + +/// A guard is its mutex in JS: replacing it would copy the other mutex's value in. +pub fn replace_guard<'a>(dst: &mut std::sync::MutexGuard<'a, u8>, src: std::sync::MutexGuard<'a, u8>) { + *dst = src; +} + +/// A boxed `PollFn` is the `rt.PollFn`, whose callback is private where a copy can't reach. +pub fn replace_boxed_poll_fn( + dst: &mut std::pin::Pin) -> std::task::Poll>>>, + src: std::pin::Pin) -> std::task::Poll>>>, +) -> std::pin::Pin) -> std::task::Poll>>> { + std::mem::replace(dst, src) +} + +/// A boxed byte array is a `Uint8Array`, which a replacement can't copy out as an object. +pub fn replace_boxed_bytes( + dst: &mut std::pin::Pin>, + src: std::pin::Pin>, +) -> std::pin::Pin> { + std::mem::replace(dst, src) +} + +/// A boxed future is whatever class its value's type is. +pub fn replace_boxed_future( + dst: &mut std::pin::Pin>>, + src: std::pin::Pin>>, +) { + *dst = src; +} + +/// Swapping two guards would swap their mutexes' values instead. +pub fn swap_guards<'a>(a: &mut std::sync::MutexGuard<'a, u8>, b: &mut std::sync::MutexGuard<'a, u8>) { + std::mem::swap(a, b); +} + +/// A type of no bytes. +pub struct Bare; + +/// A pinned reference is its referent in JS: replacing it would change what it points at. +pub fn replace_pinned_ref<'a>(dst: &mut std::pin::Pin<&'a mut Noisy>, src: std::pin::Pin<&'a mut Noisy>) { + *dst = src; +} + +/// Each copy of a closure has its own captures, which copies of an arrow function share. +pub fn copied_closure(n: u8) -> u8 { + let mut a = [n]; + let mut g = move || { + a[0] = a[0].wrapping_add(1); + a[0] + }; + let mut h = g; + g().wrapping_add(h()) +} + +fn bumped(x: &mut u8) { + *x += 1; +} + +/// A `Result`'s value passed on: a store through it makes the `Result` again, which no +/// `rt.Place` of a path does. +pub fn ok_passed(r: &mut Result) { + if let Ok(v) = r { + bumped(v); + } +} + +/// `Option`s holding `rt.Place`s, which std's runtime would compare as the Places. +pub fn places_equal(a: &mut u32, b: &mut u32) -> bool { + Some(a) == Some(b) +} + +/// A copy of a closure that rebinds a shared reference it captured: each Rust copy has +/// its own, where JS would share one binding. +pub fn rebound_reference(a: &u32, b: &u32) -> (u32, u32) { + let mut r = a; + let c = move || { + let old = *r; + r = b; + old + }; + let mut x = c; + let mut y = c; + (x(), y()) +} + +/// Two `rt.Place`s of one number, which are two objects. +pub fn places_compared(n: &mut u32) -> bool { + let a = &raw mut *n; + let b = &raw mut *n; + a == b +} + +/// An `Option` of pointers to a number, each an `rt.Place` JS makes of its own. +pub fn optional_places_compared(n: &mut u32) -> bool { + let p = std::ptr::NonNull::from(&mut *n); + Some(p) == std::ptr::NonNull::new(&raw mut *n) +} + +/// A `RefMut` mapped to a closure, which a write through the guard would put in place of +/// the cell's, though JS can't write one closure's captures into another. +pub fn mapped_closure(add: u8) -> u8 { + let cell = std::cell::RefCell::new((move |x: u8| x + add, 0u8)); + let f = std::cell::RefMut::map(cell.borrow_mut(), |pair| &mut pair.0); + f(1) +} diff --git a/ts/fixtures/reject/src/pointers.rs b/ts/fixtures/reject/src/pointers.rs new file mode 100644 index 000000000..02e3b0594 --- /dev/null +++ b/ts/fixtures/reject/src/pointers.rs @@ -0,0 +1,457 @@ +//! Raw pointers to objects that a write of the whole variable, part, or element replaces, and to arrays JS keeps apart. + +pub struct Span2 { + pub start: (u32, u32), + pub len: u32, +} + +/// A pointer to a part kept as an object, which a write of the whole part elsewhere +/// replaces with another object. +pub fn part_replaced(n: u32) -> u32 { + let mut s = Span2 { start: (n, n), len: n }; + let p = &raw mut s.start; + s.start = (0, 0); + unsafe { (*p).0 + s.len } +} + +/// A pointer to a variable's object, which an assignment of the whole variable replaces. +pub fn variable_reassigned(n: u32) -> u32 { + let mut pair = (n, n); + let p = &raw mut pair; + pair = (0, 0); + unsafe { (*p).0 + pair.1 } +} + +/// A pointer to a variable's object, which `mem::replace` of the whole variable replaces. +pub fn variable_replaced(n: u32) -> u32 { + let mut pair = (n, n); + let p = &raw mut pair; + let old = std::mem::replace(&mut pair, (0, 0)); + unsafe { (*p).0 + old.1 } +} + +/// A pointer to a variable's object, which `mem::swap` replaces. +pub fn variable_swapped(n: u32) -> u32 { + let mut a = (n, n); + let mut b = (0, 0); + let p = &raw mut a; + std::mem::swap(&mut a, &mut b); + unsafe { (*p).0 + b.1 } +} + +/// A pointer to a variable's object, which a whole write through a `&mut` to it replaces. +pub fn assigned_through(n: u32) -> u32 { + let mut pair = (n, n); + let p = &raw mut pair; + let r = &mut pair; + *r = (0, 0); + unsafe { (*p).0 } +} + +/// A pointer `NonNull::from` makes of a `&mut` to a variable, which an assignment replaces. +pub fn nonnull_reassigned(n: u32) -> u32 { + let mut pair = (n, n); + let p = std::ptr::NonNull::from(&mut pair); + pair = (0, 0); + unsafe { p.as_ref().0 + pair.1 } +} + +/// A pointer cast from a `&mut` to a variable, which an assignment replaces. +pub fn cast_reassigned(n: u32) -> u32 { + let mut pair = (n, n); + let p = &mut pair as *mut (u32, u32); + pair = (0, 0); + unsafe { (*p).0 + pair.1 } +} + +pub struct Window { + pub range: (u32, u32), +} + +/// A pointer to a part kept as an object, which `mem::replace` of the part elsewhere replaces. +pub fn range_of(w: &mut Window) -> *mut (u32, u32) { + &raw mut w.range +} + +pub fn range_replaced(w: &mut Window) -> (u32, u32) { + std::mem::replace(&mut w.range, (0, 0)) +} + +/// A pointer to an element kept as an object. +pub fn element_pointer(n: u32) -> u32 { + let mut pairs = [(n, n); 2]; + let p = &raw mut pairs[1]; + unsafe { (*p).0 } +} + +/// The pointer `UnsafeCell::get` gives to the object its `rt.Cell` holds, which a whole +/// write of the cell elsewhere replaces with another object. +pub fn cell_replaced(n: u32) -> u32 { + let mut cell = std::cell::UnsafeCell::new((n, n)); + let p = cell.get(); + let old = std::mem::replace(&mut cell, std::cell::UnsafeCell::new((0, 0))); + unsafe { (*p).0 + old.into_inner().1 } +} + +/// The pointer `UnsafeCell::get` gives to a number, the `rt.Cell` itself, which an +/// assignment of the whole variable replaces. +pub fn cell_reassigned(n: u32) -> u32 { + let mut cell = std::cell::UnsafeCell::new(n); + let p = cell.get(); + cell = std::cell::UnsafeCell::new(0); + unsafe { *p + cell.into_inner() } +} + +pub struct Hits { + pub count: std::cell::UnsafeCell, +} + +/// The pointer `UnsafeCell::get` gives to a number, the `rt.Cell` itself, which +/// `mem::take` of the whole variable replaces. +pub fn cell_taken(n: u32) -> u32 { + let mut cell = std::cell::UnsafeCell::new(n); + let p = cell.get(); + let old = std::mem::take(&mut cell); + unsafe { *p + old.into_inner() } +} + +/// The pointer `UnsafeCell::get` gives to a number, the `rt.Cell` in a struct, which a +/// write of the whole field replaces. +pub fn cell_field_replaced(n: u32) -> u32 { + let mut hits = Hits { + count: std::cell::UnsafeCell::new(n), + }; + let p = hits.count.get(); + hits.count = std::cell::UnsafeCell::new(0); + unsafe { *p + *hits.count.get_mut() } +} + +pub struct Plain { + pub at: (u32, u32), +} + +fn put(slot: &mut T, value: T) { + *slot = value; +} + +/// A pointer to a part kept as an object, which a generic body reached at its struct +/// replaces with another object. +pub fn put_replaced(n: u32) -> u32 { + let mut plain = Plain { at: (n, n) }; + let p = &raw mut plain.at; + put(&mut plain, Plain { at: (0, 0) }); + unsafe { (*p).0 } +} + +#[derive(Default)] +pub struct Track { + pub at: (u32, u32), +} + +pub struct Bin(std::cell::UnsafeCell); + +pub trait Reset { + fn reset(&self); +} + +impl Reset for Bin { + fn reset(&self) { + unsafe { *self.0.get() = T::default() }; + } +} + +/// A pointer to a part kept as an object, which a generic body reached only through a trait +/// object replaces with another object. +pub fn object_replaced(n: u32) -> u32 { + let bin = Bin(std::cell::UnsafeCell::new(Track { at: (n, n) })); + let p = unsafe { &raw mut (*bin.0.get()).at }; + let object: &dyn Reset = &bin; + object.reset(); + unsafe { (*p).0 } +} + +#[derive(Default)] +pub struct Lane { + pub at: (u32, u32), +} + +fn resetter(slot: *mut T) -> impl FnOnce() { + move || unsafe { *slot = T::default() } +} + +/// A pointer to a part kept as an object, which a generic closure reached at its struct +/// replaces with another object. +pub fn closure_replaced(n: u32) -> u32 { + let mut lane = Lane { at: (n, n) }; + let whole = &raw mut lane; + let p = unsafe { &raw mut (*whole).at }; + resetter(whole)(); + unsafe { (*p).0 } +} + +pub struct Gap { + pub range: (u32, u32), + pub slot: std::mem::MaybeUninit<(u32, u32)>, +} + +fn reset_gap(gap: &mut Gap) { + gap.range = (0, 0); + gap.slot = std::mem::MaybeUninit::new((0, 0)); +} + +/// The pointers `NonNull::from` makes of a `&mut` and of a `&` to a part kept as an object, +/// and `into` of a `&mut`, which a write of the whole part elsewhere replaces with another +/// object. +pub fn made_part_replaced(n: u32) -> u32 { + let mut gap = Gap { + range: (n, n), + slot: std::mem::MaybeUninit::new((n, n)), + }; + let p = std::ptr::NonNull::from(&mut gap.range); + let q = std::ptr::NonNull::from(&gap.range); + let r: std::ptr::NonNull<(u32, u32)> = (&mut gap.range).into(); + reset_gap(&mut gap); + unsafe { p.as_ref().0 + q.as_ref().1 + r.as_ref().0 } +} + +/// The pointers `MaybeUninit::as_ptr` and `as_mut_ptr` make to a part kept as an object, +/// which a write of the whole part elsewhere replaces with another object. +pub fn uninit_part_replaced(n: u32) -> u32 { + let mut gap = Gap { + range: (n, n), + slot: std::mem::MaybeUninit::new((n, n)), + }; + let p = gap.slot.as_ptr(); + let q = gap.slot.as_mut_ptr(); + reset_gap(&mut gap); + unsafe { (*p).0 + (*q).1 } +} + +/// A struct holding a pointer. +pub struct Aimed { + pub at: *mut (u32, u32), +} + +/// A pointer to a variable's object, copied into a struct read after an assignment of +/// the whole variable replaces the object. +pub fn pointer_in_struct(n: u32) -> u32 { + let mut pair = (n, n); + let aimed = Aimed { at: &raw mut pair }; + pair = (0, 0); + unsafe { (*aimed.at).0 + pair.1 } +} + +fn handed_back(p: *mut T) -> *mut T { + p +} + +/// A pointer to a variable's object, which a call returns, read after an assignment of +/// the whole variable replaces the object. +pub fn pointer_returned(n: u32) -> u32 { + let mut pair = (n, n); + let p = handed_back(&raw mut pair); + pair = (0, 0); + unsafe { (*p).0 + pair.1 } +} + +/// A pointer to a variable's object, kept in a `Vec` and read after an assignment of the +/// whole variable replaces the object. +pub fn pointer_pushed(n: u32) -> u32 { + let mut pair = (n, n); + let mut kept = Vec::new(); + kept.push(&raw mut pair); + pair = (0, 0); + unsafe { (*kept[0]).0 + pair.1 } +} + +/// A pointer to a variable's object, which a closure captures and reads after an +/// assignment of the whole variable replaces the object. +pub fn pointer_captured(n: u32) -> u32 { + let mut pair = (n, n); + let p = &raw mut pair; + let read = move || unsafe { (*p).0 }; + pair = (0, 0); + read() + pair.1 +} + +/// A pointer an earlier iteration made to a variable's object, read after the next +/// iteration's assignment of the whole variable replaces the object. +pub fn pointer_kept_across(data: &[u32]) -> u32 { + let mut pair = (0, 0); + let mut last = &raw mut pair; + let mut sum = 0; + for &n in data { + pair = (n, n); + sum += unsafe { (*last).0 }; + last = &raw mut pair; + } + sum +} + +/// Pointer operations on arrays of bytes that read the address or other bytes than the +/// array's: comparing addresses only, copying, offsetting, hashing, and ordering, beside +/// pointers to their first bytes. +pub fn byte_pointer_ops(mut a: [u8; 4], b: [u8; 4]) -> u64 { + use std::hash::{Hash, Hasher}; + let p: *mut [u8; 4] = &mut a; + let q: *const [u8; 4] = &b; + unsafe { + std::ptr::copy(q, p, 1); + std::ptr::copy_nonoverlapping(q, p, 1); + let same = std::ptr::addr_eq(p, q) || p < q.cast_mut(); + let byte = *p.cast::() + *(q as *const u8) + (*p.add(0))[0] + (*q.offset(0))[1]; + let slice: *const [u8] = q; + let mut h = std::collections::hash_map::DefaultHasher::new(); + q.hash(&mut h); + h.finish() + u64::from(same) + u64::from(byte) + slice.len() as u64 + } +} + +/// Pointers to arrays of bytes that are parts of an array kept apart from it: a slice +/// pattern's rest and an array's element. +pub fn byte_pointer_parts(a: [u8; 4], b: [[u8; 2]; 3]) -> bool { + let [_, ref x @ ..] = a; + let [_, ref y @ ..] = a; + std::ptr::eq(x, y) || std::ptr::eq(&b[0], &b[1]) +} + +/// Pointers to an array of bytes in a variable assigned again while they point there, +/// made of a reference and as a raw borrow. +pub fn byte_pointer_rebound(n: u8) -> u8 { + let mut a = [n; 4]; + let p: *const [u8; 4] = &a; + let q = &raw const a; + a = [n ^ 1; 4]; + unsafe { (*p)[0] + (*q)[1] + a[2] } +} + +/// Pointers into arrays whose elements JS keeps as objects: a pointer to one is the +/// object, which knows no array it is in. +pub fn object_elements(v: &mut Vec<(u8, u8)>, a: [(u8, u8); 2]) -> u8 { + let p = v.as_mut_ptr(); + unsafe { + let q = p.add(1); + std::ptr::copy(p, q, 1); + let s = std::slice::from_raw_parts(p, 2); + let first = (&raw const a).cast::<(u8, u8)>(); + (*q).0 + s[1].1 + (*first).0 + q.offset_from(p) as u8 + } +} + +/// Pointers to values of no bytes, which std's `offset_from` panics on, and a slice of +/// them from one, which has no array to be a view of. +pub fn unit_elements(p: *const ()) -> usize { + unsafe { p.offset_from(p) as usize + std::slice::from_raw_parts(p, 3).len() } +} + +/// A pointer to an element cast to one to an array of elements from it. +pub fn element_to_array(v: &[u32]) -> u32 { + unsafe { (*(v.as_ptr() as *const [u32; 2]))[1] } +} + +/// A struct holding an array. +pub struct Lanes { + /// The array a pointer points into. + pub lanes: [u32; 3], +} + +/// Pointers to elements of arrays that a later assignment gives another JS array, which a +/// pointer into the first would not see: a variable's, and a struct's field. +pub fn elements_replaced(n: u32, l: &mut Lanes) -> u32 { + let mut a = [n; 3]; + let p = &raw mut a[1]; + a = [0; 3]; + let q = &raw mut l.lanes[2]; + l.lanes = [1; 3]; + unsafe { *p + *q + a[0] } +} + +#[repr(C)] +pub struct Halves { + pub low: u32, + pub high: u32, +} + +/// Two arrays in one allocation, which JS keeps apart. +#[repr(C)] +pub struct Rows { + /// The first. + pub top: [u32; 2], + /// The second. + pub bottom: [u32; 2], +} + +/// `offset_from` of pointers the body shows JS keeps in different arrays: two made apart +/// of one variable, two of a struct's fields, into two of its array fields, into two rows +/// of a nested array, one into a shared subslice, a copy, against one into what it was +/// taken of, and one into a shared slice of a byte, also a copy, against the byte's. +pub fn pointers_apart(n: u32, h: Halves, r: Rows, byte: u8) -> isize { + let a = &raw const n; + let b = &raw const n; + let grid = [[n; 2]; 2]; + let lanes = [n; 4]; + let part = &lanes[1..3]; + let at = &raw const byte; + unsafe { + let bytes = std::slice::from_raw_parts(at, 1); + a.offset_from(b) + + (&raw const h.high).offset_from(&raw const h.low) + + r.bottom.as_ptr().offset_from(r.top.as_ptr()) + + grid[1].as_ptr().offset_from(grid[0].as_ptr()) + + part.as_ptr().offset_from(lanes.as_ptr()) + + bytes.as_ptr().offset_from(at) + } +} + +/// A raw and a mutable slice of a byte in no array, which no `Uint8Array` can share. +pub fn lone_byte_slices(mut b: u8) -> u8 { + let raw = std::ptr::slice_from_raw_parts_mut(&raw mut b, 1); + let s = unsafe { std::slice::from_raw_parts_mut(&raw mut b, 1) }; + s[0] = 1; + unsafe { (*raw)[0] } +} + +/// Pointers, slices, and copies the body shows reach out of an array of one or a copied +/// subslice, where Rust's reach the rest of what holds them. +pub fn reached_out(h: Halves, lanes: [u32; 4]) -> u32 { + let part = &lanes[1..3]; + let mut to = [0u32; 3]; + unsafe { + std::ptr::copy_nonoverlapping(part.as_ptr(), to.as_mut_ptr(), 3); + let tail = lanes.get_unchecked(2..); + *part.as_ptr().sub(1) + + std::slice::from_raw_parts(&raw const h.low, 2)[1] + + *(&raw const h.high).sub(1) + + *tail.as_ptr().offset(-2) + + to[0] + } +} + +/// 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 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 } +} diff --git a/ts/fixtures/reject/src/rebound.rs b/ts/fixtures/reject/src/rebound.rs new file mode 100644 index 000000000..6b527411b --- /dev/null +++ b/ts/fixtures/reject/src/rebound.rs @@ -0,0 +1,280 @@ +//! Pointers a callee makes, which the caller's write of the whole variable replaces. + +fn cell_of(c: &std::cell::UnsafeCell) -> *mut u64 { + c.get() +} + +/// The pointer `UnsafeCell::get` gives a callee, the `rt.Cell` itself, which the caller's +/// assignment of the variable replaces. +pub fn cell_rebound(n: u64) -> u64 { + let mut cell = std::cell::UnsafeCell::new(n); + let p = cell_of(&cell); + cell = std::cell::UnsafeCell::new(0); + unsafe { *p + cell.into_inner() } +} + +pub struct Target(pub u32); + +/// A pointer through a reference that `mem::replace` points at another variable, which an +/// assignment of that variable replaces. +pub fn retargeted(n: u32) -> u32 { + let mut a = Target(n); + let mut b = Target(n); + let mut r = &mut a; + let _ = std::mem::replace(&mut r, &mut b); + let p = &raw mut *r; + b = Target(0); + unsafe { (*p).0 + b.0 + a.0 } +} + +/// A pointer through a reference that `mem::swap` points at another variable, which an +/// assignment of that variable replaces. +pub fn swap_retargeted(n: u32) -> u32 { + let mut a = (n, n); + let mut b = (n, n); + let mut r = &mut a; + let mut s = &mut b; + std::mem::swap(&mut r, &mut s); + let p = &raw mut *r; + b = (0, 0); + unsafe { (*p).0 + b.0 + a.0 } +} + +/// A pointer through a reference a loop's `mem::swap`s may point at either variable, one +/// of which an assignment then replaces. +pub fn swapped_in_loop(n: u32) -> u32 { + let mut a = (n, n); + let mut b = (n, 1); + let mut r = &mut a; + let mut s = &mut b; + for _ in 0..n { + std::mem::swap(&mut r, &mut s); + } + let p = &raw mut *r; + a = (0, 0); + unsafe { (*p).0 + a.0 } +} + +pub struct Behind(pub std::cell::Cell); + +fn read_behind(b: &Behind) -> *const Behind { + let p = &raw const *b; + let held = (p,); + unsafe { std::ptr::read(&raw const held).0 } +} + +/// A pointer a callee reads back through a pointer to where it put it, which the read +/// holds, and returns, to a cell the caller's assignment replaces. +pub fn read_behind_rebound(n: u32) -> u32 { + let mut b = Behind(std::cell::Cell::new(n)); + let p = read_behind(&b); + b = Behind(std::cell::Cell::new(0)); + unsafe { (*p).0.get() + b.0.get() } +} + +pub struct Unboxed(pub std::cell::Cell); + +fn unbox(u: &Unboxed) -> *const Unboxed { + *Box::leak(Box::new(&raw const *u)) +} + +/// A pointer a callee reads back out of a box it put it in, and returns, to a cell the +/// caller's assignment replaces. +pub fn unboxed_rebound(n: u32) -> u32 { + let mut u = Unboxed(std::cell::Cell::new(n)); + let p = unbox(&u); + u = Unboxed(std::cell::Cell::new(0)); + unsafe { (*p).0.get() + u.0.get() } +} + +pub struct Deep { + pub mid: DeepMid, +} + +pub struct DeepMid(pub u8, pub std::cell::UnsafeCell); + +fn deep_of(d: &Deep) -> *mut u32 { + d.mid.1.get() +} + +/// A pointer a callee makes into a cell two structs deep, which the caller's assignment +/// of the outer one replaces. +pub fn deep_cell_rebound(n: u32) -> u32 { + let mut d = Deep { + mid: DeepMid(1, std::cell::UnsafeCell::new(n)), + }; + let p = deep_of(&d); + d = Deep { + mid: DeepMid(2, std::cell::UnsafeCell::new(0)), + }; + unsafe { *p + d.mid.0 as u32 } +} + +pub enum Slot { + Empty, + Full(std::cell::Cell), +} + +pub struct Slotted(pub Slot); + +fn slotted_of(s: &Slotted) -> *const Slotted { + &raw const *s +} + +/// A pointer a callee makes to a struct whose only cell is in an enum's payload, which +/// the caller's assignment replaces. +pub fn payload_cell_rebound(n: u32) -> u32 { + let mut s = Slotted(Slot::Full(std::cell::Cell::new(n))); + let p = slotted_of(&s); + s = Slotted(Slot::Empty); + let rest = matches!(s.0, Slot::Empty) as u32; + match unsafe { &(*p).0 } { + Slot::Full(c) => c.get() + rest, + Slot::Empty => rest, + } +} + +pub struct Shared(pub std::cell::RefCell); + +fn shared_of(s: &Shared) -> *const Shared { + s +} + +/// A pointer a callee makes to a `RefCell`'s holder, which the caller's assignment +/// replaces. A `usize` leaves no padding, which is not in the cell. +pub fn ref_cell_rebound(n: usize) -> usize { + let mut s = Shared(std::cell::RefCell::new(n)); + let p = shared_of(&s); + s = Shared(std::cell::RefCell::new(0)); + unsafe { *(*p).0.borrow() + *s.0.borrow() } +} + +pub struct Duo(pub u32, pub u32); + +pub struct Inside(pub std::cell::UnsafeCell); + +fn inside_of(i: &Inside) -> *mut Duo { + i.0.get() +} + +/// A pointer a callee makes through a cell to the object it holds, which the caller's +/// assignment of the cell's holder replaces. +pub fn inside_cell_rebound(n: u32) -> u32 { + let mut i = Inside(std::cell::UnsafeCell::new(Duo(n, n))); + let p = inside_of(&i); + i = Inside(std::cell::UnsafeCell::new(Duo(0, 0))); + unsafe { (*p).0 + (*i.0.get()).1 } +} + +fn inside_field_of(i: &Inside) -> *mut u32 { + unsafe { &raw mut (*i.0.get()).1 } +} + +/// A pointer a callee makes through a cell to a field of the object it holds, which the +/// caller's assignment of the cell's holder replaces. +pub fn inside_field_rebound(n: u32) -> u32 { + let mut i = Inside(std::cell::UnsafeCell::new(Duo(n, n))); + let p = inside_field_of(&i); + i = Inside(std::cell::UnsafeCell::new(Duo(0, 0))); + unsafe { *p + (*i.0.get()).0 } +} + +pub struct Compared(pub u32); + +fn compared_of(c: &Compared) -> *const Compared { + c +} + +/// A pointer a callee makes to a struct with no cell, compared after the caller's +/// assignment, which Rust defines as its address and JS as the object it replaced. +pub fn compared_rebound(n: u32) -> bool { + let mut c = Compared(n); + let p = compared_of(&c); + c = Compared(n + 1); + p == compared_of(&c) && c.0 > 0 +} + +pub struct Enclosed(pub u32); + +pub struct Enclosing(pub Enclosed); + +fn enclosed_of(e: &Enclosing) -> *const Enclosed { + &e.0 +} + +/// A pointer a callee makes to a part of a struct with no cell, compared after the +/// caller's assignment of the whole. +pub fn enclosed_compared_rebound(n: u32) -> bool { + let mut e = Enclosing(Enclosed(n)); + let p = enclosed_of(&e); + e = Enclosing(Enclosed(n + 1)); + p == enclosed_of(&e) && (e.0).0 > 0 +} + +pub struct Chosen(pub u32); + +fn choose<'a>(a: &'a mut Chosen, b: &'a mut Chosen, first: bool) -> &'a mut Chosen { + if first { a } else { b } +} + +/// A pointer made of a reference a callee picks between two variables, compared after +/// the caller's assignment of one of them. +pub fn chosen_compared_rebound(n: u32, first: bool) -> bool { + let mut a = Chosen(n); + let mut b = Chosen(n + 1); + let r = choose(&mut a, &mut b, first); + let p = &raw const *r; + a = Chosen(n + 2); + p == &raw const a && a.0 > b.0 +} + +fn bytes_of(b: &[u8; 4]) -> *const [u8; 4] { + b +} + +/// A pointer a callee makes to an array of bytes, compared after the caller's assignment. +pub fn bytes_compared_rebound(n: u8) -> bool { + let mut b = [n; 4]; + let p = bytes_of(&b); + b = [n ^ 1; 4]; + std::ptr::eq(p, bytes_of(&b)) && b[0] > 0 +} + +pub struct Wrapped(pub u8, pub T); + +fn wrapped_of(w: &Wrapped) -> *const Wrapped { + w +} + +/// A pointer a generic callee makes, instantiated with a cell, which the caller's +/// assignment replaces. +pub fn generic_cell_rebound(n: u32) -> u32 { + let mut w = Wrapped(1, std::cell::Cell::new(n)); + let p = wrapped_of(&w); + w = Wrapped(2, std::cell::Cell::new(0)); + unsafe { (*p).1.get() + w.0 as u32 } +} + +pub fn part_cell(c: &std::cell::UnsafeCell) -> *mut u16 { + c.get() +} + +pub struct Parking { + pub task: T, + pub park: Parked, +} + +pub struct Parked(pub std::cell::Cell); + +fn parked_of(a: &A) -> *const A { + a +} + +/// A pointer a callee generic over what it points at makes into a cell, which the +/// caller's assignment replaces, in a body that the census lowers over its own type +/// parameter: the callee's instance for the cell's holder takes it. +pub fn generic_park_rebound(mut w: Parking, next: Parking) -> i16 { + let p = parked_of(&w.park); + w = next; + unsafe { (*p).0.get() + w.park.0.get() } +} diff --git a/ts/fixtures/reject/src/statics.rs b/ts/fixtures/reject/src/statics.rs new file mode 100644 index 000000000..bd6e9611d --- /dev/null +++ b/ts/fixtures/reject/src/statics.rs @@ -0,0 +1,40 @@ +//! Statics and lazy cells whose state JS can't share or copy. + +static mut COUNT: u8 = 0; + +pub fn statics() -> u8 { + unsafe { COUNT } +} + +/// A pointer into memory the translation can't name. +static NAMED: &u32 = &5; + +static SLOT: std::sync::atomic::AtomicPtr = std::sync::atomic::AtomicPtr::new(std::ptr::null_mut()); + +pub fn pointer_statics(p: *mut u32) -> u32 { + use std::sync::atomic::Ordering::Relaxed; + // Two `rt.Place`s of one place are two objects, which `===` can't tell are one. + let _ = SLOT.compare_exchange(p, std::ptr::null_mut(), Relaxed, Relaxed); + *NAMED +} + +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/src/strs.rs b/ts/fixtures/reject/src/strs.rs new file mode 100644 index 000000000..9b171ca97 --- /dev/null +++ b/ts/fixtures/reject/src/strs.rs @@ -0,0 +1,40 @@ +//! Strings and `Cow`s, which JS keeps as primitives. + +/// A `Cow` is a JS string, which keeps no variant to match on or ask about. +pub fn cow_matched(c: std::borrow::Cow<'_, str>) -> String { + match c { + std::borrow::Cow::Borrowed(s) => s.to_string(), + std::borrow::Cow::Owned(s) => s, + } +} + +pub fn cow_borrowed(c: &std::borrow::Cow<'_, str>) -> bool { + std::borrow::Cow::is_borrowed(c) +} + +/// A slice's tells its variants apart, but asking is unstable. +pub fn cow_bytes(c: &std::borrow::Cow<'_, [u8]>) -> bool { + std::borrow::Cow::is_borrowed(c) +} + +/// Made where its type goes unchecked, as a local's, it is refused where it is made. +pub fn cow_made(a: &std::sync::Arc) -> usize { + { + let c: std::borrow::Cow<'_, std::sync::Arc> = std::borrow::Cow::Owned(a.clone()); + drop(c); + } + std::sync::Arc::strong_count(a) +} + +/// A `str`'s UTF-8 written as bytes, or a part of it unchecked. +pub fn str_bytes_mut(s: &mut str) { + unsafe { s.as_bytes_mut()[0] = b'a' }; + unsafe { s.get_unchecked_mut(..1) }.make_ascii_uppercase(); +} + +/// Bytes written through a `&mut str` to them, which no JS string is. +pub fn str_from_bytes_mut(bytes: &mut [u8]) { + if let Ok(text) = std::str::from_utf8_mut(bytes) { + text.make_ascii_uppercase(); + } +} diff --git a/ts/fixtures/reject/src/values.rs b/ts/fixtures/reject/src/values.rs new file mode 100644 index 000000000..9f6823bfd --- /dev/null +++ b/ts/fixtures/reject/src/values.rs @@ -0,0 +1,102 @@ +//! Values JS can't represent as Rust does. + +use crate::clones::Reused; +use crate::objects::Reading; +use crate::places::Bare; + +pub fn float(a: f16) -> f16 { + a * 2.0 +} + +/// `None` and `Some(None)` would both be `rt.None`, as `Some(Some(None))` is `undefined`. +pub fn nested(x: Option>>) -> bool { + x.is_some() +} + +/// A generic type's `Option` is `T | undefined`, which can't hold `rt.None`, the `None` +/// of an `Option<()>`. +pub struct Maybe { + pub value: Option, +} + +pub fn generic_unit(value: Option<()>) -> bool { + Maybe { value }.value.is_some() +} + +/// Parsing an address is not translated yet. +pub fn addr_parsed(s: &str) -> Result { + s.parse() +} + +pub struct Tail { + pub value: T, +} + +/// A struct whose last field unsizes to a trait object. +pub fn tail_read(t: &Tail) -> u8 { + let r: &Tail = t; + r.value.read() +} + +/// A union whose fields overlap in values JS keeps apart. +pub union Bits { + pub int: u32, + pub float: f64, +} + +pub fn bits(n: u32) -> u32 { + let b = Bits { int: n }; + unsafe { b.int } +} + +/// Pointers to places of no bytes, which Rust may put anywhere, `()`'s refused as made. +pub fn units_compared() -> bool { + let (a, b, c, d) = ((), (), Bare, Bare); + std::ptr::eq(&raw const a, std::ptr::NonNull::from(&b).as_ptr()) && std::ptr::eq(&raw const c, &raw const d) +} + +pub enum Only { + One, +} + +/// A dangling pointer to an enum of no bytes, whose value is its variant's tag. +pub fn dangling_enum() -> bool { + unsafe { std::ptr::NonNull::::dangling().as_ptr().as_ref().is_some() } +} + +/// `u8`'s unstable ASCII methods are not translated. +pub fn ascii_octal(a: u8) -> bool { + a.is_ascii_octdigit() +} + +#[derive(Clone, Copy)] +pub struct Block([u8; N]); + +/// A struct generic over a length, which no class is, cloned out of an `Option` a pair +/// holds and written back whole in a body generic over that length. +pub fn block_cloned(a: Option>) -> Option> { + reclone(a) +} + +fn reclone(a: Option>) -> Option> { + let mut pair = (a, 0u8); + #[allow(clippy::clone_on_copy, reason = "the clone `Option`'s `Clone` makes")] + let copy = pair.0.clone(); + pair.0 = copy; + pair.0 +} + +/// `LinkedList`'s unstable `retain`, which no mapping covers, as none does its other +/// unstable methods; its `clone_from` of items whose own `clone_from` it would call; and +/// an empty `IterMut` of bytes, whose places nothing makes. +pub fn lists(l: &mut std::collections::LinkedList, r: &mut std::collections::LinkedList) -> usize { + l.retain(|x| *x > 1); + r.clone_from(&std::collections::LinkedList::new()); + std::collections::linked_list::IterMut::::default().count() +} + +/// `ManuallyDrop`'s impls beyond holding a value: compared, formatted, and a constant. +pub fn manual_impls(a: std::mem::ManuallyDrop, b: std::mem::ManuallyDrop) -> String { + const HELD: std::mem::ManuallyDrop = std::mem::ManuallyDrop::new(3); + format!("{a:?} {} {}", a == b, *HELD) +} diff --git a/ts/fixtures/reject/ts.toml b/ts/fixtures/reject/ts.toml index a23d5d236..02d1f4c18 100644 --- a/ts/fixtures/reject/ts.toml +++ b/ts/fixtures/reject/ts.toml @@ -1,188 +1,188 @@ package = "reject-fixture" roots = [ - "float", - "dynamic", - "nested", - "refilled", - "scanned", - "generic_unit", - "Noisy", - "pointer", - "written", - "statics", - "generic", - "nested_poll", - "pending_output", - "replace_guard", - "swap_guards", - "replace_boxed_poll_fn", - "replace_boxed_future", - "replace_boxed_bytes", - "folds", - "backs", - "keyed", - "keyed_across", - "place_bounds", - "replace_pinned_ref", - "copied_closure", - "scanned_unit", - "set_keys", - "borrowed", - "recloned", - "shared", - "cow_matched", - "cow_borrowed", - "cow_bytes", - "cow_made", + "alloc::addressed", + "alloc::alloc_retyped", + "alloc::allocated", + "alloc::bytes_as_values", + "alloc::reinterpreted", + "alloc::vec_pointer", + "alloc::zeroed", + "bound_ranges", + "buffers::blank_bytes", + "buffers::bytes_mut_capacity", + "buffers::bytes_mut_put", + "buffers::bytes_mut_put_through", + "buffers::owned_bytes", + "buffers::shared", + "clones::cloned_slots", + "clones::dropped_slots", + "clones::ranked_slots", + "clones::recloned", + "clones::refilled", + "clones::slice_of_object", + "clones::touched_slots", + "clones::vec_clone_from", + "config::generic", + "fmt::pointer", + "fmt::written", + "futures::generic_pending", + "futures::nested_poll", + "futures::pending_output", + "iters::backs", + "iters::folds", + "iters::parts_summed", + "iters::scanned", + "iters::scanned_unit", + "iters::tens", + "kept::atomic_exchanged", + "kept::atomic_swapped", + "kept::cloned_kept", + "kept::escaped_into_call", + "kept::escaped_into_struct", + "kept::kept_across_iterations", + "kept::kept_across_writes", + "kept::kept_boxed", + "kept::kept_called", + "kept::kept_instance", + "kept::kept_object", + "kept::kept_read", + "kept::kept_replaced", + "kept::kept_swapped", + "kept::kept_written", + "kept::key_replaced", + "kept::key_set", + "kept::key_taken", + "kept::lent_kept", + "kept::mapped_kept", + "kept::pushed_part_kept", + "kept::ref_replaced", + "kept::ref_taken", + "kept::uninit_rewritten", + "kept::written_through_alias", + "kept::written_through_loaded", + "keys::batched", + "keys::borrowed", + "keys::keyed", + "keys::keyed_across", + "keys::place_bounds", + "keys::places_sorted", + "keys::ranked_cells", + "keys::set_keys", "lopsided", - "batched", - "parts_summed", - "ok_passed", - "places_equal", - "owned_bytes", - "bytes_mut_capacity", - "bytes_mut_put", - "bytes_mut_put_through", - "addr_parsed", - "generic_object", - "first_of", - "tail_read", "missing", - "generic_pending", - "rebound_reference", - "any_upcast", - "weak_any_upcast", - "any_type_id", - "reinterpreted", - "addressed", - "allocated", - "vec_pointer", - "bits", - "places_compared", - "optional_places_compared", - "part_replaced", - "variable_reassigned", - "variable_replaced", - "variable_swapped", - "assigned_through", - "nonnull_reassigned", - "cast_reassigned", - "cell_rebound", - "retargeted", - "swap_retargeted", - "swapped_in_loop", - "read_behind_rebound", - "unboxed_rebound", - "deep_cell_rebound", - "payload_cell_rebound", - "ref_cell_rebound", - "inside_cell_rebound", - "inside_field_rebound", - "generic_cell_rebound", - "part_mem_replaced", - "part_swapped", - "part_taken", - "part_assigned", - "part_replaced_deep", - "part_replaced_dyn", - "part_replaced_closure", - "element_replaced", - "compared_rebound", - "enclosed_compared_rebound", - "chosen_compared_rebound", - "bytes_compared_rebound", - "pointer_in_struct", - "pointer_returned", - "pointer_pushed", - "pointer_captured", - "pointer_kept_across", - "range_of", - "range_replaced", - "element_pointer", - "cell_replaced", - "cell_reassigned", - "cell_taken", - "cell_field_replaced", - "units_compared", - "dangling_enum", - "blank_bytes", - "places_sorted", - "pointer_statics", - "bound_ranges", - "put_replaced", - "object_replaced", - "closure_replaced", - "made_part_replaced", - "uninit_part_replaced", - "ranked_cells", - "escaped_into_struct", - "escaped_into_call", - "kept_across_writes", - "written_through_alias", - "uninit_rewritten", - "written_through_loaded", - "mapped_kept", - "cloned_kept", - "kept_across_iterations", - "lent_kept", - "pushed_part_kept", - "tens", - "ascii_octal", - "array_part_replaced", - "tuple_part_replaced", - "nested_part_replaced", - "payload_part_replaced", - "field_part_replaced", - "generic_part_replaced", - "written_part_replaced", - "kept_read", - "kept_written", - "kept_swapped", - "kept_replaced", - "kept_boxed", - "kept_called", - "kept_object", - "kept_instance", - "atomic_swapped", - "atomic_exchanged", - "ref_replaced", - "ref_taken", - "key_set", - "key_replaced", - "key_taken", - "str_bytes_mut", - "str_from_bytes_mut", - "byte_pointer_ops", - "byte_pointer_parts", - "byte_pointer_rebound", - "block_cloned", - "lists", - "mapped_closure", - "object_elements", - "unit_elements", - "element_to_array", - "elements_replaced", - "pointers_apart", - "lone_byte_slices", - "reached_out", - "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", - "bytes_as_values", - "zeroed", - "manual_impls", - "alloc_retyped", - "cloned_slots", - "dropped_slots", - "ranked_slots", - "touched_slots", - "raw_dyn_iter", + "objects::any_type_id", + "objects::any_upcast", + "objects::dyn_size", + "objects::dynamic", + "objects::first_of", + "objects::generic_object", + "objects::raw_dyn_iter", + "objects::weak_any_upcast", + "parts::array_part_replaced", + "parts::element_replaced", + "parts::field_part_replaced", + "parts::generic_part_replaced", + "parts::nested_part_replaced", + "parts::part_assigned", + "parts::part_mem_replaced", + "parts::part_replaced_closure", + "parts::part_replaced_deep", + "parts::part_replaced_dyn", + "parts::part_swapped", + "parts::part_taken", + "parts::payload_part_replaced", + "parts::tuple_part_replaced", + "parts::written_part_replaced", + "places::Noisy", + "places::copied_closure", + "places::mapped_closure", + "places::ok_passed", + "places::optional_places_compared", + "places::places_compared", + "places::places_equal", + "places::rebound_reference", + "places::replace_boxed_bytes", + "places::replace_boxed_future", + "places::replace_boxed_poll_fn", + "places::replace_guard", + "places::replace_pinned_ref", + "places::swap_guards", + "pointers::assigned_through", + "pointers::byte_pointer_ops", + "pointers::byte_pointer_parts", + "pointers::byte_pointer_rebound", + "pointers::byte_slice_of_place", + "pointers::cast_reassigned", + "pointers::cell_field_replaced", + "pointers::cell_reassigned", + "pointers::cell_replaced", + "pointers::cell_taken", + "pointers::closure_replaced", + "pointers::element_pointer", + "pointers::element_to_array", + "pointers::elements_replaced", + "pointers::lone_byte_slices", + "pointers::made_part_replaced", + "pointers::nonnull_reassigned", + "pointers::object_elements", + "pointers::object_replaced", + "pointers::part_replaced", + "pointers::pointer_captured", + "pointers::pointer_in_struct", + "pointers::pointer_kept_across", + "pointers::pointer_pushed", + "pointers::pointer_returned", + "pointers::pointers_apart", + "pointers::put_replaced", + "pointers::range_of", + "pointers::range_replaced", + "pointers::reached_out", + "pointers::uninit_part_replaced", + "pointers::unit_elements", + "pointers::variable_celled", + "pointers::variable_cloned_from", + "pointers::variable_cloned_into", + "pointers::variable_reassigned", + "pointers::variable_replaced", + "pointers::variable_swapped", + "rebound::bytes_compared_rebound", + "rebound::cell_rebound", + "rebound::chosen_compared_rebound", + "rebound::compared_rebound", + "rebound::deep_cell_rebound", + "rebound::enclosed_compared_rebound", + "rebound::generic_cell_rebound", + "rebound::inside_cell_rebound", + "rebound::inside_field_rebound", + "rebound::payload_cell_rebound", + "rebound::read_behind_rebound", + "rebound::ref_cell_rebound", + "rebound::retargeted", + "rebound::swap_retargeted", + "rebound::swapped_in_loop", + "rebound::unboxed_rebound", + "statics::key_celled", + "statics::lazy_assigned", + "statics::lazy_celled", + "statics::pointer_statics", + "statics::statics", + "strs::cow_borrowed", + "strs::cow_bytes", + "strs::cow_made", + "strs::cow_matched", + "strs::str_bytes_mut", + "strs::str_from_bytes_mut", + "values::addr_parsed", + "values::ascii_octal", + "values::bits", + "values::block_cloned", + "values::dangling_enum", + "values::float", + "values::generic_unit", + "values::lists", + "values::manual_impls", + "values::nested", + "values::tail_read", + "values::units_compared", ] -printable = ["Meters"] +printable = ["config::Meters"] diff --git a/ts/tests/differential.ts b/ts/tests/differential.ts index d777483c1..13871b6a1 100644 --- a/ts/tests/differential.ts +++ b/ts/tests/differential.ts @@ -5,9 +5,10 @@ // // A harness, or a hand-written caller wrapping one, exports `run(input: rt.ByteSlice): // Vec`, and may export `cases`, inputs it names, which run with the generated ones, -// `ops`, the bytes that pick each of its cases, if not the first byte alone, -// and `within(input, native, translated)`, which accepts outputs that differ only where -// Rust leaves the result to the platform, as libm's are. +// `ops`, the bytes that pick each of its cases, if not the first byte alone, and +// `within(input, native, translated)`, which accepts outputs that differ only where Rust +// leaves the result to the platform, as libm's are. [cases] random inputs run, or that +// many per op of a harness that exports `ops`. // The wasm build exports `input`, `run`, and `output` around the crate's entry, which // `wasm.ts` calls. A panic traps natively and throws `Panic` in // TypeScript, and the two agree only if their messages do. An abort traps natively @@ -81,15 +82,17 @@ function display(outcome: Outcome): string { } const cases: Uint8Array[] = [new Uint8Array(0)]; -const ops: Uint8Array[] = harness.ops ?? Array.from({ length: 256 }, (_, op) => Uint8Array.of(op)); +const named: Uint8Array[] | undefined = harness.ops; +const ops: Uint8Array[] = named ?? Array.from({ length: 256 }, (_, op) => Uint8Array.of(op)); if (new Set(ops.map((op) => Buffer.from(op).toString("hex"))).size !== ops.length) throw new Error("two ops are the same bytes, so one of them never runs"); // Every op with every short tail, so each path's edges are covered exhaustively. for (const op of ops) { cases.push(op); for (let b = 0; b < 256; b += 17) cases.push(Uint8Array.of(...op, b)); } -// Full-width values through the first ops: each u64 boundary 2^k - 1, 2^k, 2^k + 1. -for (const op of ops.slice(0, 8)) { +// Full-width values through the first ops: each u64 boundary 2^k - 1, 2^k, 2^k + 1. A +// harness that names its ops names these inputs itself, for the ops that take them. +for (const op of named ? [] : ops.slice(0, 8)) { for (let k = 0n; k <= 64n; k++) { for (const delta of [-1n, 0n, 1n]) { const value = ((1n << k) + delta) & 0xffffffffffffffffn; @@ -103,7 +106,7 @@ for (const op of ops.slice(0, 8)) { } // A harness's own cases, which name what they cover. if (Array.isArray(harness.cases)) for (const input of harness.cases) cases.push(input); -for (let i = 0; i < count; i++) { +for (let i = 0; i < count * (named?.length ?? 1); i++) { const len = Number(next() % 48n); const input = new Uint8Array(len + 1); input[0] = byte(); diff --git a/ts/tests/fixtures.rs b/ts/tests/fixtures.rs index 461b2a9d1..44c890172 100644 --- a/ts/tests/fixtures.rs +++ b/ts/tests/fixtures.rs @@ -360,22 +360,113 @@ fn lines(text: &str) -> Vec { lines } -#[test] -fn lang() { - let out = translated("lang"); - snapshot("lang", &out); - lang_differential(&out); -} - -fn lang_differential(out: &Path) { - // Hand-written callers, type-checked against the output they call: one runs it, with - // the one difference from native it accepts, and one mixes integer types, which `tsc` - // must refuse. - for file in ["caller.ts", "fma.ts", "brands.ts"] { - std::fs::copy(manifest_dir().join("fixtures/lang").join(file), out.join(file)).unwrap(); +/// The language, a fixture per module: each translated, compared with its snapshot, +/// type-checked with its hand-written callers, and run against its native build. +mod lang { + macro_rules! lang { + ($($module:ident),* $(,)?) => { + $( + #[test] + fn $module() { + super::lang(stringify!($module)); + } + )* + }; } - typecheck(out); - differential("lang-fixture", &[], out, "caller.ts", 50_000); + + lang!( + args, + arrays, + ascii, + atomics, + borrows, + bounds, + boxes, + capacity, + captures, + cells, + chars, + chunks, + clones, + collections, + combinators, + conversions, + counts, + cows, + cycles, + defaults, + durations, + dyns, + edits, + elements, + ends, + errors, + fields, + floats, + folds, + hashes, + heap, + hints, + holds, + ints, + iters, + joins, + keys, + lengths, + lists, + locals, + locks, + manual, + methods, + nested, + objects, + orders, + pointers, + refs, + results, + returns, + rings, + saturates, + searches, + separated, + shapes, + singles, + slices, + sorts, + splits, + statics, + strs, + tuples, + utf8, + wrappers, + wraps, + zeros + ); +} + +fn lang(module: &str) { + let name = format!("lang/{module}"); + let out = translated(&name); + snapshot(&name, &out); + // Hand-written callers, type-checked against the output they call: `lang.ts` runs the + // harness, and a fixture's own name the inputs it covers, accept the one difference from + // native it accepts, or mix integer types, which `tsc` must refuse. + let shared = manifest_dir().join("fixtures/lang"); + let mut entry = "lang.ts"; + for dir in [shared.clone(), fixture(&name)] { + for file in std::fs::read_dir(&dir).unwrap() { + let path = file.unwrap().path(); + if path.extension().is_some_and(|e| e == "ts") { + std::fs::copy(&path, out.join(path.file_name().unwrap())).unwrap(); + if path.file_name().unwrap() == "caller.ts" { + entry = "caller.ts"; + } + } + } + } + typecheck(&out); + // As many random inputs per case as when one fixture held every module. + differential(&format!("lang-{module}-fixture"), &[], &out, entry, 151); } /// A copy that only one write in the crate keeps, of each kind: one per feature. @@ -516,51 +607,196 @@ fn crates() { } } -/// The errors of a failed translation, each with where it points, against `expected`. +/// The errors of a failed translation, each with where it points, against `expected`: by +/// item rather than line and sorted, so that a case added or removed moves no other's. fn rejected(out: &Path, output: &Output, expected: &Path) { assert!(!output.status.success(), "translating {} succeeded", expected.display()); assert!(!out.join("lib.ts").exists(), "a failed translation wrote output"); let stderr = String::from_utf8_lossy(&output.stderr); // Each error and where it points, without rustc's rendering of the source, and with a // dependency's source from wherever cargo keeps it. - let mut got = String::new(); + let mut errors = Vec::new(); let mut lines = stderr.lines().peekable(); while let Some(line) = lines.next() { if let Some(error) = line.strip_prefix("error: rust2-ts: ") { - got.push_str(error); + let mut message = error.to_string(); // What goes on in the lines after, as `tsc`'s messages do. while let Some(more) = lines .peek() .filter(|l| l.starts_with(" ") && !l.trim_start().starts_with("--> ")) { - got.push_str(&format!("\n{more}")); + message.push_str(&format!("\n{more}")); lines.next(); } - if let Some(at) = lines.peek().and_then(|l| l.trim_start().strip_prefix("--> ")) { - let at = at - .split_once("/registry/src/") - .map_or(at, |(_, rest)| rest.split_once('/').map_or(rest, |(_, path)| path)); - got.push_str(&format!(" at {at}")); - } - got.push('\n'); + let at = lines + .peek() + .and_then(|l| l.trim_start().strip_prefix("--> ")) + .map(|at| { + at.split_once("/registry/src/") + .map_or(at, |(_, rest)| rest.split_once('/').map_or(rest, |(_, path)| path)) + .to_string() + }); + errors.push((at, message)); + } + } + expect(expected, &listed(errors)); +} + +/// Each refusal on a line, sorted, those without a span first: where it points as its +/// item and the line and column from where that starts, so a case added elsewhere moves +/// none of them. +fn listed(errors: Vec<(Option, String)>) -> String { + let mut errors: Vec<_> = errors + .into_iter() + .map(|(at, message)| (at.map(|at| keyed(&at)), closures(&message))) + .collect(); + errors.sort(); + let mut got = String::new(); + for (at, message) in &errors { + match at { + Some((file, item, line, col)) if item.is_empty() => got.push_str(&format!("{file}:{line}:{col}: ")), + Some((file, item, line, col)) => got.push_str(&format!("{file}:{item}{line:+}:{col}: ")), + None => {} } + got.push_str(message); + got.push('\n'); } + got +} + +/// Compare `got` with the snapshot at `path`, or rewrite it under `UPDATE_EXPECT`. +fn expect(path: &Path, got: &str) { if std::env::var_os("UPDATE_EXPECT").is_some() { - std::fs::write(expected, &got).unwrap(); + std::fs::write(path, got).unwrap(); return; } - let want = std::fs::read_to_string(expected).unwrap_or_default(); + let want = std::fs::read_to_string(path).unwrap_or_default(); assert!( got == want, - "the errors differ; rerun with UPDATE_EXPECT=1\n{}", - diff(&want, &got) + "{} differs; rerun with UPDATE_EXPECT=1\n{}", + path.display(), + diff(&want, got) + ); +} + +/// `text` with each closure's span, `{closure@file:line:col: line:col}`, keyed by item. +fn closures(text: &str) -> String { + let mut out = String::new(); + let mut rest = text; + while let Some((before, after)) = rest.split_once("{closure@") { + let (span, after) = after.split_once('}').unwrap(); + let (start, end) = span.split_once(": ").unwrap(); + let span = match keyed(start) { + (_, item, ..) if item.is_empty() => span.to_string(), + (file, item, line, col) => { + let (end_line, end_col) = end.split_once(':').unwrap(); + let lines = + end_line.parse::().unwrap() - start.rsplit(':').nth(1).unwrap().parse::().unwrap(); + format!("{file}:{item}{line:+}:{col}: {:+}:{end_col}", line + lines) + } + }; + out.push_str(&format!("{before}{{closure@{span}}}")); + rest = after; + } + out.push_str(rest); + out +} + +/// Where `at`, a `file:line:col`, points: the file, the item there, the line counted from +/// the item's own, and the column. A file outside this crate, as a dependency's, keys by +/// its line, with no item. +fn keyed(at: &str) -> (String, String, i64, i64) { + let mut parts = at.rsplitn(3, ':'); + let (Some(col), Some(line), Some(file)) = (parts.next(), parts.next(), parts.next()) else { + panic!("{at} is no file:line:col"); + }; + let (line, col): (i64, i64) = (line.parse().unwrap(), col.parse().unwrap()); + let Ok(text) = std::fs::read_to_string(manifest_dir().join(file)) else { + return (file.to_string(), String::new(), line, col); + }; + let lines: Vec<&str> = text.lines().collect(); + // Each item's name, the line its docs and attributes start at, and its header's. + let items: Vec<(String, usize, usize)> = (lines.iter().enumerate()) + .filter_map(|(i, header)| { + let name = item(header)?; + let mut first = i; + while first > 0 && (lines[first - 1].starts_with("///") || lines[first - 1].starts_with("#[")) { + first -= 1; + } + Some((name, first, i)) + }) + .collect(); + // The last item that starts at or before the line. + let (name, _, header) = (items.iter()) + .take_while(|(_, first, _)| (*first as i64) < line) + .last() + .unwrap_or_else(|| panic!("{at} is in no item")); + assert!( + items.iter().filter(|(n, ..)| n == name).count() == 1, + "{file} has two items named {name}, which errors in it can't tell apart" ); + (file.to_string(), name.clone(), line - *header as i64 - 1, col) +} + +/// The name of the item a line at the top level of a file starts, if it starts one: a +/// function's, a type's, a trait's, or a static's name, an impl's header, or a macro's +/// name and `!`. +fn item(line: &str) -> Option { + if !line.starts_with(|c: char| c.is_ascii_lowercase()) { + return None; + } + let ident = |s: &str| { + s.split(|c: char| !(c.is_alphanumeric() || c == '_')) + .next() + .unwrap() + .to_string() + }; + if let Some(header) = line.strip_prefix("impl") { + return Some(format!("impl{}", header.trim_end_matches('{').trim_end())); + } + if let Some(name) = line.strip_prefix("macro_rules! ") { + return Some(format!("{}!", ident(name))); + } + if let Some((name, _)) = line.split_once("! ").filter(|(name, _)| !name.contains(' ')) { + return Some(format!("{name}!")); + } + let mut words = line + .split_whitespace() + .skip_while(|w| ["pub", "pub(crate)", "async", "unsafe"].contains(w)); + let kind = words.next()?; + if ![ + "fn", "struct", "enum", "union", "trait", "static", "const", "type", "mod", + ] + .contains(&kind) + { + return None; + } + let name = words.find(|w| *w != "mut")?; + Some(ident(name)) } /// A census of a config without roots ranks every refusal in the crate, reached from each /// of its items, and succeeds where translation fails. #[test] fn census() { + let census = scratch().join("census").join("census.md"); + let config = fixture("census").join("ts.toml"); + let output = driver("census", &config, &["--census".as_ref(), census.as_ref()], "census"); + assert!( + output.status.success(), + "the census failed:\n{}", + String::from_utf8_lossy(&output.stderr) + ); + expect( + &fixture("census").join("census.md"), + &std::fs::read_to_string(&census).unwrap(), + ); +} + +/// A census of `reject` from each of its items, a generic one lowered over its type +/// parameters, which no root reaches: each span it lists, keyed as `reject`'s errors are. +#[test] +fn reject_census() { let census = scratch().join("reject").join("census.md"); let config = fixture("reject").join("census.toml"); let output = driver("reject", &config, &["--census".as_ref(), census.as_ref()], "census"); @@ -569,18 +805,17 @@ fn census() { "the census of reject failed:\n{}", String::from_utf8_lossy(&output.stderr) ); - let got = std::fs::read_to_string(&census).unwrap(); - let path = fixture("reject").join("census.md"); - if std::env::var_os("UPDATE_EXPECT").is_some() { - std::fs::write(&path, &got).unwrap(); - return; - } - let want = std::fs::read_to_string(&path).unwrap_or_default(); - assert!( - got == want, - "the census differs; rerun with UPDATE_EXPECT=1\n{}", - diff(&want, &got) - ); + let census = std::fs::read_to_string(&census).unwrap(); + let spans = census.split_once("\n## Spans\n").expect("a census lists its spans").1; + let errors = spans + .lines() + .filter_map(|line| line.strip_prefix("- ")) + .map(|line| { + let (at, message) = line.split_once(": ").unwrap(); + (Some(at.to_string()), message.to_string()) + }) + .collect(); + expect(&fixture("reject").join("census.txt"), &listed(errors)); } /// One target directory keeps what it checked against each sysroot apart: a crate @@ -600,7 +835,7 @@ fn sysroot() { let checked = |sysroot: &str| { let output = Command::new(env!("CARGO_BIN_EXE_rust2-ts")) .arg("--config") - .arg(fixture("reject").join("census.toml")) + .arg(fixture("census").join("ts.toml")) .arg("--census") .arg(dir.join("census.md")) .env("CARGO_TARGET_DIR", dir.join("build")) @@ -627,7 +862,7 @@ fn sysroot() { ); assert_eq!( checked(&std), - ["reject-fixture"], + ["census-fixture"], "switching back to {std} checked its crates again" ); } diff --git a/ts/tests/fma.ts b/ts/tests/fma.ts index ff819b563..8cd7dfc02 100644 --- a/ts/tests/fma.ts +++ b/ts/tests/fma.ts @@ -1,11 +1,11 @@ -// The lang fixture's `mul_add` allowance: its exact rounding agrees with the runtime's, +// The `floats` fixture's `mul_add` allowance: its exact rounding agrees with the runtime's, // and it accepts native a last place off only where the translation is exact. // // usage: node fma.ts import { strict as assert } from "node:assert"; -import { exactMulAdd, mulAddsWithin } from "../fixtures/lang/fma.ts"; +import { exactMulAdd, mulAddsWithin } from "../fixtures/lang/floats/fma.ts"; import * as rt from "../runtime/rt.ts"; function double(bits: bigint): number {