| 1220 | } |
| 1221 | |
| 1222 | void fxSetEntry(txMachine* the, txSlot* table, txSlot* list, txSlot* key, txSlot* pair, txBoolean get) |
| 1223 | { |
| 1224 | txU4 sum = fxSumEntry(the, key); |
| 1225 | txU4 index = sum & (table->value.table.length - 1); |
| 1226 | txSlot** address = &(table->value.table.address[index]); |
| 1227 | txSlot* entry = *address; |
| 1228 | txSlot* first; |
| 1229 | txSlot* last; |
| 1230 | while (entry) { |
| 1231 | if (entry->value.entry.sum == sum) { |
| 1232 | first = entry->value.entry.slot; |
| 1233 | if (fxTestEntry(the, first, key)) { |
| 1234 | if (pair) { |
| 1235 | last = first->next; |
| 1236 | if (get) { |
| 1237 | pair->kind = last->kind; |
| 1238 | pair->value = last->value; |
| 1239 | } |
| 1240 | else { |
| 1241 | last->kind = pair->kind; |
| 1242 | last->value = pair->value; |
| 1243 | } |
| 1244 | } |
| 1245 | return; |
| 1246 | } |
| 1247 | } |
| 1248 | entry = entry->next; |
| 1249 | } |
| 1250 | first = fxNewSlot(the); |
| 1251 | first->kind = key->kind; |
| 1252 | first->value = key->value; |
| 1253 | mxPushClosure(first); |
| 1254 | if (pair) { |
| 1255 | first->next = last = fxNewSlot(the); |
| 1256 | last->kind = pair->kind; |
| 1257 | last->value = pair->value; |
| 1258 | mxPushClosure(last); |
| 1259 | } |
| 1260 | entry = fxNewSlot(the); |
| 1261 | address = &(table->value.table.address[index]); |
| 1262 | entry->next = *address; |
| 1263 | entry->kind = XS_ENTRY_KIND; |
| 1264 | entry->value.entry.slot = first; |
| 1265 | entry->value.entry.sum = sum; |
| 1266 | *address = entry; |
| 1267 | if (list->value.list.last) |
| 1268 | list->value.list.last->next = first; |
| 1269 | else |
| 1270 | list->value.list.first = first; |
| 1271 | if (pair) |
| 1272 | list->value.list.last = last; |
| 1273 | else |
| 1274 | list->value.list.last = first; |
| 1275 | if (pair) |
| 1276 | mxPop(); |
| 1277 | mxPop(); |
| 1278 | list->next->value.integer++; |
| 1279 | fxResizeEntries(the, table, list); |
no test coverage detected