Skip to content

Commit 1128813

Browse files
committed
Fix testing pointers for nulls in Sonora
1 parent 1f6339b commit 1128813

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/interpreter.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,16 @@ static void opConditionalOperatorGreaterThan(Program* program)
13391339
assert(false && "Should be unreachable");
13401340
}
13411341
break;
1342+
// Sonora folks tend to use "object > 0" to test objects for nulls.
1343+
case VALUE_TYPE_PTR:
1344+
switch (value[0].opcode) {
1345+
case VALUE_TYPE_INT:
1346+
result = (intptr_t)value[1].pointerValue > (intptr_t)value[0].integerValue;
1347+
break;
1348+
default:
1349+
assert(false && "Should be unreachable");
1350+
}
1351+
break;
13421352
default:
13431353
assert(false && "Should be unreachable");
13441354
}

0 commit comments

Comments
 (0)