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

Method setRefs

include/runtime/instance/table.h:109–137  ·  view source on GitHub ↗

Replace the Refs[Dst :] by Slice[Src : Src + Length)

Source from the content-addressed store, hash-verified

107
108 /// Replace the Refs[Dst :] by Slice[Src : Src + Length)
109 Expect<void> setRefs(Span<const RefVariant> Slice, const uint64_t Dst,
110 const uint64_t Src, const uint64_t Length) noexcept {
111 // Check the accessing boundary.
112 if (!checkAccessBound(Dst, Length)) {
113 spdlog::error(ErrCode::Value::TableOutOfBounds);
114 spdlog::error(ErrInfo::InfoBoundary(Dst, Length, getSize()));
115 return Unexpect(ErrCode::Value::TableOutOfBounds);
116 }
117
118 // Check the input data validation.
119 if (std::numeric_limits<uint64_t>::max() - Src < Length ||
120 Src + Length > Slice.size()) {
121 spdlog::error(ErrCode::Value::TableOutOfBounds);
122 spdlog::error(ErrInfo::InfoBoundary(Src, Length, Slice.size()));
123 return Unexpect(ErrCode::Value::TableOutOfBounds);
124 }
125
126 // Copy the references.
127 if (Dst <= Src) {
128 std::copy(Slice.begin() + Src, Slice.begin() + Src + Length,
129 Refs.begin() + static_cast<std::ptrdiff_t>(Dst));
130 } else {
131 std::copy(std::make_reverse_iterator(Slice.begin() + Src + Length),
132 std::make_reverse_iterator(Slice.begin() + Src),
133 std::make_reverse_iterator(
134 Refs.begin() + static_cast<std::ptrdiff_t>(Dst + Length)));
135 }
136 return {};
137 }
138
139 /// Fill the Refs[Offset : Offset + Length - 1] by Val.
140 Expect<void> fillRefs(const RefVariant &Val, const uint64_t Offset,

Callers 7

initTableMethod · 0.80
runTableInitOpMethod · 0.80
runTableCopyOpMethod · 0.80
proxyTableInitMethod · 0.80
proxyTableCopyMethod · 0.80
TESTFunction · 0.80
TESTFunction · 0.80

Calls 5

InfoBoundaryClass · 0.85
UnexpectFunction · 0.85
errorFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45

Tested by 1

TESTFunction · 0.64