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

Function fxCheckArray

xs/sources/xsArray.c:336–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334}
335
336txSlot* fxCheckArray(txMachine* the, txSlot* slot, txBoolean mutable)
337{
338 txSlot* instance = fxToInstance(the, slot);
339 txSlot* array = instance->next;
340 if (array && (array->kind == XS_ARRAY_KIND) && (array->ID == XS_ARRAY_BEHAVIOR)) {
341#if mxAliasInstance
342 if (instance->ID) {
343 txSlot* alias = the->aliasArray[instance->ID];
344 if (alias)
345 array = alias->next;
346 else if (mutable) {
347 instance = fxAliasInstance(the, instance);
348 array = instance->next;
349 }
350 }
351#endif
352 {
353 txSlot* address = array->value.array.address;
354 txIndex size = (address) ? (((txChunk*)(((txByte*)address) - sizeof(txChunk)))->size) / sizeof(txSlot) : 0;
355 txSlot* prototype = instance->value.instance.prototype;
356 if (array->value.array.length != size)
357 return C_NULL;
358 if (mutable && ((instance->flag & XS_DONT_PATCH_FLAG) || (array->flag & XS_DONT_SET_FLAG)))
359 return C_NULL;
360 while (prototype) {
361 txSlot* property = prototype->next;
362 while (property) {
363 if (property->flag & XS_INTERNAL_FLAG) {
364 if ((property->kind == XS_ARRAY_KIND) && (property->value.array.address != C_NULL))
365 return C_NULL;
366 }
367 else
368 break;
369 property = property->next;
370 }
371 prototype = prototype->value.instance.prototype;
372 }
373 return array;
374 }
375 }
376 return C_NULL;
377}
378
379txSlot* fxCheckArrayItems(txMachine* the, txSlot* array, txIndex from, txIndex to)
380{

Callers 15

fxCreateArrayFunction · 0.85
fx_Array_prototype_atFunction · 0.85
fx_Array_prototype_fillFunction · 0.85
fx_Array_prototype_popFunction · 0.85
fx_Array_prototype_pushFunction · 0.85
fx_Array_prototype_shiftFunction · 0.85
fx_Array_prototype_sliceFunction · 0.85
fx_Array_prototype_sortFunction · 0.85

Calls 2

fxToInstanceFunction · 0.85
fxAliasInstanceFunction · 0.85

Tested by

no test coverage detected