1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Allow (.) inferred type cast inside ref and * unary operations

This commit is contained in:
Brian Fiete 2024-12-02 13:53:36 -05:00
parent c555b8b7ef
commit 124d191bab
3 changed files with 34 additions and 6 deletions

View file

@ -1471,7 +1471,7 @@ BfTypedValue BfMethodMatcher::ResolveArgTypedValue(BfResolvedArg& resolvedArg, B
BfExprEvaluator exprEvaluator(mModule);
exprEvaluator.mBfEvalExprFlags = (BfEvalExprFlags)(mBfEvalExprFlags & BfEvalExprFlags_InheritFlags);
exprEvaluator.mBfEvalExprFlags = (BfEvalExprFlags)(exprEvaluator.mBfEvalExprFlags | BfEvalExprFlags_AllowIntUnknown | BfEvalExprFlags_NoAutoComplete);
exprEvaluator.mBfEvalExprFlags = (BfEvalExprFlags)(exprEvaluator.mBfEvalExprFlags | BfEvalExprFlags_AllowIntUnknown | BfEvalExprFlags_AllowRefExpr | BfEvalExprFlags_NoAutoComplete);
if ((resolvedArg.mArgFlags & BfArgFlag_ParamsExpr) != 0)
exprEvaluator.mBfEvalExprFlags = (BfEvalExprFlags)(exprEvaluator.mBfEvalExprFlags | BfEvalExprFlags_AllowParamsExpr);
@ -7460,7 +7460,7 @@ void BfExprEvaluator::FinishDeferredEvals(SizedArrayImpl<BfResolvedArg>& argValu
{
auto expr = BfNodeDynCast<BfExpression>(argValues[argIdx].mExpression);
if (expr != NULL)
argValue = mModule->CreateValueFromExpression(expr, argValues[argIdx].mExpectedType);
argValue = mModule->CreateValueFromExpression(expr, argValues[argIdx].mExpectedType, BfEvalExprFlags_NoCast);
}
}
}
@ -8955,7 +8955,7 @@ BfTypedValue BfExprEvaluator::ResolveArgValue(BfResolvedArg& resolvedArg, BfType
{
BfExprEvaluator exprEvaluator(mModule);
exprEvaluator.mReceivingValue = receivingValue;
BfEvalExprFlags flags = (BfEvalExprFlags)((mBfEvalExprFlags & BfEvalExprFlags_InheritFlags) | BfEvalExprFlags_NoCast);
BfEvalExprFlags flags = (BfEvalExprFlags)((mBfEvalExprFlags & BfEvalExprFlags_InheritFlags) | BfEvalExprFlags_NoCast | BfEvalExprFlags_AllowRefExpr);
if ((paramKind == BfParamKind_Params) || (paramKind == BfParamKind_DelegateParam))
flags = (BfEvalExprFlags)(flags | BfEvalExprFlags_AllowParamsExpr);
@ -22405,15 +22405,25 @@ void BfExprEvaluator::PerformUnaryOperation(BfExpression* unaryOpExpr, BfUnaryOp
BfType* prevExpedcting = mExpectingType;
switch (unaryOp)
{
case BfUnaryOp_Ref:
// Allow
break;
case BfUnaryOp_Dereference:
if (mExpectingType != NULL)
{
if (mExpectingType->IsRef())
mExpectingType = mExpectingType->GetUnderlyingType();
mExpectingType = mModule->CreatePointerType(mExpectingType);
}
break;
case BfUnaryOp_Negate:
case BfUnaryOp_Positive:
case BfUnaryOp_InvertBits:
// If we're expecting an int64 or uint64 then just leave the type as unknown
if ((mExpectingType != NULL) && (mExpectingType->IsInteger()) && (mExpectingType->mSize == 8))
mExpectingType = NULL;
// Otherwise keep expecting type
break;
break;
default:
mExpectingType = NULL;
}