| 217 | |
| 218 | |
| 219 | U32 CompilerStringTable::add(const char *str, bool caseSens, bool tag) |
| 220 | { |
| 221 | // Is it already in? |
| 222 | Entry **walk; |
| 223 | for (walk = &list; *walk; walk = &((*walk)->next)) |
| 224 | { |
| 225 | if ((*walk)->tag != tag) |
| 226 | continue; |
| 227 | |
| 228 | if (caseSens) |
| 229 | { |
| 230 | if (!String::compare((*walk)->string, str)) |
| 231 | return (*walk)->start; |
| 232 | } |
| 233 | else |
| 234 | { |
| 235 | if (!dStricmp((*walk)->string, str)) |
| 236 | return (*walk)->start; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | // Write it out. |
| 241 | Entry *newStr = (Entry *)consoleAlloc(sizeof(Entry)); |
| 242 | *walk = newStr; |
| 243 | newStr->next = NULL; |
| 244 | newStr->start = totalLen; |
| 245 | U32 len = dStrlen(str) + 1; |
| 246 | if (tag && len < 7) // alloc space for the numeric tag 1 for tag, 5 for # and 1 for nul |
| 247 | len = 7; |
| 248 | totalLen += len; |
| 249 | newStr->string = (char *)consoleAlloc(len); |
| 250 | newStr->len = len; |
| 251 | newStr->tag = tag; |
| 252 | dStrcpy(newStr->string, str, len); |
| 253 | |
| 254 | // Put into the hash table. |
| 255 | hashTable[str] = newStr; |
| 256 | |
| 257 | return newStr->start; |
| 258 | } |
| 259 | |
| 260 | U32 CompilerStringTable::addIntString(U32 value) |
| 261 | { |
no test coverage detected