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

Function fxParseJSONObject

xs/sources/xsJSON.c:511–592  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

509}
510
511void fxParseJSONObject(txMachine* the, txJSONParser* theParser)
512{
513 txSlot* sourceObject = NULL;
514 txSlot* valueObject;
515 txBoolean comma = 0;
516 txSlot* at;
517 txIndex index;
518 txID id;
519 txSlot* property;
520
521 mxCheckCStack();
522 fxParseJSONToken(the, theParser);
523 mxPush(mxObjectPrototype);
524 valueObject = fxNewObjectInstance(the);
525 if (theParser->sourceFlag) {
526 mxPush(mxObjectPrototype);
527 sourceObject = fxNewObjectInstance(the);
528 }
529 for (;;) {
530 if (theParser->token == XS_JSON_TOKEN_RIGHT_BRACE)
531 break;
532 if (comma) {
533 if (theParser->token == XS_JSON_TOKEN_COMMA)
534 fxParseJSONToken(the, theParser);
535 else
536 mxSyntaxError("%ld: missing ,", theParser->line);
537 }
538 if (theParser->token != XS_JSON_TOKEN_STRING)
539 mxSyntaxError("%ld: missing name", theParser->line);
540 mxPushString(theParser->string->value.string);
541 at = the->stack;
542 index = 0;
543 if (theParser->keys) {
544 at->kind = XS_UNDEFINED_KIND;
545 if (fxStringToIndex(the, at->value.string, &index))
546 id = 0;
547 else
548 id = fxFindName(the, at->value.string);
549 if (id != XS_NO_ID) {
550 txSlot* item = theParser->keys->value.reference->next;
551 while (item) {
552 if ((item->value.at.id == id) && (item->value.at.index == index)) {
553 at->value.at.id = id;
554 at->value.at.index = index;
555 at->kind = XS_AT_KIND;
556 break;
557 }
558 item = item->next;
559 }
560 }
561 }
562 else {
563 if (fxStringToIndex(the, at->value.string, &index))
564 id = 0;
565 else
566 id = fxNewName(the, at);
567 at->value.at.id = id;
568 at->value.at.index = index;

Callers 1

fxParseJSONValueFunction · 0.70

Calls 6

fxNewObjectInstanceFunction · 0.85
fxStringToIndexFunction · 0.85
fxFindNameFunction · 0.85
fxNewNameFunction · 0.85
fxParseJSONTokenFunction · 0.70
fxParseJSONValueFunction · 0.70

Tested by

no test coverage detected