| 2187 | mSystemTypeDefs[name] = typeDef; |
| 2188 | |
| 2189 | BfAtom* 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 | |
| 2231 | BfAtom* BfSystem::FindAtom(const StringImpl& string) |
| 2232 | { |