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

Improved string-to-sized-array casts and initializations

This commit is contained in:
Brian Fiete 2022-09-05 06:28:23 -07:00
parent 1320b495d2
commit c6f2798db7
4 changed files with 55 additions and 1 deletions

View file

@ -1750,6 +1750,17 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
BfExprEvaluator valExprEvaluator(this);
valExprEvaluator.mAllowReadOnlyReference = isReadOnly;
initValue = CreateValueFromExpression(valExprEvaluator, varDecl->mInitializer, expectedType, (BfEvalExprFlags)(BfEvalExprFlags_NoCast | BfEvalExprFlags_AllowRefExpr | BfEvalExprFlags_VariableDeclaration));
if ((initValue) && (resolvedType->IsUndefSizedArray()))
{
int stringId = GetStringPoolIdx(initValue.mValue, mBfIRBuilder);
if (stringId >= 0)
{
BfStringPoolEntry* entry = NULL;
if (mContext->mStringObjectIdMap.TryGetValue(stringId, &entry))
resolvedType = CreateSizedArrayType(((BfSizedArrayType*)resolvedType)->mElementType, entry->mString.mLength);
}
}
auto boolType = GetPrimitiveType(BfTypeCode_Boolean);