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

Function fxScopeCodingBody

xs/sources/xsCode.c:1451–1508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1449}
1450
1451void fxScopeCodingBody(txScope* self, txCoder* coder)
1452{
1453 if ((self->node->flags & mxEvalFlag) && !(self->node->flags & mxStrictFlag)) {
1454 txDeclareNode* node = self->firstDeclareNode;
1455 while (node) {
1456 if (node->description->token == XS_TOKEN_DEFINE) {
1457 node->index = coder->scopeLevel++;
1458 fxCoderAddVariable(coder, 0, XS_CODE_NEW_CLOSURE, node->symbol, node->index);
1459 fxCoderAddByte(coder, 1, XS_CODE_NULL);
1460 fxCoderAddIndex(coder, 0, XS_CODE_VAR_CLOSURE_1, node->index);
1461 fxCoderAddByte(coder, -1, XS_CODE_POP);
1462 }
1463 else if (node->description->token == XS_TOKEN_VAR) {
1464 node->index = coder->scopeLevel++;
1465 fxCoderAddVariable(coder, 0, XS_CODE_NEW_CLOSURE, node->symbol, node->index);
1466 fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1467 fxCoderAddIndex(coder, 0, XS_CODE_VAR_CLOSURE_1, node->index);
1468 fxCoderAddByte(coder, -1, XS_CODE_POP);
1469 }
1470 node = node->nextDeclareNode;
1471 }
1472 fxCoderAddByte(coder, 1, XS_CODE_NULL);
1473 fxCoderAddByte(coder, 0, XS_CODE_WITH);
1474 node = self->firstDeclareNode;
1475 while (node) {
1476 if ((node->description->token == XS_TOKEN_DEFINE) || (node->description->token == XS_TOKEN_VAR))
1477 fxCoderAddIndex(coder, 0, XS_CODE_STORE_1, node->index);
1478 node = node->nextDeclareNode;
1479 }
1480 fxCoderAddByte(coder, -1, XS_CODE_POP);
1481 coder->environmentLevel++;
1482 node = self->firstDeclareNode;
1483 while (node) {
1484 if ((node->description->token != XS_TOKEN_DEFINE) && (node->description->token != XS_TOKEN_VAR)) {
1485 node->index = coder->scopeLevel++;
1486 if (node->symbol)
1487 fxCoderAddVariable(coder, 0, XS_CODE_NEW_CLOSURE, node->symbol, node->index);
1488 else
1489 fxCoderAddIndex(coder, 0, XS_CODE_NEW_TEMPORARY, node->index);
1490 }
1491 node = node->nextDeclareNode;
1492 }
1493 fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1494 fxCoderAddByte(coder, 0, XS_CODE_WITH);
1495 node = self->firstDeclareNode;
1496 while (node) {
1497 if ((node->description->token != XS_TOKEN_DEFINE) && (node->description->token != XS_TOKEN_VAR)) {
1498 if (node->symbol)
1499 fxCoderAddIndex(coder, 0, XS_CODE_STORE_1, node->index);
1500 }
1501 node = node->nextDeclareNode;
1502 }
1503 fxCoderAddByte(coder, -1, XS_CODE_POP);
1504 coder->environmentLevel++;
1505 }
1506 else
1507 fxScopeCodingBlock(self, coder);
1508}

Callers 1

fxBodyNodeCodeFunction · 0.85

Calls 4

fxCoderAddVariableFunction · 0.85
fxCoderAddByteFunction · 0.85
fxCoderAddIndexFunction · 0.85
fxScopeCodingBlockFunction · 0.85

Tested by

no test coverage detected