1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-22 17:48:01 +02:00

Added support for "case when" (valueless) switch cases

This commit is contained in:
Brian Fiete 2020-02-23 06:14:14 -08:00
parent 3fd81fc966
commit 857c1c384a
5 changed files with 25 additions and 11 deletions

View file

@ -4397,6 +4397,20 @@ void BfModule::Visit(BfSwitchStatement* switchStmt)
lastDefaultBlock = notEqBB;
}
if ((whenExpr != NULL) && (switchCase->mCaseExpressions.size() == 1))
{
// This was a "case when" expression, always matches
mayHaveMatch = true;
auto notEqBB = mBfIRBuilder->CreateBlock(StrFormat("switch.notEq_when.%d", blockIdx));
mBfIRBuilder->CreateBr(caseBlock);
mBfIRBuilder->AddBlock(notEqBB);
mBfIRBuilder->SetInsertPoint(notEqBB);
lastNotEqBlock = notEqBB;
}
if (lastDefaultBlock)
mBfIRBuilder->SetSwitchDefaultDest(switchStatement, lastDefaultBlock);