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

Function fxAliasInstance

xs/sources/xsType.c:59–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57
58#if mxAliasInstance
59txSlot* fxAliasInstance(txMachine* the, txSlot* instance)
60{
61 txSlot* alias;
62 txSlot* from;
63 txSlot* to;
64 the->aliasArray[instance->ID] = alias = fxNewSlot(the);
65 alias->flag = instance->flag & ~(XS_MARK_FLAG | XS_DONT_MARSHALL_FLAG);
66 alias->kind = XS_INSTANCE_KIND;
67 alias->value.instance.garbage = instance->value.instance.garbage;
68 alias->value.instance.prototype = instance->value.instance.prototype;
69 from = instance->next;
70 to = alias;
71 while (from) {
72 to = to->next = fxDuplicateSlot(the, from);
73 if (to->kind == XS_ARRAY_KIND) {
74 txSlot* address = to->value.array.address;
75 if (address) {
76 txSize size = (((txChunk*)(((txByte*)address) - sizeof(txChunk)))->size) / sizeof(txSlot);
77 txSlot* chunk = (txSlot*)fxNewChunk(the, size * sizeof(txSlot));
78 c_memcpy(chunk, address, size * sizeof(txSlot));
79 to->value.array.address = chunk;
80 while (size) {
81 chunk->flag &= ~XS_MARK_FLAG;
82 chunk++;
83 size--;
84 }
85 }
86 }
87 else if (to->kind == XS_DATE_KIND) {
88 to->flag &= ~XS_DONT_SET_FLAG;
89 }
90 else if (to->kind == XS_PRIVATE_KIND) {
91 txSlot** address = &to->value.private.first;
92 txSlot* slot;
93 while ((slot = *address)) {
94 *address = slot = fxDuplicateSlot(the, slot);
95 address = &slot->next;
96 }
97 }
98 from = from->next;
99 }
100 return alias;
101}
102#endif
103
104txSlot* fxDuplicateInstance(txMachine* the, txSlot* instance)

Callers 11

fxDefinePrivatePropertyFunction · 0.85
fxSetPrivatePropertyFunction · 0.85
fxCheckArrayFunction · 0.85
fxArrayLengthSetterFunction · 0.85
fxArrayDefineOwnPropertyFunction · 0.85
fxOrdinaryDeletePropertyFunction · 0.85
fxOrdinarySetPropertyFunction · 0.85
fxOrdinarySetPrototypeFunction · 0.85

Calls 3

fxNewSlotFunction · 0.85
fxDuplicateSlotFunction · 0.85
fxNewChunkFunction · 0.85

Tested by

no test coverage detected