Improve pointer comparsion for Nevada and Sonora mods (#291)
This commit is contained in:
parent
e23c4eddda
commit
16f4ab7787
|
@ -1131,7 +1131,12 @@ static void opConditionalOperatorLessThanEquals(Program* program)
|
|||
case VALUE_TYPE_PTR:
|
||||
switch (value[0].opcode) {
|
||||
case VALUE_TYPE_INT:
|
||||
result = (uintptr_t)value[1].pointerValue <= (uintptr_t)value[0].integerValue;
|
||||
if (value[0].integerValue > 0) {
|
||||
result = (uintptr_t)value[1].pointerValue <= (uintptr_t)value[0].integerValue;
|
||||
} else {
|
||||
// (ptr <= int{0 or negative}) means (ptr == nullptr)
|
||||
result = nullptr == value[1].pointerValue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(false && "Should be unreachable");
|
||||
|
@ -1385,7 +1390,12 @@ static void opConditionalOperatorGreaterThan(Program* program)
|
|||
case VALUE_TYPE_PTR:
|
||||
switch (value[0].opcode) {
|
||||
case VALUE_TYPE_INT:
|
||||
result = (uintptr_t)value[1].pointerValue > (uintptr_t)value[0].integerValue;
|
||||
if (value[0].integerValue > 0) {
|
||||
result = (uintptr_t)value[1].pointerValue > (uintptr_t)value[0].integerValue;
|
||||
} else {
|
||||
// (ptr > int{0 or negative}) means (ptr != nullptr)
|
||||
result = nullptr != value[1].pointerValue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(false && "Should be unreachable");
|
||||
|
|
Loading…
Reference in New Issue