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

Function fxScopeCodingParams

xs/sources/xsCode.c:1593–1632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1591}
1592
1593void fxScopeCodingParams(txScope* self, txCoder* coder)
1594{
1595 txDeclareNode* node = self->firstDeclareNode;
1596 while (node) {
1597 txToken token = node->description->token;
1598 if ((token == XS_TOKEN_ARG) || (token == XS_TOKEN_VAR) || (token == XS_TOKEN_CONST)) {
1599 if (node->flags & mxDeclareNodeClosureFlag) {
1600 if (node->flags & mxDeclareNodeUseClosureFlag) {
1601 fxReportParserError(self->parser, node->line, "argument %s use closure", node->symbol->string);
1602 }
1603 node->index = coder->scopeLevel++;
1604 fxCoderAddVariable(coder, 0, XS_CODE_NEW_CLOSURE, node->symbol, node->index);
1605 }
1606 else {
1607 node->index = coder->scopeLevel++;
1608 fxCoderAddVariable(coder, 0, XS_CODE_NEW_LOCAL, node->symbol, node->index);
1609 }
1610 }
1611 node = node->nextDeclareNode;
1612 }
1613 if (self->flags & mxEvalFlag) {
1614 if (!(self->node->flags & mxStrictFlag)) {
1615 fxCoderAddByte(coder, 1, XS_CODE_NULL);
1616 fxCoderAddByte(coder, 0, XS_CODE_WITH);
1617 fxCoderAddByte(coder, -1, XS_CODE_POP);
1618 coder->environmentLevel++;
1619 }
1620 fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1621 fxCoderAddByte(coder, 0, XS_CODE_WITH);
1622 node = self->firstDeclareNode;
1623 while (node) {
1624 txToken token = node->description->token;
1625 if ((token == XS_TOKEN_ARG) || (token == XS_TOKEN_VAR) || (token == XS_TOKEN_CONST))
1626 fxCoderAddIndex(coder, 0, XS_CODE_STORE_1, node->index);
1627 node = node->nextDeclareNode;
1628 }
1629 fxCoderAddByte(coder, -1, XS_CODE_POP);
1630 coder->environmentLevel++;
1631 }
1632}
1633
1634void fxScopeCodingProgram(txScope* self, txCoder* coder)
1635{

Callers 1

fxFunctionNodeCodeFunction · 0.85

Calls 4

fxReportParserErrorFunction · 0.85
fxCoderAddVariableFunction · 0.85
fxCoderAddByteFunction · 0.85
fxCoderAddIndexFunction · 0.85

Tested by

no test coverage detected