From ad9b8586e9f701ea59c426420ebccadb88ecc8c9 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Tue, 25 Oct 2022 09:57:13 +0300 Subject: [PATCH] Fix testing pointers for nulls in Nevada Closes #178 --- src/interpreter.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/interpreter.cc b/src/interpreter.cc index c24b0e3..c196823 100644 --- a/src/interpreter.cc +++ b/src/interpreter.cc @@ -1127,6 +1127,16 @@ static void opConditionalOperatorLessThanEquals(Program* program) assert(false && "Should be unreachable"); } 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: assert(false && "Should be unreachable"); }