From 5c8f7c4b00d2ce699cdcd98f53f7fa4581525a01 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 6 Aug 2022 16:57:43 +0300 Subject: [PATCH] Fix negate operator --- src/interpreter.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/interpreter.cc b/src/interpreter.cc index 9388481..805f375 100644 --- a/src/interpreter.cc +++ b/src/interpreter.cc @@ -1778,8 +1778,18 @@ static void opLogicalOperatorNot(Program* program) // 0x46AB2C static void opUnaryMinus(Program* program) { - int value = programStackPopInteger(program); - programStackPushInteger(program, -value); + // SFALL: Fix vanilla negate operator for float values. + ProgramValue programValue = programStackPopValue(program); + switch (programValue.opcode) { + case VALUE_TYPE_INT: + programStackPushInteger(program, -programValue.integerValue); + break; + case VALUE_TYPE_FLOAT: + programStackPushFloat(program, -programValue.floatValue); + break; + default: + programFatalError("Invalid arg given to NEG"); + } } // 0x46AB84