2019-08-23 11:56:54 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BeefySysLib/Common.h"
|
|
|
|
#include "BeefySysLib/util/CritSect.h"
|
|
|
|
#include "BeefySysLib/util/Hash.h"
|
|
|
|
#include "BeefySysLib/util/HashSet.h"
|
|
|
|
#include "BeefySysLib/util/Deque.h"
|
|
|
|
#include "BeefySysLib/util/BumpAllocator.h"
|
|
|
|
#include "BeefySysLib/util/MultiHashSet.h"
|
|
|
|
#include "../Beef/BfCommon.h"
|
|
|
|
#include "BfAst.h"
|
|
|
|
#include "BfUtil.h"
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <unordered_set>
|
|
|
|
#include <set>
|
|
|
|
#include "MemReporter.h"
|
|
|
|
|
|
|
|
namespace llvm
|
|
|
|
{
|
|
|
|
class Type;
|
|
|
|
class Function;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BF_NEW_INT_TYPES
|
|
|
|
|
|
|
|
#ifdef BF_NEW_INT_TYPES
|
|
|
|
#define BF_INT32_NAME "int32"
|
|
|
|
#else
|
|
|
|
#define BF_INT32_NAME "int"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BF_PLATFORM_WINDOWS
|
|
|
|
#define BF_OBJ_EXT ".obj"
|
|
|
|
#else
|
|
|
|
#define BF_OBJ_EXT ".o"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NS_BF_BEGIN
|
|
|
|
|
|
|
|
class BfSystem;
|
|
|
|
class BfCompiler;
|
2022-04-16 06:27:54 -07:00
|
|
|
class BfTypeReference;
|
2019-08-23 11:56:54 -07:00
|
|
|
class BfProject;
|
2021-01-11 09:41:43 -08:00
|
|
|
class BfTypeDef;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
struct BfTypeDefMapFuncs;
|
2020-07-01 12:06:28 -07:00
|
|
|
typedef HashSet<BfProject*> BfProjectSet;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
class BfAtom
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
StringView mString;
|
2020-12-25 05:22:02 -08:00
|
|
|
int mRefCount;
|
|
|
|
int mPendingDerefCount;
|
2019-08-23 11:56:54 -07:00
|
|
|
int mHash;
|
|
|
|
uint32 mAtomUpdateIdx;
|
|
|
|
bool mIsSystemType;
|
|
|
|
Dictionary<BfAtom*, int> mPrevNamesMap;
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
public:
|
|
|
|
~BfAtom();
|
|
|
|
const StringView& ToString()
|
|
|
|
{
|
|
|
|
return mString;
|
|
|
|
}
|
|
|
|
void ToString(StringImpl& str)
|
|
|
|
{
|
|
|
|
str += mString;
|
|
|
|
}
|
|
|
|
|
2022-07-26 13:27:03 -04:00
|
|
|
void Ref();
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class BfAtomComposite
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BfAtom** mParts;
|
|
|
|
int16 mSize;
|
|
|
|
int16 mAllocSize;
|
|
|
|
bool mOwns;
|
|
|
|
|
|
|
|
public:
|
2022-07-26 13:27:03 -04:00
|
|
|
BfAtomComposite();
|
2019-08-23 11:56:54 -07:00
|
|
|
BfAtomComposite(BfAtomComposite&& rhs);
|
|
|
|
BfAtomComposite(const BfAtomComposite& rhs);
|
2022-07-26 13:27:03 -04:00
|
|
|
BfAtomComposite(BfAtom* atom);
|
2019-08-23 11:56:54 -07:00
|
|
|
BfAtomComposite(const BfAtomComposite& left, const BfAtomComposite& right);
|
|
|
|
BfAtomComposite(const BfAtomComposite& left, BfAtom* right);
|
|
|
|
~BfAtomComposite();
|
2022-07-26 13:27:03 -04:00
|
|
|
|
|
|
|
void Set(const BfAtomComposite& left, const BfAtomComposite& right);
|
2019-08-23 11:56:54 -07:00
|
|
|
void Set(BfAtom** atomsA, int countA, BfAtom** atomsB, int countB);
|
|
|
|
BfAtomComposite& operator=(const BfAtomComposite& rhs);
|
|
|
|
bool operator==(const BfAtomComposite& other) const;
|
|
|
|
bool operator!=(const BfAtomComposite& other) const;
|
|
|
|
bool IsValid() const;
|
|
|
|
bool IsEmpty() const;
|
|
|
|
int GetPartsCount() const;
|
|
|
|
String ToString() const;
|
|
|
|
void ToString(StringImpl& str) const;
|
|
|
|
bool StartsWith(const BfAtomComposite& other) const;
|
|
|
|
bool EndsWith(const BfAtomComposite& other) const;
|
|
|
|
BfAtomComposite GetSub(int start, int len) const;
|
|
|
|
void Reference(const BfAtomComposite& other);
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
uint32 GetAtomUpdateIdx();
|
|
|
|
};
|
|
|
|
|
2022-05-06 11:28:38 -07:00
|
|
|
template <const int TBufSize>
|
|
|
|
class BfAtomCompositeT : public BfAtomComposite
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BfAtom* mInternalBuffer[TBufSize];
|
|
|
|
|
|
|
|
public:
|
|
|
|
BfAtomCompositeT()
|
|
|
|
{
|
|
|
|
mAllocSize = (int16)TBufSize;
|
|
|
|
mParts = mInternalBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
BfAtomCompositeT(const BfAtomComposite& rhs)
|
|
|
|
{
|
|
|
|
mAllocSize = (int16)TBufSize;
|
|
|
|
mParts = mInternalBuffer;
|
|
|
|
*this = rhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
BfAtomCompositeT& operator=(const BfAtomComposite& rhs)
|
|
|
|
{
|
|
|
|
Set(rhs.mParts, rhs.mSize, NULL, 0);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
class BfSizedAtomComposite : public BfAtomComposite
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BfAtom* mInitialAlloc[8];
|
|
|
|
|
2022-07-26 13:27:03 -04:00
|
|
|
BfSizedAtomComposite();
|
|
|
|
~BfSizedAtomComposite();
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct BfAtomCompositeHash
|
|
|
|
{
|
|
|
|
size_t operator()(const BfAtomComposite& composite) const
|
|
|
|
{
|
2022-07-26 13:27:03 -04:00
|
|
|
int curHash = 0;
|
|
|
|
for (int i = 0; i < (int)composite.mSize; i++)
|
|
|
|
curHash = ((curHash ^ (int)(intptr)composite.mParts[i]->mHash) << 5) - curHash;
|
2019-08-23 11:56:54 -07:00
|
|
|
return curHash;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BfAtomCompositeEquals
|
|
|
|
{
|
|
|
|
bool operator()(const BfAtomComposite& lhs, const BfAtomComposite& rhs) const
|
|
|
|
{
|
|
|
|
if (lhs.mSize != rhs.mSize)
|
|
|
|
return false;
|
|
|
|
for (int i = 0; i < lhs.mSize; i++)
|
|
|
|
if (lhs.mParts[i] != rhs.mParts[i])
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-12-15 11:37:53 -05:00
|
|
|
enum BfFailHandleKind
|
|
|
|
{
|
|
|
|
BfFailHandleKind_Normal,
|
|
|
|
BfFailHandleKind_Soft,
|
|
|
|
BfFailHandleKind_Ignore
|
|
|
|
};
|
|
|
|
|
2022-05-26 15:39:32 -07:00
|
|
|
enum BfWhileSpecializingFlags : int8
|
|
|
|
{
|
|
|
|
BfWhileSpecializingFlag_None = 0,
|
|
|
|
BfWhileSpecializingFlag_Type = 1,
|
|
|
|
BfWhileSpecializingFlag_Method = 2
|
|
|
|
};
|
|
|
|
|
2019-10-14 13:01:15 -07:00
|
|
|
enum BfCompilerOptionFlags
|
|
|
|
{
|
|
|
|
BfCompilerOptionFlag_EmitDebugInfo = 1,
|
|
|
|
BfCompilerOptionFlag_EmitLineInfo = 2,
|
|
|
|
BfCompilerOptionFlag_WriteIR = 4,
|
|
|
|
BfCompilerOptionFlag_GenerateOBJ = 8,
|
2022-07-26 13:27:03 -04:00
|
|
|
BfCompilerOptionFlag_GenerateBitcode = 0x10,
|
2019-10-14 13:01:15 -07:00
|
|
|
BfCompilerOptionFlag_ClearLocalVars = 0x20,
|
|
|
|
BfCompilerOptionFlag_RuntimeChecks = 0x40,
|
|
|
|
BfCompilerOptionFlag_EmitDynamicCastCheck = 0x80,
|
|
|
|
BfCompilerOptionFlag_EnableObjectDebugFlags = 0x100,
|
|
|
|
BfCompilerOptionFlag_EmitObjectAccessCheck = 0x200,
|
|
|
|
BfCompilerOptionFlag_EnableCustodian = 0x400,
|
|
|
|
BfCompilerOptionFlag_EnableRealtimeLeakCheck = 0x800,
|
2019-10-29 04:56:42 -07:00
|
|
|
BfCompilerOptionFlag_EnableSideStack = 0x1000,
|
|
|
|
BfCompilerOptionFlag_EnableHotSwapping = 0x2000,
|
|
|
|
BfCompilerOptionFlag_IncrementalBuild = 0x4000,
|
2022-07-26 13:27:03 -04:00
|
|
|
BfCompilerOptionFlag_DebugAlloc = 0x8000,
|
2019-10-29 04:56:42 -07:00
|
|
|
BfCompilerOptionFlag_OmitDebugHelpers = 0x10000,
|
|
|
|
BfCompilerOptionFlag_NoFramePointerElim = 0x20000,
|
2022-01-11 08:17:09 -05:00
|
|
|
BfCompilerOptionFlag_ArithmeticChecks = 0x40000,
|
2019-10-14 13:01:15 -07:00
|
|
|
};
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
enum BfTypeFlags
|
|
|
|
{
|
|
|
|
BfTypeFlags_UnspecializedGeneric = 0x0001,
|
|
|
|
BfTypeFlags_SpecializedGeneric = 0x0002,
|
|
|
|
BfTypeFlags_Array = 0x0004,
|
|
|
|
|
|
|
|
BfTypeFlags_Object = 0x0008,
|
|
|
|
BfTypeFlags_Boxed = 0x0010,
|
|
|
|
BfTypeFlags_Pointer = 0x0020,
|
|
|
|
BfTypeFlags_Struct = 0x0040,
|
2020-09-14 06:54:49 -07:00
|
|
|
BfTypeFlags_Interface = 0x0080,
|
|
|
|
BfTypeFlags_Primitive = 0x0100,
|
|
|
|
BfTypeFlags_TypedPrimitive = 0x0200,
|
|
|
|
BfTypeFlags_Tuple = 0x0400,
|
|
|
|
BfTypeFlags_Nullable = 0x0800,
|
|
|
|
BfTypeFlags_SizedArray = 0x1000,
|
|
|
|
BfTypeFlags_Splattable = 0x2000,
|
|
|
|
BfTypeFlags_Union = 0x4000,
|
2021-12-30 08:38:37 -05:00
|
|
|
BfTypeFlags_ConstExpr = 0x8000,
|
2019-10-11 05:58:08 -07:00
|
|
|
//
|
2021-12-30 08:38:37 -05:00
|
|
|
BfTypeFlags_WantsMarking = 0x10000,
|
|
|
|
BfTypeFlags_Delegate = 0x20000,
|
|
|
|
BfTypeFlags_Function = 0x40000,
|
|
|
|
BfTypeFlags_HasDestructor = 0x80000,
|
2023-02-17 16:00:34 +01:00
|
|
|
BfTypeFlags_GenericParam = 0x100000,
|
|
|
|
|
|
|
|
BfTypeFlags_Static = 0x200000,
|
|
|
|
BfTypeFlags_Abstract = 0x400000,
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
2021-01-13 05:09:09 -08:00
|
|
|
enum BfMethodFlags
|
|
|
|
{
|
|
|
|
BfMethodFlags_Protected = 3,
|
|
|
|
BfMethodFlags_Public = 6,
|
|
|
|
BfMethodFlags_Static = 0x10,
|
|
|
|
BfMethodFlags_Virtual = 0x40,
|
2022-05-30 06:20:47 -07:00
|
|
|
BfMethodFlags_ReadOnly = 0x100,
|
2024-04-27 13:52:00 +02:00
|
|
|
BfMethodFlags_Mixin = 0x200,
|
2021-01-13 05:09:09 -08:00
|
|
|
BfMethodFlags_StdCall = 0x1000,
|
|
|
|
BfMethodFlags_FastCall = 0x2000,
|
|
|
|
BfMethodFlags_ThisCall = 0x3000,
|
|
|
|
BfMethodFlags_Mutating = 0x4000,
|
2022-07-26 13:27:03 -04:00
|
|
|
BfMethodFlags_Constructor = 0x8000
|
2021-01-13 05:09:09 -08:00
|
|
|
};
|
|
|
|
|
2023-10-10 13:20:35 -07:00
|
|
|
enum BfComptimeMethodFlags
|
|
|
|
{
|
|
|
|
BfComptimeMethodFlags_None = 0,
|
|
|
|
BfComptimeMethodFlags_NoReflect = 1
|
|
|
|
};
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
enum BfObjectFlags : uint8
|
|
|
|
{
|
|
|
|
BfObjectFlag_None = 0,
|
|
|
|
BfObjectFlag_MarkIdMask = 0x03,
|
|
|
|
BfObjectFlag_Allocated = 0x04,
|
|
|
|
BfObjectFlag_StackAlloc = 0x08,
|
|
|
|
BfObjectFlag_AppendAlloc = 0x10,
|
|
|
|
BfObjectFlag_AllocInfo = 0x20,
|
|
|
|
BfObjectFlag_AllocInfo_Short = 0x40,
|
|
|
|
BfObjectFlag_Deleted = 0x80,
|
|
|
|
|
|
|
|
BfObjectFlag_StackDeleted = 0x80 // We remove StackAlloc so it doesn't get scanned
|
|
|
|
};
|
|
|
|
|
2020-12-29 12:41:43 -08:00
|
|
|
enum BfCustomAttributeFlags : uint8
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
|
|
|
BfCustomAttributeFlags_None,
|
|
|
|
BfCustomAttributeFlags_DisallowAllowMultiple = 1,
|
|
|
|
BfCustomAttributeFlags_NotInherited = 2,
|
|
|
|
BfCustomAttributeFlags_ReflectAttribute = 4,
|
|
|
|
BfCustomAttributeFlags_AlwaysIncludeTarget = 8
|
|
|
|
};
|
|
|
|
|
2020-12-29 12:41:43 -08:00
|
|
|
enum BfAlwaysIncludeFlags : uint8
|
|
|
|
{
|
|
|
|
BfAlwaysIncludeFlag_None = 0,
|
|
|
|
BfAlwaysIncludeFlag_Type = 1,
|
|
|
|
BfAlwaysIncludeFlag_IncludeAllMethods = 2,
|
|
|
|
BfAlwaysIncludeFlag_AssumeInstantiated = 4,
|
|
|
|
BfAlwaysIncludeFlag_All = BfAlwaysIncludeFlag_Type | BfAlwaysIncludeFlag_IncludeAllMethods | BfAlwaysIncludeFlag_AssumeInstantiated
|
|
|
|
};
|
|
|
|
|
2021-01-08 16:21:03 -08:00
|
|
|
enum BfCEOnCompileKind : uint8
|
|
|
|
{
|
|
|
|
BfCEOnCompileKind_None,
|
|
|
|
BfCEOnCompileKind_TypeInit,
|
|
|
|
BfCEOnCompileKind_TypeDone
|
|
|
|
};
|
|
|
|
|
2019-10-23 07:12:36 -07:00
|
|
|
enum BfPlatformType
|
|
|
|
{
|
|
|
|
BfPlatformType_Unknown,
|
|
|
|
BfPlatformType_Windows,
|
|
|
|
BfPlatformType_Linux,
|
|
|
|
BfPlatformType_macOS,
|
|
|
|
BfPlatformType_iOS,
|
|
|
|
BfPlatformType_Android,
|
2020-08-06 09:24:37 -07:00
|
|
|
BfPlatformType_Wasm
|
2019-10-23 07:12:36 -07:00
|
|
|
};
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
enum BfMachineType
|
|
|
|
{
|
2019-10-17 06:30:17 -07:00
|
|
|
BfMachineType_Unknown,
|
2019-08-23 11:56:54 -07:00
|
|
|
BfMachineType_x86,
|
2019-10-17 06:30:17 -07:00
|
|
|
BfMachineType_x64,
|
2019-10-23 07:12:36 -07:00
|
|
|
BfMachineType_ARM,
|
2020-08-06 09:24:37 -07:00
|
|
|
BfMachineType_AArch64,
|
|
|
|
BfMachineType_Wasm32,
|
|
|
|
BfMachineType_Wasm64,
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
enum BfToolsetType
|
|
|
|
{
|
|
|
|
BfToolsetType_GNU,
|
|
|
|
BfToolsetType_Microsoft,
|
|
|
|
BfToolsetType_LLVM
|
|
|
|
};
|
|
|
|
|
|
|
|
enum BfSIMDSetting
|
|
|
|
{
|
|
|
|
BfSIMDSetting_None,
|
|
|
|
BfSIMDSetting_MMX,
|
|
|
|
BfSIMDSetting_SSE,
|
|
|
|
BfSIMDSetting_SSE2,
|
|
|
|
BfSIMDSetting_SSE3,
|
|
|
|
BfSIMDSetting_SSE4,
|
|
|
|
BfSIMDSetting_SSE41,
|
|
|
|
BfSIMDSetting_AVX,
|
|
|
|
BfSIMDSetting_AVX2,
|
|
|
|
};
|
|
|
|
|
2019-10-11 05:58:08 -07:00
|
|
|
enum BfAsmKind
|
|
|
|
{
|
|
|
|
BfAsmKind_None,
|
|
|
|
BfAsmKind_ATT,
|
|
|
|
BfAsmKind_Intel,
|
|
|
|
};
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
enum BfOptLevel
|
|
|
|
{
|
|
|
|
BfOptLevel_NotSet = -1,
|
|
|
|
|
|
|
|
BfOptLevel_O0 = 0,
|
|
|
|
BfOptLevel_O1,
|
|
|
|
BfOptLevel_O2,
|
|
|
|
BfOptLevel_O3,
|
|
|
|
BfOptLevel_Og,
|
|
|
|
BfOptLevel_OgPlus
|
|
|
|
};
|
|
|
|
|
|
|
|
enum BfLTOType
|
|
|
|
{
|
|
|
|
BfLTOType_None = 0,
|
2024-05-05 12:26:21 -04:00
|
|
|
BfLTOType_Thin = 1,
|
|
|
|
BfLTOType_Fat = 2
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
enum BfCFLAAType
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
BfCFLAAType_None,
|
|
|
|
BfCFLAAType_Steensgaard,
|
|
|
|
BfCFLAAType_Andersen,
|
|
|
|
BfCFLAAType_Both
|
|
|
|
};
|
|
|
|
|
2019-10-23 07:12:36 -07:00
|
|
|
enum BfRelocType
|
|
|
|
{
|
|
|
|
BfRelocType_NotSet,
|
2022-07-26 13:27:03 -04:00
|
|
|
BfRelocType_Static,
|
|
|
|
BfRelocType_PIC,
|
2019-10-23 07:12:36 -07:00
|
|
|
BfRelocType_DynamicNoPIC,
|
|
|
|
BfRelocType_ROPI,
|
2022-07-26 13:27:03 -04:00
|
|
|
BfRelocType_RWPI,
|
2019-10-23 07:12:36 -07:00
|
|
|
BfRelocType_ROPI_RWPI
|
|
|
|
};
|
|
|
|
|
|
|
|
enum BfPICLevel
|
|
|
|
{
|
|
|
|
BfPICLevel_NotSet,
|
|
|
|
BfPICLevel_Not,
|
2022-07-26 13:27:03 -04:00
|
|
|
BfPICLevel_Small,
|
2019-10-23 07:12:36 -07:00
|
|
|
BfPICLevel_Big
|
|
|
|
};
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
struct BfCodeGenOptions
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mIsHotCompile;
|
|
|
|
|
|
|
|
bool mWriteObj;
|
2019-10-29 04:56:42 -07:00
|
|
|
bool mWriteBitcode;
|
2019-10-11 05:58:08 -07:00
|
|
|
BfAsmKind mAsmKind;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mWriteToLib;
|
2022-07-26 13:27:03 -04:00
|
|
|
bool mWriteLLVMIR;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
int16 mVirtualMethodOfs;
|
|
|
|
int16 mDynSlotOfs;
|
|
|
|
|
2019-10-23 07:12:36 -07:00
|
|
|
BfRelocType mRelocType;
|
|
|
|
BfPICLevel mPICLevel;
|
2022-07-26 13:27:03 -04:00
|
|
|
BfSIMDSetting mSIMDSetting;
|
2019-08-23 11:56:54 -07:00
|
|
|
BfOptLevel mOptLevel;
|
|
|
|
BfLTOType mLTOType;
|
|
|
|
int mSizeLevel;
|
|
|
|
BfCFLAAType mUseCFLAA;
|
|
|
|
bool mUseNewSROA;
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mDisableTailCalls;
|
|
|
|
bool mDisableUnitAtATime;
|
|
|
|
bool mDisableUnrollLoops;
|
|
|
|
bool mBBVectorize;
|
|
|
|
bool mSLPVectorize;
|
|
|
|
bool mLoopVectorize;
|
|
|
|
bool mRerollLoops;
|
|
|
|
bool mLoadCombine;
|
|
|
|
bool mDisableGVNLoadPRE;
|
|
|
|
bool mVerifyInput;
|
|
|
|
bool mVerifyOutput;
|
|
|
|
bool mStripDebug;
|
|
|
|
bool mMergeFunctions;
|
|
|
|
bool mEnableMLSM;
|
|
|
|
bool mRunSLPAfterLoopVectorization;
|
|
|
|
bool mUseGVNAfterVectorization;
|
|
|
|
bool mEnableLoopInterchange;
|
|
|
|
bool mEnableLoopLoadElim;
|
2022-07-26 13:27:03 -04:00
|
|
|
bool mExtraVectorizerPasses;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mEnableEarlyCSEMemSSA;
|
|
|
|
bool mEnableGVNHoist;
|
|
|
|
bool mEnableGVNSink;
|
|
|
|
bool mDisableLibCallsShrinkWrap;
|
|
|
|
bool mExpensiveCombines;
|
|
|
|
bool mEnableSimpleLoopUnswitch;
|
|
|
|
bool mDivergentTarget;
|
|
|
|
bool mNewGVN;
|
|
|
|
bool mRunPartialInlining;
|
|
|
|
bool mUseLoopVersioningLICM;
|
|
|
|
bool mEnableUnrollAndJam;
|
|
|
|
bool mEnableHotColdSplit;
|
|
|
|
|
|
|
|
Val128 mHash;
|
|
|
|
|
|
|
|
BfCodeGenOptions()
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
|
|
|
mIsHotCompile = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
mWriteObj = true;
|
2019-10-29 04:56:42 -07:00
|
|
|
mWriteBitcode = false;
|
2019-10-11 05:58:08 -07:00
|
|
|
mAsmKind = BfAsmKind_None;
|
2019-08-23 11:56:54 -07:00
|
|
|
mWriteToLib = false;
|
|
|
|
mWriteLLVMIR = false;
|
|
|
|
mVirtualMethodOfs = 0;
|
|
|
|
mDynSlotOfs = 0;
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-10-23 07:12:36 -07:00
|
|
|
mRelocType = BfRelocType_NotSet;
|
|
|
|
mPICLevel = BfPICLevel_NotSet;
|
2019-08-23 11:56:54 -07:00
|
|
|
mSIMDSetting = BfSIMDSetting_None;
|
|
|
|
mOptLevel = BfOptLevel_O0;
|
|
|
|
mLTOType = BfLTOType_None;
|
|
|
|
mSizeLevel = 0;
|
|
|
|
mUseCFLAA = BfCFLAAType_None;
|
|
|
|
mUseNewSROA = false;
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
mDisableTailCalls = false;
|
|
|
|
mDisableUnitAtATime = false;
|
|
|
|
mDisableUnrollLoops = false;
|
|
|
|
mBBVectorize = false;
|
|
|
|
mSLPVectorize = false;
|
|
|
|
mLoopVectorize = false;
|
|
|
|
mRerollLoops = false;
|
|
|
|
mLoadCombine = false;
|
|
|
|
mDisableGVNLoadPRE = false;
|
|
|
|
mVerifyInput = false;
|
|
|
|
mVerifyOutput = false;
|
|
|
|
mStripDebug = false;
|
|
|
|
mMergeFunctions = false;
|
|
|
|
mEnableMLSM = false;
|
|
|
|
mRunSLPAfterLoopVectorization = false;
|
|
|
|
mUseGVNAfterVectorization = false;
|
|
|
|
mEnableLoopInterchange = false;
|
|
|
|
mEnableLoopLoadElim = true;
|
|
|
|
mExtraVectorizerPasses = false;
|
|
|
|
mEnableEarlyCSEMemSSA = true;
|
|
|
|
mEnableGVNHoist = false;
|
|
|
|
mEnableGVNSink = false;
|
|
|
|
mDisableLibCallsShrinkWrap = false;
|
|
|
|
mExpensiveCombines = false;
|
|
|
|
mEnableSimpleLoopUnswitch = false;
|
|
|
|
mDivergentTarget = false;
|
|
|
|
mNewGVN = false;
|
|
|
|
mRunPartialInlining = false;
|
|
|
|
mUseLoopVersioningLICM = false;
|
|
|
|
mEnableUnrollAndJam = false;
|
|
|
|
mEnableHotColdSplit = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GenerateHash()
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
HashContext hashCtx;
|
|
|
|
|
|
|
|
hashCtx.Mixin(mWriteObj);
|
2020-04-16 00:14:25 -07:00
|
|
|
hashCtx.Mixin(mWriteBitcode);
|
|
|
|
hashCtx.Mixin(mAsmKind);
|
2019-08-23 11:56:54 -07:00
|
|
|
hashCtx.Mixin(mWriteToLib);
|
|
|
|
hashCtx.Mixin(mWriteLLVMIR);
|
|
|
|
hashCtx.Mixin(mVirtualMethodOfs);
|
|
|
|
hashCtx.Mixin(mDynSlotOfs);
|
|
|
|
|
2019-10-23 07:12:36 -07:00
|
|
|
hashCtx.Mixin(mRelocType);
|
|
|
|
hashCtx.Mixin(mPICLevel);
|
2019-08-23 11:56:54 -07:00
|
|
|
hashCtx.Mixin(mSIMDSetting);
|
|
|
|
hashCtx.Mixin(mOptLevel);
|
|
|
|
hashCtx.Mixin(mLTOType);
|
|
|
|
hashCtx.Mixin(mSizeLevel);
|
|
|
|
hashCtx.Mixin(mUseCFLAA);
|
|
|
|
hashCtx.Mixin(mUseNewSROA);
|
|
|
|
|
|
|
|
hashCtx.Mixin(mDisableTailCalls);
|
|
|
|
hashCtx.Mixin(mDisableUnitAtATime);
|
|
|
|
hashCtx.Mixin(mDisableUnrollLoops);
|
|
|
|
hashCtx.Mixin(mBBVectorize);
|
|
|
|
hashCtx.Mixin(mSLPVectorize);
|
|
|
|
hashCtx.Mixin(mLoopVectorize);
|
|
|
|
hashCtx.Mixin(mRerollLoops);
|
|
|
|
hashCtx.Mixin(mLoadCombine);
|
|
|
|
hashCtx.Mixin(mDisableGVNLoadPRE);
|
|
|
|
hashCtx.Mixin(mVerifyInput);
|
|
|
|
hashCtx.Mixin(mVerifyOutput);
|
|
|
|
hashCtx.Mixin(mStripDebug);
|
|
|
|
hashCtx.Mixin(mMergeFunctions);
|
|
|
|
hashCtx.Mixin(mEnableMLSM);
|
|
|
|
hashCtx.Mixin(mRunSLPAfterLoopVectorization);
|
|
|
|
hashCtx.Mixin(mUseGVNAfterVectorization);
|
|
|
|
hashCtx.Mixin(mEnableLoopInterchange);
|
|
|
|
hashCtx.Mixin(mEnableLoopLoadElim);
|
|
|
|
hashCtx.Mixin(mExtraVectorizerPasses);
|
|
|
|
|
|
|
|
mHash = hashCtx.Finish128();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
enum BfParamKind : uint8
|
|
|
|
{
|
2020-09-11 10:33:16 -07:00
|
|
|
BfParamKind_Normal,
|
|
|
|
BfParamKind_ExplicitThis,
|
2019-08-23 11:56:54 -07:00
|
|
|
BfParamKind_Params,
|
|
|
|
BfParamKind_DelegateParam,
|
|
|
|
BfParamKind_ImplicitCapture,
|
|
|
|
BfParamKind_AppendIdx,
|
2020-02-11 07:34:47 -08:00
|
|
|
BfParamKind_VarArgs
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
2022-06-24 06:45:35 -07:00
|
|
|
enum BfShow : uint8
|
|
|
|
{
|
|
|
|
BfShow_Show,
|
|
|
|
BfShow_HideIndirect,
|
|
|
|
BfShow_Hide
|
|
|
|
};
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
class BfParameterDef
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
String mName;
|
2022-07-26 13:27:03 -04:00
|
|
|
BfTypeReference* mTypeRef;
|
2019-08-23 11:56:54 -07:00
|
|
|
BfParameterDeclaration* mParamDeclaration;
|
|
|
|
int mMethodGenericParamIdx;
|
|
|
|
BfParamKind mParamKind;
|
2021-11-29 08:38:42 -08:00
|
|
|
uint8 mNamePrefixCount; // Number of @'s
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
BfParameterDef()
|
|
|
|
{
|
|
|
|
mTypeRef = NULL;
|
|
|
|
mMethodGenericParamIdx = -1;
|
|
|
|
mParamKind = BfParamKind_Normal;
|
2022-07-26 13:27:03 -04:00
|
|
|
mParamDeclaration = NULL;
|
2021-11-29 08:38:42 -08:00
|
|
|
mNamePrefixCount = 0;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
2021-11-29 08:38:42 -08:00
|
|
|
void SetName(BfAstNode* nameNode);
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class BfMemberDef
|
|
|
|
{
|
|
|
|
public:
|
2020-10-12 10:12:18 -07:00
|
|
|
#ifdef _DEBUG
|
|
|
|
StringT<48> mName;
|
|
|
|
#else
|
2019-08-23 11:56:54 -07:00
|
|
|
String mName;
|
2020-10-12 10:12:18 -07:00
|
|
|
#endif
|
2019-08-23 11:56:54 -07:00
|
|
|
BfTypeDef* mDeclaringType;
|
|
|
|
BfProtection mProtection;
|
2021-11-29 08:38:42 -08:00
|
|
|
uint8 mNamePrefixCount; // Number of @'s
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mIsStatic;
|
2022-06-24 06:45:35 -07:00
|
|
|
BfShow mShow;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mIsReadOnly;
|
2022-07-26 13:27:03 -04:00
|
|
|
bool mHasMultiDefs;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
BfMemberDef()
|
|
|
|
{
|
|
|
|
mDeclaringType = NULL;
|
|
|
|
mProtection = BfProtection_Public;
|
2021-11-29 08:38:42 -08:00
|
|
|
mNamePrefixCount = 0;
|
2019-08-23 11:56:54 -07:00
|
|
|
mIsStatic = false;
|
2022-06-24 06:45:35 -07:00
|
|
|
mShow = BfShow_Show;
|
2019-08-23 11:56:54 -07:00
|
|
|
mIsReadOnly = false;
|
|
|
|
mHasMultiDefs = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~BfMemberDef()
|
|
|
|
{
|
|
|
|
}
|
2021-11-29 08:38:42 -08:00
|
|
|
|
|
|
|
void SetName(BfAstNode* nameNode);
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class BfFieldDef : public BfMemberDef
|
|
|
|
{
|
|
|
|
public:
|
2022-07-26 13:27:03 -04:00
|
|
|
int mIdx;
|
|
|
|
bool mIsConst; // Note: Consts are also all considered Static
|
2022-04-16 16:43:21 -07:00
|
|
|
BfTypeReference* mTypeRef;
|
2022-02-19 07:38:05 -05:00
|
|
|
BfProtection mUsingProtection;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mIsInline;
|
|
|
|
bool mIsVolatile;
|
2022-07-26 13:27:03 -04:00
|
|
|
bool mIsExtern;
|
2022-06-27 10:55:31 -07:00
|
|
|
bool mIsAppend;
|
2022-07-26 13:27:03 -04:00
|
|
|
bool mIsProperty;
|
2022-04-16 16:43:21 -07:00
|
|
|
BfAstNode* mFieldDeclaration;
|
2019-08-23 11:56:54 -07:00
|
|
|
// It may seem that fields and properties don't need a 'mNextWithSameName', but with extensions it's possible
|
2022-07-26 13:27:03 -04:00
|
|
|
// to have two libraries which each add a field to a type with the same name
|
2019-08-23 11:56:54 -07:00
|
|
|
BfFieldDef* mNextWithSameName;
|
|
|
|
|
|
|
|
public:
|
|
|
|
BfFieldDef()
|
|
|
|
{
|
|
|
|
mIdx = 0;
|
2022-07-26 13:27:03 -04:00
|
|
|
mIsConst = false;
|
2022-04-16 16:43:21 -07:00
|
|
|
mTypeRef = NULL;
|
2022-02-19 07:38:05 -05:00
|
|
|
mUsingProtection = BfProtection_Hidden;
|
2019-08-23 11:56:54 -07:00
|
|
|
mIsInline = false;
|
|
|
|
mIsExtern = false;
|
2022-06-27 10:55:31 -07:00
|
|
|
mIsAppend = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
mIsVolatile = false;
|
2022-02-19 07:38:05 -05:00
|
|
|
mIsProperty = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
mFieldDeclaration = NULL;
|
|
|
|
mNextWithSameName = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsUnnamedTupleField()
|
|
|
|
{
|
|
|
|
return (mName[0] >= '0') && (mName[0] <= '9');
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsEnumCaseEntry()
|
|
|
|
{
|
|
|
|
return (mFieldDeclaration != NULL) && (BfNodeIsA<BfEnumEntryDeclaration>(mFieldDeclaration));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsNonConstStatic()
|
|
|
|
{
|
|
|
|
return mIsStatic && !mIsConst;
|
|
|
|
}
|
|
|
|
|
|
|
|
BfAstNode* GetRefNode()
|
|
|
|
{
|
|
|
|
if (mFieldDeclaration == NULL)
|
|
|
|
return NULL;
|
2022-04-16 16:43:21 -07:00
|
|
|
|
|
|
|
if (auto fieldDeclaration = BfNodeDynCast<BfFieldDeclaration>(mFieldDeclaration))
|
|
|
|
{
|
|
|
|
if (fieldDeclaration->mNameNode != NULL)
|
|
|
|
return fieldDeclaration->mNameNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auto paramDeclaration = BfNodeDynCast<BfParameterDeclaration>(mFieldDeclaration))
|
|
|
|
{
|
|
|
|
if (paramDeclaration->mNameNode != NULL)
|
|
|
|
return paramDeclaration->mNameNode;
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
return mFieldDeclaration;
|
|
|
|
}
|
2022-04-16 16:43:21 -07:00
|
|
|
|
|
|
|
BfFieldDeclaration* GetFieldDeclaration()
|
|
|
|
{
|
|
|
|
return BfNodeDynCast<BfFieldDeclaration>(mFieldDeclaration);
|
|
|
|
}
|
|
|
|
|
|
|
|
BfParameterDeclaration* GetParamDeclaration()
|
|
|
|
{
|
|
|
|
return BfNodeDynCast<BfParameterDeclaration>(mFieldDeclaration);
|
|
|
|
}
|
|
|
|
|
|
|
|
BfExpression* GetInitializer()
|
|
|
|
{
|
|
|
|
if (auto fieldDecl = GetFieldDeclaration())
|
|
|
|
return fieldDecl->mInitializer;
|
|
|
|
if (auto paramDecl = GetParamDeclaration())
|
|
|
|
return paramDecl->mInitializer;
|
|
|
|
return NULL;
|
|
|
|
}
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2022-04-16 16:43:21 -07:00
|
|
|
BfAstNode* GetNameNode()
|
|
|
|
{
|
|
|
|
if (auto fieldDecl = GetFieldDeclaration())
|
|
|
|
return fieldDecl->mNameNode;
|
|
|
|
if (auto paramDecl = GetParamDeclaration())
|
|
|
|
return paramDecl->mNameNode;
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class BfPropertyDef : public BfFieldDef
|
|
|
|
{
|
2022-07-26 13:27:03 -04:00
|
|
|
public:
|
|
|
|
Array<BfMethodDef*> mMethods;
|
2019-08-23 11:56:54 -07:00
|
|
|
BfPropertyDef* mNextWithSameName;
|
|
|
|
|
|
|
|
public:
|
|
|
|
BfPropertyDef()
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
mNextWithSameName = NULL;
|
2022-07-26 13:27:03 -04:00
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
|
2020-08-03 06:09:45 -07:00
|
|
|
bool IsVirtual();
|
2022-07-26 13:27:03 -04:00
|
|
|
bool HasExplicitInterface();
|
2020-08-29 11:28:11 -07:00
|
|
|
bool IsExpressionBodied();
|
2019-08-23 11:56:54 -07:00
|
|
|
BfAstNode* GetRefNode();
|
|
|
|
};
|
|
|
|
|
2019-11-17 09:28:39 -08:00
|
|
|
enum BfGenericParamFlags : uint16
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
2020-11-10 05:44:23 -08:00
|
|
|
BfGenericParamFlag_None = 0,
|
|
|
|
BfGenericParamFlag_Class = 1,
|
|
|
|
BfGenericParamFlag_Struct = 2,
|
|
|
|
BfGenericParamFlag_StructPtr = 4,
|
|
|
|
BfGenericParamFlag_Enum = 8,
|
2022-07-26 13:27:03 -04:00
|
|
|
BfGenericParamFlag_Interface = 0x10,
|
2021-01-13 09:24:15 -08:00
|
|
|
BfGenericParamFlag_Concrete = 0x20,
|
|
|
|
BfGenericParamFlag_New = 0x40,
|
|
|
|
BfGenericParamFlag_Delete = 0x80,
|
|
|
|
BfGenericParamFlag_Var = 0x100,
|
|
|
|
BfGenericParamFlag_Const = 0x200,
|
|
|
|
BfGenericParamFlag_Equals = 0x400,
|
|
|
|
BfGenericParamFlag_Equals_Op = 0x800,
|
|
|
|
BfGenericParamFlag_Equals_Type = 0x1000,
|
2021-01-15 14:28:21 -08:00
|
|
|
BfGenericParamFlag_Equals_IFace = 0x2000,
|
|
|
|
BfGenericParamFlag_ComptypeExpr = 0x4000
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
2019-11-17 09:28:39 -08:00
|
|
|
class BfConstraintDef
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
|
|
|
public:
|
2019-11-17 09:28:39 -08:00
|
|
|
BfGenericParamFlags mGenericParamFlags;
|
|
|
|
Array<BfAstNode*> mConstraints;
|
|
|
|
|
|
|
|
BfConstraintDef()
|
|
|
|
{
|
|
|
|
mGenericParamFlags = BfGenericParamFlag_None;
|
|
|
|
}
|
2020-12-31 09:56:51 -08:00
|
|
|
|
|
|
|
bool operator==(const BfConstraintDef& other) const
|
|
|
|
{
|
|
|
|
if (mGenericParamFlags != other.mGenericParamFlags)
|
|
|
|
return false;
|
|
|
|
if (mConstraints.mSize != other.mConstraints.mSize)
|
|
|
|
return false;
|
|
|
|
for (int i = 0; i < mConstraints.mSize; i++)
|
|
|
|
{
|
|
|
|
if (!mConstraints[i]->Equals(other.mConstraints[i]->ToStringView()))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const BfConstraintDef& other) const
|
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
2019-11-17 09:28:39 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class BfGenericParamDef : public BfConstraintDef
|
|
|
|
{
|
2022-07-26 13:27:03 -04:00
|
|
|
public:
|
|
|
|
String mName;
|
2020-12-31 09:56:51 -08:00
|
|
|
Array<BfIdentifierNode*> mNameNodes; // 0 is always the def name
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2020-12-31 09:56:51 -08:00
|
|
|
bool operator==(const BfGenericParamDef& other) const
|
|
|
|
{
|
|
|
|
if (mName != other.mName)
|
|
|
|
return false;
|
|
|
|
return *(BfConstraintDef*)this == *(BfConstraintDef*)&other;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const BfGenericParamDef& other) const
|
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
2019-11-17 09:28:39 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class BfExternalConstraintDef : public BfConstraintDef
|
|
|
|
{
|
|
|
|
public:
|
2022-07-26 13:27:03 -04:00
|
|
|
BfTypeReference* mTypeRef;
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// CTOR is split into two for Objects - Ctor clears and sets up VData, Ctor_Body executes ctor body code
|
|
|
|
enum BfMethodType : uint8
|
|
|
|
{
|
|
|
|
BfMethodType_Ignore,
|
2020-10-23 07:48:41 -07:00
|
|
|
BfMethodType_Normal,
|
2019-08-23 11:56:54 -07:00
|
|
|
BfMethodType_PropertyGetter,
|
|
|
|
BfMethodType_PropertySetter,
|
|
|
|
BfMethodType_CtorCalcAppend,
|
|
|
|
BfMethodType_Ctor,
|
|
|
|
BfMethodType_CtorNoBody,
|
|
|
|
BfMethodType_CtorClear,
|
2020-10-23 07:48:41 -07:00
|
|
|
BfMethodType_Init,
|
2019-08-23 11:56:54 -07:00
|
|
|
BfMethodType_Dtor,
|
|
|
|
BfMethodType_Operator,
|
2020-06-03 05:22:11 -07:00
|
|
|
BfMethodType_Mixin,
|
|
|
|
BfMethodType_Extension
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
enum BfCallingConvention : uint8
|
|
|
|
{
|
|
|
|
BfCallingConvention_Unspecified,
|
|
|
|
BfCallingConvention_Cdecl,
|
|
|
|
BfCallingConvention_Stdcall,
|
2022-07-26 13:27:03 -04:00
|
|
|
BfCallingConvention_Fastcall,
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define BF_METHODNAME_MARKMEMBERS "GCMarkMembers"
|
|
|
|
#define BF_METHODNAME_MARKMEMBERS_STATIC "GCMarkStaticMembers"
|
|
|
|
#define BF_METHODNAME_FIND_TLS_MEMBERS "GCFindTLSMembers"
|
|
|
|
#define BF_METHODNAME_DYNAMICCAST "DynamicCastToTypeId"
|
|
|
|
#define BF_METHODNAME_DYNAMICCAST_INTERFACE "DynamicCastToInterface"
|
|
|
|
#define BF_METHODNAME_CALCAPPEND "this$calcAppend"
|
|
|
|
#define BF_METHODNAME_ENUM_HASFLAG "HasFlag"
|
|
|
|
#define BF_METHODNAME_ENUM_GETUNDERLYING "get__Underlying"
|
|
|
|
#define BF_METHODNAME_ENUM_GETUNDERLYINGREF "get__UnderlyingRef"
|
|
|
|
#define BF_METHODNAME_EQUALS "Equals"
|
|
|
|
#define BF_METHODNAME_INVOKE "Invoke"
|
|
|
|
#define BF_METHODNAME_TO_STRING "ToString"
|
|
|
|
#define BF_METHODNAME_DEFAULT_EQUALS "__Equals"
|
2020-06-17 05:13:53 -07:00
|
|
|
#define BF_METHODNAME_DEFAULT_STRICT_EQUALS "__StrictEquals"
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
enum BfOptimize : int8
|
|
|
|
{
|
|
|
|
BfOptimize_Default,
|
|
|
|
BfOptimize_Unoptimized,
|
|
|
|
BfOptimize_Optimized
|
|
|
|
};
|
|
|
|
|
|
|
|
enum BfImportKind : int8
|
|
|
|
{
|
|
|
|
BfImportKind_None,
|
2019-12-21 05:44:01 -08:00
|
|
|
BfImportKind_Import_Unknown,
|
|
|
|
BfImportKind_Import_Dynamic,
|
|
|
|
BfImportKind_Import_Static,
|
2019-08-27 08:04:41 -07:00
|
|
|
BfImportKind_Export
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
2019-11-17 09:28:39 -08:00
|
|
|
enum BfCommutableKind : int8
|
|
|
|
{
|
|
|
|
BfCommutableKind_None,
|
2020-12-03 07:50:36 -08:00
|
|
|
BfCommutableKind_Operator,
|
2019-11-17 09:28:39 -08:00
|
|
|
BfCommutableKind_Forward,
|
|
|
|
BfCommutableKind_Reverse,
|
|
|
|
};
|
|
|
|
|
2021-01-08 16:21:03 -08:00
|
|
|
enum BfComptimeFlags : int8
|
|
|
|
{
|
|
|
|
BfComptimeFlag_None,
|
|
|
|
BfComptimeFlag_Comptime = 1,
|
|
|
|
BfComptimeFlag_OnlyFromComptime = 2,
|
|
|
|
BfComptimeFlag_ConstEval = 4
|
|
|
|
};
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
class BfMethodDef : public BfMemberDef
|
|
|
|
{
|
2022-07-26 13:27:03 -04:00
|
|
|
public:
|
|
|
|
BfAstNode* mMethodDeclaration;
|
|
|
|
BfAstNode* mBody;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
BfTypeReference* mExplicitInterface;
|
|
|
|
BfTypeReference* mReturnTypeRef;
|
|
|
|
Array<BfParameterDef*> mParams;
|
|
|
|
Array<BfGenericParamDef*> mGenericParams;
|
2019-11-17 09:28:39 -08:00
|
|
|
Array<BfExternalConstraintDef> mExternalConstraints;
|
2022-06-24 18:41:54 -07:00
|
|
|
Dictionary<StringView, int>* mParamNameMap;
|
2019-08-23 11:56:54 -07:00
|
|
|
BfMethodDef* mNextWithSameName;
|
|
|
|
Val128 mFullHash;
|
|
|
|
|
|
|
|
int mIdx;
|
|
|
|
int mPropertyIdx;
|
|
|
|
BfMethodType mMethodType;
|
|
|
|
bool mIsLocalMethod;
|
|
|
|
bool mIsVirtual;
|
|
|
|
bool mIsOverride;
|
|
|
|
bool mIsAbstract;
|
|
|
|
bool mIsConcrete;
|
|
|
|
bool mIsPartial;
|
|
|
|
bool mIsNew;
|
|
|
|
bool mCodeChanged;
|
|
|
|
bool mWantsBody;
|
|
|
|
bool mCLink;
|
|
|
|
bool mHasAppend;
|
2022-07-26 13:27:03 -04:00
|
|
|
bool mAlwaysInline;
|
2020-10-07 11:07:10 -07:00
|
|
|
bool mIsNoReturn;
|
|
|
|
bool mIsMutating;
|
|
|
|
bool mIsNoSplat;
|
|
|
|
bool mIsNoReflect;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mIsSkipCall;
|
2021-01-08 16:21:03 -08:00
|
|
|
bool mHasComptime;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mIsOperator;
|
2022-07-26 13:27:03 -04:00
|
|
|
bool mIsExtern;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mIsNoDiscard;
|
2020-09-11 10:33:16 -07:00
|
|
|
bool mHasExplicitThis;
|
2021-01-11 09:41:43 -08:00
|
|
|
bool mAddedAfterEmit;
|
2019-11-17 09:28:39 -08:00
|
|
|
BfCommutableKind mCommutableKind;
|
2019-08-23 11:56:54 -07:00
|
|
|
BfCheckedKind mCheckedKind;
|
2022-07-26 13:27:03 -04:00
|
|
|
BfImportKind mImportKind;
|
|
|
|
BfCallingConvention mCallingConvention;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
BfMethodDef()
|
|
|
|
{
|
|
|
|
mIdx = -1;
|
|
|
|
mPropertyIdx = -1;
|
|
|
|
mIsLocalMethod = false;
|
|
|
|
mIsVirtual = false;
|
|
|
|
mIsOverride = false;
|
|
|
|
mIsAbstract = false;
|
|
|
|
mIsConcrete = false;
|
|
|
|
mIsStatic = false;
|
|
|
|
mIsNew = false;
|
|
|
|
mIsPartial = false;
|
2022-07-26 13:27:03 -04:00
|
|
|
mCLink = false;
|
2020-10-07 11:07:10 -07:00
|
|
|
mIsNoReturn = false;
|
|
|
|
mIsMutating = false;
|
|
|
|
mIsNoSplat = false;
|
|
|
|
mIsNoReflect = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
mIsSkipCall = false;
|
2021-01-08 16:21:03 -08:00
|
|
|
mHasComptime = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
mIsOperator = false;
|
|
|
|
mIsExtern = false;
|
|
|
|
mIsNoDiscard = false;
|
2020-09-11 10:33:16 -07:00
|
|
|
mHasExplicitThis = false;
|
2021-01-11 09:41:43 -08:00
|
|
|
mAddedAfterEmit = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
mBody = NULL;
|
|
|
|
mExplicitInterface = NULL;
|
2022-06-24 18:41:54 -07:00
|
|
|
mReturnTypeRef = NULL;
|
|
|
|
mMethodDeclaration = NULL;
|
2019-08-23 11:56:54 -07:00
|
|
|
mCodeChanged = false;
|
|
|
|
mWantsBody = true;
|
2019-11-17 09:28:39 -08:00
|
|
|
mCommutableKind = BfCommutableKind_None;
|
2019-08-23 11:56:54 -07:00
|
|
|
mCheckedKind = BfCheckedKind_NotSet;
|
|
|
|
mImportKind = BfImportKind_None;
|
|
|
|
mMethodType = BfMethodType_Normal;
|
|
|
|
mCallingConvention = BfCallingConvention_Unspecified;
|
|
|
|
mHasAppend = false;
|
2022-06-24 18:41:54 -07:00
|
|
|
mAlwaysInline = false;
|
|
|
|
mParamNameMap = NULL;
|
2019-08-23 11:56:54 -07:00
|
|
|
mNextWithSameName = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~BfMethodDef();
|
|
|
|
|
2019-12-21 05:44:01 -08:00
|
|
|
static BfImportKind GetImportKindFromPath(const StringImpl& filePath);
|
2020-10-07 11:07:10 -07:00
|
|
|
bool HasNoThisSplat() { return mIsMutating || mIsNoSplat; }
|
2019-08-23 11:56:54 -07:00
|
|
|
void Reset();
|
|
|
|
void FreeMembers();
|
2022-07-26 13:27:03 -04:00
|
|
|
BfMethodDeclaration* GetMethodDeclaration();
|
2019-08-23 11:56:54 -07:00
|
|
|
BfPropertyMethodDeclaration* GetPropertyMethodDeclaration();
|
|
|
|
BfPropertyDeclaration* GetPropertyDeclaration();
|
|
|
|
BfAstNode* GetRefNode();
|
2022-07-26 13:27:03 -04:00
|
|
|
BfTokenNode* GetMutNode();
|
2019-08-23 11:56:54 -07:00
|
|
|
bool HasBody();
|
2022-07-26 13:27:03 -04:00
|
|
|
bool IsEmptyPartial();
|
2019-08-23 11:56:54 -07:00
|
|
|
bool IsDefaultCtor();
|
2021-11-28 09:42:22 -08:00
|
|
|
bool IsCtorOrInit();
|
2022-07-26 13:27:03 -04:00
|
|
|
String ToString();
|
2023-10-10 13:20:35 -07:00
|
|
|
String GetReflectName();
|
2020-01-15 08:31:34 -08:00
|
|
|
int GetExplicitParamCount();
|
2022-06-24 18:41:54 -07:00
|
|
|
void BuildParamNameMap();
|
2023-10-10 13:20:35 -07:00
|
|
|
bool CanReflect();
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class BfOperatorDef : public BfMethodDef
|
|
|
|
{
|
|
|
|
public:
|
2022-07-26 13:27:03 -04:00
|
|
|
BfOperatorDeclaration* mOperatorDeclaration;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
BfOperatorDef()
|
|
|
|
{
|
|
|
|
mOperatorDeclaration = NULL;
|
|
|
|
}
|
2022-01-17 17:10:37 -05:00
|
|
|
|
|
|
|
bool IsExplicit()
|
|
|
|
{
|
|
|
|
if (mOperatorDeclaration->mExplicitToken != NULL)
|
|
|
|
return mOperatorDeclaration->mExplicitToken->mToken == BfToken_Explicit;
|
2022-01-19 14:34:37 -05:00
|
|
|
if (mOperatorDeclaration->mOpTypeToken != NULL)
|
|
|
|
return mOperatorDeclaration->mOpTypeToken->mToken == BfToken_Explicit;
|
2022-01-17 17:10:37 -05:00
|
|
|
return false;
|
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct BfTypeDefLookupContext
|
|
|
|
{
|
|
|
|
public:
|
2022-07-26 13:27:03 -04:00
|
|
|
int mBestPri;
|
2019-08-23 11:56:54 -07:00
|
|
|
BfTypeDef* mBestTypeDef;
|
|
|
|
BfTypeDef* mAmbiguousTypeDef;
|
2023-03-14 07:01:44 -07:00
|
|
|
Array<BfProject*>* mCheckProjects;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
BfTypeDefLookupContext()
|
|
|
|
{
|
|
|
|
mBestPri = (int)0x80000000;
|
|
|
|
mBestTypeDef = NULL;
|
2022-07-26 13:27:03 -04:00
|
|
|
mAmbiguousTypeDef = NULL;
|
2023-03-14 07:01:44 -07:00
|
|
|
mCheckProjects = NULL;
|
2022-07-26 13:27:03 -04:00
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
bool HasValidMatch()
|
|
|
|
{
|
|
|
|
return (mBestPri >= 0) && (mBestTypeDef != NULL);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BfMemberSetEntry
|
|
|
|
{
|
|
|
|
BfMemberDef* mMemberDef;
|
|
|
|
|
|
|
|
BfMemberSetEntry(BfMemberDef* memberDef)
|
|
|
|
{
|
|
|
|
mMemberDef = memberDef;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const BfMemberSetEntry& other) const
|
|
|
|
{
|
|
|
|
return mMemberDef->mName == other.mMemberDef->mName;
|
|
|
|
}
|
|
|
|
|
2020-01-23 13:07:43 -08:00
|
|
|
bool operator==(const StringImpl& other) const
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
|
|
|
return mMemberDef->mName == other;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-12-28 13:10:52 -05:00
|
|
|
class BfTypeDefMemberSet : public HashSet<BfMemberSetEntry>
|
|
|
|
{
|
2022-07-26 13:27:03 -04:00
|
|
|
public:
|
2021-12-28 13:10:52 -05:00
|
|
|
int mSourceSize;
|
|
|
|
|
|
|
|
public:
|
|
|
|
BfTypeDefMemberSet()
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2021-12-28 13:10:52 -05:00
|
|
|
mSourceSize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
HashSet<BfMemberSetEntry>::Clear();
|
|
|
|
mSourceSize = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-07-26 13:27:03 -04:00
|
|
|
// For partial classes, the first entry in the map will contain the combined data
|
2019-08-23 11:56:54 -07:00
|
|
|
class BfTypeDef
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum DefState
|
|
|
|
{
|
|
|
|
DefState_New,
|
|
|
|
DefState_Defined,
|
|
|
|
DefState_CompositeWithPartials, // Temporary condition
|
|
|
|
DefState_AwaitingNewVersion,
|
|
|
|
DefState_Signature_Changed,
|
|
|
|
DefState_InlinedInternals_Changed, // Code within methods, including inlined methods, changed
|
|
|
|
DefState_Internals_Changed, // Only code within a non-inlined methods changed
|
2020-12-31 11:31:19 -08:00
|
|
|
DefState_Refresh,
|
2021-10-28 08:05:14 -07:00
|
|
|
DefState_Deleted,
|
|
|
|
DefState_Emitted,
|
|
|
|
DefState_EmittedDirty
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
BfTypeDef* mNextRevision;
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
BfSystem* mSystem;
|
|
|
|
BfProject* mProject;
|
|
|
|
BfTypeDeclaration* mTypeDeclaration;
|
2022-07-26 13:27:03 -04:00
|
|
|
BfSource* mSource;
|
|
|
|
DefState mDefState;
|
2019-08-23 11:56:54 -07:00
|
|
|
Val128 mSignatureHash; // Data, methods, etc
|
2022-07-26 13:27:03 -04:00
|
|
|
Val128 mFullHash;
|
2019-08-23 11:56:54 -07:00
|
|
|
Val128 mInlineHash;
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2021-10-28 08:05:14 -07:00
|
|
|
BfTypeDef* mEmitParent;
|
2019-08-23 11:56:54 -07:00
|
|
|
BfTypeDef* mOuterType;
|
|
|
|
BfAtomComposite mNamespace;
|
|
|
|
BfAtom* mName;
|
|
|
|
BfAtom* mNameEx; // Contains extensions like `1 for param counts
|
|
|
|
BfAtomComposite mFullName;
|
|
|
|
BfAtomComposite mFullNameEx;
|
|
|
|
BfProtection mProtection;
|
|
|
|
Array<BfAtomComposite> mNamespaceSearch;
|
|
|
|
Array<BfTypeReference*> mStaticSearch;
|
2020-10-14 11:33:41 -07:00
|
|
|
Array<BfTypeReference*> mInternalAccessSet;
|
2022-02-19 07:38:05 -05:00
|
|
|
Array<BfFieldDef*> mFields;
|
2019-08-23 11:56:54 -07:00
|
|
|
Array<BfPropertyDef*> mProperties;
|
|
|
|
Array<BfMethodDef*> mMethods;
|
2021-12-28 13:10:52 -05:00
|
|
|
BfTypeDefMemberSet mMethodSet;
|
|
|
|
BfTypeDefMemberSet mFieldSet;
|
|
|
|
BfTypeDefMemberSet mPropertySet;
|
2022-02-19 07:38:05 -05:00
|
|
|
Array<BfOperatorDef*> mOperators;
|
2022-07-26 13:27:03 -04:00
|
|
|
Array<BfGenericParamDef*> mGenericParamDefs;
|
2020-08-05 05:34:32 -07:00
|
|
|
Array<BfExternalConstraintDef> mExternalConstraints;
|
2022-07-26 13:27:03 -04:00
|
|
|
Array<BfTypeReference*> mBaseTypes;
|
|
|
|
Array<BfTypeDef*> mNestedTypes;
|
2019-08-23 11:56:54 -07:00
|
|
|
Array<BfDirectStrTypeReference*> mDirectAllocNodes;
|
2022-07-26 13:27:03 -04:00
|
|
|
Array<BfTypeDef*> mPartials; // Only valid for mIsCombinedPartial
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
int mHash;
|
|
|
|
int mPartialIdx;
|
|
|
|
int mNestDepth;
|
|
|
|
int mDupDetectedRevision; // Error state
|
2022-06-24 06:45:35 -07:00
|
|
|
BfTypeCode mTypeCode;
|
|
|
|
BfShow mShow;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mIsAlwaysInclude;
|
|
|
|
bool mIsNoDiscard;
|
|
|
|
bool mIsPartial;
|
|
|
|
bool mIsExplicitPartial;
|
|
|
|
bool mPartialUsed;
|
|
|
|
bool mIsCombinedPartial;
|
|
|
|
bool mIsDelegate;
|
|
|
|
bool mIsFunction;
|
|
|
|
bool mIsClosure;
|
2022-07-26 13:27:03 -04:00
|
|
|
bool mIsAbstract;
|
|
|
|
bool mIsStatic;
|
2021-01-08 16:21:03 -08:00
|
|
|
bool mHasCEOnCompile;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mHasAppendCtor;
|
2020-10-22 11:33:13 -07:00
|
|
|
bool mHasCtorNoBody;
|
2020-06-03 05:22:11 -07:00
|
|
|
bool mHasExtensionMethods;
|
2022-07-26 13:27:03 -04:00
|
|
|
bool mHasOverrideMethods;
|
2022-02-19 07:38:05 -05:00
|
|
|
bool mHasUsingFields;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mIsOpaque;
|
2020-12-25 05:22:02 -08:00
|
|
|
bool mIsNextRevision;
|
2022-07-26 13:27:03 -04:00
|
|
|
bool mInDeleteQueue;
|
2021-02-25 10:14:22 -08:00
|
|
|
bool mForceUseNextRevision;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
BfTypeDef()
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
~BfTypeDef();
|
|
|
|
|
|
|
|
void Init()
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
mName = NULL;
|
|
|
|
mNameEx = NULL;
|
|
|
|
mSystem = NULL;
|
|
|
|
mProject = NULL;
|
2022-06-24 06:45:35 -07:00
|
|
|
mTypeCode = BfTypeCode_None;
|
|
|
|
mShow = BfShow_Show;
|
2019-08-23 11:56:54 -07:00
|
|
|
mIsAlwaysInclude = false;
|
|
|
|
mIsNoDiscard = false;
|
|
|
|
mIsExplicitPartial = false;
|
|
|
|
mIsPartial = false;
|
|
|
|
mIsCombinedPartial = false;
|
|
|
|
mTypeDeclaration = NULL;
|
2022-07-26 13:27:03 -04:00
|
|
|
mSource = NULL;
|
2019-08-23 11:56:54 -07:00
|
|
|
mDefState = DefState_New;
|
2022-07-26 13:27:03 -04:00
|
|
|
mHash = 0;
|
2019-08-23 11:56:54 -07:00
|
|
|
mPartialIdx = -1;
|
2022-07-26 13:27:03 -04:00
|
|
|
mIsAbstract = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
mIsDelegate = false;
|
|
|
|
mIsFunction = false;
|
|
|
|
mIsClosure = false;
|
|
|
|
mIsStatic = false;
|
2021-01-08 16:21:03 -08:00
|
|
|
mHasCEOnCompile = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
mHasAppendCtor = false;
|
2020-10-22 11:33:13 -07:00
|
|
|
mHasCtorNoBody = false;
|
2020-06-03 05:22:11 -07:00
|
|
|
mHasExtensionMethods = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
mHasOverrideMethods = false;
|
2022-02-19 07:38:05 -05:00
|
|
|
mHasUsingFields = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
mIsOpaque = false;
|
|
|
|
mPartialUsed = false;
|
|
|
|
mIsNextRevision = false;
|
2022-07-26 13:27:03 -04:00
|
|
|
mInDeleteQueue = false;
|
2021-02-25 10:14:22 -08:00
|
|
|
mForceUseNextRevision = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
mDupDetectedRevision = -1;
|
|
|
|
mNestDepth = 0;
|
2021-10-28 08:05:14 -07:00
|
|
|
mEmitParent = NULL;
|
2019-08-23 11:56:54 -07:00
|
|
|
mOuterType = NULL;
|
2022-07-26 13:27:03 -04:00
|
|
|
mTypeDeclaration = NULL;
|
2022-02-19 07:38:05 -05:00
|
|
|
mNextRevision = NULL;
|
2022-07-26 13:27:03 -04:00
|
|
|
mProtection = BfProtection_Public;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
BfSource* GetLastSource();
|
2022-07-26 13:27:03 -04:00
|
|
|
bool IsGlobalsContainer();
|
2019-08-23 11:56:54 -07:00
|
|
|
void Reset();
|
|
|
|
void FreeMembers();
|
|
|
|
void PopulateMemberSets();
|
2021-01-08 16:21:03 -08:00
|
|
|
void ClearMemberSets();
|
2022-07-26 13:27:03 -04:00
|
|
|
void RemoveGenericParamDef(BfGenericParamDef* genericParamDef);
|
2019-08-23 11:56:54 -07:00
|
|
|
int GetSelfGenericParamCount();
|
|
|
|
String ToString();
|
|
|
|
BfMethodDef* GetMethodByName(const StringImpl& name, int paramCount = -1);
|
2021-01-11 09:41:43 -08:00
|
|
|
BfFieldDef* GetFieldByName(const StringImpl& name);
|
2022-07-26 13:27:03 -04:00
|
|
|
bool HasAutoProperty(BfPropertyDeclaration* propertyDeclaration);
|
2022-05-25 15:03:06 -07:00
|
|
|
bool ContainsPartial(BfTypeDef* partialTypeDef);
|
2022-05-27 07:24:33 -07:00
|
|
|
bool HasParsingFailed();
|
2019-08-23 11:56:54 -07:00
|
|
|
String GetAutoPropertyName(BfPropertyDeclaration* propertyDeclaration);
|
|
|
|
BfAstNode* GetRefNode();
|
|
|
|
|
2021-10-28 08:05:14 -07:00
|
|
|
bool IsEmitted() { return mEmitParent != NULL; }
|
|
|
|
|
2022-08-25 07:46:37 -07:00
|
|
|
BfTypeDef* GetDefinition(bool getEmitRoot = false)
|
2021-10-28 08:05:14 -07:00
|
|
|
{
|
|
|
|
if (mEmitParent != NULL)
|
2022-08-25 07:46:37 -07:00
|
|
|
{
|
|
|
|
if ((getEmitRoot) && (mEmitParent->mIsCombinedPartial))
|
|
|
|
return mEmitParent->mPartials[0];
|
2021-10-28 08:05:14 -07:00
|
|
|
return mEmitParent;
|
2022-08-25 07:46:37 -07:00
|
|
|
}
|
2021-10-28 08:05:14 -07:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
BfTypeDef* GetLatest()
|
|
|
|
{
|
2021-10-28 08:05:14 -07:00
|
|
|
if (mEmitParent != NULL)
|
|
|
|
return mEmitParent->GetLatest();
|
2019-08-23 11:56:54 -07:00
|
|
|
if (mNextRevision != NULL)
|
|
|
|
return mNextRevision;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportMemory(MemReporter* memReporter);
|
|
|
|
bool NameEquals(BfTypeDef* otherTypeDef);
|
|
|
|
bool IsExtension()
|
|
|
|
{
|
|
|
|
return mTypeCode == BfTypeCode_Extension;
|
|
|
|
}
|
|
|
|
bool HasSource(BfSource* source);
|
2022-02-04 12:00:43 -05:00
|
|
|
bool HasCustomAttributes();
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct BfTypeDefMapFuncs : public MultiHashSetFuncs
|
|
|
|
{
|
|
|
|
int GetHash(BfTypeDef* typeDef)
|
|
|
|
{
|
|
|
|
return GetHash(typeDef->mFullName);
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetHash(const BfAtomComposite& name)
|
|
|
|
{
|
|
|
|
int hash = 0;
|
|
|
|
for (int i = 0; i < name.mSize; i++)
|
|
|
|
{
|
|
|
|
auto atom = name.mParts[i];
|
|
|
|
hash = ((hash ^ atom->mHash) << 5) - hash;
|
|
|
|
}
|
|
|
|
return (hash & 0x7FFFFFFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Matches(const BfAtomComposite& name, BfTypeDef* typeDef)
|
|
|
|
{
|
|
|
|
return name == typeDef->mFullName;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Matches(BfTypeDef* keyTypeDef, BfTypeDef* typeDef)
|
|
|
|
{
|
|
|
|
return keyTypeDef == typeDef;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-05-06 11:28:38 -07:00
|
|
|
class BfTypeDefMap : public MultiHashSet<BfTypeDef*, BfTypeDefMapFuncs>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct SkipEntry
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int mIndex;
|
|
|
|
int mRevision;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SkipEntry()
|
|
|
|
{
|
|
|
|
mIndex = -1;
|
2022-07-26 13:27:03 -04:00
|
|
|
mRevision = -1;
|
2022-05-06 11:28:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
SkipEntry(int index, int revision)
|
|
|
|
{
|
|
|
|
mIndex = index;
|
|
|
|
mRevision = revision;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Array<SkipEntry> mPartialSkipCache;
|
|
|
|
int mRevision;
|
|
|
|
|
|
|
|
public:
|
|
|
|
BfTypeDefMap()
|
|
|
|
{
|
|
|
|
mRevision = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Add(BfTypeDef* value)
|
|
|
|
{
|
|
|
|
MultiHashSet::Add(value);
|
|
|
|
mRevision++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddAfter(BfTypeDef* value, Entry* afterEntry)
|
|
|
|
{
|
|
|
|
MultiHashSet::AddAfter(value, afterEntry);
|
|
|
|
mRevision++;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename TKey>
|
|
|
|
bool Remove(const TKey& key)
|
|
|
|
{
|
|
|
|
bool result = MultiHashSet::Remove(key);
|
|
|
|
mRevision++;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
Iterator Erase(const Iterator& itr)
|
|
|
|
{
|
|
|
|
auto result = MultiHashSet::Erase(itr);
|
|
|
|
mRevision++;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
MultiHashSet::Clear();
|
|
|
|
mRevision++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetPartialSkipCache(int partialIdx, int mapToIdx)
|
|
|
|
{
|
|
|
|
while (partialIdx >= mPartialSkipCache.mSize)
|
|
|
|
mPartialSkipCache.Add(SkipEntry());
|
|
|
|
mPartialSkipCache[partialIdx] = SkipEntry(mapToIdx, mRevision);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
enum BfTargetType
|
|
|
|
{
|
|
|
|
BfTargetType_BeefConsoleApplication,
|
2022-07-26 13:27:03 -04:00
|
|
|
BfTargetType_BeefWindowsApplication,
|
|
|
|
BfTargetType_BeefLib,
|
2019-08-23 11:56:54 -07:00
|
|
|
BfTargetType_CustomBuild,
|
2019-10-23 07:12:36 -07:00
|
|
|
BfTargetType_BeefTest,
|
2020-09-27 22:20:26 -07:00
|
|
|
BfTargetType_C_ConsoleApplication,
|
2022-07-26 13:27:03 -04:00
|
|
|
BfTargetType_C_WindowsApplication,
|
2019-10-23 07:12:36 -07:00
|
|
|
BfTargetType_BeefApplication_StaticLib,
|
2021-06-28 09:44:47 -07:00
|
|
|
BfTargetType_BeefApplication_DynamicLib,
|
|
|
|
BfTargetType_BeefLib_StaticLib,
|
|
|
|
BfTargetType_BeefLib_DynamicLib,
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
2019-10-11 05:58:08 -07:00
|
|
|
enum BfProjectFlags
|
|
|
|
{
|
|
|
|
BfProjectFlags_None = 0,
|
|
|
|
BfProjectFlags_MergeFunctions = 1,
|
|
|
|
BfProjectFlags_CombineLoads = 2,
|
|
|
|
BfProjectFlags_VectorizeLoops = 4,
|
|
|
|
BfProjectFlags_VectorizeSLP = 8,
|
|
|
|
BfProjectFlags_SingleModule = 0x10,
|
|
|
|
BfProjectFlags_AsmOutput = 0x20,
|
|
|
|
BfProjectFlags_AsmOutput_ATT = 0x40,
|
|
|
|
BfProjectFlags_AlwaysIncludeAll = 0x80,
|
|
|
|
};
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
class BfProject
|
|
|
|
{
|
2020-05-19 09:07:34 -07:00
|
|
|
public:
|
|
|
|
enum DeleteStage
|
|
|
|
{
|
|
|
|
DeleteStage_None,
|
|
|
|
DeleteStage_Queued,
|
|
|
|
DeleteStage_AwaitingRefs,
|
|
|
|
};
|
|
|
|
|
2022-07-26 13:27:03 -04:00
|
|
|
public:
|
2019-08-23 11:56:54 -07:00
|
|
|
BfSystem* mSystem;
|
|
|
|
String mName;
|
2020-12-27 10:56:14 -08:00
|
|
|
String mSafeName;
|
2021-12-20 09:39:39 -05:00
|
|
|
String mDirectory;
|
2019-08-23 11:56:54 -07:00
|
|
|
Array<BfProject*> mDependencies;
|
|
|
|
BfTargetType mTargetType;
|
2022-07-26 13:27:03 -04:00
|
|
|
BfCodeGenOptions mCodeGenOptions;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mDisabled;
|
2019-10-11 05:58:08 -07:00
|
|
|
bool mSingleModule;
|
|
|
|
bool mAlwaysIncludeAll;
|
2020-05-19 09:07:34 -07:00
|
|
|
DeleteStage mDeleteStage;
|
2019-08-23 11:56:54 -07:00
|
|
|
int mIdx;
|
|
|
|
|
|
|
|
String mStartupObject;
|
2022-07-26 13:27:03 -04:00
|
|
|
Array<String> mPreprocessorMacros;
|
2019-08-23 11:56:54 -07:00
|
|
|
Dictionary<BfAtomComposite, int> mNamespaces;
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
HashSet<BfModule*> mUsedModules;
|
2022-07-26 13:27:03 -04:00
|
|
|
HashSet<BfType*> mReferencedTypeData;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
Val128 mBuildConfigHash;
|
|
|
|
Val128 mVDataConfigHash;
|
|
|
|
|
|
|
|
bool mBuildConfigChanged;
|
|
|
|
|
|
|
|
public:
|
|
|
|
BfProject();
|
|
|
|
~BfProject();
|
|
|
|
|
|
|
|
bool ContainsReference(BfProject* refProject);
|
2022-07-26 13:27:03 -04:00
|
|
|
bool ReferencesOrReferencedBy(BfProject* refProject);
|
2019-08-23 11:56:54 -07:00
|
|
|
bool IsTestProject();
|
|
|
|
};
|
|
|
|
|
|
|
|
//CDH TODO move these out to separate header if list gets big/unwieldy
|
|
|
|
enum BfWarning
|
|
|
|
{
|
|
|
|
BfWarning_CS0108_MemberHidesInherited = 108,
|
|
|
|
BfWarning_CS0114_MethodHidesInherited = 114,
|
|
|
|
BfWarning_CS0162_UnreachableCode = 162,
|
|
|
|
BfWarning_CS0168_VariableDeclaredButNeverUsed = 168,
|
|
|
|
BfWarning_CS0472_ValueTypeNullCompare = 472,
|
2022-07-26 13:27:03 -04:00
|
|
|
BfWarning_CS1030_PragmaWarning = 1030,
|
2019-08-23 11:56:54 -07:00
|
|
|
BfWarning_BF4201_Only7Hex = 4201,
|
|
|
|
BfWarning_BF4202_TooManyHexForInt = 4202,
|
2020-10-06 07:38:56 -07:00
|
|
|
BfWarning_BF4203_UnnecessaryDynamicCast = 4203,
|
2020-10-07 11:07:10 -07:00
|
|
|
BfWarning_BF4204_AddressOfReadOnly = 4204,
|
2020-12-05 04:44:43 -08:00
|
|
|
BfWarning_BF4205_StringInterpolationParam = 4205,
|
|
|
|
BfWarning_BF4206_OperatorCommutableUsage = 4206,
|
2020-10-06 07:38:56 -07:00
|
|
|
BfWarning_C4554_PossiblePrecedenceError = 4554
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
2020-12-17 04:51:05 -08:00
|
|
|
class BfErrorLocation
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
String mFile;
|
|
|
|
int mLine;
|
|
|
|
int mColumn;
|
|
|
|
};
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
class BfErrorBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool mIsWarning;
|
|
|
|
bool mIsDeferred;
|
2022-07-26 13:27:03 -04:00
|
|
|
BfSourceData* mSource;
|
2019-08-23 11:56:54 -07:00
|
|
|
int mSrcStart;
|
2022-07-26 13:27:03 -04:00
|
|
|
int mSrcEnd;
|
2020-12-17 04:51:05 -08:00
|
|
|
BfErrorLocation* mLocation;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
BfErrorBase()
|
|
|
|
{
|
|
|
|
mIsWarning = false;
|
|
|
|
mIsDeferred = false;
|
2022-07-26 13:27:03 -04:00
|
|
|
mSource = NULL;
|
2019-08-23 11:56:54 -07:00
|
|
|
mSrcStart = -1;
|
|
|
|
mSrcEnd = -1;
|
2020-12-17 04:51:05 -08:00
|
|
|
mLocation = NULL;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
~BfErrorBase();
|
|
|
|
void SetSource(BfPassInstance* passInstance, BfSourceData* source);
|
|
|
|
};
|
|
|
|
|
|
|
|
class BfMoreInfo : public BfErrorBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
String mInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
class BfError : public BfErrorBase
|
|
|
|
{
|
2022-07-26 13:27:03 -04:00
|
|
|
public:
|
|
|
|
bool mIsAfter;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mIsPersistent;
|
2022-05-26 15:39:32 -07:00
|
|
|
BfWhileSpecializingFlags mIsWhileSpecializing;
|
2022-07-26 13:27:03 -04:00
|
|
|
bool mIgnore;
|
2020-01-06 13:49:35 -08:00
|
|
|
BfProject* mProject;
|
2019-08-23 11:56:54 -07:00
|
|
|
String mError;
|
|
|
|
int mWarningNumber;
|
|
|
|
Array<BfMoreInfo*> mMoreInfo;
|
|
|
|
|
|
|
|
public:
|
|
|
|
BfError()
|
2022-05-26 15:39:32 -07:00
|
|
|
{
|
2022-07-26 13:27:03 -04:00
|
|
|
mIsAfter = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
mIsPersistent = false;
|
2022-05-26 15:39:32 -07:00
|
|
|
mIsWhileSpecializing = BfWhileSpecializingFlag_None;
|
2022-07-26 13:27:03 -04:00
|
|
|
mIgnore = false;
|
2020-01-06 13:49:35 -08:00
|
|
|
mProject = NULL;
|
2019-08-23 11:56:54 -07:00
|
|
|
mWarningNumber = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
~BfError()
|
|
|
|
{
|
|
|
|
for (auto moreInfo : mMoreInfo)
|
|
|
|
delete moreInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetSrcStart()
|
|
|
|
{
|
|
|
|
return mSrcStart;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetSrcLength()
|
|
|
|
{
|
|
|
|
return mSrcEnd - mSrcStart;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetSrcEnd()
|
|
|
|
{
|
|
|
|
return mSrcEnd;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class BfSourceClassifier;
|
|
|
|
class BfAutoComplete;
|
|
|
|
|
|
|
|
enum BfFailFlags
|
|
|
|
{
|
|
|
|
BfFailFlag_None = 0,
|
|
|
|
BfFailFlag_ShowSpaceChars = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BfErrorEntry
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BfErrorBase* mError;
|
|
|
|
|
|
|
|
BfErrorEntry(BfErrorBase* error)
|
|
|
|
{
|
|
|
|
mError = error;
|
|
|
|
}
|
|
|
|
size_t GetHashCode() const;
|
|
|
|
bool operator==(const BfErrorEntry& other) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class BfPassInstance
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
const int sMaxDisplayErrors = 100;
|
|
|
|
const int sMaxErrors = 1000;
|
|
|
|
|
|
|
|
BfSystem* mSystem;
|
2022-04-16 06:27:54 -07:00
|
|
|
BfCompiler* mCompiler;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mTrimMessagesToCursor;
|
2022-07-26 13:27:03 -04:00
|
|
|
int mFailedIdx;
|
2021-01-08 16:21:03 -08:00
|
|
|
int mWarnIdx;
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
Dictionary<BfSourceData*, String> mSourceFileNameMap;
|
|
|
|
HashSet<BfErrorEntry> mErrorSet;
|
|
|
|
Array<BfError*> mErrors;
|
|
|
|
int mIgnoreCount;
|
2022-07-26 13:27:03 -04:00
|
|
|
int mWarningCount;
|
2019-08-23 11:56:54 -07:00
|
|
|
int mDeferredErrorCount;
|
2022-07-26 13:27:03 -04:00
|
|
|
Deque<String> mOutStream;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mLastWasDisplayed;
|
|
|
|
bool mLastWasAdded;
|
|
|
|
uint8 mClassifierPassId;
|
2022-04-16 06:27:54 -07:00
|
|
|
HashSet<BfSourceData*> mFilterErrorsTo;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mHadSignatureChanges;
|
|
|
|
|
|
|
|
public:
|
|
|
|
BfPassInstance(BfSystem* bfSystem)
|
|
|
|
{
|
|
|
|
mTrimMessagesToCursor = false;
|
|
|
|
mFailedIdx = 0;
|
2021-01-08 16:21:03 -08:00
|
|
|
mWarnIdx = 0;
|
2019-08-23 11:56:54 -07:00
|
|
|
mSystem = bfSystem;
|
2022-04-16 06:27:54 -07:00
|
|
|
mCompiler = NULL;
|
2019-08-23 11:56:54 -07:00
|
|
|
mLastWasDisplayed = false;
|
|
|
|
mLastWasAdded = false;
|
|
|
|
mClassifierPassId = 0;
|
2022-07-26 13:27:03 -04:00
|
|
|
mWarningCount = 0;
|
2019-08-23 11:56:54 -07:00
|
|
|
mDeferredErrorCount = 0;
|
2022-07-26 13:27:03 -04:00
|
|
|
mIgnoreCount = 0;
|
2019-08-23 11:56:54 -07:00
|
|
|
mHadSignatureChanges = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
~BfPassInstance();
|
|
|
|
|
|
|
|
void ClearErrors();
|
|
|
|
bool HasFailed();
|
|
|
|
bool HasMessages();
|
|
|
|
void OutputLine(const StringImpl& str);
|
|
|
|
bool PopOutString(String* outString);
|
|
|
|
bool WantsRangeRecorded(BfSourceData* bfSource, int srcIdx, int srcLen, bool isWarning, bool isDeferred = false);
|
|
|
|
bool WantsRangeDisplayed(BfSourceData* bfSource, int srcIdx, int srcLen, bool isWarning, bool isDeferred = false);
|
|
|
|
void TrimSourceRange(BfSourceData* source, int startIdx, int& srcLen); // Trim to a single line, in cases when we reference a large multi-line node
|
|
|
|
|
|
|
|
bool HasLastFailedAt(BfAstNode* astNode);
|
|
|
|
|
|
|
|
void MessageAt(const StringImpl& msgPrefix, const StringImpl& error, BfSourceData* bfSource, int srcIdx, int srcLen = 1, BfFailFlags flags = BfFailFlag_None);
|
|
|
|
void FixSrcStartAndEnd(BfSourceData* source, int& startIdx, int& endIdx);
|
|
|
|
|
2021-11-01 13:46:24 -07:00
|
|
|
BfError* WarnAt(int warningNumber, const StringImpl& warning, BfSourceData* bfSource, int srcIdx, int srcLen = 1, bool isDeferred = false);
|
2019-08-23 11:56:54 -07:00
|
|
|
BfError* Warn(int warningNumber, const StringImpl& warning);
|
2021-11-01 13:46:24 -07:00
|
|
|
BfError* Warn(int warningNumber, const StringImpl& warning, BfAstNode* refNode, bool isDeferred = false);
|
|
|
|
BfError* DeferWarn(int warningNumber, const StringImpl& warning, BfAstNode* refNode);
|
2019-08-23 11:56:54 -07:00
|
|
|
BfError* WarnAfter(int warningNumber, const StringImpl& warning, BfAstNode* refNode);
|
2022-07-26 13:27:03 -04:00
|
|
|
BfError* WarnAfterAt(int warningNumber, const StringImpl& error, BfSourceData* bfSource, int srcIdx);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
2020-12-17 04:51:05 -08:00
|
|
|
BfMoreInfo* MoreInfoAt(const StringImpl& info, BfSourceData* bfSource, int srcIdx, int srcLen, BfFailFlags flags = BfFailFlag_None);
|
2021-01-08 16:21:03 -08:00
|
|
|
BfMoreInfo* MoreInfo(const StringImpl& info, bool forceQueue = false);
|
2020-12-17 04:51:05 -08:00
|
|
|
BfMoreInfo* MoreInfo(const StringImpl& info, BfAstNode* refNode);
|
|
|
|
BfMoreInfo* MoreInfoAfter(const StringImpl& info, BfAstNode* refNode);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
BfError* FailAt(const StringImpl& error, BfSourceData* bfSource, int srcIdx, int srcLen = 1, BfFailFlags flags = BfFailFlag_None);
|
|
|
|
BfError* FailAfterAt(const StringImpl& error, BfSourceData* bfSource, int srcIdx);
|
|
|
|
BfError* Fail(const StringImpl& error);
|
|
|
|
BfError* Fail(const StringImpl& error, BfAstNode* refNode);
|
|
|
|
BfError* FailAfter(const StringImpl& error, BfAstNode* refNode);
|
|
|
|
BfError* DeferFail(const StringImpl& error, BfAstNode* refNode);
|
|
|
|
void SilentFail();
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
void TryFlushDeferredError();
|
|
|
|
void WriteErrorSummary();
|
|
|
|
};
|
|
|
|
|
2020-07-11 16:24:07 -07:00
|
|
|
enum BfOptionFlags
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
2020-07-11 16:24:07 -07:00
|
|
|
BfOptionFlags_None = 0,
|
|
|
|
BfOptionFlags_RuntimeChecks = 1,
|
|
|
|
BfOptionFlags_InitLocalVariables = 2,
|
|
|
|
BfOptionFlags_EmitDynamicCastCheck = 4,
|
|
|
|
BfOptionFlags_EmitObjectAccessCheck = 8,
|
2022-01-11 08:17:09 -05:00
|
|
|
BfOptionFlags_ArithmeticCheck = 0x10,
|
|
|
|
|
|
|
|
BfOptionFlags_ReflectAlwaysIncludeType = 0x20,
|
|
|
|
BfOptionFlags_ReflectAlwaysIncludeAll = 0x40,
|
|
|
|
BfOptionFlags_ReflectAssumeInstantiated = 0x80,
|
|
|
|
BfOptionFlags_ReflectBoxing = 0x100,
|
|
|
|
BfOptionFlags_ReflectStaticFields = 0x200,
|
|
|
|
BfOptionFlags_ReflectNonStaticFields = 0x400,
|
|
|
|
BfOptionFlags_ReflectStaticMethods = 0x800,
|
|
|
|
BfOptionFlags_ReflectNonStaticMethods = 0x1000,
|
|
|
|
BfOptionFlags_ReflectConstructors = 0x2000,
|
2022-02-04 12:00:43 -05:00
|
|
|
BfOptionFlags_ReflectAlwaysIncludeFiltered = 0x4000,
|
2020-07-11 16:24:07 -07:00
|
|
|
|
2020-07-14 08:27:25 -07:00
|
|
|
BfOptionFlags_Reflect_MethodMask = BfOptionFlags_ReflectStaticMethods | BfOptionFlags_ReflectNonStaticMethods | BfOptionFlags_ReflectConstructors,
|
2022-01-11 08:17:09 -05:00
|
|
|
BfOptionFlags_Mask = 0x3FFF
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
2022-02-11 05:47:32 -05:00
|
|
|
enum BfFieldFlags
|
|
|
|
{
|
|
|
|
BfFieldFlags_Protected = 3,
|
|
|
|
BfFieldFlags_Public = 6,
|
|
|
|
BfFieldFlags_Static = 0x10,
|
|
|
|
BfFieldFlags_Const = 0x40,
|
|
|
|
BfFieldFlags_SpecialName = 0x80,
|
|
|
|
BfFieldFlags_EnumPayload = 0x100,
|
|
|
|
BfFieldFlags_EnumDiscriminator = 0x200,
|
2022-05-30 06:20:47 -07:00
|
|
|
BfFieldFlags_EnumCase = 0x400,
|
2022-06-27 10:55:31 -07:00
|
|
|
BfFieldFlags_ReadOnly = 0x800,
|
|
|
|
BfFieldFlags_Appended = 0x1000
|
2022-02-11 05:47:32 -05:00
|
|
|
};
|
|
|
|
|
2020-09-14 11:18:24 -07:00
|
|
|
enum BfReflectKind
|
|
|
|
{
|
|
|
|
BfReflectKind_None = 0,
|
|
|
|
BfReflectKind_Type = 1,
|
|
|
|
BfReflectKind_NonStaticFields = 2,
|
|
|
|
BfReflectKind_StaticFields = 4,
|
|
|
|
BfReflectKind_DefaultConstructor = 8,
|
|
|
|
BfReflectKind_Constructors = 0x10,
|
|
|
|
BfReflectKind_StaticMethods = 0x20,
|
2022-07-26 13:27:03 -04:00
|
|
|
BfReflectKind_Methods = 0x40,
|
2020-09-14 11:18:24 -07:00
|
|
|
BfReflectKind_DynamicBoxing = 0x80,
|
|
|
|
BfReflectKind_User = 0x100,
|
|
|
|
BfReflectKind_All = 0x1FF,
|
|
|
|
|
|
|
|
BfReflectKind_ApplyToInnerTypes = 0x200
|
|
|
|
};
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
class BfTypeOptions
|
|
|
|
{
|
2020-07-14 08:27:25 -07:00
|
|
|
public:
|
|
|
|
struct MethodFilter
|
|
|
|
{
|
|
|
|
String mFilter;
|
|
|
|
BfOptionFlags mOrFlags;
|
|
|
|
BfOptionFlags mAndFlags;
|
|
|
|
};
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
public:
|
|
|
|
Array<String> mTypeFilters;
|
|
|
|
Array<String> mAttributeFilters;
|
2022-07-26 13:27:03 -04:00
|
|
|
Array<int> mMatchedIndices;
|
2019-08-23 11:56:54 -07:00
|
|
|
int mSIMDSetting;
|
|
|
|
int mOptimizationLevel;
|
2022-07-26 13:27:03 -04:00
|
|
|
int mEmitDebugInfo;
|
2020-07-11 16:24:07 -07:00
|
|
|
BfOptionFlags mAndFlags;
|
|
|
|
BfOptionFlags mOrFlags;
|
2020-07-14 08:27:25 -07:00
|
|
|
Array<MethodFilter> mReflectMethodFilters;
|
|
|
|
Array<MethodFilter> mReflectMethodAttributeFilters;
|
2022-07-26 13:27:03 -04:00
|
|
|
int mAllocStackTraceDepth;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
static int Apply(int val, int applyVal)
|
|
|
|
{
|
|
|
|
if (applyVal != -1)
|
|
|
|
return applyVal;
|
|
|
|
return val;
|
2022-07-26 13:27:03 -04:00
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
|
2020-07-11 16:24:07 -07:00
|
|
|
bool Apply(bool val, BfOptionFlags flags)
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
2020-07-11 16:24:07 -07:00
|
|
|
if (val)
|
|
|
|
return (mAndFlags & flags) != 0;
|
|
|
|
else
|
|
|
|
return (mOrFlags & flags) != 0;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
2020-07-14 08:27:25 -07:00
|
|
|
|
|
|
|
bool HasReflectMethodFilters()
|
|
|
|
{
|
|
|
|
return !mReflectMethodFilters.IsEmpty() || !mReflectMethodAttributeFilters.IsEmpty();
|
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
};
|
|
|
|
|
2020-09-22 15:39:14 -07:00
|
|
|
enum BfFindTypeDefFlags
|
|
|
|
{
|
|
|
|
BfFindTypeDefFlag_None,
|
|
|
|
BfFindTypeDefFlag_AllowGlobal
|
|
|
|
};
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
class BfSystem
|
|
|
|
{
|
2022-07-26 13:27:03 -04:00
|
|
|
public:
|
|
|
|
int mPtrSize;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mIsResolveOnly;
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
CritSect mDataLock; // short-lived, hold only while active modifying data
|
|
|
|
// The following are protected by mDataLock:
|
2020-12-27 10:56:14 -08:00
|
|
|
HashSet<String> mUsedSafeProjectNames;
|
2019-08-23 11:56:54 -07:00
|
|
|
Array<BfProject*> mProjects;
|
|
|
|
Array<BfProject*> mProjectDeleteQueue;
|
|
|
|
Array<BfParser*> mParsers;
|
|
|
|
Array<BfParser*> mParserDeleteQueue;
|
|
|
|
Array<BfTypeDef*> mTypeDefDeleteQueue;
|
|
|
|
Array<BfTypeOptions> mTypeOptions;
|
|
|
|
Array<BfTypeOptions> mMergedTypeOptions;
|
|
|
|
int mUpdateCnt;
|
|
|
|
bool mWorkspaceConfigChanged;
|
2021-02-25 10:14:22 -08:00
|
|
|
Val128 mWorkspaceConfigHash;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
Array<BfCompiler*> mCompilers;
|
|
|
|
|
|
|
|
BfAtom* mGlobalsAtom;
|
|
|
|
BfAtom* mEmptyAtom;
|
|
|
|
BfAtom* mBfAtom;
|
|
|
|
CritSect mSystemLock; // long-lived, hold while compiling
|
|
|
|
int mYieldDisallowCount; // We can only yield lock when we are at 0
|
|
|
|
volatile int mCurSystemLockPri;
|
|
|
|
BfpThreadId mCurSystemLockThreadId;
|
|
|
|
volatile int mPendingSystemLockPri;
|
|
|
|
uint32 mYieldTickCount;
|
|
|
|
int mHighestYieldTime;
|
|
|
|
// The following are protected by mSystemLock - can only be accessed by the compiling thread
|
2022-07-26 13:27:03 -04:00
|
|
|
Dictionary<String, BfTypeDef*> mSystemTypeDefs;
|
|
|
|
BfTypeDefMap mTypeDefs;
|
2019-08-23 11:56:54 -07:00
|
|
|
bool mNeedsTypesHandledByCompiler;
|
2022-07-26 13:27:03 -04:00
|
|
|
BumpAllocator mAlloc;
|
|
|
|
int mAtomCreateIdx;
|
2019-08-23 11:56:54 -07:00
|
|
|
Dictionary<StringView, BfAtom*> mAtomMap;
|
|
|
|
Array<BfAtom*> mAtomGraveyard;
|
|
|
|
uint32 mAtomUpdateIdx;
|
|
|
|
int32 mTypeMapVersion; // Increment when we add any new types or namespaces
|
|
|
|
|
|
|
|
OwnedVector<BfMethodDef> mMethodGraveyard;
|
|
|
|
OwnedVector<BfFieldDef> mFieldGraveyard;
|
|
|
|
OwnedVector<BfDirectStrTypeReference> mDirectTypeRefs;
|
|
|
|
OwnedVector<BfRefTypeRef> mRefTypeRefs;
|
|
|
|
|
|
|
|
public:
|
|
|
|
BfTypeDef* mTypeVoid;
|
|
|
|
BfTypeDef* mTypeNullPtr;
|
|
|
|
BfTypeDef* mTypeSelf;
|
|
|
|
BfTypeDef* mTypeDot;
|
|
|
|
BfTypeDef* mTypeVar;
|
|
|
|
BfTypeDef* mTypeLet;
|
|
|
|
BfTypeDef* mTypeBool;
|
|
|
|
BfTypeDef* mTypeIntPtr;
|
|
|
|
BfTypeDef* mTypeUIntPtr;
|
|
|
|
BfTypeDef* mTypeIntUnknown;
|
|
|
|
BfTypeDef* mTypeUIntUnknown;
|
|
|
|
BfTypeDef* mTypeInt8;
|
|
|
|
BfTypeDef* mTypeUInt8;
|
|
|
|
BfTypeDef* mTypeInt16;
|
|
|
|
BfTypeDef* mTypeUInt16;
|
|
|
|
BfTypeDef* mTypeInt32;
|
|
|
|
BfTypeDef* mTypeUInt32;
|
|
|
|
BfTypeDef* mTypeInt64;
|
|
|
|
BfTypeDef* mTypeUInt64;
|
|
|
|
BfTypeDef* mTypeChar8;
|
|
|
|
BfTypeDef* mTypeChar16;
|
|
|
|
BfTypeDef* mTypeChar32;
|
|
|
|
BfTypeDef* mTypeSingle;
|
2022-07-26 13:27:03 -04:00
|
|
|
BfTypeDef* mTypeDouble;
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
BfDirectStrTypeReference* mDirectVoidTypeRef;
|
|
|
|
BfDirectStrTypeReference* mDirectBoolTypeRef;
|
|
|
|
BfDirectStrTypeReference* mDirectSelfTypeRef;
|
|
|
|
BfDirectStrTypeReference* mDirectSelfBaseTypeRef;
|
|
|
|
BfRefTypeRef* mDirectRefSelfBaseTypeRef;
|
|
|
|
BfDirectStrTypeReference* mDirectObjectTypeRef;
|
|
|
|
BfDirectStrTypeReference* mDirectStringTypeRef;
|
|
|
|
BfDirectStrTypeReference* mDirectIntTypeRef;
|
|
|
|
BfRefTypeRef* mDirectRefIntTypeRef;
|
|
|
|
BfDirectStrTypeReference* mDirectInt32TypeRef;
|
|
|
|
|
|
|
|
public:
|
|
|
|
BfSystem();
|
|
|
|
~BfSystem();
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
BfAtom* GetAtom(const StringImpl& string);
|
|
|
|
BfAtom* FindAtom(const StringImpl& string); // Doesn't create a ref
|
|
|
|
BfAtom* FindAtom(const StringView& string); // Doesn't create a ref
|
2022-07-26 13:27:03 -04:00
|
|
|
void ReleaseAtom(BfAtom* atom);
|
2019-08-23 11:56:54 -07:00
|
|
|
void ProcessAtomGraveyard();
|
|
|
|
void RefAtomComposite(const BfAtomComposite& atomComposite);
|
2022-07-26 13:27:03 -04:00
|
|
|
void ReleaseAtomComposite(const BfAtomComposite& atomComposite);
|
2019-08-23 11:56:54 -07:00
|
|
|
void SanityCheckAtomComposite(const BfAtomComposite& atomComposite);
|
|
|
|
void TrackName(BfTypeDef* typeDef);
|
2022-07-26 13:27:03 -04:00
|
|
|
void UntrackName(BfTypeDef* typeDef);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
bool ParseAtomComposite(const StringView& name, BfAtomComposite& composite, bool addRefs = false);
|
|
|
|
|
2022-07-26 13:27:03 -04:00
|
|
|
void CreateBasicTypes();
|
2019-08-23 11:56:54 -07:00
|
|
|
bool DoesLiteralFit(BfTypeCode typeCode, int64 value);
|
2021-12-15 12:17:20 -05:00
|
|
|
bool DoesLiteralFit(BfTypeCode typeCode, uint64 value);
|
2021-12-31 07:56:57 -05:00
|
|
|
bool DoesLiteralFit(BfTypeCode typeCode, const BfVariant& variant);
|
2022-07-26 13:27:03 -04:00
|
|
|
BfParser* CreateParser(BfProject* bfProject);
|
|
|
|
BfCompiler* CreateCompiler(bool isResolveOnly);
|
2019-08-23 11:56:54 -07:00
|
|
|
BfProject* GetProject(const StringImpl& projName);
|
|
|
|
|
2022-07-26 13:27:03 -04:00
|
|
|
BfTypeReference* GetTypeRefElement(BfTypeReference* typeRef);
|
2019-08-23 11:56:54 -07:00
|
|
|
BfTypeDef* FilterDeletedTypeDef(BfTypeDef* typeDef);
|
2022-07-26 13:27:03 -04:00
|
|
|
bool CheckTypeDefReference(BfTypeDef* typeDef, BfProject* project);
|
2020-09-22 15:39:14 -07:00
|
|
|
BfTypeDef* FindTypeDef(const BfAtomComposite& findName, int numGenericArgs = 0, BfProject* project = NULL, const Array<BfAtomComposite>& namespaceSearch = Array<BfAtomComposite>(), BfTypeDef** ambiguousTypeDef = NULL, BfFindTypeDefFlags flags = BfFindTypeDefFlag_None);
|
2019-08-23 11:56:54 -07:00
|
|
|
bool FindTypeDef(const BfAtomComposite& findName, int numGenericArgs, BfProject* project, const BfAtomComposite& checkNamespace, bool allowPrivate, BfTypeDefLookupContext* ctx);
|
2020-09-22 15:39:14 -07:00
|
|
|
BfTypeDef* FindTypeDef(const StringImpl& typeName, int numGenericArgs = 0, BfProject* project = NULL, const Array<BfAtomComposite>& namespaceSearch = Array<BfAtomComposite>(), BfTypeDef** ambiguousTypeDef = NULL, BfFindTypeDefFlags flags = BfFindTypeDefFlag_None);
|
2019-08-23 11:56:54 -07:00
|
|
|
BfTypeDef* FindTypeDef(const StringImpl& typeName, BfProject* project);
|
|
|
|
BfTypeDef* FindTypeDefEx(const StringImpl& typeName);
|
2022-05-06 11:28:38 -07:00
|
|
|
void ClearTypeDefCache();
|
2022-07-26 13:27:03 -04:00
|
|
|
void FindFixitNamespaces(const StringImpl& typeName, int numGenericArgs, BfProject* project, std::set<String>& fixitNamespaces);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
void RemoveTypeDef(BfTypeDef* typeDef);
|
|
|
|
//BfTypeDefMap::Iterator RemoveTypeDef(BfTypeDefMap::Iterator typeDefItr);
|
|
|
|
void AddNamespaceUsage(const BfAtomComposite& namespaceStr, BfProject* bfProject);
|
|
|
|
void RemoveNamespaceUsage(const BfAtomComposite& namespaceStr, BfProject* bfProject);
|
2022-07-26 13:27:03 -04:00
|
|
|
bool ContainsNamespace(const BfAtomComposite& namespaceStr, BfProject* bfProject);
|
2019-08-23 11:56:54 -07:00
|
|
|
void InjectNewRevision(BfTypeDef* typeDef);
|
|
|
|
void AddToCompositePartial(BfPassInstance* passInstance, BfTypeDef* compositeTypeDef, BfTypeDef* partialTypeDef);
|
2022-07-26 13:27:03 -04:00
|
|
|
void FinishCompositePartial(BfTypeDef* compositeTypeDef);
|
2021-10-28 08:05:14 -07:00
|
|
|
void CopyTypeDef(BfTypeDef* typeDef, BfTypeDef* nextTypeDef);
|
|
|
|
void UpdateEmittedTypeDef(BfTypeDef* typeDef);
|
|
|
|
|
2019-09-10 11:27:53 -07:00
|
|
|
BfTypeDef* GetCombinedPartial(BfTypeDef* typeDef);
|
2019-08-23 11:56:54 -07:00
|
|
|
BfTypeDef* GetOuterTypeNonPartial(BfTypeDef* typeDef);
|
|
|
|
|
|
|
|
int GetGenericParamIdx(const Array<BfGenericParamDef*>& genericParams, const StringImpl& name);
|
|
|
|
int GetGenericParamIdx(const Array<BfGenericParamDef*>& genericParams, BfTypeReference* typeRef);
|
|
|
|
|
2022-07-26 13:27:03 -04:00
|
|
|
void StartYieldSection();
|
2019-08-23 11:56:54 -07:00
|
|
|
void CheckLockYield(); // Yields to a higher priority request
|
|
|
|
void SummarizeYieldSection();
|
|
|
|
|
|
|
|
void NotifyWillRequestLock(int priority);
|
|
|
|
void Lock(int priority);
|
|
|
|
void Unlock();
|
|
|
|
void AssertWeHaveLock();
|
|
|
|
|
|
|
|
void RemoveDeletedParsers();
|
|
|
|
void RemoveOldParsers();
|
|
|
|
void RemoveOldData();
|
|
|
|
|
|
|
|
void VerifyTypeDef(BfTypeDef* typeDef);
|
|
|
|
|
|
|
|
BfPassInstance* CreatePassInstance();
|
|
|
|
BfTypeOptions* GetTypeOptions(int optionsIdx);
|
|
|
|
bool HasTestProjects();
|
|
|
|
bool IsCompatibleCallingConvention(BfCallingConvention callConvA, BfCallingConvention callConvB);
|
|
|
|
};
|
|
|
|
|
|
|
|
class AutoDisallowYield
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BfSystem* mSystem;
|
|
|
|
bool mHeld;
|
|
|
|
|
|
|
|
public:
|
|
|
|
AutoDisallowYield(BfSystem* system)
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
mSystem = system;
|
|
|
|
mSystem->mYieldDisallowCount++;
|
|
|
|
mHeld = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
~AutoDisallowYield()
|
|
|
|
{
|
|
|
|
if (mHeld)
|
|
|
|
mSystem->mYieldDisallowCount--;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Release()
|
|
|
|
{
|
|
|
|
BF_ASSERT(mHeld);
|
|
|
|
if (mHeld)
|
|
|
|
{
|
|
|
|
mHeld = false;
|
|
|
|
mSystem->mYieldDisallowCount--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Acquire()
|
|
|
|
{
|
|
|
|
BF_ASSERT(!mHeld);
|
|
|
|
if (!mHeld)
|
|
|
|
{
|
|
|
|
mHeld = true;
|
|
|
|
mSystem->mYieldDisallowCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
|
|
|
#ifdef BF_PLATFORM_WINDOWS
|
2022-05-04 06:40:26 -07:00
|
|
|
#define BF_WANTS_LOG_HI
|
2019-08-23 11:56:54 -07:00
|
|
|
#define BF_WANTS_LOG
|
|
|
|
#define BF_WANTS_LOG_SYS
|
|
|
|
//#define BF_WANTS_LOG2
|
|
|
|
//#define BF_WANTS_LOG_CLANG
|
|
|
|
#define BF_WANTS_LOG_DBG
|
|
|
|
#define BF_WANTS_LOG_DBGEXPR
|
|
|
|
//#define BF_WANTS_LOG_CV
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#else
|
2022-05-04 06:40:26 -07:00
|
|
|
#define BF_WANTS_LOG_HI
|
2019-08-23 11:56:54 -07:00
|
|
|
//#define BF_WANTS_LOG
|
2022-05-04 06:40:26 -07:00
|
|
|
//#define BF_WANTS_LOG_SYS
|
2019-08-23 11:56:54 -07:00
|
|
|
//#define BF_WANTS_LOG2
|
|
|
|
//#define BF_WANTS_LOG_CLANG
|
|
|
|
//#define BF_WANTS_LOG_DBGEXPR
|
|
|
|
//#define BF_WANTS_LOG_CV
|
2019-08-29 17:40:17 -07:00
|
|
|
//#define BF_WANTS_LOG_DBG
|
2019-08-23 11:56:54 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BF_WANTS_LOG
|
|
|
|
#define BfLog(fmt, ...) DoBfLog(0, fmt, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
//#define BfLog(fmt) {} // Nothing
|
|
|
|
#define BfLog(fmt, ...) {} // Nothing
|
|
|
|
#endif
|
|
|
|
|
2022-05-04 12:51:45 -07:00
|
|
|
#ifdef BF_WANTS_LOG
|
|
|
|
#define BfLogX(logIdx, fmt, ...) DoBfLog(logIdx, fmt, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define BfLogX(logIdx, fmt, ...) {} // Nothing
|
|
|
|
#endif
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
#ifdef BF_WANTS_LOG_SYS
|
|
|
|
#define BfLogSys(sys, fmt, ...) DoBfLog((sys)->mIsResolveOnly ? 1 : 2, fmt, ##__VA_ARGS__)
|
|
|
|
#define BfLogSysM(fmt, ...) DoBfLog(mSystem->mIsResolveOnly ? 1 : 2, fmt, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define BfLogSys(...) {} // Nothing
|
|
|
|
#define BfLogSysM(...) {} // Nothing
|
|
|
|
#endif
|
|
|
|
|
2022-05-04 06:40:26 -07:00
|
|
|
#ifdef BF_WANTS_LOG_HI
|
|
|
|
#define BfLogSysHI(sys, fmt, ...) DoBfLog((sys)->mIsResolveOnly ? 1 : 2, fmt, ##__VA_ARGS__)
|
|
|
|
#define BfLogSysMHI(fmt, ...) DoBfLog(mSystem->mIsResolveOnly ? 1 : 2, fmt, ##__VA_ARGS__)
|
2022-08-26 10:40:40 -07:00
|
|
|
#define BfLogDbgHI(fmt, ...) DoBfLog(0, fmt, ##__VA_ARGS__)
|
2022-05-04 06:40:26 -07:00
|
|
|
#else
|
|
|
|
#define BfLogSysHI(...) {} // Nothing
|
|
|
|
#define BfLogSysMHI(...) {} // Nothing
|
|
|
|
#endif
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
#ifdef BF_WANTS_LOG_CLANG
|
|
|
|
//#define BfLogClang(fmt) DoBfLog(fmt)
|
|
|
|
#define BfLogClang(fmt, ...) DoBfLog(0, fmt, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define BfLogClang(fmt, ...) {} // Nothing
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BF_WANTS_LOG_DBG
|
|
|
|
#define BfLogDbg(fmt, ...) DoBfLog(0, fmt, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define BfLogDbg(fmt, ...) {} // Nothing
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BF_WANTS_LOG_DBGEXPR
|
|
|
|
#define BfLogDbgExpr(fmt, ...) DoBfLog(0, fmt, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define BfLogDbgExpr(fmt, ...) {} // Nothing
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BF_WANTS_LOG2
|
|
|
|
#define BfLog2(fmt, ...) DoBfLog(0, fmt, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define BfLog2(fmt, ...) {} // Nothing
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BF_WANTS_LOG_CV
|
|
|
|
#define BfLogCv(fmt, ...) DoBfLog(0, fmt, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define BfLogCv(fmt, ...) {} // Nothing
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void DoBfLog(int fileIdx, const char* fmt ...);
|
|
|
|
|
|
|
|
NS_BF_END
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
template <>
|
|
|
|
struct hash<Beefy::BfAtomComposite>
|
|
|
|
{
|
|
|
|
size_t operator()(const Beefy::BfAtomComposite& composite) const
|
|
|
|
{
|
|
|
|
int curHash = 0;
|
|
|
|
for (int i = 0; i < (int)composite.mSize; i++)
|
|
|
|
curHash = ((curHash ^ (int)(intptr)composite.mParts[i]->mHash) << 5) - curHash;
|
|
|
|
return curHash;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct hash<Beefy::BfMemberSetEntry>
|
|
|
|
{
|
|
|
|
size_t operator()(const Beefy::BfMemberSetEntry& entry) const
|
|
|
|
{
|
|
|
|
return std::hash<Beefy::String>()(entry.mMemberDef->mName);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
template<>
|
|
|
|
struct hash<Beefy::BfErrorEntry>
|
|
|
|
{
|
|
|
|
size_t operator()(const Beefy::BfErrorEntry& val) const
|
|
|
|
{
|
|
|
|
return val.GetHashCode();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|