Same as [`Self::from_raw`], but with a monomorphic store.
(
store: &mut AutoAssertNoGc<'_>,
raw: ValRaw,
ty: &ValType,
)
| 306 | |
| 307 | /// Same as [`Self::from_raw`], but with a monomorphic store. |
| 308 | pub(crate) unsafe fn _from_raw( |
| 309 | store: &mut AutoAssertNoGc<'_>, |
| 310 | raw: ValRaw, |
| 311 | ty: &ValType, |
| 312 | ) -> Val { |
| 313 | match ty { |
| 314 | ValType::I32 => Val::I32(raw.get_i32()), |
| 315 | ValType::I64 => Val::I64(raw.get_i64()), |
| 316 | ValType::F32 => Val::F32(raw.get_f32()), |
| 317 | ValType::F64 => Val::F64(raw.get_f64()), |
| 318 | ValType::V128 => Val::V128(raw.get_v128().into()), |
| 319 | ValType::Ref(ref_ty) => { |
| 320 | let ref_ = match ref_ty.heap_type() { |
| 321 | // SAFETY: it's a safety contract of this function that the |
| 322 | // funcref is valid and owned by the provided store. |
| 323 | HeapType::Func | HeapType::ConcreteFunc(_) => unsafe { |
| 324 | Func::_from_raw(store, raw.get_funcref()).into() |
| 325 | }, |
| 326 | |
| 327 | HeapType::NoFunc => Ref::Func(None), |
| 328 | |
| 329 | HeapType::NoCont | HeapType::ConcreteCont(_) | HeapType::Cont => { |
| 330 | // TODO(#10248): Required to support stack switching in the embedder API. |
| 331 | unimplemented!() |
| 332 | } |
| 333 | |
| 334 | HeapType::Extern => ExternRef::_from_raw(store, raw.get_externref()).into(), |
| 335 | |
| 336 | HeapType::NoExtern => Ref::Extern(None), |
| 337 | |
| 338 | HeapType::Any |
| 339 | | HeapType::Eq |
| 340 | | HeapType::I31 |
| 341 | | HeapType::Array |
| 342 | | HeapType::ConcreteArray(_) |
| 343 | | HeapType::Struct |
| 344 | | HeapType::ConcreteStruct(_) => { |
| 345 | AnyRef::_from_raw(store, raw.get_anyref()).into() |
| 346 | } |
| 347 | |
| 348 | HeapType::Exn | HeapType::ConcreteExn(_) => { |
| 349 | ExnRef::_from_raw(store, raw.get_exnref()).into() |
| 350 | } |
| 351 | HeapType::NoExn => Ref::Exn(None), |
| 352 | |
| 353 | HeapType::None => Ref::Any(None), |
| 354 | }; |
| 355 | assert!( |
| 356 | ref_ty.is_nullable() || !ref_.is_null(), |
| 357 | "if the type is not nullable, we shouldn't get null; got \ |
| 358 | type = {ref_ty}, ref = {ref_:?}" |
| 359 | ); |
| 360 | ref_.into() |
| 361 | } |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | accessors! { |
nothing calls this directly
no test coverage detected