parent
62c5c4757c
commit
95f023c98c
|
@ -1131,7 +1131,12 @@ static void opConditionalOperatorLessThanEquals(Program* program)
|
||||||
case VALUE_TYPE_PTR:
|
case VALUE_TYPE_PTR:
|
||||||
switch (value[0].opcode) {
|
switch (value[0].opcode) {
|
||||||
case VALUE_TYPE_INT:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false && "Should be unreachable");
|
assert(false && "Should be unreachable");
|
||||||
|
@ -1385,7 +1390,12 @@ static void opConditionalOperatorGreaterThan(Program* program)
|
||||||
case VALUE_TYPE_PTR:
|
case VALUE_TYPE_PTR:
|
||||||
switch (value[0].opcode) {
|
switch (value[0].opcode) {
|
||||||
case VALUE_TYPE_INT:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false && "Should be unreachable");
|
assert(false && "Should be unreachable");
|
||||||
|
|
|
@ -148,6 +148,7 @@ typedef struct ProgramValue {
|
||||||
void* pointerValue;
|
void* pointerValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ProgramValue() : opcode(0), pointerValue(nullptr) {}
|
||||||
bool isEmpty();
|
bool isEmpty();
|
||||||
bool isInt();
|
bool isInt();
|
||||||
bool isFloat();
|
bool isFloat();
|
||||||
|
|
Loading…
Reference in New Issue