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

Function fxStringGetOwnProperty

xs/sources/xsString.c:483–504  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481}
482
483txBoolean fxStringGetOwnProperty(txMachine* the, txSlot* instance, txID id, txIndex index, txSlot* descriptor)
484{
485 if (id == mxID(_length)) {
486 descriptor->flag = XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG;
487 descriptor->ID = id;
488 descriptor->kind = XS_INTEGER_KIND;
489 descriptor->value.integer = mxStringInstanceLength(instance);
490 return 1;
491 }
492 if (!id && (mxCacheStringInstanceLength(instance) > index)) {
493 txSlot* string = instance->next;
494 txInteger from = fxCacheUnicodeToUTF8Offset(the, string->value.key.string, index);
495 txInteger length = fxUnicodeToUTF8Offset(string->value.key.string + from, 1);
496 descriptor->value.string = fxNewChunk(the, length + 1);
497 c_memcpy(descriptor->value.string, string->value.key.string + from, length);
498 descriptor->value.string[length] = 0;
499 descriptor->kind = XS_STRING_KIND;
500 descriptor->flag = XS_DONT_DELETE_FLAG | XS_DONT_SET_FLAG;
501 return 1;
502 }
503 return fxOrdinaryGetOwnProperty(the, instance, id, index, descriptor);
504}
505
506txSlot* fxStringGetProperty(txMachine* the, txSlot* instance, txID id, txIndex index, txFlag flag)
507{

Callers

nothing calls this directly

Calls 4

fxUnicodeToUTF8OffsetFunction · 0.85
fxNewChunkFunction · 0.85
fxOrdinaryGetOwnPropertyFunction · 0.85

Tested by

no test coverage detected