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 @@ -22,7 +22,6 @@ generic std gap is planned here even when moq never calls it.
- [bytes' Chain as a Buf object](/quest/m3/ts-buf-chain.md) - `Chain::copy_to_bytes` across both halves translates, and with it a `Chain` as a `dyn Buf`
- [A Buf object's size](/quest/m3/ts-dyn-buf-size.md) - a `dyn Buf` object holds only the methods some call dispatches to
- [A boxed iterator folds as std's box does](/quest/m3/ts-box-folds.md) - a `Box<I>` reads by `next` where std's `Iterator` for `Box<I>` forwards nothing else
- [Debug of a RefCell or a Cell](/quest/m3/ts-refcell-debug.md) - `{:?}` of a `RefCell`, `Ref`, `RefMut`, and `Cell` translates as std's writes them
- [Placeholders written to a crate's own fmt::Write](/quest/m3/ts-fmt-calls.md) - `write!` with placeholders into a crate's own writer translates, its `write_str` seeing each call std makes
- [Waiting: drop the lang fixture's mul_add allowance](/quest/m3/ts-fma-allowance.md) - the differential fails on any `mul_add` difference again once wasm32's `fma` rounds exactly
- [Waiting: type-check in process with tsrs](/quest/m3/ts-tsrs.md) - rust2-ts checks bindings through tsrs instead of `tsc` once it is a stable library
Expand Down
17 changes: 0 additions & 17 deletions quest/m3/ts-refcell-debug.md

This file was deleted.

5 changes: 4 additions & 1 deletion ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ and of their iterators and `Chars` the items each has left, in std's wrapper; a
swap them, and its `Drain` its counts; a list's `Iter` and `IterMut` write what is left and
its length, as std's do. `Debug` of `Bound`, `Ordering`, `Reverse`, and `ControlFlow` is
their derived one, whichever way each is held, and a guard of a cell or a lock, mapped or
not, writes what it lends by its own `Debug` and `Display`. A caller prints a
not, writes what it lends by its own `Debug` and `Display`. `Debug` of a `Cell`, a
`RefCell`, a `Mutex`, and an `RwLock` writes what each holds, or `<borrowed>` and
`<locked>` while a guard keeps it from being read, as std's do; an `UnsafeCell` writes only
its name. A caller prints a
`printable` type as `to_string()` and `format!("{err:?}")`
would: `rt.fmtToString((f) => DecodeError.fmt$fmt_Display(err, f))` and
`rt.fmtFormat([(f) => DecodeError.fmt$fmt_Debug(err, f)])`, after
Expand Down
3 changes: 1 addition & 2 deletions ts/fixtures/codec/expected/coding/encode.Encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ export function fill(self: Encoder, prefix: Prefix.Prefix): rt.Result<undefined,
const size2: Uint8Array = rt.bytes(9);
rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(size2), 0, len), rt.byteSliceRange(rt.byteVecSlice(self.buf), end));
rt.byteVecTruncate(self.buf, rt.usizeSub(rt.usizeAdd(end, len), 1));
const _58: rt.usize = rt.usizeSub(rt.usizeAdd(body, len), 1);
rt.byteSliceCopyWithin(rt.byteVecSlice(self.buf), body, end, _58);
rt.byteSliceCopyWithin(rt.byteVecSlice(self.buf), body, end, rt.usizeSub(rt.usizeAdd(body, len), 1));
const _84: rt.ByteVec = self.buf;
const part2 = rt.usizeSub(body, 1);
const part3 = rt.usizeAdd(rt.usizeSub(body, 1), len);
Expand Down
3 changes: 1 addition & 2 deletions ts/fixtures/codec/expected/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,7 @@ export function encodeScript(dataData: Uint8Array, dataStart: number, dataLen: n
}
result = Encoder.varintOpt(w, _47);
} else if (_33 === 5) {
const part = rt.u8Rem(rt.u8Div(step, 10), 9) as rt.usize;
const _51: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceFrom(rt.u64ToBeBytes(value)), 0, part);
const _51: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceFrom(rt.u64ToBeBytes(value)), 0, rt.u8Rem(rt.u8Div(step, 10), 9) as rt.usize);
result = Encoder.bytes(w, _51);
} else if (_33 === 6) {
const _60: rt.Result<string, rt.FromUtf8Error> = rt.stringFromUtf8(rt.byteSliceToByteVec(rt.byteSliceFrom(rt.u64ToBeBytes(value))));
Expand Down
17 changes: 7 additions & 10 deletions ts/fixtures/lang/arrays/expected/arrays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,8 @@ export function givenN$0(data: rt.ByteSlice, out: rt.ByteVec): void {
_173.v = 238;
}
put$0(out, [copy$array_u8(b)]);
const _192: rt.ByteSlice = rt.byteSliceFrom(a);
const _190: Uint8Array[] = [rt.byteSliceView(rt.byteSliceFrom(b))];
const _192: rt.ByteSlice = rt.byteSliceFrom(a);
const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_192), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(_190, f, (value: Uint8Array, f: rt.Formatter) => rt.fmtList(value, f, rt.u8Debug))];
rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1]])));
if (isSomeAnd$09tpccf(rt.byteSliceFirst(data), (d2: rt.u8): boolean => {
Expand Down Expand Up @@ -750,9 +750,8 @@ export function givenN$1(data: rt.ByteSlice, out: rt.ByteVec): void {
const swapped2 = rt.byteSliceToArray(_50);
_50.data.set(rt.byteSliceToArray(_52), _50.start);
_52.data.set(swapped2, _52.start);
const at2 = rt.idx(v, 2);
const _54: rt.ByteSlice = rt.byteSliceFrom(v[rt.idx(v, 2)]);
const _56: Uint8Array = copy$array_u8(b);
const _54: rt.ByteSlice = rt.byteSliceFrom(v[at2]);
const old3 = rt.byteSliceToArray(_54);
_54.data.set(_56, _54.start);
const old: Uint8Array = old3;
Expand Down Expand Up @@ -813,8 +812,8 @@ export function givenN$1(data: rt.ByteSlice, out: rt.ByteVec): void {
_173.v = 238;
}
put$1(out, [copy$array_u8(b)]);
const _192: rt.ByteSlice = rt.byteSliceFrom(a);
const _190: Uint8Array[] = [rt.byteSliceView(rt.byteSliceFrom(b))];
const _192: rt.ByteSlice = rt.byteSliceFrom(a);
const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_192), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(_190, f, (value: Uint8Array, f: rt.Formatter) => rt.fmtList(value, f, rt.u8Debug))];
rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1]])));
if (isSomeAnd$09tpccf(rt.byteSliceFirst(data), (d2: rt.u8): boolean => {
Expand Down Expand Up @@ -868,9 +867,8 @@ export function givenN$3(data: rt.ByteSlice, out: rt.ByteVec): void {
const swapped2 = rt.byteSliceToArray(_50);
_50.data.set(rt.byteSliceToArray(_52), _50.start);
_52.data.set(swapped2, _52.start);
const at2 = rt.idx(v, 2);
const _54: rt.ByteSlice = rt.byteSliceFrom(v[rt.idx(v, 2)]);
const _56: Uint8Array = copy$array_u8(b);
const _54: rt.ByteSlice = rt.byteSliceFrom(v[at2]);
const old3 = rt.byteSliceToArray(_54);
_54.data.set(_56, _54.start);
const old: Uint8Array = old3;
Expand Down Expand Up @@ -931,8 +929,8 @@ export function givenN$3(data: rt.ByteSlice, out: rt.ByteVec): void {
_173.v = 238;
}
put$3(out, [copy$array_u8(b)]);
const _192: rt.ByteSlice = rt.byteSliceFrom(a);
const _190: Uint8Array[] = [rt.byteSliceView(rt.byteSliceFrom(b))];
const _192: rt.ByteSlice = rt.byteSliceFrom(a);
const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_192), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(_190, f, (value: Uint8Array, f: rt.Formatter) => rt.fmtList(value, f, rt.u8Debug))];
rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1]])));
if (isSomeAnd$09tpccf(rt.byteSliceFirst(data), (d2: rt.u8): boolean => {
Expand Down Expand Up @@ -986,9 +984,8 @@ export function givenN$40(data: rt.ByteSlice, out: rt.ByteVec): void {
const swapped2 = rt.byteSliceToArray(_50);
_50.data.set(rt.byteSliceToArray(_52), _50.start);
_52.data.set(swapped2, _52.start);
const at2 = rt.idx(v, 2);
const _54: rt.ByteSlice = rt.byteSliceFrom(v[rt.idx(v, 2)]);
const _56: Uint8Array = copy$array_u8(b);
const _54: rt.ByteSlice = rt.byteSliceFrom(v[at2]);
const old3 = rt.byteSliceToArray(_54);
_54.data.set(_56, _54.start);
const old: Uint8Array = old3;
Expand Down Expand Up @@ -1049,8 +1046,8 @@ export function givenN$40(data: rt.ByteSlice, out: rt.ByteVec): void {
_173.v = 238;
}
put$40(out, [copy$array_u8(b)]);
const _192: rt.ByteSlice = rt.byteSliceFrom(a);
const _190: Uint8Array[] = [rt.byteSliceView(rt.byteSliceFrom(b))];
const _192: rt.ByteSlice = rt.byteSliceFrom(a);
const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_192), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(_190, f, (value: Uint8Array, f: rt.Formatter) => rt.fmtList(value, f, rt.u8Debug))];
rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1]])));
if (isSomeAnd$09tpccf(rt.byteSliceFirst(data), (d2: rt.u8): boolean => {
Expand Down
11 changes: 10 additions & 1 deletion ts/fixtures/lang/borrows/caller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,13 @@ const leaks = [[0x00, 0x01, 0x02, 0xf1, 0xf2, 0x04, 0x05, 0x03, 0x06], [0xe3], [
Uint8Array.of(...op("borrows::leaks"), 0, ...bytes),
);

export const cases: Uint8Array[] = [...guards, ...maps, ...tries, ...leaks];
/**
* `borrows::printed` scripts: each cell printed, free, shared, and borrowed exclusively,
* nested, through guards, and borrowed while it writes what it holds, more than once so
* that what each holds grows.
*/
const printed = [[0x00, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x18, 0xf1, 0x12, 0xfb, 0x24, 0x2d], []].map((bytes) =>
Uint8Array.of(...op("borrows::printed"), 0, ...bytes),
);

export const cases: Uint8Array[] = [...guards, ...maps, ...tries, ...leaks, ...printed];
37 changes: 37 additions & 0 deletions ts/fixtures/lang/borrows/expected/borrows.Probe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import { drop$Result_cell_RefMut_borrows_Probe_cell_BorrowMutError, drop$Result_cell_Ref_borrows_Probe_cell_BorrowError } from "./lib.ts";

/**
* Writes whether the cell it is in can be borrowed, shared and exclusively, and how it
* writes, while the cell writes it.
*/
export class Probe {
_0: rt.Weak<rt.RefCell<Probe>>;

constructor(_0: rt.Weak<rt.RefCell<Probe>>) {
this._0 = _0;
}

[Symbol.dispose](): void {
this._0[Symbol.dispose]();
}
}

export function fmt$fmt_Debug(self: Probe, f: rt.Formatter): rt.Result<undefined, rt.FmtError> {
const cell: rt.Arc<rt.RefCell<Probe>> = rt.optionUnwrap(rt.weakUpgrade(self._0));
const _8: rt.Result<rt.RefCell<Probe>, rt.BorrowError> = rt.refCellTryBorrow(cell.value);
const shared: boolean = _8.ok;
drop$Result_cell_Ref_borrows_Probe_cell_BorrowError(_8);
const _13: rt.Result<rt.RefCell<Probe>, rt.BorrowMutError> = rt.refCellTryBorrowMut(cell.value);
const exclusive: boolean = _13.ok;
drop$Result_cell_RefMut_borrows_Probe_cell_BorrowMutError(_13);
const _19: boolean = rt.fmtAlternate(f);
const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(shared, f), (f: rt.Formatter) => rt.fmtBool(exclusive, f), (f: rt.Formatter) => rt.fmtBool(_19, f)];
const _0: rt.Result<undefined, rt.FmtError> = rt.fmtWriteFmt(f, [args2[0], " ", args2[1], " ", args2[2]]);
cell[Symbol.dispose]();
return _0;
}

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

import * as rt from "./rt.ts";

export function fmt$fmt_Debug(self: Shown, f: rt.Formatter): rt.Result<undefined, rt.FmtError> {
const _3: string = "Shown";
const _4: string = "cell";
const _5: rt.Fmt = (f: rt.Formatter) => rt.cellDebug(self.cell.v, f, rt.u8Debug);
const _7: string = "refcell";
const _8: rt.Fmt = (f: rt.Formatter) => rt.refCellDebug(self.refcell, f, (value: rt.ByteVec, f: rt.Formatter) => rt.fmtList(rt.byteVecView(value), f, rt.u8Debug));
return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8));
}

/** What a derived `Debug` writes each cell of as its field. */
export interface Shown {
cell: rt.Cell<rt.u8>;
refcell: rt.RefCell<rt.ByteVec>;
}

//# sourceMappingURL=borrows.Shown.ts.map
Loading