| 410 | } |
| 411 | |
| 412 | Expect<RefVariant> |
| 413 | Executor::structNew(Runtime::StackManager &StackMgr, const uint32_t TypeIdx, |
| 414 | Span<const ValVariant> Args) const noexcept { |
| 415 | /// TODO: The array and struct instances are currently owned by the module |
| 416 | /// instance because they refer to the defined types of the module instances. |
| 417 | /// This may be changed after applying the garbage collection mechanism. |
| 418 | const auto &CompType = getCompositeTypeByIdx(StackMgr, TypeIdx); |
| 419 | uint32_t N = static_cast<uint32_t>(CompType.getFieldTypes().size()); |
| 420 | Runtime::Instance::ModuleInstance *ModInst = |
| 421 | const_cast<Runtime::Instance::ModuleInstance *>(StackMgr.getModule()); |
| 422 | std::vector<ValVariant> Vals(N); |
| 423 | for (uint32_t I = 0; I < N; I++) { |
| 424 | const auto &VType = CompType.getFieldTypes()[I].getStorageType(); |
| 425 | if (Args.size() > 0) { |
| 426 | Vals[I] = packVal(VType, Args[I]); |
| 427 | } else { |
| 428 | Vals[I] = VType.isRefType() |
| 429 | ? ValVariant(RefVariant(toBottomType(StackMgr, VType))) |
| 430 | : ValVariant(static_cast<uint128_t>(0U)); |
| 431 | } |
| 432 | } |
| 433 | WasmEdge::Runtime::Instance::StructInstance *Inst = |
| 434 | ModInst->newStruct(TypeIdx, std::move(Vals)); |
| 435 | return RefVariant(Inst->getDefType(), Inst); |
| 436 | } |
| 437 | |
| 438 | Expect<ValVariant> Executor::structGet(Runtime::StackManager &StackMgr, |
| 439 | const RefVariant Ref, |
nothing calls this directly
no test coverage detected