void fxSlotToID(txMachine* the, txSlot* slot, txInteger* id) { txString string; txSlot* key; again: if ((slot->kind == XS_INTEGER_KIND) && fxIntegerToIndex(the->dtoa, slot->value.integer, id)) return; if ((slot->kind == XS_NUMBER_KIND) && fxNumberToIndex(the->dtoa, slot->value.number, id)) return; if (slot->kind == XS_SYMBOL_KIND) { *id = slot->value.ID; return; } if (slot->kind == XS_REFERENCE_KIND) { fxToPrimitive(the, slot, XS_STRING_HINT); goto again; } string = fxToString(the, slot); if (!fxStringToIndex(the->dtoa, string, id)) { if (slot->kind == XS_STRING_X_KIND) key = fxNewNameX(the, string); else key = fxNewName(the, slot); *id = key->ID; } }
txSlot* fxAt(txMachine* the, txSlot* slot) { txIndex index; txString string; txSlot* key; again: if ((slot->kind == XS_INTEGER_KIND) && fxIntegerToIndex(the->dtoa, slot->value.integer, &index)) { slot->value.at.id = 0; slot->value.at.index = index; } else if ((slot->kind == XS_NUMBER_KIND) && fxNumberToIndex(the->dtoa, slot->value.number, &index)) { slot->value.at.id = 0; slot->value.at.index = index; } else if (slot->kind == XS_SYMBOL_KIND) { slot->value.at.id = slot->value.symbol; slot->value.at.index = XS_NO_ID; } else { if (slot->kind == XS_REFERENCE_KIND) { fxToPrimitive(the, slot, XS_STRING_HINT); goto again; } string = fxToString(the, slot); if (fxStringToIndex(the->dtoa, string, &index)) { slot->value.at.id = 0; slot->value.at.index = index; } else { if (slot->kind == XS_STRING_X_KIND) key = fxNewNameX(the, string); else key = fxNewName(the, slot); slot->value.at.id = key->ID; slot->value.at.index = XS_NO_ID; } } slot->kind = XS_AT_KIND; return slot; }
txInteger fxSlotToIndex(txMachine* the, txSlot* slot, txIndex* index) { txString string; txSlot* key; again: if ((slot->kind == XS_INTEGER_KIND) && fxIntegerToIndex(the->dtoa, slot->value.integer, index)) return 0; if ((slot->kind == XS_NUMBER_KIND) && fxNumberToIndex(the->dtoa, slot->value.number, index)) return 0; if (slot->kind == XS_SYMBOL_KIND) return slot->value.symbol; if (slot->kind == XS_REFERENCE_KIND) { fxToPrimitive(the, slot, XS_STRING_HINT); goto again; } string = fxToString(the, slot); if (fxStringToIndex(the->dtoa, string, index)) return 0; if (slot->kind == XS_STRING_X_KIND) key = fxNewNameX(the, string); else key = fxNewName(the, slot); return key->ID; }