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

Function fxToString

xs/sources/xsAPI.c:273–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271}
272
273txString fxToString(txMachine* the, txSlot* theSlot)
274{
275 char aBuffer[256];
276again:
277 switch (theSlot->kind) {
278 case XS_UNDEFINED_KIND:
279 *theSlot = mxUndefinedString;
280 break;
281 case XS_NULL_KIND:
282 fxStringX(the, theSlot, "null");
283 break;
284 case XS_BOOLEAN_KIND:
285 if (theSlot->value.boolean == 0)
286 fxStringX(the, theSlot, "false");
287 else
288 fxStringX(the, theSlot, "true");
289 break;
290 case XS_INTEGER_KIND:
291 fxCopyStringC(the, theSlot, fxIntegerToString(the, theSlot->value.integer, aBuffer, sizeof(aBuffer)));
292 mxMeterOne();
293 break;
294 case XS_NUMBER_KIND:
295 fxCopyStringC(the, theSlot, fxNumberToString(the, theSlot->value.number, aBuffer, sizeof(aBuffer), 0, 0));
296 mxMeterOne();
297 break;
298 case XS_SYMBOL_KIND:
299 mxTypeError("cannot coerce symbol to string");
300 break;
301 case XS_BIGINT_KIND:
302 case XS_BIGINT_X_KIND:
303 gxTypeBigInt.toString(the, theSlot, 0);
304 break;
305 case XS_STRING_KIND:
306 case XS_STRING_X_KIND:
307 break;
308 case XS_REFERENCE_KIND:
309 fxToPrimitive(the, theSlot, XS_STRING_HINT);
310 goto again;
311 default:
312 mxTypeError("cannot coerce to string");
313 break;
314 }
315 return theSlot->value.string;
316}
317
318txString fxToStringBuffer(txMachine* the, txSlot* theSlot, txString theBuffer, txSize theSize)
319{

Callers 15

_xsbug_doneFunction · 0.85
_xsbug_importRejectedFunction · 0.85
_xsbug_module_Function · 0.85
_xsbug_script_Function · 0.85
_262_evalScriptFunction · 0.85
PiuDebugBehavior_compileFunction · 0.85
fx_parseURLFunction · 0.85
fx_parseQueryFunction · 0.85
fx_serializeQueryPlusFunction · 0.85
fxFindStringFunction · 0.85
fxDuplicateStringFunction · 0.85

Calls 6

fxStringXFunction · 0.85
fxCopyStringCFunction · 0.85
fxIntegerToStringFunction · 0.85
fxNumberToStringFunction · 0.85
fxToPrimitiveFunction · 0.85
toStringMethod · 0.45

Tested by

no test coverage detected