mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Fixed tuple pattern matching
This commit is contained in:
parent
582556dee2
commit
c1d1659e2a
3 changed files with 201 additions and 8 deletions
|
@ -2396,7 +2396,11 @@ void BfExprEvaluator::Visit(BfCaseExpression* caseExpr)
|
|||
}
|
||||
}
|
||||
|
||||
if ((caseValAddr) && (caseValAddr.mType->IsPayloadEnum()))
|
||||
bool isPayloadEnum = caseValAddr.mType->IsPayloadEnum();
|
||||
auto tupleExpr = BfNodeDynCast<BfTupleExpression>(caseExpr->mCaseExpression);
|
||||
|
||||
if ((caseValAddr) &&
|
||||
((isPayloadEnum) || (tupleExpr != NULL)))
|
||||
{
|
||||
bool hasVariable = false;
|
||||
bool hasOut = false;
|
||||
|
@ -2429,12 +2433,19 @@ void BfExprEvaluator::Visit(BfCaseExpression* caseExpr)
|
|||
if (hasOut)
|
||||
clearOutOnMismatch = !CheckVariableDeclaration(caseExpr, true, true, true);
|
||||
|
||||
int dscrDataIdx;
|
||||
auto dscrType = caseValAddr.mType->ToTypeInstance()->GetDiscriminatorType(&dscrDataIdx);
|
||||
auto enumTagVal = mModule->LoadValue(mModule->ExtractValue(caseValAddr, NULL, 2));
|
||||
int uncondTagId = -1;
|
||||
bool hadConditional = false;
|
||||
mResult = mModule->TryCaseEnumMatch(caseValAddr, enumTagVal, caseExpr->mCaseExpression, NULL, NULL, NULL, uncondTagId, hadConditional, clearOutOnMismatch);
|
||||
if (isPayloadEnum)
|
||||
{
|
||||
int dscrDataIdx;
|
||||
auto dscrType = caseValAddr.mType->ToTypeInstance()->GetDiscriminatorType(&dscrDataIdx);
|
||||
auto enumTagVal = mModule->LoadValue(mModule->ExtractValue(caseValAddr, NULL, 2));
|
||||
int uncondTagId = -1;
|
||||
mResult = mModule->TryCaseEnumMatch(caseValAddr, enumTagVal, caseExpr->mCaseExpression, NULL, NULL, NULL, uncondTagId, hadConditional, clearOutOnMismatch);
|
||||
}
|
||||
else
|
||||
{
|
||||
mResult = mModule->TryCaseTupleMatch(caseValAddr, tupleExpr, NULL, NULL, NULL, hadConditional, clearOutOnMismatch);
|
||||
}
|
||||
|
||||
if (mResult)
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue