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

Method arrayNewElem

lib/executor/engine/refInstr.cpp:518–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

516}
517
518Expect<RefVariant>
519Executor::arrayNewElem(Runtime::StackManager &StackMgr, const uint32_t TypeIdx,
520 const uint32_t ElemIdx, const uint32_t Start,
521 const uint32_t Length) const noexcept {
522 const auto &VType = getArrayStorageTypeByIdx(StackMgr, TypeIdx);
523 auto *ElemInst = getElemInstByIdx(StackMgr, ElemIdx);
524 assuming(ElemInst);
525 auto ElemSrc = ElemInst->getRefs();
526 if (static_cast<uint64_t>(Start) + static_cast<uint64_t>(Length) >
527 ElemSrc.size()) {
528 return Unexpect(ErrCode::Value::TableOutOfBounds);
529 }
530 std::vector<ValVariant> Refs(ElemSrc.begin() + Start,
531 ElemSrc.begin() + Start + Length);
532 Runtime::Instance::ModuleInstance *ModInst =
533 const_cast<Runtime::Instance::ModuleInstance *>(StackMgr.getModule());
534 WasmEdge::Runtime::Instance::ArrayInstance *Inst =
535 ModInst->newArray(TypeIdx, packVals(VType, std::move(Refs)));
536 return RefVariant(Inst->getDefType(), Inst);
537}
538
539Expect<ValVariant> Executor::arrayGet(Runtime::StackManager &StackMgr,
540 const RefVariant &Ref,

Callers

nothing calls this directly

Calls 8

UnexpectFunction · 0.85
RefVariantClass · 0.85
newArrayMethod · 0.80
getRefsMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
getModuleMethod · 0.45
getDefTypeMethod · 0.45

Tested by

no test coverage detected