| 605 | } |
| 606 | |
| 607 | Expect<void *> Executor::proxyTableGetFuncSymbol( |
| 608 | Runtime::StackManager &StackMgr, const uint32_t TableIdx, |
| 609 | const uint32_t FuncTypeIdx, const uint32_t FuncIdx) noexcept { |
| 610 | const auto *TabInst = getTabInstByIdx(StackMgr, TableIdx); |
| 611 | assuming(TabInst); |
| 612 | |
| 613 | if (unlikely(FuncIdx >= TabInst->getSize())) { |
| 614 | return Unexpect(ErrCode::Value::UndefinedElement); |
| 615 | } |
| 616 | |
| 617 | auto Ref = TabInst->getRefAddr(FuncIdx); |
| 618 | assuming(Ref); |
| 619 | if (unlikely(Ref->isNull())) { |
| 620 | return Unexpect(ErrCode::Value::UninitializedElement); |
| 621 | } |
| 622 | |
| 623 | const auto *ModInst = StackMgr.getModule(); |
| 624 | assuming(ModInst); |
| 625 | const auto &ExpDefType = **ModInst->getType(FuncTypeIdx); |
| 626 | const auto *FuncInst = retrieveFuncRef(*Ref); |
| 627 | assuming(FuncInst); |
| 628 | bool IsMatch = false; |
| 629 | if (FuncInst->getModule()) { |
| 630 | IsMatch = AST::TypeMatcher::matchType( |
| 631 | ModInst->getTypeList(), *ExpDefType.getTypeIndex(), |
| 632 | FuncInst->getModule()->getTypeList(), FuncInst->getTypeIndex()); |
| 633 | } else { |
| 634 | // Independent host module instance case. Matching the composite type |
| 635 | // directly. |
| 636 | IsMatch = AST::TypeMatcher::matchType( |
| 637 | ModInst->getTypeList(), ExpDefType.getCompositeType(), |
| 638 | FuncInst->getHostFunc().getDefinedType().getCompositeType()); |
| 639 | } |
| 640 | if (!IsMatch) { |
| 641 | return Unexpect(ErrCode::Value::IndirectCallTypeMismatch); |
| 642 | } |
| 643 | |
| 644 | if (unlikely(!FuncInst->isCompiledFunction())) { |
| 645 | return nullptr; |
| 646 | } |
| 647 | return FuncInst->getSymbol().get(); |
| 648 | } |
| 649 | |
| 650 | Expect<void *> Executor::proxyRefGetFuncSymbol(Runtime::StackManager &, |
| 651 | const RefVariant Ref) noexcept { |
nothing calls this directly
no test coverage detected