Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion quest/m3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ generic std gap is planned here even when moq never calls it.
- [An array as a slice](/quest/m3/ts-array-as-slice.md) - `<[T; N]>::as_slice` and `as_mut_slice` translate
- [Closures that return an Option whose None is rt.None](/quest/m3/ts-option-closures.md) - `find_map`, `filter_map`, and `map_while` to `Option<Option<u8>>` keep `None` apart from `Some(None)`
- [Peekable::next_if_eq against another type](/quest/m3/ts-next-if-eq-other.md) - `next_if_eq` with an expected value of another type than the item, such as a `&str` of `String` items, translates
- [A slice's edits in place](/quest/m3/ts-slice-edits.md) - `fill`, `rotate_left`, and `copy_from_slice` of other values translate
- [Waiting: a slice object for a mutable part of other values](/quest/m3/ts-slice-object.md) - waits on a moq profile showing the `Proxy` view's traps matter, then decides on an `rt.ByteSlice`-like form
- [Port the workflow guard to kixelated/quest](/quest/m3/quest-workflow-guard.md) - quest's environment guard parses YAML as this repository's does
- [A parameter read only where lowering leaves nothing](/quest/m3/ts-unread-params.md) - an instance whose lowering drops every read of a parameter marks it unused, so `tsc` accepts it
15 changes: 0 additions & 15 deletions quest/m3/ts-slice-edits.md

This file was deleted.

14 changes: 13 additions & 1 deletion ts/fixtures/lang/caller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,4 +366,16 @@ const ranges = [0, 1, 2, 3, 4].flatMap((n) => {
*/
const reducers = [[], [9], [9, 9], [8, 4, 12, 0x40, 0x80]].map((bytes) => Uint8Array.of(op("iters::reducers"), 0, ...bytes));

export const cases: Uint8Array[] = [...loops, ...durations, ...ints(), ...utf8, ...floats, ...formats, ...parsed, ...dyns, ...cells, ...shared, ...locks, ...onces, ...bounds, ...unsafeCells, ...edits, ...subslices, ...consumers, ...ranges, ...reducers];
/**
* `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[] = [...loops, ...durations, ...ints(), ...utf8, ...floats, ...formats, ...parsed, ...dyns, ...cells, ...shared, ...locks, ...onces, ...bounds, ...unsafeCells, ...edits, ...subslices, ...consumers, ...ranges, ...reducers, ...sliceEdits];
15 changes: 15 additions & 0 deletions ts/fixtures/lang/expected/core/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import type * as Point from "../shapes.Point.ts";
import type * as shapes_Shape from "../shapes.Shape.ts";
import { 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 Short from "../splits.Short.ts";

Expand Down Expand Up @@ -511,6 +512,13 @@ export function mapOr$0qqbaqw(self: Noisy.Noisy | undefined, default_: rt.u8, f:
return f(self);
}

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$0cqaybi(self: locals_Noisy.Noisy | undefined, default_: rt.u8, f: (a0: locals_Noisy.Noisy) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
Expand Down Expand Up @@ -1090,6 +1098,13 @@ export function clone$0vcwlo5(self: Named.Named | undefined): Named.Named | unde
return 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 clone$14nprly(self: string | undefined): string | undefined {
if (self === undefined) {
return undefined;
Expand Down
6 changes: 3 additions & 3 deletions ts/fixtures/lang/expected/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { orders, bytes as orders_bytes } from "./orders.ts";
import { lists, shared as pointers_shared, places, unchecked, nested as pointers_nested, copies as pointers_copies, sentinels, cells as pointers_cells, rebound, writers } from "./pointers.ts";
import { refs, toRefs } from "./refs.ts";
import { copies as shapes_copies, order, discriminants, loops, patterns, closures, library, flows } from "./shapes.ts";
import { parts, chunked, subslices, drains, ranges as slices_ranges } from "./slices.ts";
import { parts, chunked, subslices, drains, ranges as slices_ranges, edits as slices_edits } from "./slices.ts";
import { splits } from "./splits.ts";
import { statics, cells as statics_cells, onces } from "./statics.ts";
import { strs, slices, edits as strs_edits, parses as strs_parses } from "./strs.ts";
Expand Down Expand Up @@ -90,7 +90,7 @@ export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec)
refs(data21, out21);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::counts", (_2121: rt.u8, data22: rt.ByteSlice, out22: rt.ByteVec): void => {
counts(data22, out22);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::rounding", (_2122: rt.u8, _375: rt.ByteSlice, out23: rt.ByteVec): void => {
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::rounding", (_2122: rt.u8, _378: rt.ByteSlice, out23: rt.ByteVec): void => {
rounding(out23);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::skips", skips] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["wrappers::wrappers", wrappers] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["edits::edits", edits] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["utf8::decodes", decodes] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["floats::floats", floats] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["atomics::atomics", atomics] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["keys::overrides", overrides] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["dyns::dyns", (_2123: rt.u8, data23: rt.ByteSlice, out24: rt.ByteVec): void => {
dyns(data23, out24);
Expand Down Expand Up @@ -176,7 +176,7 @@ export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec)
reducers(data63, out64);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::writers", (_2164: rt.u8, data64: rt.ByteSlice, out65: rt.ByteVec): void => {
writers(data64, out65);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["errors::eqs", eqs] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void]];
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["errors::eqs", eqs] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["slices::edits", slices_edits] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void]];
}

/** Run one case. */
Expand Down
21 changes: 21 additions & 0 deletions ts/fixtures/lang/expected/slices.Counted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import { LOG } from "./slices.ts";

/**
* A `Copy` element whose own `Clone` logs, which `fill` and `clone_from_slice` call and
* `copy_within` and `copy_from_slice` do not.
*/
export interface Counted {
n: rt.u8;
}

export function clone$Clone(self: Counted): Counted {
rt.localKeyWithBorrowMut(LOG, (log: rt.ByteVec): void => {
rt.byteVecPush(log, self.n ^ 64);
});
return self;
}

//# sourceMappingURL=slices.Counted.ts.map
35 changes: 35 additions & 0 deletions ts/fixtures/lang/expected/slices.Noisy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.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
* its tag as it drops.
*/
export class Noisy {
tag: rt.u8;

constructor(tag: rt.u8) {
this.tag = tag;
}

[Symbol.dispose](): void {
drop$Drop(this);
}
}

export function clone$Clone(self: Noisy): Noisy {
rt.localKeyWithBorrowMut(LOG, (log: rt.ByteVec): void => {
rt.byteVecPush(log, self.tag | 128);
});
return new Noisy(rt.u8WrappingAdd(self.tag, 1));
}

export function drop$Drop(self: Noisy): void {
rt.localKeyWithBorrowMut(LOG, (log: rt.ByteVec): void => {
rt.byteVecPush(log, self.tag);
});
}

//# sourceMappingURL=slices.Noisy.ts.map
Loading