MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / WasmEdge_Result WasmEdge_TableInstanceSetData

Function WasmEdge_Result WasmEdge_TableInstanceSetData

lib/api/wasmedge.cpp:2806–2836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2804}
2805
2806WASMEDGE_CAPI_EXPORT WasmEdge_Result WasmEdge_TableInstanceSetData(
2807 WasmEdge_TableInstanceContext *Cxt, WasmEdge_Value Data,
2808 const uint64_t Offset) noexcept {
2809 return wrap(
2810 [&]() -> WasmEdge::Expect<void> {
2811 // Comparison of the value types needs the module instance to retrieve
2812 // the function type index after applying the typed function reference
2813 // proposal. It's impossible to do this without refactoring. Therefore
2814 // simply match the FuncRef and ExternRef here.
2815 WasmEdge::ValType ExpType =
2816 fromTabCxt(Cxt)->getTableType().getRefType();
2817 WasmEdge::ValType GotType = genValType(Data.Type);
2818 if (!GotType.isRefType() ||
2819 ExpType.isFuncRefType() != GotType.isFuncRefType()) {
2820 spdlog::error(WasmEdge::ErrCode::Value::RefTypeMismatch);
2821 spdlog::error(WasmEdge::ErrInfo::InfoMismatch(ExpType, GotType));
2822 return Unexpect(WasmEdge::ErrCode::Value::RefTypeMismatch);
2823 }
2824 auto Val = WasmEdge::ValVariant(
2825 to_WasmEdge_128_t<WasmEdge::uint128_t>(Data.Value))
2826 .get<WasmEdge::RefVariant>();
2827 if (!ExpType.isNullableRefType() && Val.isNull()) {
2828 // If this table is not a nullable ref type, the data should not be
2829 // null.
2830 spdlog::error(WasmEdge::ErrCode::Value::NonNullRequired);
2831 return Unexpect(WasmEdge::ErrCode::Value::NonNullRequired);
2832 }
2833 return fromTabCxt(Cxt)->setRefAddr(Offset, Val);
2834 },
2835 EmptyThen, Cxt);
2836}
2837
2838WASMEDGE_CAPI_EXPORT uint64_t WasmEdge_TableInstanceGetSize(
2839 const WasmEdge_TableInstanceContext *Cxt) noexcept {

Callers

nothing calls this directly

Calls 10

wrapFunction · 0.85
InfoMismatchClass · 0.85
UnexpectFunction · 0.85
isRefTypeMethod · 0.80
isFuncRefTypeMethod · 0.80
isNullableRefTypeMethod · 0.80
isNullMethod · 0.80
setRefAddrMethod · 0.80
genValTypeFunction · 0.70
errorFunction · 0.50

Tested by

no test coverage detected