| 268 | } |
| 269 | |
| 270 | void 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 | |
| 299 | void fxToSpeciesConstructor(txMachine* the, txSlot* constructor) |
| 300 | { |
no test coverage detected