MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / add

Method add

Engine/source/console/compiler.cpp:219–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217
218
219U32 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
260U32 CompilerStringTable::addIntString(U32 value)
261{

Callers 9

setCurVarNameCreateMethod · 0.45
execMethod · 0.45
compileSTEtoCodeFunction · 0.45
precompileIdentFunction · 0.45
compileMethod · 0.45
compileStmtMethod · 0.45
addVariableEntryFunction · 0.45
getAddVariableEntryFunction · 0.45
getAddLocalVariableEntryFunction · 0.45

Calls 8

compareFunction · 0.85
dStricmpFunction · 0.85
consoleAllocFunction · 0.85
dStrcpyFunction · 0.85
avarFunction · 0.85
dStrlenFunction · 0.50
insertMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected