mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Fixed attribs for properties, renamed SkipAccessCheckAttribute
This commit is contained in:
parent
9c44273737
commit
04a46850d6
19 changed files with 162 additions and 58 deletions
|
@ -1438,11 +1438,14 @@ bool BfAutoComplete::CheckMemberReference(BfAstNode* target, BfAstNode* dotToken
|
|||
if ((attrIdentifier = BfNodeDynCast<BfAttributedIdentifierNode>(memberName)))
|
||||
{
|
||||
memberName = attrIdentifier->mIdentifier;
|
||||
if ((memberName == NULL) && (IsAutocompleteNode(attrIdentifier->mAttributes)))
|
||||
if (IsAutocompleteNode(attrIdentifier->mAttributes))
|
||||
{
|
||||
auto bfParser = attrIdentifier->mAttributes->GetSourceData()->ToParser();
|
||||
int cursorIdx = bfParser->mCursorIdx;
|
||||
isAutocompletingName = cursorIdx == attrIdentifier->mAttributes->GetSrcEnd();
|
||||
if (cursorIdx == attrIdentifier->mAttributes->GetSrcEnd())
|
||||
isAutocompletingName = true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -417,7 +417,6 @@ BfCompiler::BfCompiler(BfSystem* bfSystem, bool isResolveOnly)
|
|||
mReflectTypeInstanceTypeDef = NULL;
|
||||
mReflectUnspecializedGenericType = NULL;
|
||||
mSizedArrayTypeDef = NULL;
|
||||
mSkipAccessCheckAttributeTypeDef = NULL;
|
||||
mStaticInitAfterAttributeTypeDef = NULL;
|
||||
mStaticInitPriorityAttributeTypeDef = NULL;
|
||||
mStringTypeDef = NULL;
|
||||
|
@ -5870,8 +5869,7 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
|||
mReflectSpecializedGenericType = _GetRequiredType("System.Reflection.SpecializedGenericType");
|
||||
mReflectTypeInstanceTypeDef = _GetRequiredType("System.Reflection.TypeInstance");
|
||||
mReflectUnspecializedGenericType = _GetRequiredType("System.Reflection.UnspecializedGenericType");
|
||||
mSizedArrayTypeDef = _GetRequiredType("System.SizedArray", 2);
|
||||
mSkipAccessCheckAttributeTypeDef = _GetRequiredType("System.SkipAccessCheckAttribute");
|
||||
mSizedArrayTypeDef = _GetRequiredType("System.SizedArray", 2);
|
||||
mStaticInitAfterAttributeTypeDef = _GetRequiredType("System.StaticInitAfterAttribute");
|
||||
mStaticInitPriorityAttributeTypeDef = _GetRequiredType("System.StaticInitPriorityAttribute");
|
||||
mStringTypeDef = _GetRequiredType("System.String");
|
||||
|
|
|
@ -384,8 +384,7 @@ public:
|
|||
BfTypeDef* mDisableObjectAccessChecksAttributeTypeDef;
|
||||
BfTypeDef* mFriendAttributeTypeDef;
|
||||
BfTypeDef* mCheckedAttributeTypeDef;
|
||||
BfTypeDef* mUncheckedAttributeTypeDef;
|
||||
BfTypeDef* mSkipAccessCheckAttributeTypeDef;
|
||||
BfTypeDef* mUncheckedAttributeTypeDef;
|
||||
BfTypeDef* mStaticInitAfterAttributeTypeDef;
|
||||
BfTypeDef* mStaticInitPriorityAttributeTypeDef;
|
||||
BfTypeDef* mTestAttributeTypeDef;
|
||||
|
|
|
@ -3441,7 +3441,7 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
|
||||
bool doAccessCheck = true;
|
||||
|
||||
if ((mModule->mAttributeState != NULL) && (mModule->mAttributeState->mCustomAttributes != NULL) && (mModule->mAttributeState->mCustomAttributes->Contains(mModule->mCompiler->mSkipAccessCheckAttributeTypeDef)))
|
||||
if ((mModule->mAttributeState != NULL) && (mModule->mAttributeState->mCustomAttributes != NULL) && (mModule->mAttributeState->mCustomAttributes->Contains(mModule->mCompiler->mDisableObjectAccessChecksAttributeTypeDef)))
|
||||
doAccessCheck = false;
|
||||
|
||||
if (target.IsThis())
|
||||
|
@ -3583,6 +3583,14 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
if (isInlined)
|
||||
mPropGetMethodFlags = (BfGetMethodInstanceFlags)(mPropGetMethodFlags | BfGetMethodInstanceFlag_ForceInline);
|
||||
|
||||
if ((mModule->mAttributeState != NULL) && (mModule->mAttributeState->mCustomAttributes != NULL))
|
||||
{
|
||||
if (mModule->mAttributeState->mCustomAttributes->Contains(mModule->mCompiler->mFriendAttributeTypeDef))
|
||||
mPropGetMethodFlags = (BfGetMethodInstanceFlags)(mPropGetMethodFlags | BfGetMethodInstanceFlag_Friend);
|
||||
if (mModule->mAttributeState->mCustomAttributes->Contains(mModule->mCompiler->mDisableObjectAccessChecksAttributeTypeDef))
|
||||
mPropGetMethodFlags = (BfGetMethodInstanceFlags)(mPropGetMethodFlags | BfGetMethodInstanceFlag_DisableObjectAccessChecks);
|
||||
}
|
||||
|
||||
if (mPropDef->mIsStatic)
|
||||
{
|
||||
if ((target) && ((flags & BfLookupFieldFlag_IsImplicitThis) == 0) && (!curCheckType->mTypeDef->IsGlobalsContainer()))
|
||||
|
@ -4800,7 +4808,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
|
|||
if (!mModule->mCurMethodState->mMayNeedThisAccessCheck)
|
||||
doAccessCheck = false;
|
||||
}
|
||||
if ((mModule->mAttributeState != NULL) && (mModule->mAttributeState->mCustomAttributes != NULL) && (mModule->mAttributeState->mCustomAttributes->Contains(mModule->mCompiler->mSkipAccessCheckAttributeTypeDef)))
|
||||
if ((mModule->mAttributeState != NULL) && (mModule->mAttributeState->mCustomAttributes != NULL) && (mModule->mAttributeState->mCustomAttributes->Contains(mModule->mCompiler->mDisableObjectAccessChecksAttributeTypeDef)))
|
||||
doAccessCheck = false;
|
||||
if ((doAccessCheck) && (!isSkipCall))
|
||||
mModule->EmitObjectAccessCheck(target);
|
||||
|
@ -11735,7 +11743,7 @@ BfAllocTarget BfExprEvaluator::ResolveAllocTarget(BfAstNode* allocNode, BfTokenN
|
|||
if ((alignOverride & (alignOverride - 1)) == 0)
|
||||
allocTarget.mAlignOverride = alignOverride;
|
||||
else
|
||||
mModule->Fail("Alignment must be a power of 2", attrib.mRef);
|
||||
mModule->Fail("Alignment must be a power of 2", attrib.GetRefNode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13787,7 +13795,8 @@ BfTypedValue BfExprEvaluator::GetResult(bool clearResult, bool resolveGenericTyp
|
|||
if (mPropSrc != NULL)
|
||||
mModule->UpdateExprSrcPos(mPropSrc);
|
||||
|
||||
CheckPropFail(matchedMethod, methodInstance.mMethodInstance);
|
||||
if ((mPropGetMethodFlags & BfGetMethodInstanceFlag_Friend) == 0)
|
||||
CheckPropFail(matchedMethod, methodInstance.mMethodInstance);
|
||||
PerformCallChecks(methodInstance.mMethodInstance, mPropSrc);
|
||||
|
||||
if (methodInstance.mMethodInstance->IsSkipCall())
|
||||
|
@ -13802,7 +13811,8 @@ BfTypedValue BfExprEvaluator::GetResult(bool clearResult, bool resolveGenericTyp
|
|||
if ((mPropDefBypassVirtual) && (mPropTarget.mType != methodInstance.mMethodInstance->GetOwner()))
|
||||
mPropTarget = mModule->Cast(mPropSrc, mOrigPropTarget, methodInstance.mMethodInstance->GetOwner());
|
||||
|
||||
mModule->EmitObjectAccessCheck(mPropTarget);
|
||||
if ((mPropGetMethodFlags & BfGetMethodInstanceFlag_DisableObjectAccessChecks) == 0)
|
||||
mModule->EmitObjectAccessCheck(mPropTarget);
|
||||
PushThis(mPropSrc, mPropTarget, methodInstance.mMethodInstance, args);
|
||||
}
|
||||
|
||||
|
@ -15512,7 +15522,7 @@ void BfExprEvaluator::DoMemberReference(BfMemberReferenceExpression* memberRefEx
|
|||
if (attributeState.mCustomAttributes != NULL)
|
||||
{
|
||||
if (mPropDef != NULL)
|
||||
attributeState.mTarget = BfAttributeTargets_Invocation;
|
||||
attributeState.mTarget = (BfAttributeTargets)(attributeState.mTarget | BfAttributeTargets_Invocation);
|
||||
mModule->ValidateCustomAttributes(attributeState.mCustomAttributes, attributeState.mTarget);
|
||||
}
|
||||
);
|
||||
|
|
|
@ -9393,7 +9393,7 @@ void BfModule::ValidateCustomAttributes(BfCustomAttributes* customAttributes, Bf
|
|||
if ((customAttribute.mType->mAttributeData->mAttributeTargets & attrTarget) == 0)
|
||||
{
|
||||
Fail(StrFormat("Attribute '%s' is not valid on this declaration type. It is only valid on %s.",
|
||||
customAttribute.mRef->ToString().c_str(), GetAttributesTargetListString(customAttribute.mType->mAttributeData->mAttributeTargets).c_str()), customAttribute.mRef->mAttributeTypeRef); // CS0592
|
||||
customAttribute.GetRefNode()->ToString().c_str(), GetAttributesTargetListString(customAttribute.mType->mAttributeData->mAttributeTargets).c_str()), customAttribute.mRef->mAttributeTypeRef); // CS0592
|
||||
}
|
||||
|
||||
customAttribute.mAwaitingValidation = false;
|
||||
|
|
|
@ -37,7 +37,7 @@ enum BfMethodNameFlags : uint8
|
|||
BfMethodNameFlag_OmitTypeName = 2
|
||||
};
|
||||
|
||||
enum BfGetMethodInstanceFlags : uint8
|
||||
enum BfGetMethodInstanceFlags : uint16
|
||||
{
|
||||
BfGetMethodInstanceFlag_None = 0,
|
||||
BfGetMethodInstanceFlag_UnspecializedPass = 1,
|
||||
|
@ -47,7 +47,9 @@ enum BfGetMethodInstanceFlags : uint8
|
|||
BfGetMethodInstanceFlag_Unreified = 0x10,
|
||||
BfGetMethodInstanceFlag_NoForceReification = 0x20,
|
||||
BfGetMethodInstanceFlag_ResultNotUsed = 0x40,
|
||||
BfGetMethodInstanceFlag_ForceInline = 0x80
|
||||
BfGetMethodInstanceFlag_ForceInline = 0x80,
|
||||
BfGetMethodInstanceFlag_Friend = 0x100,
|
||||
BfGetMethodInstanceFlag_DisableObjectAccessChecks = 0x200,
|
||||
};
|
||||
|
||||
class BfDependencyMap
|
||||
|
@ -2203,6 +2205,13 @@ public:
|
|||
Array<BfCustomAttributeSetProperty> mSetProperties;
|
||||
Array<BfCustomAttributeSetField> mSetField;
|
||||
bool mAwaitingValidation;
|
||||
|
||||
BfAstNode* GetRefNode()
|
||||
{
|
||||
if (mRef->mAttributeTypeRef != NULL)
|
||||
return mRef->mAttributeTypeRef;
|
||||
return mRef;
|
||||
}
|
||||
};
|
||||
|
||||
class BfCustomAttributes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue