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

Function fxDuplicateInstance

xs/sources/xsType.c:104–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102#endif
103
104txSlot* fxDuplicateInstance(txMachine* the, txSlot* instance)
105{
106 txSlot* result;
107 txSlot* from;
108 txSlot* to;
109 result = fxNewInstance(the);
110 result->flag = instance->flag & ~XS_MARK_FLAG;
111 result->value.instance.garbage = C_NULL;
112 result->value.instance.prototype = instance->value.instance.prototype;
113 from = instance->next;
114 to = result;
115 while (from) {
116 if (from->kind != XS_WEAK_ENTRY_KIND) {
117 to = to->next = fxDuplicateSlot(the, from);
118 if (from->kind == XS_ARRAY_KIND) {
119 txSlot* address = from->value.array.address;
120 to->value.array.address = C_NULL;
121 if (address) {
122 txSize size = (((txChunk*)(((txByte*)address) - sizeof(txChunk)))->size) / sizeof(txSlot);
123 txSlot* chunk = (txSlot*)fxNewChunk(the, size * sizeof(txSlot));
124 address = from->value.array.address;
125 c_memcpy(chunk, address, size * sizeof(txSlot));
126 to->value.array.address = chunk;
127 while (size) {
128 chunk->flag &= ~XS_MARK_FLAG;
129 chunk++;
130 size--;
131 }
132 }
133 }
134 }
135 from = from->next;
136 }
137 return result;
138}
139
140txSlot* fxGetInstance(txMachine* the, txSlot* theSlot)
141{

Callers 5

mainFunction · 0.85
fx_CompartmentFunction · 0.85
fx_lockdown_auxFunction · 0.85
fx_lockdownFunction · 0.85

Calls 3

fxNewInstanceFunction · 0.85
fxDuplicateSlotFunction · 0.85
fxNewChunkFunction · 0.85

Tested by

no test coverage detected