| 569 | } |
| 570 | |
| 571 | Expect<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 | |
| 589 | Expect<void> |
| 590 | Executor::arrayInitData(Runtime::StackManager &StackMgr, const RefVariant &Ref, |