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

Function fxAt

xs/sources/xsSymbol.c:432–471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432txSlot* fxAt(txMachine* the, txSlot* slot)
433{
434 txIndex index;
435 txString string;
436again:
437 if ((slot->kind == XS_INTEGER_KIND) && fxIntegerToIndex(the, slot->value.integer, &index)) {
438 slot->value.at.id = XS_NO_ID;
439 slot->value.at.index = index;
440 }
441 else if ((slot->kind == XS_NUMBER_KIND) && fxNumberToIndex(the, slot->value.number, &index)) {
442 slot->value.at.id = XS_NO_ID;
443 slot->value.at.index = index;
444 }
445 else if (slot->kind == XS_SYMBOL_KIND) {
446 slot->value.at.id = slot->value.symbol;
447 slot->value.at.index = 0;
448 }
449 else {
450 if (slot->kind == XS_REFERENCE_KIND) {
451 fxToPrimitive(the, slot, XS_STRING_HINT);
452 goto again;
453 }
454 string = fxToString(the, slot);
455 if (fxStringToIndex(the, string, &index)) {
456 slot->value.at.id = XS_NO_ID;
457 slot->value.at.index = index;
458 }
459 else {
460 txID id;
461 if (slot->kind == XS_STRING_X_KIND)
462 id = fxNewNameX(the, string);
463 else
464 id = fxNewName(the, slot);
465 slot->value.at.id = id;
466 slot->value.at.index = 0;
467 }
468 }
469 slot->kind = XS_AT_KIND;
470 return slot;
471}
472
473void fxKeyAt(txMachine* the, txID id, txIndex index, txSlot* slot)
474{

Callers 15

fxGetAtFunction · 0.85
fxHasAtFunction · 0.85
fxSetAtFunction · 0.85
fxDeleteAtFunction · 0.85
fxDefineAtFunction · 0.85
fx_Object_definePropertyFunction · 0.85

Calls 7

fxIntegerToIndexFunction · 0.85
fxNumberToIndexFunction · 0.85
fxToPrimitiveFunction · 0.85
fxToStringFunction · 0.85
fxStringToIndexFunction · 0.85
fxNewNameXFunction · 0.85
fxNewNameFunction · 0.85

Tested by

no test coverage detected