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

Function fxObjectBinding

xs/sources/xsSyntaxical.c:3685–3783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3683}
3684
3685txUnsigned fxObjectBinding(txParser* parser, txToken theToken)
3686{
3687 txUnsigned flags = 0;
3688 txInteger aCount = 0;
3689 txInteger aLine = parser->states[0].line;
3690 txSymbol* aSymbol;
3691 txToken aToken;
3692 txIndex index;
3693 fxMatchToken(parser, XS_TOKEN_LEFT_BRACE);
3694 for (;;) {
3695 txInteger aPropertyLine = parser->states[0].line;
3696 if (parser->states[0].token == XS_TOKEN_RIGHT_BRACE)
3697 break;
3698 aSymbol = NULL;
3699 aToken = XS_TOKEN_PROPERTY_BINDING;
3700 if ((gxTokenFlags[parser->states[0].token] & XS_TOKEN_IDENTIFIER_NAME)) {
3701 aSymbol = parser->states[0].symbol;
3702 fxPushSymbol(parser, aSymbol);
3703 aToken = XS_TOKEN_PROPERTY_BINDING;
3704 }
3705 else if (parser->states[0].token == XS_TOKEN_INTEGER) {
3706 if (fxIntegerToIndex(parser->console, parser->states[0].integer, &index)) {
3707 fxPushIndexNode(parser, index, aPropertyLine);
3708 aToken = XS_TOKEN_PROPERTY_BINDING_AT;
3709 }
3710 else {
3711 aSymbol = fxNewParserSymbol(parser, fxIntegerToString(parser->console, parser->states[0].integer, parser->buffer, parser->bufferSize));
3712 fxPushSymbol(parser, aSymbol);
3713 aToken = XS_TOKEN_PROPERTY_BINDING;
3714 }
3715 }
3716 else if (parser->states[0].token == XS_TOKEN_NUMBER) {
3717 if (fxNumberToIndex(parser->console, parser->states[0].number, &index)) {
3718 fxPushIndexNode(parser, index, aPropertyLine);
3719 aToken = XS_TOKEN_PROPERTY_BINDING_AT;
3720 }
3721 else {
3722 aSymbol = fxNewParserSymbol(parser, fxNumberToString(parser->console, parser->states[0].number, parser->buffer, parser->bufferSize, 0, 0));
3723 fxPushSymbol(parser, aSymbol);
3724 aToken = XS_TOKEN_PROPERTY_BINDING;
3725 }
3726 }
3727 else if (parser->states[0].token == XS_TOKEN_STRING) {
3728 if (fxStringToIndex(parser->console, parser->states[0].string, &index)) {
3729 fxPushIndexNode(parser, index, aPropertyLine);
3730 aToken = XS_TOKEN_PROPERTY_BINDING_AT;
3731 }
3732 else {
3733 aSymbol = fxNewParserSymbol(parser, parser->states[0].string);
3734 fxPushSymbol(parser, aSymbol);
3735 aToken = XS_TOKEN_PROPERTY_BINDING;
3736 }
3737 }
3738 else if (parser->states[0].token == XS_TOKEN_LEFT_BRACKET) {
3739 fxGetNextToken(parser);
3740 fxCommaExpression(parser);
3741 if (parser->states[0].token != XS_TOKEN_RIGHT_BRACKET) {
3742 fxReportParserError(parser, parser->states[0].line, "missing ]");

Callers 1

fxBindingFunction · 0.85

Calls 15

fxMatchTokenFunction · 0.85
fxPushSymbolFunction · 0.85
fxIntegerToIndexFunction · 0.85
fxPushIndexNodeFunction · 0.85
fxNewParserSymbolFunction · 0.85
fxIntegerToStringFunction · 0.85
fxNumberToIndexFunction · 0.85
fxNumberToStringFunction · 0.85
fxStringToIndexFunction · 0.85
fxGetNextTokenFunction · 0.85
fxCommaExpressionFunction · 0.85
fxReportParserErrorFunction · 0.85

Tested by

no test coverage detected