| 384 | } |
| 385 | |
| 386 | Expect<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 |
nothing calls this directly
no test coverage detected