Fix testing pointers for nulls in Nevada

Closes #178
This commit is contained in:
Alexander Batalov 2022-10-25 09:57:13 +03:00
parent 5b151634a5
commit ad9b8586e9
1 changed files with 10 additions and 0 deletions

View File

@ -1127,6 +1127,16 @@ static void opConditionalOperatorLessThanEquals(Program* program)
assert(false && "Should be unreachable"); assert(false && "Should be unreachable");
} }
break; break;
// Nevada folks tend to use "object <= 0" to test objects for nulls.
case VALUE_TYPE_PTR:
switch (value[0].opcode) {
case VALUE_TYPE_INT:
result = (intptr_t)value[1].pointerValue <= (intptr_t)value[0].integerValue;
break;
default:
assert(false && "Should be unreachable");
}
break;
default: default:
assert(false && "Should be unreachable"); assert(false && "Should be unreachable");
} }