mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Added [?] implied size for sized arrays with initializers
This commit is contained in:
parent
82d2963a9e
commit
08e38a03f9
10 changed files with 250 additions and 162 deletions
|
@ -3721,7 +3721,7 @@ bool BfModule::IsThreadLocal(BfFieldInstance * fieldInstance)
|
|||
return false;
|
||||
}
|
||||
|
||||
BfTypedValue BfModule::GetFieldInitializerValue(BfFieldInstance* fieldInstance, BfExpression* initializer, BfFieldDef* fieldDef, BfType* fieldType)
|
||||
BfTypedValue BfModule::GetFieldInitializerValue(BfFieldInstance* fieldInstance, BfExpression* initializer, BfFieldDef* fieldDef, BfType* fieldType, bool doStore)
|
||||
{
|
||||
if (fieldDef == NULL)
|
||||
fieldDef = fieldInstance->GetFieldDef();
|
||||
|
@ -3734,6 +3734,8 @@ BfTypedValue BfModule::GetFieldInitializerValue(BfFieldInstance* fieldInstance,
|
|||
initializer = fieldDef->mInitializer;
|
||||
}
|
||||
|
||||
BfTypedValue staticVarRef;
|
||||
|
||||
BfTypedValue result;
|
||||
if (initializer == NULL)
|
||||
{
|
||||
|
@ -3779,16 +3781,34 @@ BfTypedValue BfModule::GetFieldInitializerValue(BfFieldInstance* fieldInstance,
|
|||
return constResolver.Resolve(initializer, fieldType, resolveFlags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BfExprEvaluator exprEvaluator(this);
|
||||
if (doStore)
|
||||
{
|
||||
staticVarRef = ReferenceStaticField(fieldInstance);
|
||||
exprEvaluator.mReceivingValue = &staticVarRef;
|
||||
}
|
||||
if (fieldType->IsVar())
|
||||
result = CreateValueFromExpression(initializer, NULL, (BfEvalExprFlags)(BfEvalExprFlags_NoValueAddr | BfEvalExprFlags_FieldInitializer));
|
||||
result = CreateValueFromExpression(exprEvaluator, initializer, NULL, (BfEvalExprFlags)(BfEvalExprFlags_NoValueAddr | BfEvalExprFlags_FieldInitializer));
|
||||
else
|
||||
result = CreateValueFromExpression(initializer, fieldType, (BfEvalExprFlags)(BfEvalExprFlags_NoValueAddr | BfEvalExprFlags_FieldInitializer));
|
||||
result = CreateValueFromExpression(exprEvaluator, initializer, fieldType, (BfEvalExprFlags)(BfEvalExprFlags_NoValueAddr | BfEvalExprFlags_FieldInitializer));
|
||||
if (doStore)
|
||||
{
|
||||
if (exprEvaluator.mReceivingValue == NULL)
|
||||
doStore = false; // Already stored
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldInstance != NULL)
|
||||
MarkFieldInitialized(fieldInstance);
|
||||
|
||||
if (doStore)
|
||||
{
|
||||
result = LoadValue(result);
|
||||
if (!result.mType->IsValuelessType())
|
||||
mBfIRBuilder->CreateStore(result.mValue, staticVarRef.mValue);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -13893,16 +13913,8 @@ void BfModule::CreateStaticCtor()
|
|||
{
|
||||
continue;
|
||||
}
|
||||
auto assignValue = GetFieldInitializerValue(fieldInst);
|
||||
if (assignValue)
|
||||
{
|
||||
assignValue = LoadValue(assignValue);
|
||||
if (!assignValue.mType->IsValuelessType())
|
||||
{
|
||||
auto staticVarRef = ReferenceStaticField(fieldInst).mValue;
|
||||
mBfIRBuilder->CreateStore(assignValue.mValue, staticVarRef);
|
||||
}
|
||||
}
|
||||
GetFieldInitializerValue(fieldInst, NULL, NULL, NULL, true);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16457,7 +16469,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
|||
}
|
||||
|
||||
BfTypeState typeState(mCurTypeInstance);
|
||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||
|
||||
bool isGenericVariation = (methodInstance->mIsUnspecializedVariation) || (mCurTypeInstance->IsUnspecializedTypeVariation());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue