MCPcopy Create free account
hub / github.com/beefytech/Beef / GetAtom

Method GetAtom

IDEHelper/Compiler/BfSystem.cpp:2189–2229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2187 mSystemTypeDefs[name] = typeDef;
2188
2189BfAtom* BfSystem::GetAtom(const StringImpl& string, BfAtom::Kind kind)
2190{
2191 StringView* stringPtr = NULL;
2192 BfAtom* atom = NULL;
2193 BfAtom** atomPtr = NULL;
2194 if (mAtomMap.TryAdd(string, &stringPtr, &atomPtr))
2195 {
2196 atom = new BfAtom();
2197 *atomPtr = atom;
2198 stringPtr->mPtr = strdup(string.c_str());
2199#ifdef _DEBUG
2200 for (int i = 0; i < (int)string.length(); i++)
2201 {
2202 BF_ASSERT(string[i] != '.'); // Should be a composite
2203 }
2204#endif
2205 mAtomCreateIdx++;
2206 atom->mKind = kind;
2207 atom->mIsSystemType = false;
2208 atom->mAtomUpdateIdx = ++mAtomUpdateIdx;
2209 atom->mString = *stringPtr;
2210 atom->mRefCount = 1;
2211 atom->mPendingDerefCount = 0;
2212
2213 atom->mHash = 0;
2214 for (char c : string)
2215 atom->mHash = ((atom->mHash ^ c) << 5) - atom->mHash;
2216
2217 if (kind == BfAtom::Kind_Anon)
2218 mAnonymousAtomCount++;
2219
2220 BfLogSys(this, "Atom Allocated %p %s\n", atom, string.c_str());
2221
2222 return atom;
2223 }
2224 else
2225 atom = *atomPtr;
2226
2227 atom->Ref();
2228 return atom;
2229}
2230
2231BfAtom* BfSystem::FindAtom(const StringImpl& string)
2232{

Callers 2

VisitMethod · 0.80
InitMethod · 0.80

Calls 5

strdupFunction · 0.85
RefMethod · 0.80
TryAddMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected