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

Function fxVerifyInstance

xs/sources/xsLockdown.c:750–891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

748}
749
750void fxVerifyInstance(txMachine* the, txSlot* list, txSlot* path, txSlot* instance)
751{
752 txSlot* property;
753 txSlot* prototype;
754
755 instance->flag |= XS_LEVEL_FLAG;
756
757 if (instance->next && (instance->next->ID == XS_ENVIRONMENT_BEHAVIOR)) {
758 property = instance->next->next;
759 while (property) {
760 if ((property->kind == XS_CLOSURE_KIND) && (property->ID != XS_NO_ID)) { // skip private fields initializers
761 txSlot* closure = property->value.closure;
762 if (!(closure->flag & XS_DONT_SET_FLAG)) {
763 fxVerifyError(the, path, property->ID, 0, C_NULL);
764 }
765 if (closure->kind == XS_REFERENCE_KIND) {
766 fxVerifyQueue(the, list, path, closure->value.reference, property->ID, 0, C_NULL);
767 }
768 }
769 property = property->next;
770 }
771 return;
772 }
773
774 if (!(instance->flag & XS_DONT_PATCH_FLAG)) {
775 fxVerifyError(the, path, XS_NO_ID, 0, "Extensible");
776 }
777
778 prototype = fxGetPrototype(the, instance);
779 if (prototype) {
780 fxVerifyQueue(the, list, path, prototype, mxID(___proto__), 0, C_NULL);
781 }
782
783 property = instance->next;
784 while (property) {
785 if (property->flag & XS_INTERNAL_FLAG) {
786 switch (property->kind) {
787 case XS_ARRAY_KIND:
788 {
789 txSlot* address = property->value.array.address;
790 if (address) {
791 txIndex index, offset = 0, size = (((txChunk*)(((txByte*)address) - sizeof(txChunk)))->size) / sizeof(txSlot);
792 while (offset < size) {
793 address = property->value.array.address + offset;
794 index = *((txIndex*)address);
795 fxVerifyPropertyError(the, list, path, address, XS_NO_ID, index);
796 address = property->value.array.address + offset;
797 if (address->kind == XS_REFERENCE_KIND)
798 fxVerifyQueue(the, list, path, address->value.reference, XS_NO_ID, index, C_NULL);
799 else if (address->kind == XS_ACCESSOR_KIND) {
800 if (address->value.accessor.getter)
801 fxVerifyQueue(the, list, path, address->value.accessor.getter, XS_NO_ID, index, C_NULL);
802 address = property->value.array.address + offset;
803 if (address->value.accessor.setter)
804 fxVerifyQueue(the, list, path, address->value.accessor.setter, XS_NO_ID, index, C_NULL);
805 }
806 offset++;
807 }

Callers 1

fx_mutabilitiesFunction · 0.85

Calls 6

fxVerifyErrorFunction · 0.85
fxVerifyQueueFunction · 0.85
fxGetPrototypeFunction · 0.85
fxVerifyPropertyErrorFunction · 0.85
fxVerifyCodeFunction · 0.85
fxVerifyPropertyFunction · 0.85

Tested by

no test coverage detected