MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxNewName

Function fxNewName

xs/sources/xsSymbol.c:326–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326txID fxNewName(txMachine* the, txSlot* theSlot)
327{
328 txU1* string;
329 txU4 sum;
330 txU4 modulo;
331 txSlot* result;
332
333 string = (txU1*)theSlot->value.string;
334 sum = 0;
335 while(*string != 0) {
336 sum = (sum << 1) + *string++;
337 }
338 sum &= 0x7FFFFFFF;
339 modulo = sum % the->nameModulo;
340 result = the->nameTable[modulo];
341 while (result != C_NULL) {
342 if (result->value.key.sum == sum) {
343 if (c_strcmp(result->value.key.string, theSlot->value.string) == 0)
344 return mxGetKeySlotID(result);
345 }
346 result = result->next;
347 }
348 result = fxFindKey(the);
349 result->next = the->nameTable[modulo];
350 result->flag = XS_INTERNAL_FLAG | XS_DONT_ENUM_FLAG;
351 result->kind = XS_KEY_KIND;
352 result->value.key.string = theSlot->value.string;
353 result->value.key.sum = sum;
354 the->nameTable[modulo] = result;
355 return result->ID;
356}
357
358txID fxNewNameC(txMachine* the, txString theString)
359{

Callers 9

fxMapModuleDescriptorFunction · 0.85
fxResolveSpecifierFunction · 0.85
fxImportModuleStuffFunction · 0.85
fxRunIDFunction · 0.85
fxAtFunction · 0.85
fxDemarshallFunction · 0.85
fxToIDFunction · 0.85
fxParseJSONObjectFunction · 0.85
fxToJSONKeysFunction · 0.85

Calls 1

fxFindKeyFunction · 0.85

Tested by

no test coverage detected