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

Function fxNewNameX

xs/sources/xsSymbol.c:396–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394}
395
396txID fxNewNameX(txMachine* the, txString theString)
397{
398 txU1* string;
399 txU4 sum;
400 txU4 modulo;
401 txSlot* result;
402
403 string = (txU1*)theString;
404 sum = 0;
405 while (c_read8(string) != 0) {
406 sum = (sum << 1) + c_read8(string++);
407 }
408 sum &= 0x7FFFFFFF;
409 modulo = sum % the->nameModulo;
410 result = the->nameTable[modulo];
411 while (result != C_NULL) {
412 if (result->value.key.sum == sum) {
413 if (c_strcmp(result->value.key.string, theString) == 0) {
414 txID id = mxGetKeySlotID(result);
415 if (id >= the->keyOffset)
416 result->flag |= XS_DONT_DELETE_FLAG;
417 return id;
418 }
419 }
420 result = result->next;
421 }
422 result = fxFindKey(the);
423 result->next = the->nameTable[modulo];
424 result->flag = XS_INTERNAL_FLAG | XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG;
425 result->kind = XS_KEY_X_KIND;
426 result->value.key.string = theString;
427 result->value.key.sum = sum;
428 the->nameTable[modulo] = result;
429 return result->ID;
430}
431
432txSlot* fxAt(txMachine* the, txSlot* slot)
433{

Callers 8

fxBuildKeysFunction · 0.85
fxMapModuleDescriptorFunction · 0.85
fxResolveSpecifierFunction · 0.85
fxImportModuleStuffFunction · 0.85
fxRunIDFunction · 0.85
fxAtFunction · 0.85
fxToIDFunction · 0.85
fxToJSONKeysFunction · 0.85

Calls 1

fxFindKeyFunction · 0.85

Tested by

no test coverage detected