mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Improved unknown-sized array in BfInvocationExpression
This commit is contained in:
parent
eb4d2a1757
commit
9e71acc003
1 changed files with 15 additions and 5 deletions
|
@ -19704,16 +19704,23 @@ void BfExprEvaluator::DoInvocation(BfInvocationExpression* invocationExpr)
|
||||||
typeState.mArrayInitializerSize = (int)invocationExpr->mArguments.size();
|
typeState.mArrayInitializerSize = (int)invocationExpr->mArguments.size();
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mModule->mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mModule->mContext->mCurTypeState, &typeState);
|
||||||
|
|
||||||
|
BfType* undefSizeParam = NULL;
|
||||||
|
|
||||||
if (indexerExpr->mArguments.size() != 0)
|
if (indexerExpr->mArguments.size() != 0)
|
||||||
{
|
{
|
||||||
BfConstResolver constResolver(mModule);
|
BfConstResolver constResolver(mModule);
|
||||||
auto arg = indexerExpr->mArguments[0];
|
auto arg = indexerExpr->mArguments[0];
|
||||||
constResolver.mExpectingType = mModule->GetPrimitiveType(BfTypeCode_IntPtr);
|
constResolver.mExpectingType = mModule->GetPrimitiveType(BfTypeCode_IntPtr);
|
||||||
|
constResolver.mBfEvalExprFlags = (BfEvalExprFlags)(constResolver.mBfEvalExprFlags | BfEvalExprFlags_AllowGenericConstValue);
|
||||||
|
|
||||||
if (arg != NULL)
|
if (arg != NULL)
|
||||||
constResolver.Resolve(arg, NULL, BfConstResolveFlag_ArrayInitSize);
|
constResolver.Resolve(arg, NULL, BfConstResolveFlag_ArrayInitSize);
|
||||||
|
|
||||||
if (constResolver.mResult.mValue.IsConst())
|
if (constResolver.mResult.mKind == BfTypedValueKind_GenericConstValue)
|
||||||
|
{
|
||||||
|
undefSizeParam = constResolver.mResult.mType;
|
||||||
|
}
|
||||||
|
else if (constResolver.mResult.mValue.IsConst())
|
||||||
{
|
{
|
||||||
auto constant = mModule->mBfIRBuilder->GetConstant(constResolver.mResult.mValue);
|
auto constant = mModule->mBfIRBuilder->GetConstant(constResolver.mResult.mValue);
|
||||||
|
|
||||||
|
@ -19728,6 +19735,9 @@ void BfExprEvaluator::DoInvocation(BfInvocationExpression* invocationExpr)
|
||||||
else
|
else
|
||||||
arrSize = invocationExpr->mArguments.size();
|
arrSize = invocationExpr->mArguments.size();
|
||||||
|
|
||||||
|
if (undefSizeParam != NULL)
|
||||||
|
curType = mModule->CreateUnknownSizedArrayType(curType, undefSizeParam);
|
||||||
|
else
|
||||||
curType = mModule->CreateSizedArrayType(curType, arrSize);
|
curType = mModule->CreateSizedArrayType(curType, arrSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue