| 549 | } |
| 550 | |
| 551 | ValVariant 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 |
nothing calls this directly
no test coverage detected