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

Function fxObjectExpression

xs/sources/xsSyntaxical.c:3124–3215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3122}
3123
3124void fxObjectExpression(txParser* parser)
3125{
3126 txInteger aCount = 0;
3127 txSymbol* aSymbol;
3128 txToken aToken0;
3129 txToken aToken1;
3130 txToken aToken2;
3131 txInteger aLine = parser->states[0].line;
3132 txNode* base = parser->root;
3133 fxMatchToken(parser, XS_TOKEN_LEFT_BRACE);
3134 for (;;) {
3135 txInteger aPropertyLine = parser->states[0].line;
3136 txUnsigned flags = 0;
3137 if (parser->states[0].token == XS_TOKEN_RIGHT_BRACE)
3138 break;
3139 if (parser->states[0].token == XS_TOKEN_SPREAD) {
3140 fxGetNextToken(parser);
3141 fxAssignmentExpression(parser);
3142 fxPushNodeStruct(parser, 1, XS_TOKEN_SPREAD, aPropertyLine);
3143 }
3144 else {
3145 fxPropertyName(parser, &aSymbol, &aToken0, &aToken1, &aToken2, &flags);
3146 if (aToken1 == XS_TOKEN_PRIVATE_PROPERTY) {
3147 fxReportParserError(parser, parser->states[0].line, "invalid private property");
3148 }
3149 else if ((aToken2 == XS_TOKEN_GETTER) || (aToken2 == XS_TOKEN_SETTER)) {
3150 flags |= mxShorthandFlag;
3151 if (aToken2 == XS_TOKEN_GETTER)
3152 flags |= mxGetterFlag;
3153 else if (aToken2 == XS_TOKEN_SETTER)
3154 flags |= mxSetterFlag;
3155 if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS)
3156 fxFunctionExpression(parser, aPropertyLine, C_NULL, mxSuperFlag);
3157 else
3158 fxReportParserError(parser, parser->states[0].line, "missing (");
3159 }
3160 else if (aToken2 == XS_TOKEN_GENERATOR) {
3161 flags |= mxShorthandFlag | mxMethodFlag;
3162 if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS)
3163 fxGeneratorExpression(parser, aPropertyLine, C_NULL, mxSuperFlag | flags);
3164 else
3165 fxReportParserError(parser, parser->states[0].line, "missing (");
3166 }
3167 else if (aToken2 == XS_TOKEN_FUNCTION) {
3168 flags |= mxShorthandFlag | mxMethodFlag;
3169 if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS)
3170 fxFunctionExpression(parser, aPropertyLine, C_NULL, mxSuperFlag | flags);
3171 else
3172 fxReportParserError(parser, parser->states[0].line, "missing (");
3173 }
3174 else if (parser->states[0].token == XS_TOKEN_LEFT_PARENTHESIS) {
3175 flags |= mxShorthandFlag | mxMethodFlag;
3176 fxFunctionExpression(parser, aPropertyLine, C_NULL, mxSuperFlag | flags);
3177 }
3178 else if (parser->states[0].token == XS_TOKEN_COLON) {
3179 fxGetNextToken(parser);
3180 fxAssignmentExpression(parser);
3181 }

Callers 1

fxLiteralExpressionFunction · 0.85

Calls 11

fxMatchTokenFunction · 0.85
fxGetNextTokenFunction · 0.85
fxAssignmentExpressionFunction · 0.85
fxPushNodeStructFunction · 0.85
fxPropertyNameFunction · 0.85
fxReportParserErrorFunction · 0.85
fxFunctionExpressionFunction · 0.85
fxGeneratorExpressionFunction · 0.85
fxPushSymbolFunction · 0.85
fxCheckUniquePropertyFunction · 0.85
fxPushNodeListFunction · 0.85

Tested by

no test coverage detected