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

Method arrayFill

lib/executor/engine/refInstr.cpp:571–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

569}
570
571Expect<void> Executor::arrayFill(Runtime::StackManager &StackMgr,
572 const RefVariant &Ref, const ValVariant &Val,
573 const uint32_t TypeIdx, const uint32_t Idx,
574 const uint32_t Cnt) const noexcept {
575 auto *Inst = Ref.getPtr<Runtime::Instance::ArrayInstance>();
576 if (Inst == nullptr) {
577 return Unexpect(ErrCode::Value::AccessNullArray);
578 }
579 if (static_cast<uint64_t>(Idx) + static_cast<uint64_t>(Cnt) >
580 Inst->getLength()) {
581 return Unexpect(ErrCode::Value::ArrayOutOfBounds);
582 }
583 const auto &VType = getArrayStorageTypeByIdx(StackMgr, TypeIdx);
584 auto Arr = Inst->getArray();
585 std::fill(Arr.begin() + Idx, Arr.begin() + Idx + Cnt, packVal(VType, Val));
586 return {};
587}
588
589Expect<void>
590Executor::arrayInitData(Runtime::StackManager &StackMgr, const RefVariant &Ref,

Callers

nothing calls this directly

Calls 4

UnexpectFunction · 0.85
getLengthMethod · 0.80
getArrayMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected