Merge remote-tracking branch 'origin/GP-2079_RelativePointerCompare'

(Closes #4224)
This commit is contained in:
Ryan Kurtz 2022-06-10 01:26:31 -04:00
commit 91f44ba36e
2 changed files with 21 additions and 0 deletions

View File

@ -1870,6 +1870,26 @@ void TypePointerRel::printRaw(ostream &s) const
s << ']';
}
int4 TypePointerRel::compare(const Datatype &op,int4 level) const
{
int4 res = TypePointer::compare(op,level); // Compare as plain pointers first
if (res != 0) return res;
// Both must be relative pointers
TypePointerRel *tp = (TypePointerRel *) &op;
// Its possible a formal relative pointer gets compared to its equivalent ephemeral version.
// In which case, we prefer the formal version.
if (stripped == (TypePointer *)0) {
if (tp->stripped != (TypePointer *)0)
return -1;
}
else {
if (tp->stripped == (TypePointer *)0)
return 1;
}
return 0;
}
int4 TypePointerRel::compareDependency(const Datatype &op) const
{

View File

@ -461,6 +461,7 @@ public:
/// \return the offset value in \e address \e units
int4 getPointerOffset(void) const { return AddrSpace::byteToAddressInt(offset, wordsize); }
virtual void printRaw(ostream &s) const;
virtual int4 compare(const Datatype &op,int4 level) const;
virtual int4 compareDependency(const Datatype &op) const;
virtual Datatype *clone(void) const { return new TypePointerRel(*this); }
virtual void saveXml(ostream &s) const;