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

Method proxyRefTest

lib/executor/engine/proxy.cpp:358–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356}
357
358Expect<uint32_t> Executor::proxyRefTest(Runtime::StackManager &StackMgr,
359 const RefVariant Ref,
360 ValType VTTest) noexcept {
361 // Copy the value type here due to handling the externalized case.
362 auto VT = Ref.getType();
363 if (VT.isExternalized()) {
364 VT = ValType(TypeCode::Ref, TypeCode::ExternRef);
365 }
366 const auto *ModInst = StackMgr.getModule();
367 assuming(ModInst);
368 Span<const AST::SubType *const> GotTypeList = ModInst->getTypeList();
369 if (!VT.isAbsHeapType()) {
370 auto *Inst = Ref.getPtr<Runtime::Instance::CompositeBase>();
371 // Reference must not be nullptr here because the null references are typed
372 // with the least abstract heap type.
373 if (Inst->getModule()) {
374 GotTypeList = Inst->getModule()->getTypeList();
375 }
376 }
377
378 if (AST::TypeMatcher::matchType(ModInst->getTypeList(), VTTest, GotTypeList,
379 VT)) {
380 return static_cast<uint32_t>(1);
381 } else {
382 return static_cast<uint32_t>(0);
383 }
384}
385
386Expect<RefVariant> Executor::proxyRefCast(Runtime::StackManager &StackMgr,
387 const RefVariant Ref,

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected