Skip to content
Merged
1 change: 0 additions & 1 deletion quest/m3/ts-unsafe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ Public API: the translator's output.

- [A raw pointer behind a reference](/quest/m3/ts-unsafe/raw-behind-ref.md) - `&raw const *r` of a value JS copies points where the reference came from
- [Vec::from_raw_parts of a typed allocation](/quest/m3/ts-unsafe/vec-from-raw-parts.md) - a `Vec` adopts an `alloc`ed array of `T`s, with its length, capacity, and drops
- [Unchecked integer operations](/quest/m3/ts-unsafe/unchecked-ops.md) - `unchecked_*` and `NonZero::new_unchecked` translate, aborting on a violated precondition
- [NonZero's unchecked arithmetic](/quest/m3/ts-unsafe/nonzero-unchecked-ops.md) - `NonZero::unchecked_add` and `unchecked_mul` translate, aborting at std's site
- [UnsafeCell's raw accessors](/quest/m3/ts-unsafe/unsafecell.md) - `UnsafeCell::raw_get`, `from_mut`, and `replace` translate
- [A byte local whose address is taken, in a buffer of its own](/quest/m3/ts-unsafe/lone-byte-buffers.md) - raw and mutable slices of a `u8` local, and casts of them to byte arrays, translate instead of being refused
16 changes: 0 additions & 16 deletions quest/m3/ts-unsafe/unchecked-ops.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 @@ -225,7 +225,10 @@ one call, `rs.u64FromHalves(hi, lo)`.

Each integer's inherent methods are std's, and a `NonZero`'s, a `Wrapping`'s, and a
`Saturating`'s are its integer's, as std defines them: a `Wrapping`'s `pow` is
`wrapping_pow`. `pow` and `abs` panic on overflow as a debug build's do. Those the operators
`wrapping_pow`. `pow` and `abs` panic on overflow as a debug build's do. An `unchecked_`
method and `NonZero::new_unchecked` are their checked form, `rs.precondition(rs.u32CheckedAdd(a, b), ...)`,
which aborts where it gives `None` as a debug build's check of the precondition does; a
`NonZero`'s own `unchecked_` methods are refused. Those the operators
lack are one runtime function for every width, `rs.intCheckedPow(a, n, 64, false)`, given
the width and sign, which computes on the value's `bigint`.

Expand Down
4 changes: 2 additions & 2 deletions ts/fixtures/lang/methods/caller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export { ops, run } from "./lang.ts";
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 exponents = new Set([3, 4, 7, 8, 21, 22, 23, 38, 39, 40, 45, 46, 47]);
const cases: Uint8Array[] = [];
for (const [name, bits, signed] of widths) {
const o = op(`methods::${name}`);
Expand All @@ -32,7 +32,7 @@ function methods(): Uint8Array[] {
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 (let kind = 0; kind < 49; 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)));
Expand Down
Loading