MCPcopy Create free account
hub / github.com/WheretIB/nullc / GetNameInNamespace

Function GetNameInNamespace

NULLC/Callbacks.cpp:162–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162InplaceStr GetNameInNamespace(InplaceStr name, bool alwaysRelocate = false)
163{
164 if(namespaceStack.size() > 1)
165 {
166 // A full name must be created if we are in a namespace
167 unsigned nameLength = int(name.end - name.begin) + 1, lastLength = nameLength;
168 for(unsigned int i = 1; i < namespaceStack.size(); i++)
169 nameLength += namespaceStack[i]->nameLength + 1; // add space for namespace name and a point
170 char *newName = AllocateString(nameLength), *currPos = newName;
171 for(unsigned int i = 1; i < namespaceStack.size(); i++)
172 {
173 memcpy(currPos, namespaceStack[i]->name.begin, namespaceStack[i]->nameLength);
174 currPos += namespaceStack[i]->nameLength;
175 *currPos++ = '.';
176 }
177 memcpy(currPos, name.begin, lastLength);
178 currPos[lastLength - 1] = 0;
179 name = InplaceStr(newName);
180 }else if(alwaysRelocate){
181 char *newName = AllocateString(int(name.end - name.begin) + 1);
182 memcpy(newName, name.begin, int(name.end - name.begin));
183 newName[int(name.end - name.begin)] = 0;
184 name = InplaceStr(newName);
185 }
186 return name;
187}
188unsigned AddNamespaceToHash(unsigned hash, NamespaceInfo* info)
189{
190 if(info->parent)

Callers 3

AddVariableFunction · 0.85
FunctionAddFunction · 0.85
TypeBeginFunction · 0.85

Calls 3

AllocateStringFunction · 0.85
InplaceStrClass · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected