case eTypeInvalid:
break;
case eTypeBytes: {
- switch (buffer.length) {
- default:
- break;
- case 1:
- scalar = *(const uint8_t *)buffer.bytes;
- return true;
- case 2:
- scalar = *reinterpret_cast<const uint16_t *>(buffer.bytes);
- return true;
- case 4:
- scalar = *reinterpret_cast<const uint32_t *>(buffer.bytes);
+ DataExtractor data(buffer.bytes, buffer.length, buffer.byte_order, 1);
+ if (scalar.SetValueFromData(data, lldb::eEncodingUint,
+ buffer.length).Success())
return true;
- case 8:
- scalar = *reinterpret_cast<const uint64_t *>(buffer.bytes);
- return true;
- case 16:
- case 32:
- case 64:
- if (buffer.length % sizeof(uint64_t) == 0) {
- const auto length_in_bits = buffer.length * 8;
- const auto length_in_uint64 = buffer.length / sizeof(uint64_t);
- scalar =
- llvm::APInt(length_in_bits,
- llvm::ArrayRef<uint64_t>(
- reinterpret_cast<const uint64_t *>(buffer.bytes),
- length_in_uint64));
- return true;
- }
- break;
- }
} break;
case eTypeUInt8:
case eTypeUInt16:
EXPECT_EQ(Get(RV(47.5L)), Scalar(47.5L));
EXPECT_EQ(Get(RV({0xff, 0xee, 0xdd, 0xcc}, lldb::eByteOrderLittle)),
Scalar(0xccddeeff));
- // EXPECT_EQ(Get(RV({0xff, 0xee, 0xdd, 0xcc}, lldb::eByteOrderBig)),
- // Scalar(0xffeeddcc));
+ EXPECT_EQ(Get(RV({0xff, 0xee, 0xdd, 0xcc}, lldb::eByteOrderBig)),
+ Scalar(0xffeeddcc));
EXPECT_EQ(Get(RV({0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, 0x77, 0x66,
0x55, 0x44, 0x33, 0x22, 0x11, 0x00},
lldb::eByteOrderLittle)),
Scalar((APInt(128, 0x0011223344556677ull) << 64) |
APInt(128, 0x8899aabbccddeeff)));
-#if 0
EXPECT_EQ(Get(RV({0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, 0x77, 0x66,
0x55, 0x44, 0x33, 0x22, 0x11, 0x00},
lldb::eByteOrderBig)),
Scalar((APInt(128, 0xffeeddccbbaa9988ull) << 64) |
APInt(128, 0x7766554433221100)));
-#endif
}