| 1191 | } |
| 1192 | |
| 1193 | txSlot* fxToJSONKeys(txMachine* the, txSlot* reference) |
| 1194 | { |
| 1195 | txSlot* list = fxNewInstance(the); |
| 1196 | txSlot* item = list; |
| 1197 | txSlot* slot; |
| 1198 | txIndex length, i; |
| 1199 | mxPushSlot(reference); |
| 1200 | mxGetID(mxID(_length)); |
| 1201 | length = (txIndex)fxToLength(the, the->stack); |
| 1202 | mxPop(); |
| 1203 | i = 0; |
| 1204 | while (i < length) { |
| 1205 | txBoolean flag = 0; |
| 1206 | txID id = XS_NO_ID; |
| 1207 | txIndex index = 0; |
| 1208 | mxPushSlot(reference); |
| 1209 | mxGetIndex(i); |
| 1210 | slot = the->stack; |
| 1211 | again: |
| 1212 | if ((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) { |
| 1213 | if (fxStringToIndex(the, slot->value.string, &index)) |
| 1214 | flag = 1; |
| 1215 | else { |
| 1216 | if (slot->kind == XS_STRING_X_KIND) |
| 1217 | id = fxNewNameX(the, slot->value.string); |
| 1218 | else |
| 1219 | id = fxNewName(the, slot); |
| 1220 | flag = 1; |
| 1221 | } |
| 1222 | } |
| 1223 | else if (slot->kind == XS_INTEGER_KIND) { |
| 1224 | if (fxIntegerToIndex(the, slot->value.integer, &index)) |
| 1225 | flag = 1; |
| 1226 | else { |
| 1227 | fxToString(the, slot); |
| 1228 | goto again; |
| 1229 | } |
| 1230 | } |
| 1231 | else if (slot->kind == XS_NUMBER_KIND){ |
| 1232 | if (fxNumberToIndex(the, slot->value.number, &index)) |
| 1233 | flag = 1; |
| 1234 | else { |
| 1235 | fxToString(the, slot); |
| 1236 | goto again; |
| 1237 | } |
| 1238 | } |
| 1239 | else if (slot->kind == XS_REFERENCE_KIND) { |
| 1240 | txSlot* instance = slot->value.reference; |
| 1241 | if (mxIsNumber(instance) || mxIsString(instance)) { |
| 1242 | fxToString(the, slot); |
| 1243 | goto again; |
| 1244 | } |
| 1245 | } |
| 1246 | if (flag) { |
| 1247 | txSlot* already = list->next; |
| 1248 | while (already) { |
| 1249 | if ((already->value.at.id == id) && (already->value.at.index == index)) |
| 1250 | break; |
no test coverage detected