|
1 | 1 | use crate::limits::MAX_WASM_CANONICAL_OPTIONS; |
2 | 2 | use crate::prelude::*; |
3 | | -use crate::{BinaryReader, FromReader, Result, SectionLimited}; |
| 3 | +use crate::{BinaryReader, ComponentFuncResult, FromReader, Result, SectionLimited}; |
4 | 4 |
|
5 | 5 | /// Represents options for component functions. |
6 | 6 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
@@ -32,7 +32,7 @@ pub enum CanonicalOption { |
32 | 32 |
|
33 | 33 | /// Represents a canonical function in a WebAssembly component. |
34 | 34 | #[derive(Debug, Clone, Eq, PartialEq)] |
35 | | -pub enum CanonicalFunction { |
| 35 | +pub enum CanonicalFunction<'a> { |
36 | 36 | /// The function lifts a core WebAssembly function to the canonical ABI. |
37 | 37 | Lift { |
38 | 38 | /// The index of the core WebAssembly function to lift. |
@@ -80,10 +80,8 @@ pub enum CanonicalFunction { |
80 | 80 | /// function. This allows the callee to continue executing after returning |
81 | 81 | /// a result. |
82 | 82 | TaskReturn { |
83 | | - /// Core function type whose parameters represent the flattened |
84 | | - /// representation of the component-level results to be returned by the |
85 | | - /// currently executing task. |
86 | | - type_index: u32, |
| 83 | + /// The result type(s). |
| 84 | + results: ComponentFuncResult<'a>, |
87 | 85 | }, |
88 | 86 | /// A function which waits for at least one outstanding async |
89 | 87 | /// task/stream/future to make progress, returning the first such event. |
@@ -231,10 +229,10 @@ pub enum CanonicalFunction { |
231 | 229 | } |
232 | 230 |
|
233 | 231 | /// A reader for the canonical section of a WebAssembly component. |
234 | | -pub type ComponentCanonicalSectionReader<'a> = SectionLimited<'a, CanonicalFunction>; |
| 232 | +pub type ComponentCanonicalSectionReader<'a> = SectionLimited<'a, CanonicalFunction<'a>>; |
235 | 233 |
|
236 | | -impl<'a> FromReader<'a> for CanonicalFunction { |
237 | | - fn from_reader(reader: &mut BinaryReader<'a>) -> Result<CanonicalFunction> { |
| 234 | +impl<'a> FromReader<'a> for CanonicalFunction<'a> { |
| 235 | + fn from_reader(reader: &mut BinaryReader<'a>) -> Result<CanonicalFunction<'a>> { |
238 | 236 | Ok(match reader.read_u8()? { |
239 | 237 | 0x00 => match reader.read_u8()? { |
240 | 238 | 0x00 => { |
@@ -275,7 +273,7 @@ impl<'a> FromReader<'a> for CanonicalFunction { |
275 | 273 | 0x06 => CanonicalFunction::ThreadHwConcurrency, |
276 | 274 | 0x08 => CanonicalFunction::TaskBackpressure, |
277 | 275 | 0x09 => CanonicalFunction::TaskReturn { |
278 | | - type_index: reader.read()?, |
| 276 | + results: reader.read()?, |
279 | 277 | }, |
280 | 278 | 0x0a => CanonicalFunction::TaskWait { |
281 | 279 | async_: reader.read()?, |
|
0 commit comments