MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxToPrimitive

Function fxToPrimitive

xs/sources/xsType.c:270–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270void fxToPrimitive(txMachine* the, txSlot* theSlot, txInteger theHint)
271{
272 if (mxIsReference(theSlot)) {
273 fxBeginHost(the);
274 mxPushSlot(theSlot);
275 mxPushSlot(theSlot);
276 mxGetID(mxID(_Symbol_toPrimitive));
277 if (mxIsUndefined(the->stack) || mxIsNull(the->stack)) {
278 mxPop();
279 mxPush(mxOrdinaryToPrimitiveFunction);
280 }
281 mxCall();
282 if (theHint == XS_NO_HINT)
283 mxPushSlot(&mxDefaultString);
284 else if (theHint == XS_NUMBER_HINT)
285 mxPushSlot(&mxNumberString);
286 else
287 mxPushSlot(&mxStringString);
288 mxRunCount(1);
289 theSlot->kind = the->stack->kind;
290 theSlot->value = the->stack->value;
291 if (mxIsReference(the->stack)) {
292 mxTypeError("cannot coerce to primitive");
293 }
294 mxPullSlot(theSlot);
295 fxEndHost(the);
296 }
297}
298
299void fxToSpeciesConstructor(txMachine* the, txSlot* constructor)
300{

Callers 14

fxRunIDFunction · 0.85
xsRun.cFile · 0.85
fxToNumericIntegerFunction · 0.85
fxToNumericNumberFunction · 0.85
fxAtFunction · 0.85
fxToIntegerFunction · 0.85
fxToNumberFunction · 0.85
fxToStringFunction · 0.85
fxToUnsignedFunction · 0.85
fx_BigIntFunction · 0.85
fxToBigIntFunction · 0.85
fx_Date_auxFunction · 0.85

Calls 2

fxBeginHostFunction · 0.85
fxEndHostFunction · 0.85

Tested by

no test coverage detected