MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / lift_variant

Function lift_variant

crates/wasmtime/src/runtime/component/values.rs:1068–1090  ·  view source on GitHub ↗
(
    cx: &mut LiftContext<'_>,
    flatten_count: usize,
    mut types: impl ExactSizeIterator<Item = Option<InterfaceType>>,
    src: &mut Iter<'_, ValRaw>,
)

Source from the content-addressed store, hash-verified

1066}
1067
1068fn lift_variant(
1069 cx: &mut LiftContext<'_>,
1070 flatten_count: usize,
1071 mut types: impl ExactSizeIterator<Item = Option<InterfaceType>>,
1072 src: &mut Iter<'_, ValRaw>,
1073) -> Result<(u32, Option<Box<Val>>)> {
1074 let len = types.len();
1075 let discriminant = next(src).get_u32();
1076 let ty = types
1077 .nth(discriminant as usize)
1078 .ok_or_else(|| format_err!("discriminant {discriminant} out of range [0..{len})"))?;
1079 let (value, value_flat) = match ty {
1080 Some(ty) => (
1081 Some(Box::new(Val::lift(cx, ty, src)?)),
1082 cx.types.canonical_abi(&ty).flat_count(usize::MAX).unwrap(),
1083 ),
1084 None => (None, 0),
1085 };
1086 for _ in (1 + value_flat)..flatten_count {
1087 next(src);
1088 }
1089 Ok((discriminant, value))
1090}
1091
1092/// Lower a list with the specified element type and values.
1093fn lower_list<T>(

Callers 1

liftMethod · 0.85

Calls 9

nextFunction · 0.85
OkFunction · 0.85
flat_countMethod · 0.80
newFunction · 0.50
liftFunction · 0.50
lenMethod · 0.45
get_u32Method · 0.45
unwrapMethod · 0.45
canonical_abiMethod · 0.45

Tested by

no test coverage detected