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

Fixed attribs for properties, renamed SkipAccessCheckAttribute

This commit is contained in:
Brian Fiete 2019-12-01 14:40:17 -08:00
parent 9c44273737
commit 04a46850d6
19 changed files with 162 additions and 58 deletions

View file

@ -1,15 +1,14 @@
FileVersion = 1 FileVersion = 1
Projects = {BeefBuild = {Path = "."}, corlib = "*", Beefy2D = {Path = "../BeefLibs/Beefy2D"}, IDEHelper = {Path = "../IDEHelper"}, Debugger64 = {Path = "../Debugger64"}, BeefySysLib = {Path = "../BeefySysLib"}} Projects = {BeefBuild = {Path = "."}, corlib = "*", Beefy2D = {Path = "../BeefLibs/Beefy2D"}, IDEHelper = {Path = "../IDEHelper"}, Debugger64 = {Path = "../Debugger64"}, BeefySysLib = {Path = "../BeefySysLib"}}
Unlocked = ["corlib"]
[Workspace] [Workspace]
StartupProject = "BeefBuild" StartupProject = "BeefBuild"
[Configs.Debug.Win32] [Configs.Debug.Win32]
Toolset = "GNU" Toolset = "GNU"
BfOptimizationLevel = "O0"
InitLocalVariables = true InitLocalVariables = true
EmitObjectAccessCheck = false EmitObjectAccessCheck = false
EnableCustodian = false
EnableRealtimeLeakCheck = false EnableRealtimeLeakCheck = false
AllocStackTraceDepth = 0 AllocStackTraceDepth = 0
ConfigSelections = {IDEHelper = {Enabled = false}} ConfigSelections = {IDEHelper = {Enabled = false}}
@ -25,24 +24,18 @@ EmitDebugInfo = "No"
AllocStackTraceDepth = 0 AllocStackTraceDepth = 0
ConfigSelections = {IDEHelper = {Enabled = false}} ConfigSelections = {IDEHelper = {Enabled = false}}
[Configs.Release.Win64]
[Configs.Release.Win64z] [Configs.Release.Win64z]
EnableObjectDebugFlags = true EnableObjectDebugFlags = true
EmitObjectAccessCheck = true EmitObjectAccessCheck = true
EnableCustodian = true
EnableRealtimeLeakCheck = true EnableRealtimeLeakCheck = true
AllocStackTraceDepth = 0 AllocStackTraceDepth = 0
[Configs.Debug-IDE.Win32] [Configs.Debug-IDE.Win32]
Toolset = "GNU" Toolset = "GNU"
BfOptimizationLevel = "O0"
EmitDebugInfo = "No" EmitDebugInfo = "No"
ArrayBoundsCheck = false
EmitDynamicCastCheck = false EmitDynamicCastCheck = false
EnableObjectDebugFlags = false EnableObjectDebugFlags = false
EmitObjectAccessCheck = false EmitObjectAccessCheck = false
EnableCustodian = false
EnableRealtimeLeakCheck = false EnableRealtimeLeakCheck = false
AllocStackTraceDepth = 0 AllocStackTraceDepth = 0
ConfigSelections = {corlib = {Config = "Debug"}, Beefy2D = {Config = "Debug"}, IDEHelper = {Config = "Debug"}, Debugger64 = {Config = "Debug"}, BeefySysLib = {Config = "Debug"}} ConfigSelections = {corlib = {Config = "Debug"}, Beefy2D = {Config = "Debug"}, IDEHelper = {Config = "Debug"}, Debugger64 = {Config = "Debug"}, BeefySysLib = {Config = "Debug"}}
@ -51,29 +44,25 @@ ConfigSelections = {corlib = {Config = "Debug"}, Beefy2D = {Config = "Debug"}, I
Toolset = "GNU" Toolset = "GNU"
BfOptimizationLevel = "O0" BfOptimizationLevel = "O0"
EmitDebugInfo = "No" EmitDebugInfo = "No"
ArrayBoundsCheck = false
EmitDynamicCastCheck = false EmitDynamicCastCheck = false
EnableObjectDebugFlags = false EnableObjectDebugFlags = false
EmitObjectAccessCheck = false EmitObjectAccessCheck = false
EnableCustodian = false
EnableRealtimeLeakCheck = false EnableRealtimeLeakCheck = false
ConfigSelections = {corlib = {Config = "Debug"}, Beefy2D = {Config = "Debug"}, IDEHelper = {Config = "Debug"}, Debugger64 = {Config = "Debug"}, BeefySysLib = {Config = "Debug"}} ConfigSelections = {corlib = {Config = "Debug"}, Beefy2D = {Config = "Debug"}, IDEHelper = {Config = "Debug"}, Debugger64 = {Config = "Debug"}, BeefySysLib = {Config = "Debug"}}
[Configs.Debug2.Win32] [Configs.Debug2.Win32]
Toolset = "GNU" Toolset = "GNU"
BfOptimizationLevel = "O0"
EmitDebugInfo = "No" EmitDebugInfo = "No"
ArrayBoundsCheck = false
EmitDynamicCastCheck = false EmitDynamicCastCheck = false
EnableObjectDebugFlags = false EnableObjectDebugFlags = false
EmitObjectAccessCheck = false EmitObjectAccessCheck = false
EnableCustodian = false
EnableRealtimeLeakCheck = false EnableRealtimeLeakCheck = false
AllocStackTraceDepth = 0 AllocStackTraceDepth = 0
ConfigSelections = {corlib = {Config = "Debug"}, Beefy2D = {Config = "Debug"}, IDEHelper = {Config = "Debug"}, Debugger64 = {Config = "Debug"}, BeefySysLib = {Config = "Debug"}} ConfigSelections = {corlib = {Config = "Debug"}, Beefy2D = {Config = "Debug"}, IDEHelper = {Config = "Debug"}, Debugger64 = {Config = "Debug"}, BeefySysLib = {Config = "Debug"}}
[Configs.Debug2.Win64] [Configs.Debug2.Win64]
PreprocessorMacros = ["NEWFONT"] PreprocessorMacros = ["NEWFONT"]
BfOptimizationLevel = "O0"
IntermediateType = "ObjectAndIRCode" IntermediateType = "ObjectAndIRCode"
ConfigSelections = {corlib = {Config = "Debug"}, Beefy2D = {Config = "Debug"}, IDEHelper = {Config = "Debug"}, Debugger64 = {Config = "Debug"}, BeefySysLib = {Config = "Debug"}} ConfigSelections = {corlib = {Config = "Debug"}, Beefy2D = {Config = "Debug"}, IDEHelper = {Config = "Debug"}, Debugger64 = {Config = "Debug"}, BeefySysLib = {Config = "Debug"}}

View file

@ -132,12 +132,6 @@ namespace System
} }
[AttributeUsage(.MemberAccess)]
public struct SkipAccessCheckAttribute : Attribute
{
}
[AttributeUsage(.Method | .Class | .Struct | .Enum)] [AttributeUsage(.Method | .Class | .Struct | .Enum)]
public struct OptimizeAttribute : Attribute public struct OptimizeAttribute : Attribute
{ {
@ -331,7 +325,7 @@ namespace System
/// Generally used as a per-method optimization, [DisableObjectAccessChecks] will avoid the runtime per-object-access /// Generally used as a per-method optimization, [DisableObjectAccessChecks] will avoid the runtime per-object-access
/// checks which by default are only applied in debug builds anyway. /// checks which by default are only applied in debug builds anyway.
[AttributeUsage(.Method/*, AlwaysIncludeTarget=true*/)] [AttributeUsage(.Method | .MemberAccess)]
public struct DisableObjectAccessChecksAttribute : Attribute public struct DisableObjectAccessChecksAttribute : Attribute
{ {
} }

View file

@ -159,7 +159,7 @@ namespace System
static void Object_GCMarkMembers(Object obj) static void Object_GCMarkMembers(Object obj)
{ {
#if BF_ENABLE_REALTIME_LEAK_CHECK #if BF_ENABLE_REALTIME_LEAK_CHECK
obj.[Friend, SkipAccessCheck]GCMarkMembers(); obj.[Friend, DisableObjectAccessChecks]GCMarkMembers();
#endif #endif
} }

View file

@ -25,7 +25,7 @@ OtherLinkFlags = ""
TargetDirectory = "$(WorkspaceDir)/dist" TargetDirectory = "$(WorkspaceDir)/dist"
TargetName = "BeefIDE_d" TargetName = "BeefIDE_d"
OtherLinkFlags = "$(LinkFlags) Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib IDEHelper64_d.lib" OtherLinkFlags = "$(LinkFlags) Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib IDEHelper64_d.lib"
DebugCommandArguments = "-proddir=C:\\Beef\\IDE\\Tests\\Test1 -test=scripts\\Data01.txt -testNoExit" DebugCommandArguments = "-proddir=C:\\Beef\\IDE"
DebugWorkingDirectory = "c:\\Beef\\IDE\\Tests\\EmptyTest" DebugWorkingDirectory = "c:\\Beef\\IDE\\Tests\\EmptyTest"
EnvironmentVars = ["_NO_DEBUG_HEAP=1"] EnvironmentVars = ["_NO_DEBUG_HEAP=1"]
@ -37,7 +37,7 @@ OtherLinkFlags = ""
TargetDirectory = "$(WorkspaceDir)/dist" TargetDirectory = "$(WorkspaceDir)/dist"
TargetName = "BeefIDE" TargetName = "BeefIDE"
OtherLinkFlags = "Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib Beef042RT64.lib IDEHelper64.lib BeefySysLib64.lib" OtherLinkFlags = "Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib Beef042RT64.lib IDEHelper64.lib BeefySysLib64.lib"
DebugCommandArguments = "-proddir=C:\\Beef\\IDE" DebugCommandArguments = "-proddir=C:\\Beef\\IDE\\Tests\\Test1 -test=scripts\\Data01.txt -testNoExit"
DebugWorkingDirectory = "$(ProjectDir)\\dist" DebugWorkingDirectory = "$(ProjectDir)\\dist"
EnvironmentVars = ["_NO_DEBUG_HEAP=1"] EnvironmentVars = ["_NO_DEBUG_HEAP=1"]

View file

@ -100,6 +100,7 @@ AllowHotSwapping = false
AllocStackTraceDepth = 0 AllocStackTraceDepth = 0
[Configs.Debug3.Win64] [Configs.Debug3.Win64]
BfOptimizationLevel = "O0"
IntermediateType = "ObjectAndIRCode" IntermediateType = "ObjectAndIRCode"
ConfigSelections = {Beefy2D = {Config = "Debug"}, IDEHelper = {Config = "Debug"}, Debugger64 = {Config = "Debug"}, BeefySysLib = {Config = "Debug"}} ConfigSelections = {Beefy2D = {Config = "Debug"}, IDEHelper = {Config = "Debug"}, Debugger64 = {Config = "Debug"}, BeefySysLib = {Config = "Debug"}}

View file

@ -5,7 +5,6 @@ Dependencies = {minlib = "*"}
Name = "mintest" Name = "mintest"
StartupObject = "Hey.Dude.Bro.TestClass" StartupObject = "Hey.Dude.Bro.TestClass"
DefaultNamespace = "Mintest" DefaultNamespace = "Mintest"
Aliases = ["corlib"]
[Platform.Windows] [Platform.Windows]
Description = "Mintest" Description = "Mintest"

View file

@ -11,6 +11,9 @@ InitLocalVariables = true
IntermediateType = "ObjectAndIRCode" IntermediateType = "ObjectAndIRCode"
ConfigSelections = {mintest2 = {Enabled = false}} ConfigSelections = {mintest2 = {Enabled = false}}
[[Configs.Debug.Win32.DistinctOptions]]
Filter = "NoFrame"
[Configs.Debug.Win64] [Configs.Debug.Win64]
IntermediateType = "ObjectAndIRCode" IntermediateType = "ObjectAndIRCode"
COptimizationLevel = "Og" COptimizationLevel = "Og"

View file

@ -5,6 +5,7 @@ Dependencies = {}
Name = "minlib" Name = "minlib"
TargetType = "BeefLib" TargetType = "BeefLib"
DefaultNamespace = "" DefaultNamespace = ""
Aliases = ["corlib"]
[Configs.Debug.Win32] [Configs.Debug.Win32]
OtherLinkFlags = "" OtherLinkFlags = ""

View file

@ -132,12 +132,6 @@ namespace System
} }
[AttributeUsage(.MemberAccess)]
public struct SkipAccessCheckAttribute : Attribute
{
}
[AttributeUsage(.Method | .Class | .Struct | .Enum)] [AttributeUsage(.Method | .Class | .Struct | .Enum)]
public struct OptimizeAttribute : Attribute public struct OptimizeAttribute : Attribute
{ {
@ -337,7 +331,7 @@ namespace System
{ {
} }
[AttributeUsage(.Method/*, AlwaysIncludeTarget=true*/)] [AttributeUsage(.Method | .MemberAccess)]
public struct DisableObjectAccessChecksAttribute : Attribute public struct DisableObjectAccessChecksAttribute : Attribute
{ {
} }

View file

@ -159,7 +159,7 @@ namespace System
static void Object_GCMarkMembers(Object obj) static void Object_GCMarkMembers(Object obj)
{ {
#if BF_ENABLE_REALTIME_LEAK_CHECK #if BF_ENABLE_REALTIME_LEAK_CHECK
obj.[Friend, SkipAccessCheck]GCMarkMembers(); obj.[Friend, DisableObjectAccessChecks]GCMarkMembers();
#endif #endif
} }

View file

@ -241,6 +241,14 @@ namespace System
} }
} }
private int PrivateLength
{
get
{
return mLength;
}
}
int32 AllocSize int32 AllocSize
{ {
[Inline] [Inline]

View file

@ -195,15 +195,20 @@ struct Blurg
}*/ }*/
struct Base public struct Base
{ {
int32 mA; int32 mA;
int64 mB; int64 mB;
} }
struct Derived : Base public struct Derived : Base
{ {
int8 mC; int8 mC;
public int GetC()
{
return mC + 10000;
}
} }
static int[] gArr = new .(1, 2, 3, 4, 5, ); static int[] gArr = new .(1, 2, 3, 4, 5, );
@ -225,17 +230,105 @@ struct Blurg
return 3; return 3;
} }
public static void Test()
{
//Test_Start
Derived dr = .();
dr.GetC();
Int iVal = (.)123;
int q = 999;
//Test_End
}
public static void Test2(int aa, int bb, int cc)
{
//Test_Start
Derived dr2 = .();
Int iVal2 = (.)123;
int q2 = 999;
String str = scope .();
//Test_End
}
public static void Recurse(int a)
{
int b = 234;
//Recurse_C
int c = 345;
if (a == 10)
return;
Recurse(a + 1);
int d = 100 + a;
}
public static void Test3()
{
//BreakpointTester_Test
int a = 0;
int b = 0;
while (a < 20)
{
//BreakpointTester_LoopA
a++;
}
//BreakpointTester_Recurse
Recurse(0);
}
public static void Test4()
{
//Test_Start
Derived dr = .();
Int iVal = (.)123;
int q = 999;
//Test_End
}
//[DisableObjectAccessChecks]
public static void Hey2()
{
String str = "Hey";
//int len = str.[Friend, DisableObjectAccessChecks]PrivateLength;
int len = str.[DisableObjectAccessChecks]Length;
//int len = str.[Friend]GetLength();
}
public static int32 Hey() public static int32 Hey()
{ {
/*Self.[Checked]GetVal(); Hey2();
Self.[Unchecked]GetVal(); Test();
GetVal2();*/ Test2(11, 22, 33);
Test3();
int a = gArr[1]; Test4();
a = gArr[[Unchecked]2]; NoFrame.Test();
return (int32)123; return (int32)123;
} }
} }
class NoFrame
{
public static void Test()
{
//Test_Start
Blurg.Derived dr = .();
Int iVal = (.)123;
int q = 999;
//Test_End
}
}

View file

@ -1151,7 +1151,10 @@ namespace IDE.ui
gApp.WithTabs(scope (tab) => gApp.WithTabs(scope (tab) =>
{ {
var sourceViewPanel = tab.mContent as SourceViewPanel; var sourceViewPanel = tab.mContent as SourceViewPanel;
if ((sourceViewPanel != null) && (sourceViewPanel.mProjectSource.mProject == project)) //if (sourceViewPanel?.mProjectSource?.mProject == project)
if ((sourceViewPanel != null) &&
(sourceViewPanel.mProjectSource != null) &&
(sourceViewPanel.mProjectSource.mProject == project))
{ {
sourceViewPanel.DetachFromProjectItem(); sourceViewPanel.DetachFromProjectItem();
} }

View file

@ -1438,11 +1438,14 @@ bool BfAutoComplete::CheckMemberReference(BfAstNode* target, BfAstNode* dotToken
if ((attrIdentifier = BfNodeDynCast<BfAttributedIdentifierNode>(memberName))) if ((attrIdentifier = BfNodeDynCast<BfAttributedIdentifierNode>(memberName)))
{ {
memberName = attrIdentifier->mIdentifier; memberName = attrIdentifier->mIdentifier;
if ((memberName == NULL) && (IsAutocompleteNode(attrIdentifier->mAttributes))) if (IsAutocompleteNode(attrIdentifier->mAttributes))
{ {
auto bfParser = attrIdentifier->mAttributes->GetSourceData()->ToParser(); auto bfParser = attrIdentifier->mAttributes->GetSourceData()->ToParser();
int cursorIdx = bfParser->mCursorIdx; int cursorIdx = bfParser->mCursorIdx;
isAutocompletingName = cursorIdx == attrIdentifier->mAttributes->GetSrcEnd(); if (cursorIdx == attrIdentifier->mAttributes->GetSrcEnd())
isAutocompletingName = true;
else
return false;
} }
} }

View file

@ -417,7 +417,6 @@ BfCompiler::BfCompiler(BfSystem* bfSystem, bool isResolveOnly)
mReflectTypeInstanceTypeDef = NULL; mReflectTypeInstanceTypeDef = NULL;
mReflectUnspecializedGenericType = NULL; mReflectUnspecializedGenericType = NULL;
mSizedArrayTypeDef = NULL; mSizedArrayTypeDef = NULL;
mSkipAccessCheckAttributeTypeDef = NULL;
mStaticInitAfterAttributeTypeDef = NULL; mStaticInitAfterAttributeTypeDef = NULL;
mStaticInitPriorityAttributeTypeDef = NULL; mStaticInitPriorityAttributeTypeDef = NULL;
mStringTypeDef = NULL; mStringTypeDef = NULL;
@ -5871,7 +5870,6 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
mReflectTypeInstanceTypeDef = _GetRequiredType("System.Reflection.TypeInstance"); mReflectTypeInstanceTypeDef = _GetRequiredType("System.Reflection.TypeInstance");
mReflectUnspecializedGenericType = _GetRequiredType("System.Reflection.UnspecializedGenericType"); mReflectUnspecializedGenericType = _GetRequiredType("System.Reflection.UnspecializedGenericType");
mSizedArrayTypeDef = _GetRequiredType("System.SizedArray", 2); mSizedArrayTypeDef = _GetRequiredType("System.SizedArray", 2);
mSkipAccessCheckAttributeTypeDef = _GetRequiredType("System.SkipAccessCheckAttribute");
mStaticInitAfterAttributeTypeDef = _GetRequiredType("System.StaticInitAfterAttribute"); mStaticInitAfterAttributeTypeDef = _GetRequiredType("System.StaticInitAfterAttribute");
mStaticInitPriorityAttributeTypeDef = _GetRequiredType("System.StaticInitPriorityAttribute"); mStaticInitPriorityAttributeTypeDef = _GetRequiredType("System.StaticInitPriorityAttribute");
mStringTypeDef = _GetRequiredType("System.String"); mStringTypeDef = _GetRequiredType("System.String");

View file

@ -385,7 +385,6 @@ public:
BfTypeDef* mFriendAttributeTypeDef; BfTypeDef* mFriendAttributeTypeDef;
BfTypeDef* mCheckedAttributeTypeDef; BfTypeDef* mCheckedAttributeTypeDef;
BfTypeDef* mUncheckedAttributeTypeDef; BfTypeDef* mUncheckedAttributeTypeDef;
BfTypeDef* mSkipAccessCheckAttributeTypeDef;
BfTypeDef* mStaticInitAfterAttributeTypeDef; BfTypeDef* mStaticInitAfterAttributeTypeDef;
BfTypeDef* mStaticInitPriorityAttributeTypeDef; BfTypeDef* mStaticInitPriorityAttributeTypeDef;
BfTypeDef* mTestAttributeTypeDef; BfTypeDef* mTestAttributeTypeDef;

View file

@ -3441,7 +3441,7 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
bool doAccessCheck = true; 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; doAccessCheck = false;
if (target.IsThis()) if (target.IsThis())
@ -3583,6 +3583,14 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
if (isInlined) if (isInlined)
mPropGetMethodFlags = (BfGetMethodInstanceFlags)(mPropGetMethodFlags | BfGetMethodInstanceFlag_ForceInline); 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 (mPropDef->mIsStatic)
{ {
if ((target) && ((flags & BfLookupFieldFlag_IsImplicitThis) == 0) && (!curCheckType->mTypeDef->IsGlobalsContainer())) if ((target) && ((flags & BfLookupFieldFlag_IsImplicitThis) == 0) && (!curCheckType->mTypeDef->IsGlobalsContainer()))
@ -4800,7 +4808,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
if (!mModule->mCurMethodState->mMayNeedThisAccessCheck) if (!mModule->mCurMethodState->mMayNeedThisAccessCheck)
doAccessCheck = false; 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; doAccessCheck = false;
if ((doAccessCheck) && (!isSkipCall)) if ((doAccessCheck) && (!isSkipCall))
mModule->EmitObjectAccessCheck(target); mModule->EmitObjectAccessCheck(target);
@ -11735,7 +11743,7 @@ BfAllocTarget BfExprEvaluator::ResolveAllocTarget(BfAstNode* allocNode, BfTokenN
if ((alignOverride & (alignOverride - 1)) == 0) if ((alignOverride & (alignOverride - 1)) == 0)
allocTarget.mAlignOverride = alignOverride; allocTarget.mAlignOverride = alignOverride;
else else
mModule->Fail("Alignment must be a power of 2", attrib.mRef); mModule->Fail("Alignment must be a power of 2", attrib.GetRefNode());
} }
} }
} }
@ -13787,6 +13795,7 @@ BfTypedValue BfExprEvaluator::GetResult(bool clearResult, bool resolveGenericTyp
if (mPropSrc != NULL) if (mPropSrc != NULL)
mModule->UpdateExprSrcPos(mPropSrc); mModule->UpdateExprSrcPos(mPropSrc);
if ((mPropGetMethodFlags & BfGetMethodInstanceFlag_Friend) == 0)
CheckPropFail(matchedMethod, methodInstance.mMethodInstance); CheckPropFail(matchedMethod, methodInstance.mMethodInstance);
PerformCallChecks(methodInstance.mMethodInstance, mPropSrc); PerformCallChecks(methodInstance.mMethodInstance, mPropSrc);
@ -13802,6 +13811,7 @@ BfTypedValue BfExprEvaluator::GetResult(bool clearResult, bool resolveGenericTyp
if ((mPropDefBypassVirtual) && (mPropTarget.mType != methodInstance.mMethodInstance->GetOwner())) if ((mPropDefBypassVirtual) && (mPropTarget.mType != methodInstance.mMethodInstance->GetOwner()))
mPropTarget = mModule->Cast(mPropSrc, mOrigPropTarget, methodInstance.mMethodInstance->GetOwner()); mPropTarget = mModule->Cast(mPropSrc, mOrigPropTarget, methodInstance.mMethodInstance->GetOwner());
if ((mPropGetMethodFlags & BfGetMethodInstanceFlag_DisableObjectAccessChecks) == 0)
mModule->EmitObjectAccessCheck(mPropTarget); mModule->EmitObjectAccessCheck(mPropTarget);
PushThis(mPropSrc, mPropTarget, methodInstance.mMethodInstance, args); PushThis(mPropSrc, mPropTarget, methodInstance.mMethodInstance, args);
} }
@ -15512,7 +15522,7 @@ void BfExprEvaluator::DoMemberReference(BfMemberReferenceExpression* memberRefEx
if (attributeState.mCustomAttributes != NULL) if (attributeState.mCustomAttributes != NULL)
{ {
if (mPropDef != NULL) if (mPropDef != NULL)
attributeState.mTarget = BfAttributeTargets_Invocation; attributeState.mTarget = (BfAttributeTargets)(attributeState.mTarget | BfAttributeTargets_Invocation);
mModule->ValidateCustomAttributes(attributeState.mCustomAttributes, attributeState.mTarget); mModule->ValidateCustomAttributes(attributeState.mCustomAttributes, attributeState.mTarget);
} }
); );

View file

@ -9393,7 +9393,7 @@ void BfModule::ValidateCustomAttributes(BfCustomAttributes* customAttributes, Bf
if ((customAttribute.mType->mAttributeData->mAttributeTargets & attrTarget) == 0) if ((customAttribute.mType->mAttributeData->mAttributeTargets & attrTarget) == 0)
{ {
Fail(StrFormat("Attribute '%s' is not valid on this declaration type. It is only valid on %s.", 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; customAttribute.mAwaitingValidation = false;

View file

@ -37,7 +37,7 @@ enum BfMethodNameFlags : uint8
BfMethodNameFlag_OmitTypeName = 2 BfMethodNameFlag_OmitTypeName = 2
}; };
enum BfGetMethodInstanceFlags : uint8 enum BfGetMethodInstanceFlags : uint16
{ {
BfGetMethodInstanceFlag_None = 0, BfGetMethodInstanceFlag_None = 0,
BfGetMethodInstanceFlag_UnspecializedPass = 1, BfGetMethodInstanceFlag_UnspecializedPass = 1,
@ -47,7 +47,9 @@ enum BfGetMethodInstanceFlags : uint8
BfGetMethodInstanceFlag_Unreified = 0x10, BfGetMethodInstanceFlag_Unreified = 0x10,
BfGetMethodInstanceFlag_NoForceReification = 0x20, BfGetMethodInstanceFlag_NoForceReification = 0x20,
BfGetMethodInstanceFlag_ResultNotUsed = 0x40, BfGetMethodInstanceFlag_ResultNotUsed = 0x40,
BfGetMethodInstanceFlag_ForceInline = 0x80 BfGetMethodInstanceFlag_ForceInline = 0x80,
BfGetMethodInstanceFlag_Friend = 0x100,
BfGetMethodInstanceFlag_DisableObjectAccessChecks = 0x200,
}; };
class BfDependencyMap class BfDependencyMap
@ -2203,6 +2205,13 @@ public:
Array<BfCustomAttributeSetProperty> mSetProperties; Array<BfCustomAttributeSetProperty> mSetProperties;
Array<BfCustomAttributeSetField> mSetField; Array<BfCustomAttributeSetField> mSetField;
bool mAwaitingValidation; bool mAwaitingValidation;
BfAstNode* GetRefNode()
{
if (mRef->mAttributeTypeRef != NULL)
return mRef->mAttributeTypeRef;
return mRef;
}
}; };
class BfCustomAttributes class BfCustomAttributes