Exemple #1
0
void fxGetClosure(txMachine* the, txInteger theID)
{
	txSlot* closures = mxFunctionInstanceClosures(the->stack->value.reference);
	txSlot* slot = fxGetOwnProperty(the, closures->value.reference, theID);
	if (slot) {
		if (slot->kind == XS_CLOSURE_KIND)
			slot = slot->value.closure;
		the->stack->kind = slot->kind;
		the->stack->value = slot->value;
	}
	else
		the->stack->kind = XS_UNDEFINED_KIND;
}
Exemple #2
0
void fxSetClosure(txMachine* the, txInteger theID)
{
	txSlot* closures = mxFunctionInstanceClosures(the->stack->value.reference);
	txSlot* slot = fxGetOwnProperty(the, closures->value.reference, theID);
	the->stack++;
	if (slot) {
		if (slot->kind == XS_CLOSURE_KIND)
			slot = slot->value.closure;
		slot->kind = the->stack->kind;
		slot->value = the->stack->value;
	}
	else
		mxDebugID(XS_TYPE_ERROR, "C: xsSet %s: not extensible", theID);
}
Exemple #3
0
txBoolean fxHasOwnID(txMachine* the, txInteger theID)
{
	txSlot* anInstance;
	txSlot* aProperty;

	fxToInstance(the, the->stack);
	anInstance = fxGetInstance(the, the->stack);
	aProperty = fxGetOwnProperty(the, anInstance, theID);
	the->stack++;
	if (aProperty) {
		the->scratch.kind = aProperty->kind;
		the->scratch.value = aProperty->value;
		return 1;
	}
	the->scratch.kind = XS_UNDEFINED_KIND;
	return 0;
}
Exemple #4
0
void fxBufferFrameName(txMachine* the, txString buffer, txSize size, txSlot* frame, txString suffix)
{
	txSlot* target = frame + 2; 
	txSlot* function = frame + 3; 
	txSlot* _this = frame + 4;
	if (function->kind == XS_REFERENCE_KIND) {
		function = function->value.reference;
		if (mxIsFunction(function)) {
			if (target->kind == XS_UNDEFINED_KIND) {
				txSlot* home = mxFunctionInstanceHome(function);
				if (home->kind == XS_REFERENCE_KIND) {
					home = home->value.reference;
					if (mxIsFunction(home)) {
						fxBufferFunctionName(the, buffer, size, home, ".");
					}
					else {
						txSlot* constructor = fxGetOwnProperty(the, home, mxID(_constructor));
						if (constructor) {
							if (constructor->kind == XS_REFERENCE_KIND) {
								constructor = constructor->value.reference;
								if (mxIsFunction(constructor))
									fxBufferFunctionName(the, buffer, size, constructor, ".prototype.");
							}
						}
						else if (_this->kind == XS_REFERENCE_KIND) {
							fxBufferObjectName(the, buffer, size, _this->value.reference, ".");
						}
					}
				}
			}
			fxBufferFunctionName(the, buffer, size, function, "");
		}
	}
	else
		c_strncat(buffer, "(host)", size - c_strlen(buffer) - 1);
	c_strncat(buffer, suffix, size - c_strlen(buffer) - 1);
}
Exemple #5
0
txBoolean fxHasOwnProperty(txMachine* the, txSlot* theInstance, txInteger theID) 
{
	if ((theInstance->flag & XS_VALUE_FLAG) && (theInstance->next->kind == XS_PROXY_KIND))
		return fxHasProxyProperty(the, theInstance, theID);
	return (fxGetOwnProperty(the, theInstance, theID)) ? 1 : 0;
}