コード例 #1
0
ファイル: xs6Function.c プロジェクト: afrog33k/kinomajs
void fx_Function_prototype_hasInstance(txMachine* the)
{
    txSlot* instance;
    txSlot* prototype;
    mxResult->value.boolean = 0;
    mxResult->kind = XS_BOOLEAN_KIND;
    if (mxArgc == 0)
        return;
    instance = fxGetInstance(the, mxArgv(0));
    if (!instance)
        return;
    mxPushSlot(mxThis);
    fxGetID(the, mxID(_prototype));
    prototype = fxGetInstance(the, the->stack);
    if (!prototype)
        mxTypeError("prototype is no object");
    while (instance) {
        if (instance == prototype) {
            mxResult->value.boolean = 1;
            break;
        }
        instance = fxGetParent(the, instance);
    }
    the->stack++;
}
コード例 #2
0
ファイル: xs6Host.c プロジェクト: dadongdong/kinomajs
void fxRunForIn(txMachine* the)
{
	txSlot* limit = the->stack;
	txSlot* slot = fxToInstance(the, limit);
	while (slot) {
		fxEachInstanceProperty(the, slot, XS_EACH_ENUMERABLE_FLAG | XS_EACH_STRING_FLAG, fxRunForInProperty, limit, slot);
		slot = fxGetParent(the, slot);
	}
	slot = the->stack;
	while (slot < limit) {
		txInteger id = slot->value.integer;
		if (id < 0) {
			txSlot* key = fxGetKey(the, (txID)id);
			if (key && (key->flag & XS_DONT_ENUM_FLAG)) {
				if (key->kind == XS_KEY_KIND) {
					slot->kind = XS_STRING_KIND;
					slot->value.string = key->value.key.string;
				}
				else {
					slot->kind = XS_STRING_X_KIND;
					slot->value.string = key->value.key.string;
				}
			}
			else {
				slot->kind = XS_SYMBOL_KIND;
				slot->value.ID = (txID)id;
			}
		}
		slot++;
	}
	limit->kind = XS_NULL_KIND;
}
コード例 #3
0
ファイル: xs6API.c プロジェクト: dadongdong/kinomajs
txBoolean fxIsInstanceOf(txMachine* the)
{
	txBoolean result = 0;
	txSlot* theInstance = the->stack++;
	txSlot* thePrototype = the->stack++;

	if (mxIsReference(theInstance) && mxIsReference(thePrototype)) {
		theInstance	= fxGetInstance(the, theInstance);
		thePrototype = fxGetInstance(the, thePrototype);
		while (theInstance) {
			if (theInstance == thePrototype) {
				result = 1;
				break;
			}
			theInstance = fxGetParent(the, theInstance);
		}
	}
	return result;
}