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

Fixes for readonly

This commit is contained in:
Brian Fiete 2020-09-16 15:53:42 -07:00
parent 7e111329c7
commit 63ce6eb07b

View file

@ -3981,8 +3981,9 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
bool isTemporary = target.IsTempAddr(); bool isTemporary = target.IsTempAddr();
bool wantsLoadValue = false; bool wantsLoadValue = false;
bool wantsReadOnly = false;
if ((field->mIsReadOnly) && ((mModule->mCurMethodInstance->mMethodDef->mMethodType != BfMethodType_Ctor) || (!target.IsThis()))) if ((field->mIsReadOnly) && ((mModule->mCurMethodInstance->mMethodDef->mMethodType != BfMethodType_Ctor) || (!target.IsThis())))
wantsLoadValue = true; wantsReadOnly = true;
bool isComposite = target.mType->IsComposite(); bool isComposite = target.mType->IsComposite();
if ((isComposite) && (!target.mType->IsTypedPrimitive()) && (!target.IsAddr())) if ((isComposite) && (!target.mType->IsTypedPrimitive()) && (!target.IsAddr()))
@ -4072,7 +4073,11 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
if (wantsLoadValue) if (wantsLoadValue)
retVal = mModule->LoadValue(retVal, NULL, mIsVolatileReference); retVal = mModule->LoadValue(retVal, NULL, mIsVolatileReference);
else else
{
if ((wantsReadOnly) && (retVal.IsAddr())&& (!retVal.IsReadOnly()))
retVal.mKind = BfTypedValueKind_ReadOnlyAddr;
mIsHeapReference = true; mIsHeapReference = true;
}
if (isTemporary) if (isTemporary)
{ {