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:
parent
1320b495d2
commit
c6f2798db7
4 changed files with 55 additions and 1 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue