mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
Implemented serialization of signed integers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43828 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -105,6 +105,12 @@ uint64_t Deserializer::ReadInt() {
|
||||
return Record[RecIdx++];
|
||||
}
|
||||
|
||||
int64_t Deserializer::ReadSInt() {
|
||||
uint64_t x = ReadInt();
|
||||
int64_t magnitude = x >> 1;
|
||||
return x & 0x1 ? -magnitude : magnitude;
|
||||
}
|
||||
|
||||
char* Deserializer::ReadCStr(char* cstr, unsigned MaxLen, bool isNullTerm) {
|
||||
if (cstr == NULL)
|
||||
MaxLen = 0; // Zero this just in case someone does something funny.
|
||||
@ -226,3 +232,12 @@ INT_READ(unsigned char)
|
||||
INT_READ(unsigned short)
|
||||
INT_READ(unsigned int)
|
||||
INT_READ(unsigned long)
|
||||
|
||||
#define SINT_READ(TYPE)\
|
||||
void SerializeTrait<TYPE>::Read(Deserializer& D, TYPE& X) {\
|
||||
X = (TYPE) D.ReadSInt(); }
|
||||
|
||||
INT_READ(signed char)
|
||||
INT_READ(signed short)
|
||||
INT_READ(signed int)
|
||||
INT_READ(signed long)
|
||||
|
Reference in New Issue
Block a user