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/m2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ The fork's feature quests folded into the [exporter](/quest/m1/ffi-export.md);
- [str and String methods over char](/quest/m2/ts-str-char.md) - `chars`, `char` patterns, and `String::push` translate, unblocking `ietf/namespace.rs`
- [Share a held-back read across a call](/quest/m2/ts-shared-read.md) - `leading-ones` decode recovers what #83's copy fix cost
- [Output tsc accepts for writes through Result and Poll compares](/quest/m2/ts-tsc-shapes.md) - two shapes whose output fails `tsc` type-check
- [Translate derived == through references and slice index writes](/quest/m2/ts-ref-shapes.md) - two refused shapes #83's tests hit
- [Translate moq-net's model to TypeScript](/quest/m2/ts-model.md) - the driver grows from moq-net's codec to its model, for moq to compare against WASM
- [Waiting: Swift 6.4 in nixpkgs-unstable](/quest/m2/uniffi-swift-arm.md) - the nightly UniFFI fixtures move back to arm
- [Waiting: ubrn reads UniFFI 0.32](/quest/m2/ubrn-release.md) - the binding benchmark's browser runner pins a ubrn release, not an open PR
17 changes: 0 additions & 17 deletions quest/m2/ts-ref-shapes.md

This file was deleted.

80 changes: 80 additions & 0 deletions ts/fixtures/lang/expected/keys.Seen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import * as Hop from "./keys.Hop.ts";
import * as Horizon from "./keys.Horizon.ts";
import * as Name from "./keys.Name.ts";

export function eq$PartialEq(self: Seen, other: Seen): boolean {
if (!({ Hop: 0, Twice: 1, Text: 2, Name: 3, Mut: 4 }[self.tag] === { Hop: 0, Twice: 1, Text: 2, Name: 3, Mut: 4 }[other.tag])) {
return false;
}
if (self.tag === "Hop") {
return rt.eqOption(Hop.eq$PartialEq)(self._0, (other as { tag: "Hop"; _0: Hop.Hop | undefined })._0);
}
if (self.tag === "Twice") {
return Horizon.eq$PartialEq(self._0, (other as { tag: "Twice"; _0: Horizon.Horizon })._0);
}
if (self.tag === "Text") {
return self._0 === (other as { tag: "Text"; _0: string })._0;
}
if (self.tag === "Name") {
return Name.eq$PartialEq(self._0, (other as { tag: "Name"; _0: Name.Name })._0);
}
return Hop.eq$PartialEq(self._0, (other as { tag: "Mut"; _0: Hop.Hop })._0);
}

export function partialCmp$PartialOrd(self: Seen, other: Seen): rt.Ordering | undefined {
return cmp$Ord(self, other);
}

export function cmp$Ord(self: Seen, other: Seen): rt.Ordering {
if (self.tag === "Hop") {
if (other.tag === "Hop") {
return rt.cmpOption(Hop.cmp$Ord)(self._0, other._0);
}
} else if (self.tag === "Twice") {
if (other.tag === "Twice") {
return Horizon.cmp$Ord(self._0, other._0);
}
} else if (self.tag === "Text") {
if (other.tag === "Text") {
return rt.cmpStr(self._0, other._0);
}
} else if (self.tag === "Name") {
if (other.tag === "Name") {
return Name.cmp$Ord(self._0, other._0);
}
} else if (other.tag === "Mut") {
return Hop.cmp$Ord(self._0, other._0);
}
return rt.cmp({ Hop: 0, Twice: 1, Text: 2, Name: 3, Mut: 4 }[self.tag], { Hop: 0, Twice: 1, Text: 2, Name: 3, Mut: 4 }[other.tag]);
}

export function hash$Hash_DefaultHasher(self: Seen, state: rt.Hasher): void {
rt.hashInt({ Hop: 0, Twice: 1, Text: 2, Name: 3, Mut: 4 }[self.tag], state);
if (self.tag === "Hop") {
rt.hashOption(Hop.hash$Hash_DefaultHasher)(self._0, state);
} else if (self.tag === "Twice") {
Horizon.hash$Hash_DefaultHasher(self._0, state);
} else if (self.tag === "Text") {
rt.hashStr(self._0, state);
} else if (self.tag === "Name") {
Name.hash$Hash_DefaultHasher(self._0, state);
} else {
Hop.hash$Hash_DefaultHasher(self._0, state);
}
}

/**
* Borrows, whose derived impls compare, order, and hash what they point at through
* std's impls for references.
*/
export type Seen =
| { tag: "Hop"; _0: Hop.Hop | undefined }
| { tag: "Twice"; _0: Horizon.Horizon }
| { tag: "Text"; _0: string }
| { tag: "Name"; _0: Name.Name }
| { tag: "Mut"; _0: Hop.Hop };

//# sourceMappingURL=keys.Seen.ts.map
4 changes: 4 additions & 0 deletions ts/fixtures/lang/expected/keys.Skew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

export function eq$PartialEq(self: Skew, other: Skew): boolean {
return self._0 === other._0;
}

/**
* An `Ord` by value whose `PartialOrd` disagrees: reversed, and unordered between odd
* values, so a `partial_cmp` that calls `cmp` shows.
Expand Down
22 changes: 22 additions & 0 deletions ts/fixtures/lang/expected/keys.Skewed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Generated by rust2-ts. Do not edit.

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

export function eq$PartialEq(self: Skewed, other: Skewed): boolean {
return Skew.eq$PartialEq(self._0, other._0);
}

export function partialCmp$PartialOrd(self: Skewed, other: Skewed): rt.Ordering | undefined {
return Skew.partialCmp$PartialOrd(self._0, other._0);
}

/**
* A borrow of a `Skew`, whose derived `partial_cmp` reaches its own, not its `cmp`: a
* derived `Ord` beside it would be called instead.
*/
export interface Skewed {
_0: Skew.Skew;
}

//# sourceMappingURL=keys.Skewed.ts.map
124 changes: 122 additions & 2 deletions ts/fixtures/lang/expected/keys.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import { copy$Horizon } from "./lib.ts";
import { copy$Hop, copy$Horizon } from "./lib.ts";
import * as Hop from "./keys.Hop.ts";
import * as Horizon from "./keys.Horizon.ts";
import * as Liar from "./keys.Liar.ts";
import * as Name from "./keys.Name.ts";
import * as Never from "./keys.Never.ts";
import * as Picky from "./keys.Picky.ts";
import * as Seen from "./keys.Seen.ts";
import * as Side from "./keys.Side.ts";
import * as Skew from "./keys.Skew.ts";
import * as Skewed from "./keys.Skewed.ts";
import * as Touchy from "./keys.Touchy.ts";
import * as Way from "./keys.Way.ts";

Expand Down Expand Up @@ -89,6 +91,18 @@ export function hashOf$Arc_str(value: rt.Arc<string>): rt.u64 {
return rt.hashFinish(h);
}

export function hashOf$Hop(value: Hop.Hop): rt.u64 {
const h: rt.Hasher = rt.hasher();
Hop.hash$Hash_DefaultHasher(value, h);
return rt.hashFinish(h);
}

export function hashOf$Hop$2(value: Hop.Hop): rt.u64 {
const h: rt.Hasher = rt.hasher();
Hop.hash$Hash_DefaultHasher(value, h);
return rt.hashFinish(h);
}

export function hashOf$Name(value: Name.Name): rt.u64 {
const h: rt.Hasher = rt.hasher();
Name.hash$Hash_DefaultHasher(value, h);
Expand All @@ -101,6 +115,12 @@ export function hashOf$Option_Hop(value: Hop.Hop | undefined): rt.u64 {
return rt.hashFinish(h);
}

export function hashOf$Seen(value: Seen.Seen): rt.u64 {
const h: rt.Hasher = rt.hasher();
Seen.hash$Hash_DefaultHasher(value, h);
return rt.hashFinish(h);
}

export function order(o: rt.Ordering): rt.u8 {
if (o === -1) {
return 1;
Expand Down Expand Up @@ -165,16 +185,116 @@ export function find$u8_u8(keys_: Uint8Array, q: rt.u8): rt.u8 {

/** Run one case. */
export function keys(kind: rt.u8, data: Uint8Array, out: rt.ByteVec): void {
const _4: rt.u8 = rt.u8Rem(kind, 3);
const _4: rt.u8 = rt.u8Rem(kind, 4);
if (_4 === 0) {
options(data, out);
} else if (_4 === 1) {
arcs(data, out);
} else if (_4 === 2) {
borrows(data, out);
} else {
places(data, out);
}
}

/** One of `Seen`'s variants, by `k`. */
export function seen(k: rt.u8, hop_: Hop.Hop | undefined, horizon: Horizon.Horizon, name_: Name.Name, mine: Hop.Hop): Seen.Seen {
const _6: rt.u8 = rt.u8Rem(k, 5);
if (_6 === 0) {
return { tag: "Hop", _0: hop_ } as Seen.Seen;
}
if (_6 === 1) {
return { tag: "Twice", _0: horizon } as Seen.Seen;
}
if (_6 === 2) {
const _9: rt.usize = rt.usizeRem(rt.usizeDiv(k as rt.usize, 5), ["", "a", "ab", "", "￿", "𐀀"].length);
if (!(_9 < 6)) {
rt.panic("index out of bounds: the len is " + 6 + " but the index is " + _9);
}
return { tag: "Text", _0: ["", "a", "ab", "", "￿", "𐀀"][_9] } as Seen.Seen;
}
if (_6 === 3) {
return { tag: "Name", _0: name_ } as Seen.Seen;
}
return { tag: "Mut", _0: mine } as Seen.Seen;
}

/**
* Borrows compared, ordered, and hashed as what they point at, through one reference
* or two, shared or mutable.
*/
export function borrows(data: Uint8Array, out: rt.ByteVec): void {
let _7!: rt.usize;
let m!: Name.Name;
let n!: Name.Name;
let _43!: Name.Name;
let unwind: number = 0;
try {
let iterStart: rt.usize = 1;
const iterEnd: rt.usize = data.length;
while ((_7 = iterStart++) < iterEnd) {
const i: rt.usize = _7;
const _15: rt.usize = rt.usizeSub(i, 1);
rt.idx(data, _15);
const _14: rt.u8 = data[_15];
rt.idx(data, i);
const _13: [rt.u8, rt.u8] = [_14, data[i]];
const c: rt.u8 = _14;
const d: rt.u8 = _13[1];
const _24: [Hop.Hop | undefined, Hop.Hop | undefined] = [hop(c), hop(d)];
const a: Hop.Hop | undefined = _24[0];
const b: Hop.Hop | undefined = _24[1];
const _28: boolean = rt.u8Rem(c, 2) === 0;
const g: Horizon.Horizon = { exclude: a, local: _28 };
unwind = 0;
const _32: boolean = rt.u8Rem(d, 2) === 0;
const gr: Horizon.Horizon = g;
const hr: Horizon.Horizon = { exclude: b, local: _32 };
_43 = name(c);
unwind = 55;
const _44: Name.Name = name(d);
unwind = 53;
m = _43;
n = _44;
const _47: [Hop.Hop, Hop.Hop] = [{ _0: rt.u64Rem(c as rt.u64, 3) }, { _0: rt.u64Rem(d as rt.u64, 3) }];
const x: Hop.Hop = copy$Hop(_47[0]);
const y: Hop.Hop = copy$Hop(_47[1]);
const _58: [Seen.Seen, Seen.Seen] = [seen(c, a, gr, m, x), seen(d, b, hr, n, y)];
const l: Seen.Seen = _58[0];
const r: Seen.Seen = _58[1];
rt.byteVecPush(out, (Seen.eq$PartialEq(l, r) ? 1 : 0) | ((order(Seen.cmp$Ord(l, r)) << 1) & 0xff) | ((partial(Seen.partialCmp$PartialOrd(l, r)) << 3) & 0xff) | (((rt.u64Eq(hashOf$Seen(l), hashOf$Seen(r)) ? 1 : 0) << 5) & 0xff));
const _102: [Skew.Skew, Skew.Skew] = [{ _0: rt.u8Rem(c, 4) }, { _0: rt.u8Rem(d, 4) }];
const s: Skew.Skew = _102[0];
const t: Skew.Skew = _102[1];
const _111: [Skewed.Skewed, Skewed.Skewed] = [{ _0: s }, { _0: t }];
const s2: Skewed.Skewed = _111[0];
const t2: Skewed.Skewed = _111[1];
const _119: boolean = Skewed.eq$PartialEq(s2, t2);
unwind = 53;
rt.byteVecPush(out, (_119 ? 1 : 0) | ((partial(Skewed.partialCmp$PartialOrd(s2, t2)) << 1) & 0xff));
rt.byteVecPush(out, (rt.eqOption(Hop.eq$PartialEq)(a, b) ? 1 : 0) | (((Horizon.eq$PartialEq(gr, hr) ? 1 : 0) << 1) & 0xff) | (((Hop.eq$PartialEq(x, y) ? 1 : 0) << 2) & 0xff) | (((Hop.eq$PartialEq(x, y) ? 1 : 0) << 3) & 0xff) | (((Hop.eq$PartialEq(x, y) ? 1 : 0) << 4) & 0xff) | (((rt.u64Eq(hashOf$Hop(x), hashOf$Hop$2(y)) ? 1 : 0) << 5) & 0xff));
unwind = 54;
rt.drop(n);
unwind = 0;
rt.drop(m);
}
} catch (e) {
b2: {
if (unwind === 0) {
throw e;
}
if (unwind === 53) {
rt.drop(n);
} else if (unwind !== 54) {
rt.drop(_43);
break b2;
}
rt.drop(m);
}
throw e;
}
}

/** `Option`s compared, ordered, and hashed, alone and in keys. */
export function options(data: Uint8Array, out: rt.ByteVec): void {
let _10!: rt.usize;
Expand Down
Loading