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

Function fx_Number

xs/sources/xsNumber.c:209–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209void fx_Number(txMachine* the)
210{
211 txNumber value = 0;
212 if (mxArgc > 0) {
213 txSlot* slot = mxArgv(0);
214 if (slot->kind == XS_REFERENCE_KIND)
215 fxToPrimitive(the, slot, XS_NUMBER_HINT);
216 if ((slot->kind == XS_BIGINT_KIND) || (slot->kind == XS_BIGINT_X_KIND))
217 value = gxTypeBigInt.toNumber(the, slot);
218 else
219 value = fxToNumber(the, slot);
220 }
221 if (!mxHasTarget) {
222 mxResult->kind = XS_NUMBER_KIND;
223 mxResult->value.number = value;
224 fx_Math_toInteger(the);
225 }
226 else {
227 txSlot* instance;
228 mxPushSlot(mxTarget);
229 fxGetPrototypeFromConstructor(the, &mxNumberPrototype);
230 instance = fxNewNumberInstance(the);
231 instance->next->value.number = value;
232 mxPullSlot(mxResult);
233 }
234}
235
236void fx_Number_isFinite(txMachine* the)
237{

Callers

nothing calls this directly

Calls 5

fxToPrimitiveFunction · 0.85
fxToNumberFunction · 0.85
fx_Math_toIntegerFunction · 0.85
fxNewNumberInstanceFunction · 0.85

Tested by

no test coverage detected