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

Function fxStringifyJSONProperty

xs/sources/xsJSON.c:954–1139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

952}
953
954void fxStringifyJSONProperty(txMachine* the, txJSONStringifier* theStringifier, txInteger* theFlag)
955{
956 txSlot* aWrapper = the->stack + 2;
957 txSlot* aValue = the->stack + 1;
958 txSlot* aKey = the->stack;
959 txSlot* anInstance;
960 txSlot* aSlot;
961 txInteger aFlag;
962 txIndex aLength, anIndex;
963
964 mxCheckCStack();
965 if (mxIsReference(aValue) || mxIsBigInt(aValue)) {
966 /* THIS */
967 mxPushSlot(aValue);
968 /* FUNCTION */
969 mxDub();
970 mxGetID(mxID(_toJSON));
971 if (mxIsReference(the->stack) && mxIsFunction(the->stack->value.reference)) {
972 mxCall();
973 mxPushSlot(aKey);
974 fxToString(the, the->stack);
975 mxRunCount(1);
976 mxPullSlot(aValue);
977 }
978 the->stack = aKey;
979 }
980 if (theStringifier->replacer) {
981 /* THIS */
982 mxPushSlot(aWrapper);
983 /* FUNCTION */
984 mxPushSlot(theStringifier->replacer);
985 mxCall();
986 /* ARGUMENTS */
987 mxPushSlot(aKey);
988 fxToString(the, the->stack);
989 mxPushSlot(aValue);
990 /* COUNT */
991 mxRunCount(2);
992 mxPullSlot(aValue);
993 the->stack = aKey;
994 }
995 if (mxIsReference(aValue)) {
996 mxPushSlot(aValue);
997 anInstance = fxToInstance(the, the->stack);
998 if (anInstance->flag & XS_LEVEL_FLAG)
999 mxTypeError("cyclic value");
1000 the->stack = aKey;
1001 aSlot = anInstance->next;
1002 if (aSlot && (aSlot->flag & XS_INTERNAL_FLAG)) {
1003 if ((aSlot->kind == XS_INTEGER_KIND) || (aSlot->kind == XS_NUMBER_KIND)) {
1004 fxToNumber(the, aValue);
1005 }
1006 else if (mxIsStringPrimitive(aSlot)) {
1007 fxToString(the, aValue);
1008 }
1009 else if ((aSlot->kind == XS_BOOLEAN_KIND) || (aSlot->kind == XS_BIGINT_KIND) || (aSlot->kind == XS_BIGINT_X_KIND)) {
1010 aValue->kind = aSlot->kind;
1011 aValue->value = aSlot->value;

Callers 1

fxStringifyJSONFunction · 0.85

Calls 15

fxToStringFunction · 0.85
fxToInstanceFunction · 0.85
fxToNumberFunction · 0.85
fxStringifyJSONNameFunction · 0.85
fxStringifyJSONCharsFunction · 0.85
fxStringifyJSONIntegerFunction · 0.85
fxStringifyJSONNumberFunction · 0.85
fxStringifyJSONStringFunction · 0.85
fxIsCallableFunction · 0.85
fxIsArrayFunction · 0.85
fxToIntegerFunction · 0.85
fxStringifyJSONIndentFunction · 0.85

Tested by

no test coverage detected