1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Fixed const expr canonicalization and negative value issues

This commit is contained in:
Brian Fiete 2021-12-31 07:56:57 -05:00
parent e7f079f611
commit fa7638621d
7 changed files with 53 additions and 22 deletions

View file

@ -10,6 +10,7 @@
#include "BfResolvePass.h"
#include "MemReporter.h"
#include "BfIRCodeGen.h"
#include "BfIRBuilder.h"
#include "BeefySysLib/util/AllocDebug.h"
@ -2300,6 +2301,20 @@ bool BfSystem::DoesLiteralFit(BfTypeCode typeCode, uint64 value)
return false;
}
bool BfSystem::DoesLiteralFit(BfTypeCode typeCode, const BfVariant& variant)
{
if ((BfIRConstHolder::IsIntable(typeCode)) && (BfIRConstHolder::IsIntable(variant.mTypeCode)))
{
if (BfIRConstHolder::IsSigned(variant.mTypeCode))
return DoesLiteralFit(typeCode, variant.mInt64);
else
return DoesLiteralFit(typeCode, variant.mUInt64);
}
if ((BfIRConstHolder::IsFloat(typeCode)) && (BfIRConstHolder::IsFloat(variant.mTypeCode)))
return true;
return typeCode == variant.mTypeCode;
}
BfParser* BfSystem::CreateParser(BfProject* bfProject)
{
AutoCrit crit(mDataLock);