Ejemplo n.º 1
0
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;
    }
}
Ejemplo n.º 2
0
void fxBuildKeys(txMachine* the)
{
	txArchive* archive = the->archive;
	if (archive && archive->keys)
		(*archive->keys)(the);
	else {
	#ifdef mxParse
		txSlot* code = &mxIDs;
		txID c, i;
		if (archive) {
			c = archive->symbolCount;
			code->value.code = (txByte *)fxNewChunk(the, c * sizeof(txID));
			code->kind = XS_CODE_KIND;	
			for (i = 0; i < XS_SYMBOL_ID_COUNT; i++) {
				txString string = archive->symbols[i];
				txID id = the->keyIndex;
				txSlot* description = fxNewSlot(the);
				description->flag = XS_DONT_ENUM_FLAG;
				fxCopyStringC(the, description, string);
				the->keyArray[id] = description;
				the->keyIndex++;
				mxID(i) = 0x8000 | id;
			}
			for (; i < c; i++) {
				txString string = archive->symbols[i];
				mxID(i) = fxNewNameX(the, string)->ID;
			}
		}
		else {
			code->value.code = (txByte *)fxNewChunk(the, XS_ID_COUNT * sizeof(txID));
			code->kind = XS_CODE_KIND;	
			for (i = 0; i < XS_SYMBOL_ID_COUNT; i++) {
				txID id = the->keyIndex;
				txSlot* description = fxNewSlot(the);
				description->flag = XS_DONT_ENUM_FLAG;
				fxCopyStringC(the, description, gxIDStrings[i]);
				the->keyArray[id] = description;
				the->keyIndex++;
				mxID(i) = 0x8000 | id;
			}
			for (; i < XS_ID_COUNT; i++) {
				mxID(i) = fxID(the, gxIDStrings[i]);
			}
		}
	#else
		fxCheck(the, __FILE__, __LINE__);
	#endif
	}
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
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;
}