17 pointer() { ptr_ =
nullptr; }
18 pointer(
const void* p) { ptr_ =
reinterpret_cast<const char*
>(p); }
23 static pointer ofTagged(
const void* p, uint64_t mask)
25 return pointer(
reinterpret_cast<const char*
>(
26 reinterpret_cast<uint64_t
>(p) & mask));
29 pointer follow()
const
31 return pointer(ptr_ + getInt());
34 pointer followUnaligned()
const
36 return pointer(ptr_ + getUnalignedInt());
39 pointer follow(
int ofs)
const
41 return pointer(ptr_ + getInt(ofs) + ofs);
44 pointer followUnaligned(
int ofs)
const
46 return pointer(ptr_ + getUnalignedInt(ofs) + ofs);
49 pointer followTagged(uint64_t mask)
const
51 return pointer(ptr_ + (getInt() & mask));
54 int16_t getShort()
const {
return *
reinterpret_cast<const int16_t*
>(ptr_); }
55 int16_t getShort(
int ofs)
const {
return *
reinterpret_cast<const int16_t*
>(ptr_ + ofs); }
56 uint16_t getUnsignedShort()
const {
return *
reinterpret_cast<const uint16_t*
>(ptr_); }
57 uint16_t getUnsignedShort(
int ofs)
const {
return *
reinterpret_cast<const uint16_t*
>(ptr_ + ofs); }
58 int32_t getInt()
const {
return *
reinterpret_cast<const int32_t*
>(ptr_); }
59 int32_t getInt(
int ofs)
const {
return *
reinterpret_cast<const int32_t*
>(ptr_ + ofs); }
60 int32_t getUnalignedInt()
const {
return *
reinterpret_cast<const int32_t*
>(ptr_); }
61 int32_t getUnalignedInt(
int ofs)
const {
return *
reinterpret_cast<const int32_t*
>(ptr_ + ofs); }
62 uint32_t getUnsignedInt()
const {
return *
reinterpret_cast<const uint32_t*
>(ptr_); }
63 uint32_t getUnsignedInt(
int ofs)
const {
return *
reinterpret_cast<const uint32_t*
>(ptr_ + ofs); }
64 uint32_t getUnalignedUnsignedInt()
const {
return *
reinterpret_cast<const uint32_t*
>(ptr_); }
65 int64_t getLong()
const {
return *
reinterpret_cast<const int64_t*
>(ptr_); }
66 uint64_t getUnsignedLong()
const {
return *
reinterpret_cast<const uint64_t*
>(ptr_); }
67 uint64_t getUnsignedLong(
int ofs)
const {
return *
reinterpret_cast<const uint64_t*
>(ptr_ + ofs); }
68 int64_t getUnalignedLong()
const {
return *
reinterpret_cast<const int64_t*
>(ptr_); }
69 int64_t getUnalignedLong(
int ofs)
const {
return *
reinterpret_cast<const int64_t*
>(ptr_ + ofs); }
72 pointer& operator+=(int32_t delta)
78 pointer& operator-=(int32_t delta)
84 pointer operator+(int32_t delta)
const {
return pointer(ptr_ + delta); }
85 pointer operator-(int32_t delta)
const {
return pointer(ptr_ - delta); }
86 pointer operator+(uint32_t delta)
const {
return pointer(ptr_ + delta); }
87 pointer operator-(uint32_t delta)
const {
return pointer(ptr_ - delta); }
88 int32_t operator-(pointer other)
const
90 return static_cast<int32_t
>(ptr_ - other.ptr_);
93 int32_t operator-(
const void* other)
const
95 return static_cast<int32_t
>(ptr_ -
reinterpret_cast<const char*
>(other));
98 int32_t operator-(
const uint8_t* other)
const
100 return static_cast<int32_t
>(ptr_ -
reinterpret_cast<const char*
>(other));
103 pointer operator&(uint64_t mask)
const
106 reinterpret_cast<const void*
>(
107 reinterpret_cast<uint64_t
>(ptr_) & mask));
110 operator bool()
const {
return ptr_ !=
nullptr; }
112 bool operator<(
const pointer other)
114 return ptr_ < other.ptr_;
117 operator const uint8_t* ()
const
119 return reinterpret_cast<const uint8_t*
>(ptr_);
122 operator const char* ()
const
124 return reinterpret_cast<const char*
>(ptr_);
127 operator const void* ()
const
129 return reinterpret_cast<const void*
>(ptr_);
132 uint64_t pointerAsULong()
const
134 return reinterpret_cast<uint64_t
>(ptr_);
137 const uint8_t* asBytePointer()
const
139 return reinterpret_cast<const uint8_t*
>(ptr_);
142 inline bool testAllFlags(
int flags)
144 return (
reinterpret_cast<std::uintptr_t
>(ptr_) & flags) == flags;
147 inline bool testAnyFlags(
int flags)
149 return (
reinterpret_cast<std::uintptr_t
>(ptr_) & flags) != 0;