From 214ac828085973b63d3d2ed6e4e5be0b02a5ec97 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Sun, 9 Aug 2020 07:19:10 -0700 Subject: [PATCH] Fixed const evaluation of float modulos --- IDEHelper/Compiler/BfIRBuilder.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/IDEHelper/Compiler/BfIRBuilder.cpp b/IDEHelper/Compiler/BfIRBuilder.cpp index e9a4b78d..9ef8cd7d 100644 --- a/IDEHelper/Compiler/BfIRBuilder.cpp +++ b/IDEHelper/Compiler/BfIRBuilder.cpp @@ -135,20 +135,18 @@ USING_NS_BF; uint64 val = 0; \ switch (constLHS->mTypeCode) \ { \ - case BfTypeCode_Int8: val = constLHS->mInt8 OP constRHS->mInt8; break; \ - case BfTypeCode_Char8: val = constLHS->mUInt8 OP constRHS->mUInt8; break; \ - case BfTypeCode_UInt8: val = constLHS->mUInt8 OP constRHS->mUInt8; break; \ - case BfTypeCode_Int16: val = constLHS->mInt16 OP constRHS->mInt16; break; \ - case BfTypeCode_UInt16: val = constLHS->mUInt16 OP constRHS->mUInt16; break; \ - case BfTypeCode_Char16: val = constLHS->mUInt16 OP constRHS->mUInt16; break; \ - case BfTypeCode_Int32: val = constLHS->mInt32 OP constRHS->mInt32; break; \ - case BfTypeCode_UInt32: val = constLHS->mUInt32 OP constRHS->mUInt32; break; \ - case BfTypeCode_Char32: val = constLHS->mUInt32 OP constRHS->mUInt32; break; \ - case BfTypeCode_Int64: val = constLHS->mInt64 OP constRHS->mInt64; break; \ - case BfTypeCode_UInt64: val = constLHS->mUInt64 OP constRHS->mUInt64; break; \ - default: break; \ - } \ - return CreateConst(constLHS->mTypeCode, val); + case BfTypeCode_Int8: return CreateConst(constLHS->mTypeCode, constLHS->mInt8 OP constRHS->mInt8); \ + case BfTypeCode_Char8: return CreateConst(constLHS->mTypeCode, constLHS->mUInt8 OP constRHS->mUInt8); \ + case BfTypeCode_UInt8: return CreateConst(constLHS->mTypeCode, constLHS->mUInt8 OP constRHS->mUInt8); \ + case BfTypeCode_Int16: return CreateConst(constLHS->mTypeCode, constLHS->mInt16 OP constRHS->mInt16); \ + case BfTypeCode_UInt16: return CreateConst(constLHS->mTypeCode, constLHS->mUInt16 OP constRHS->mUInt16); \ + case BfTypeCode_Char16: return CreateConst(constLHS->mTypeCode, constLHS->mUInt16 OP constRHS->mUInt16); \ + case BfTypeCode_Int32: return CreateConst(constLHS->mTypeCode, constLHS->mInt32 OP constRHS->mInt32); \ + case BfTypeCode_UInt32: return CreateConst(constLHS->mTypeCode, (uint64)(constLHS->mUInt32 OP constRHS->mUInt32)); \ + case BfTypeCode_Char32: return CreateConst(constLHS->mTypeCode, (uint64)(constLHS->mUInt32 OP constRHS->mUInt32)); \ + case BfTypeCode_Int64: return CreateConst(constLHS->mTypeCode, (uint64)(constLHS->mInt64 OP constRHS->mInt64)); \ + case BfTypeCode_UInt64: return CreateConst(constLHS->mTypeCode, constLHS->mUInt64 OP constRHS->mUInt64); \ + } #define UNARYOP_APPLY(val, OP) \ auto constVal = GetConstantById(val.mId); \