Skip to content

Commit 5a019a4

Browse files
committed
add enough implementation to make wasmtime compile
1 parent ebb3f83 commit 5a019a4

4 files changed

Lines changed: 13 additions & 0 deletions

File tree

crates/c-api/src/component/types/val.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub enum wasmtime_component_valtype_t {
3232
Stream(Box<wasmtime_component_stream_type_t>),
3333
ErrorContext,
3434
Map(Box<wasmtime_component_map_type_t>),
35+
FixedLengthList(Box<wasmtime_component_list_type_t>),
3536
}
3637

3738
impl From<Type> for wasmtime_component_valtype_t {
@@ -63,6 +64,7 @@ impl From<Type> for wasmtime_component_valtype_t {
6364
Type::Future(ty) => Self::Future(Box::new(ty.into())),
6465
Type::Stream(ty) => Self::Stream(Box::new(ty.into())),
6566
Type::Map(ty) => Self::Map(Box::new(ty.into())),
67+
Type::FixedLengthList(ty) => Self::FixedLengthList(Box::new(ty.into())),
6668
Type::ErrorContext => Self::ErrorContext,
6769
}
6870
}

crates/c-api/src/component/val.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ pub enum wasmtime_component_val_t {
274274
Flags(wasmtime_component_valflags_t),
275275
Resource(Box<wasmtime_component_resource_any_t>),
276276
Map(wasmtime_component_valmap_t),
277+
FixedLengthList(wasmtime_component_vallist_t),
277278
}
278279

279280
// Safety: the C API async contract (documented in async.h) guarantees that
@@ -321,6 +322,7 @@ impl From<&wasmtime_component_val_t> for Val {
321322
wasmtime_component_val_t::Flags(x) => Val::Flags(x.into()),
322323
wasmtime_component_val_t::Map(x) => Val::Map(x.into()),
323324
wasmtime_component_val_t::Resource(x) => Val::Resource(x.resource),
325+
wasmtime_component_val_t::FixedSizeList(x) => Val::FixedSizeList(x.into()),
324326
}
325327
}
326328
}
@@ -363,6 +365,9 @@ impl From<&Val> for wasmtime_component_val_t {
363365
Val::Future(_) => todo!(),
364366
Val::Stream(_) => todo!(),
365367
Val::ErrorContext(_) => todo!(),
368+
Val::FixedSizeList(ty) => wasmtime_component_val_t::FixedSizeList(
369+
wasmtime_component_vallist_t::from(ty.as_ref()),
370+
),
366371
}
367372
}
368373
}

crates/fuzzing/src/oracles/component_api.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ fn arbitrary_val(
138138
})
139139
.collect::<arbitrary::Result<_>>()?,
140140
),
141+
Type::FixedSizeList(list) => Val::FixedSizeList(
142+
(0..list.size())
143+
.map(|_| arbitrary_val(&list.ty(), input))
144+
.collect::<arbitrary::Result<_>>()?,
145+
),
141146

142147
Type::Map(map) => {
143148
let mut pairs = Vec::new();

crates/wast/src/component.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ fn mismatch(expected: &ComponentConst<'_>, actual: &Val) -> Result<()> {
291291
Val::Stream(..) => "stream",
292292
Val::ErrorContext(..) => "error-context",
293293
Val::Map(..) => "map",
294+
Val::FixedLengthList(..) => "list<_, N>",
294295
};
295296
bail!("expected `{expected}` got `{actual}`")
296297
}

0 commit comments

Comments
 (0)