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

Function parseExpectedList

test/spec/spectest.cpp:198–231  ·  view source on GitHub ↗

Helper function to parse parameters from JSON to a vector of string pairs.

Source from the content-addressed store, hash-verified

196
197// Helper function to parse parameters from JSON to a vector of string pairs.
198std::vector<std::pair<std::string, std::string>>
199parseExpectedList(const simdjson::dom::array &Args) {
200 std::vector<std::pair<std::string, std::string>> Result;
201 Result.reserve(Args.size());
202 for (const simdjson::dom::object &Element : Args) {
203 std::string_view Type = Element["type"];
204 simdjson::dom::element Value;
205 auto NoValue = Element["value"].get(Value);
206 if (NoValue) {
207 // Only marked the result type, not check the opaque result reference
208 // value.
209 Result.emplace_back(std::string(Type), "");
210 } else {
211 if (Value.type() == simdjson::dom::element_type::ARRAY) {
212 simdjson::dom::array ValueNodeArray = Value;
213 std::string StrValue;
214 std::string_view LaneType = Element["lane_type"];
215 for (std::string_view X : ValueNodeArray) {
216 StrValue += std::string(X);
217 StrValue += ' ';
218 }
219 StrValue.pop_back();
220 Result.emplace_back(std::string(Type) + std::string(LaneType),
221 std::move(StrValue));
222 } else if (Value.type() == simdjson::dom::element_type::STRING) {
223 std::string_view ValueStr = Value;
224 Result.emplace_back(std::string(Type), std::string(ValueStr));
225 } else {
226 assumingUnreachable();
227 }
228 }
229 }
230 return Result;
231}
232
233std::vector<std::vector<std::pair<std::string, std::string>>>
234parseEithersList(const simdjson::dom::array &Args) {

Callers 2

parseEithersListFunction · 0.85
processCommandsMethod · 0.85

Calls 3

sizeMethod · 0.45
getMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected