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

Inline anonymous type declarations

This commit is contained in:
Brian Fiete 2025-01-02 11:42:33 -08:00
parent f609062c2a
commit 958fc30310
20 changed files with 600 additions and 48 deletions

View file

@ -1984,6 +1984,8 @@ BfSystem::BfSystem()
gPerfManager = new PerfManager();
//gPerfManager->StartRecording();
mAnonymousAtomCount = 0;
mCurUniqueId = 0;
mAtomUpdateIdx = 0;
mAtomCreateIdx = 0;
mTypeMapVersion = 1;
@ -2094,7 +2096,7 @@ BfSystem::~BfSystem()
typeDef->mHash = typeCode + 1000; \
mSystemTypeDefs[name] = typeDef;
BfAtom* BfSystem::GetAtom(const StringImpl& string)
BfAtom* BfSystem::GetAtom(const StringImpl& string, BfAtom::Kind kind)
{
StringView* stringPtr = NULL;
BfAtom* atom = NULL;
@ -2111,6 +2113,7 @@ BfAtom* BfSystem::GetAtom(const StringImpl& string)
}
#endif
mAtomCreateIdx++;
atom->mKind = kind;
atom->mIsSystemType = false;
atom->mAtomUpdateIdx = ++mAtomUpdateIdx;
atom->mString = *stringPtr;
@ -2121,6 +2124,9 @@ BfAtom* BfSystem::GetAtom(const StringImpl& string)
for (char c : string)
atom->mHash = ((atom->mHash ^ c) << 5) - atom->mHash;
if (kind == BfAtom::Kind_Anon)
mAnonymousAtomCount++;
BfLogSys(this, "Atom Allocated %p %s\n", atom, string.c_str());
return atom;
@ -2152,6 +2158,12 @@ void BfSystem::ReleaseAtom(BfAtom* atom)
{
if (--atom->mRefCount == 0)
{
if (atom->mKind == BfAtom::Kind_Anon)
{
mAnonymousAtomCount--;
BF_ASSERT(mAnonymousAtomCount >= 0);
}
mAtomGraveyard.push_back(atom);
return;
}