diff --git a/BeefLibs/corlib/src/Reflection/FieldInfo.bf b/BeefLibs/corlib/src/Reflection/FieldInfo.bf index 562a8a01..e75d8f57 100644 --- a/BeefLibs/corlib/src/Reflection/FieldInfo.bf +++ b/BeefLibs/corlib/src/Reflection/FieldInfo.bf @@ -24,6 +24,7 @@ namespace System.Reflection public int32 MemberOffset => (int32)mFieldData.mData; public Type FieldType => Type.[Friend]GetType(mFieldData.mFieldTypeId); public bool IsConst => mFieldData.mFlags.HasFlag(.Const); + public bool IsReadOnly => mFieldData.mFlags.HasFlag(.ReadOnly); public bool IsStatic => mFieldData.mFlags.HasFlag(.Static); public bool IsPublic => (mFieldData.mFlags & .FieldAccessMask) == .Public; public bool IsProtected => (mFieldData.mFlags & .FieldAccessMask) == .Protected; diff --git a/BeefLibs/corlib/src/Reflection/MethodInfo.bf b/BeefLibs/corlib/src/Reflection/MethodInfo.bf index 95bc79d7..5cf4f49d 100644 --- a/BeefLibs/corlib/src/Reflection/MethodInfo.bf +++ b/BeefLibs/corlib/src/Reflection/MethodInfo.bf @@ -47,6 +47,9 @@ namespace System.Reflection public bool IsPrivate => Compiler.IsComptime ? (Type.[Friend]Comptime_Method_GetInfo(mData.mComptimeMethodInstance).mMethodFlags & .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 ? Type.[Friend]Comptime_Method_GetName(mData.mComptimeMethodInstance) : diff --git a/BeefLibs/corlib/src/Type.bf b/BeefLibs/corlib/src/Type.bf index 0f961213..f4159dfa 100644 --- a/BeefLibs/corlib/src/Type.bf +++ b/BeefLibs/corlib/src/Type.bf @@ -1477,7 +1477,8 @@ namespace System.Reflection SpecialName = 0x0080, // field is special. Name describes how. EnumPayload = 0x0100, EnumDiscriminator = 0x0200, - EnumCase = 0x0400 + EnumCase = 0x0400, + ReadOnly = 0x0800, } public enum MethodFlags : uint16 @@ -1487,27 +1488,17 @@ namespace System.Reflection Public = 0x0006, // method contract attributes. - Static = 0x0010, // Defined on type, else per instance. - Final = 0x0020, // Method may not be overridden. - Virtual = 0x0040, // Method virtual. - HideBySig = 0x0080, // Method hides by name+sig, else just by name. - CheckAccessOnOverride = 0x0200, - - // vtable layout mask - Use this mask to retrieve vtable attributes. - VtableLayoutMask = 0x0100, -#unwarn - ReuseSlot = 0x0000, // The default. -#unwarn - NewSlot = 0x0100, // Method always gets a new slot in the vtable. - // 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, + Static = 0x0010, // Defined on type, else per instance. + Final = 0x0020, // Method may not be overridden. + Virtual = 0x0040, // Method virtual. + HideBySig = 0x0080, // Method hides by name+sig, else just by name. + ReadOnly = 0x0100, + 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, } } diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 9a773843..f9e59303 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -5585,6 +5585,8 @@ BfIRValue BfModule::CreateFieldData(BfFieldInstance* fieldInstance, int customAt fieldFlags = (BfFieldFlags)(fieldFlags | BfFieldFlags_Const); if (fieldDef->IsEnumCaseEntry()) fieldFlags = (BfFieldFlags)(fieldFlags | BfFieldFlags_EnumCase); + if (fieldDef->mIsReadOnly) + fieldFlags = (BfFieldFlags)(fieldFlags | BfFieldFlags_ReadOnly); BfIRValue constValue; BfIRValue constValue2; @@ -7163,7 +7165,7 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary& usedStrin paramFlags = (ParamFlags)(paramFlags | ParamFlag_Splat); if (defaultMethod->GetParamKind(paramIdx) == BfParamKind_AppendIdx) paramFlags = (ParamFlags)(paramFlags | ParamFlag_Implicit | ParamFlag_AppendIdx); - + BfIRValue paramNameConst = GetStringObjectValue(paramName, !mIsComptimeModule); int paramCustomAttrIdx = -1; diff --git a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp index 26f82802..177b30f6 100644 --- a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp +++ b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp @@ -697,6 +697,8 @@ BfMethodFlags BfMethodInstance::GetMethodFlags() methodFlags = (BfMethodFlags)(methodFlags | BfMethodFlags_Mutating); if (mMethodDef->mMethodType == BfMethodType_Ctor) methodFlags = (BfMethodFlags)(methodFlags | BfMethodFlags_Constructor); + if (mMethodDef->mIsReadOnly) + methodFlags = (BfMethodFlags)(methodFlags | BfMethodFlags_ReadOnly); auto callingConvention = GetOwner()->mModule->GetIRCallingConvention(this); if (callingConvention == BfIRCallingConv_ThisCall) @@ -705,6 +707,7 @@ BfMethodFlags BfMethodInstance::GetMethodFlags() methodFlags = (BfMethodFlags)(methodFlags | BfMethodFlags_StdCall); else if (callingConvention == BfIRCallingConv_FastCall) methodFlags = (BfMethodFlags)(methodFlags | BfMethodFlags_FastCall); + return methodFlags; } diff --git a/IDEHelper/Compiler/BfSystem.h b/IDEHelper/Compiler/BfSystem.h index 100efd8f..8d9465be 100644 --- a/IDEHelper/Compiler/BfSystem.h +++ b/IDEHelper/Compiler/BfSystem.h @@ -229,11 +229,12 @@ enum BfMethodFlags BfMethodFlags_Public = 6, BfMethodFlags_Static = 0x10, BfMethodFlags_Virtual = 0x40, + BfMethodFlags_ReadOnly = 0x100, BfMethodFlags_StdCall = 0x1000, BfMethodFlags_FastCall = 0x2000, BfMethodFlags_ThisCall = 0x3000, BfMethodFlags_Mutating = 0x4000, - BfMethodFlags_Constructor = 0x8000, + BfMethodFlags_Constructor = 0x8000 }; enum BfObjectFlags : uint8 @@ -1666,7 +1667,8 @@ enum BfFieldFlags BfFieldFlags_SpecialName = 0x80, BfFieldFlags_EnumPayload = 0x100, BfFieldFlags_EnumDiscriminator = 0x200, - BfFieldFlags_EnumCase = 0x400 + BfFieldFlags_EnumCase = 0x400, + BfFieldFlags_ReadOnly = 0x800 }; enum BfReflectKind