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

Added IsReadOnly to FieldInfo and MethodInfo

This commit is contained in:
Brian Fiete 2022-05-30 06:20:47 -07:00
parent c080f1cbb1
commit 996377909f
6 changed files with 28 additions and 26 deletions

View file

@ -24,6 +24,7 @@ namespace System.Reflection
public int32 MemberOffset => (int32)mFieldData.mData; public int32 MemberOffset => (int32)mFieldData.mData;
public Type FieldType => Type.[Friend]GetType(mFieldData.mFieldTypeId); public Type FieldType => Type.[Friend]GetType(mFieldData.mFieldTypeId);
public bool IsConst => mFieldData.mFlags.HasFlag(.Const); public bool IsConst => mFieldData.mFlags.HasFlag(.Const);
public bool IsReadOnly => mFieldData.mFlags.HasFlag(.ReadOnly);
public bool IsStatic => mFieldData.mFlags.HasFlag(.Static); public bool IsStatic => mFieldData.mFlags.HasFlag(.Static);
public bool IsPublic => (mFieldData.mFlags & .FieldAccessMask) == .Public; public bool IsPublic => (mFieldData.mFlags & .FieldAccessMask) == .Public;
public bool IsProtected => (mFieldData.mFlags & .FieldAccessMask) == .Protected; public bool IsProtected => (mFieldData.mFlags & .FieldAccessMask) == .Protected;

View file

@ -47,6 +47,9 @@ namespace System.Reflection
public bool IsPrivate => Compiler.IsComptime ? public bool IsPrivate => Compiler.IsComptime ?
(Type.[Friend]Comptime_Method_GetInfo(mData.mComptimeMethodInstance).mMethodFlags & .MethodAccessMask) == 0 : (Type.[Friend]Comptime_Method_GetInfo(mData.mComptimeMethodInstance).mMethodFlags & .MethodAccessMask) == 0 :
(mData.mMethodData.[Friend]mFlags & .MethodAccessMask) == 0; (mData.mMethodData.[Friend]mFlags & .MethodAccessMask) == 0;
public bool IsReadOnly => Compiler.IsComptime ?
(Type.[Friend]Comptime_Method_GetInfo(mData.mComptimeMethodInstance).mMethodFlags & .ReadOnly) == 0 :
(mData.mMethodData.[Friend]mFlags & .ReadOnly) == 0;
public StringView Name => Compiler.IsComptime ? public StringView Name => Compiler.IsComptime ?
Type.[Friend]Comptime_Method_GetName(mData.mComptimeMethodInstance) : Type.[Friend]Comptime_Method_GetName(mData.mComptimeMethodInstance) :

View file

@ -1477,7 +1477,8 @@ namespace System.Reflection
SpecialName = 0x0080, // field is special. Name describes how. SpecialName = 0x0080, // field is special. Name describes how.
EnumPayload = 0x0100, EnumPayload = 0x0100,
EnumDiscriminator = 0x0200, EnumDiscriminator = 0x0200,
EnumCase = 0x0400 EnumCase = 0x0400,
ReadOnly = 0x0800,
} }
public enum MethodFlags : uint16 public enum MethodFlags : uint16
@ -1487,27 +1488,17 @@ namespace System.Reflection
Public = 0x0006, Public = 0x0006,
// method contract attributes. // method contract attributes.
Static = 0x0010, // Defined on type, else per instance. Static = 0x0010, // Defined on type, else per instance.
Final = 0x0020, // Method may not be overridden. Final = 0x0020, // Method may not be overridden.
Virtual = 0x0040, // Method virtual. Virtual = 0x0040, // Method virtual.
HideBySig = 0x0080, // Method hides by name+sig, else just by name. HideBySig = 0x0080, // Method hides by name+sig, else just by name.
CheckAccessOnOverride = 0x0200, ReadOnly = 0x0100,
Abstract = 0x0400, // Method does not provide an implementation.
// vtable layout mask - Use this mask to retrieve vtable attributes. SpecialName = 0x0800, // Method is special. Name describes how.
VtableLayoutMask = 0x0100, StdCall = 0x1000,
#unwarn FastCall = 0x2000,
ReuseSlot = 0x0000, // The default. ThisCall = 0x3000, // Purposely resuing StdCall|FastCall
#unwarn Mutating = 0x4000,
NewSlot = 0x0100, // Method always gets a new slot in the vtable. Constructor = 0x8000,
// end vtable layout mask
// method implementation attributes.
Abstract = 0x0400, // Method does not provide an implementation.
SpecialName = 0x0800, // Method is special. Name describes how.
StdCall = 0x1000,
FastCall = 0x2000,
ThisCall = 0x3000, // Purposely resuing StdCall|FastCall
Mutating = 0x4000,
Constructor = 0x8000,
} }
} }

View file

@ -5585,6 +5585,8 @@ BfIRValue BfModule::CreateFieldData(BfFieldInstance* fieldInstance, int customAt
fieldFlags = (BfFieldFlags)(fieldFlags | BfFieldFlags_Const); fieldFlags = (BfFieldFlags)(fieldFlags | BfFieldFlags_Const);
if (fieldDef->IsEnumCaseEntry()) if (fieldDef->IsEnumCaseEntry())
fieldFlags = (BfFieldFlags)(fieldFlags | BfFieldFlags_EnumCase); fieldFlags = (BfFieldFlags)(fieldFlags | BfFieldFlags_EnumCase);
if (fieldDef->mIsReadOnly)
fieldFlags = (BfFieldFlags)(fieldFlags | BfFieldFlags_ReadOnly);
BfIRValue constValue; BfIRValue constValue;
BfIRValue constValue2; BfIRValue constValue2;
@ -7163,7 +7165,7 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
paramFlags = (ParamFlags)(paramFlags | ParamFlag_Splat); paramFlags = (ParamFlags)(paramFlags | ParamFlag_Splat);
if (defaultMethod->GetParamKind(paramIdx) == BfParamKind_AppendIdx) if (defaultMethod->GetParamKind(paramIdx) == BfParamKind_AppendIdx)
paramFlags = (ParamFlags)(paramFlags | ParamFlag_Implicit | ParamFlag_AppendIdx); paramFlags = (ParamFlags)(paramFlags | ParamFlag_Implicit | ParamFlag_AppendIdx);
BfIRValue paramNameConst = GetStringObjectValue(paramName, !mIsComptimeModule); BfIRValue paramNameConst = GetStringObjectValue(paramName, !mIsComptimeModule);
int paramCustomAttrIdx = -1; int paramCustomAttrIdx = -1;

View file

@ -697,6 +697,8 @@ BfMethodFlags BfMethodInstance::GetMethodFlags()
methodFlags = (BfMethodFlags)(methodFlags | BfMethodFlags_Mutating); methodFlags = (BfMethodFlags)(methodFlags | BfMethodFlags_Mutating);
if (mMethodDef->mMethodType == BfMethodType_Ctor) if (mMethodDef->mMethodType == BfMethodType_Ctor)
methodFlags = (BfMethodFlags)(methodFlags | BfMethodFlags_Constructor); methodFlags = (BfMethodFlags)(methodFlags | BfMethodFlags_Constructor);
if (mMethodDef->mIsReadOnly)
methodFlags = (BfMethodFlags)(methodFlags | BfMethodFlags_ReadOnly);
auto callingConvention = GetOwner()->mModule->GetIRCallingConvention(this); auto callingConvention = GetOwner()->mModule->GetIRCallingConvention(this);
if (callingConvention == BfIRCallingConv_ThisCall) if (callingConvention == BfIRCallingConv_ThisCall)
@ -705,6 +707,7 @@ BfMethodFlags BfMethodInstance::GetMethodFlags()
methodFlags = (BfMethodFlags)(methodFlags | BfMethodFlags_StdCall); methodFlags = (BfMethodFlags)(methodFlags | BfMethodFlags_StdCall);
else if (callingConvention == BfIRCallingConv_FastCall) else if (callingConvention == BfIRCallingConv_FastCall)
methodFlags = (BfMethodFlags)(methodFlags | BfMethodFlags_FastCall); methodFlags = (BfMethodFlags)(methodFlags | BfMethodFlags_FastCall);
return methodFlags; return methodFlags;
} }

View file

@ -229,11 +229,12 @@ enum BfMethodFlags
BfMethodFlags_Public = 6, BfMethodFlags_Public = 6,
BfMethodFlags_Static = 0x10, BfMethodFlags_Static = 0x10,
BfMethodFlags_Virtual = 0x40, BfMethodFlags_Virtual = 0x40,
BfMethodFlags_ReadOnly = 0x100,
BfMethodFlags_StdCall = 0x1000, BfMethodFlags_StdCall = 0x1000,
BfMethodFlags_FastCall = 0x2000, BfMethodFlags_FastCall = 0x2000,
BfMethodFlags_ThisCall = 0x3000, BfMethodFlags_ThisCall = 0x3000,
BfMethodFlags_Mutating = 0x4000, BfMethodFlags_Mutating = 0x4000,
BfMethodFlags_Constructor = 0x8000, BfMethodFlags_Constructor = 0x8000
}; };
enum BfObjectFlags : uint8 enum BfObjectFlags : uint8
@ -1666,7 +1667,8 @@ enum BfFieldFlags
BfFieldFlags_SpecialName = 0x80, BfFieldFlags_SpecialName = 0x80,
BfFieldFlags_EnumPayload = 0x100, BfFieldFlags_EnumPayload = 0x100,
BfFieldFlags_EnumDiscriminator = 0x200, BfFieldFlags_EnumDiscriminator = 0x200,
BfFieldFlags_EnumCase = 0x400 BfFieldFlags_EnumCase = 0x400,
BfFieldFlags_ReadOnly = 0x800
}; };
enum BfReflectKind enum BfReflectKind