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

Method unpackVal

lib/executor/helper.cpp:551–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

549}
550
551ValVariant Executor::unpackVal(const ValType &Type, const ValVariant &Val,
552 bool IsSigned) const noexcept {
553 if (Type.isPackType()) {
554 uint32_t Num = Val.get<uint32_t>();
555 switch (Type.getCode()) {
556 case TypeCode::I8:
557 if constexpr (Endian::native == Endian::big) {
558 Num >>= 24;
559 }
560 if (IsSigned) {
561 return static_cast<uint32_t>(static_cast<int8_t>(Num));
562 } else {
563 return static_cast<uint32_t>(static_cast<uint8_t>(Num));
564 }
565 case TypeCode::I16:
566 if constexpr (Endian::native == Endian::big) {
567 Num >>= 16;
568 }
569 if (IsSigned) {
570 return static_cast<uint32_t>(static_cast<int16_t>(Num));
571 } else {
572 return static_cast<uint32_t>(static_cast<uint16_t>(Num));
573 }
574 default:
575 assumingUnreachable();
576 }
577 }
578 return Val;
579}
580
581} // namespace Executor
582} // namespace WasmEdge

Callers

nothing calls this directly

Calls 2

isPackTypeMethod · 0.80
getCodeMethod · 0.45

Tested by

no test coverage detected