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

Method packVal

lib/executor/helper.cpp:519–540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517}
518
519ValVariant Executor::packVal(const ValType &Type,
520 const ValVariant &Val) const noexcept {
521 if (Type.isPackType()) {
522 switch (Type.getCode()) {
523 case TypeCode::I8:
524 if constexpr (Endian::native == Endian::little) {
525 return ValVariant(Val.get<uint32_t>() & 0xFFU);
526 } else {
527 return ValVariant(Val.get<uint32_t>() << 24);
528 }
529 case TypeCode::I16:
530 if constexpr (Endian::native == Endian::little) {
531 return ValVariant(Val.get<uint32_t>() & 0xFFFFU);
532 } else {
533 return ValVariant(Val.get<uint32_t>() << 16);
534 }
535 default:
536 assumingUnreachable();
537 }
538 }
539 return Val;
540}
541
542std::vector<ValVariant>
543Executor::packVals(const ValType &Type,

Callers

nothing calls this directly

Calls 2

isPackTypeMethod · 0.80
getCodeMethod · 0.45

Tested by

no test coverage detected