MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / proxyRefCast

Method proxyRefCast

lib/executor/engine/proxy.cpp:386–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384}
385
386Expect<RefVariant> Executor::proxyRefCast(Runtime::StackManager &StackMgr,
387 const RefVariant Ref,
388 ValType VTCast) noexcept {
389 // Copy the value type here due to handling the externalized case.
390 auto VT = Ref.getType();
391 if (VT.isExternalized()) {
392 VT = ValType(TypeCode::Ref, TypeCode::ExternRef);
393 }
394 const auto *ModInst = StackMgr.getModule();
395 assuming(ModInst);
396 Span<const AST::SubType *const> GotTypeList = ModInst->getTypeList();
397 if (!VT.isAbsHeapType()) {
398 auto *Inst = Ref.getPtr<Runtime::Instance::CompositeBase>();
399 // Reference must not be nullptr here because the null references are typed
400 // with the least abstract heap type.
401 if (Inst->getModule()) {
402 GotTypeList = Inst->getModule()->getTypeList();
403 }
404 }
405
406 if (!AST::TypeMatcher::matchType(ModInst->getTypeList(), VTCast, GotTypeList,
407 VT)) {
408 return Unexpect(ErrCode::Value::CastFailed);
409 }
410 return Ref;
411}
412
413// For the runtime value of `uint64_t`, arguments are expected to be extended
414// to 64-bit width in the LLVM compiler regardless of whether the address type

Callers

nothing calls this directly

Calls 7

ValTypeClass · 0.85
UnexpectFunction · 0.85
isExternalizedMethod · 0.80
getTypeListMethod · 0.80
isAbsHeapTypeMethod · 0.80
getTypeMethod · 0.45
getModuleMethod · 0.45

Tested by

no test coverage detected