@@ -1121,26 +1121,26 @@ Wado types are stored internally as WebAssembly core and GC types, and lift/lowe
11211121
11221122The table below is the Wado↔CM correspondence, read in both directions: Wado→CM when generating a component's exported interface, and CM→Wado when importing an external component (` use { Iface } from "./c.wasm" with { type: "wasm" } ` , see [ Wasm Module and Component Imports] ( #wasm-module-and-component-imports ) ). CM types are written in their WIT spelling.
11231123
1124- | Wado Type | Internal Representation | CM Type at Boundary | Notes |
1125- | ------------------------- | ---------------------------- | ----------- ------------------------- | ------------------------------------------------------------------------ |
1126- | ` bool ` | ` i32 ` | ` bool ` | Boolean value |
1127- | ` char ` | ` i32 ` | ` char ` | Unicode scalar value |
1128- | ` i8 ` , ` i16 ` , ` i32 ` , ` i64 ` | ` i32 ` , ` i32 ` , ` i32 ` , ` i64 ` | ` s8 ` , ` s16 ` , ` s32 ` , ` s64 ` | Signed integers |
1129- | ` u8 ` , ` u16 ` , ` u32 ` , ` u64 ` | ` i32 ` , ` i32 ` , ` i32 ` , ` i64 ` | ` u8 ` , ` u16 ` , ` u32 ` , ` u64 ` | Unsigned integers |
1130- | ` i128 ` , ` u128 ` | ` i64 ` pair (Wide Arithmetic) | ` tuple<s64, s64> ` , ` tuple< u64, u64> ` | 128-bit integers |
1131- | ` f32 ` , ` f64 ` | ` f32 ` , ` f64 ` | ` f32 ` , ` f64 ` | Floating point |
1132- | ` String ` | GC ` array i8 ` (UTF-8) | ` string ` | UTF-8 string, GC-managed internally |
1133- | ` List<T> ` | GC ` array T ` | ` list<T> ` | Dynamic array, GC-managed internally |
1134- | ` [T1, T2, ...] ` | GC ` struct {T1, T2, ...} ` | ` tuple<T1, T2, ...> ` | Tuple types |
1135- | ` Option<T> ` | GC variant | ` option<T> ` | Optional value |
1136- | ` Result<T, E> ` | GC variant | ` result<T, E> ` | Result type; ` result<ok> ` and bare ` result ` are the payload-elided forms |
1137- | ` struct { ... } ` | GC ` struct ` | ` record { ... } ` | Wasm GC struct internally, record at CM boundary |
1138- | ` enum { ... } ` | ` i32 ` | ` enum { ... } ` | Enumeration without payloads |
1139- | ` variant { ... } ` | GC variant | ` variant { ... } ` | Variant/sum type with payloads |
1140- | ` flags { ... } ` | ` i32 ` /` i64 ` | ` flags { ... } ` | Bit flags |
1141- | ` resource ` | ` i32 ` (handle) | ` resource ` | Resource handle; owned and borrowed handles both map here |
1142- | ` Stream<T> ` | CM stream (P3) | ` stream<T> ` | Component Model async stream |
1143- | ` Future<T> ` | CM future (P3) | ` future<T> ` | Component Model async future |
1124+ | Wado Type | Internal Representation | CM Type at Boundary | Notes |
1125+ | ------------------------- | -------------------------- | ------------------------- | ------------------------------------------------------------------------ |
1126+ | ` bool ` | ` i32 ` | ` bool ` | Boolean value |
1127+ | ` char ` | ` i32 ` | ` char ` | Unicode scalar value |
1128+ | ` i8 ` , ` i16 ` , ` i32 ` , ` i64 ` | ` i32 ` , ` i32 ` , ` i32 ` , ` i64 ` | ` s8 ` , ` s16 ` , ` s32 ` , ` s64 ` | Signed integers |
1129+ | ` u8 ` , ` u16 ` , ` u32 ` , ` u64 ` | ` i32 ` , ` i32 ` , ` i32 ` , ` i64 ` | ` u8 ` , ` u16 ` , ` u32 ` , ` u64 ` | Unsigned integers |
1130+ | ` i128 ` , ` u128 ` | GC ` struct { u64, i64/ u64} ` | ` record { low, high } ` | Prelude structs, so each crosses as its own record |
1131+ | ` f32 ` , ` f64 ` | ` f32 ` , ` f64 ` | ` f32 ` , ` f64 ` | Floating point |
1132+ | ` String ` | GC ` array i8 ` (UTF-8) | ` string ` | UTF-8 string, GC-managed internally |
1133+ | ` List<T> ` | GC ` array T ` | ` list<T> ` | Dynamic array, GC-managed internally |
1134+ | ` [T1, T2, ...] ` | GC ` struct {T1, T2, ...} ` | ` tuple<T1, T2, ...> ` | Tuple types |
1135+ | ` Option<T> ` | GC variant | ` option<T> ` | Optional value |
1136+ | ` Result<T, E> ` | GC variant | ` result<T, E> ` | Result type; ` result<ok> ` and bare ` result ` are the payload-elided forms |
1137+ | ` struct { ... } ` | GC ` struct ` | ` record { ... } ` | Wasm GC struct internally, record at CM boundary |
1138+ | ` enum { ... } ` | ` i32 ` | ` enum { ... } ` | Enumeration without payloads |
1139+ | ` variant { ... } ` | GC variant | ` variant { ... } ` | Variant/sum type with payloads |
1140+ | ` flags { ... } ` | ` i32 ` /` i64 ` | ` flags { ... } ` | Bit flags |
1141+ | ` resource ` | ` i32 ` (handle) | ` resource ` | Resource handle; owned and borrowed handles both map here |
1142+ | ` Stream<T> ` | CM stream (P3) | ` stream<T> ` | Component Model async stream |
1143+ | ` Future<T> ` | CM future (P3) | ` future<T> ` | Component Model async future |
11441144
11451145### The Prelude
11461146
@@ -1222,6 +1222,10 @@ Available operations:
12221222| Bitwise | ` & ` , ` \| ` , ` ^ ` , ` ~ ` , ` << ` , ` >> ` |
12231223| Conversion | ` from_u64() ` , ` from_i64() ` , ` low() ` , ` high() ` , ` as ` , ` TryFrom ` |
12241224
1225+ Literal and range patterns work on them in every pattern position, nested ones
1226+ included: ` match [x, y] { [1..=5, _] => … } ` . Each lowers to the same ` Eq ` /
1227+ ` Ord ` call the equivalent comparison does.
1228+
12251229` as ` casts follow Rust semantics in both directions:
12261230
12271231``` wado
0 commit comments