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

Function fxScopeCodingBlock

xs/sources/xsCode.c:1407–1449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1405}
1406
1407void fxScopeCodingBlock(txScope* self, txCoder* coder)
1408{
1409 if (self->declareNodeCount) {
1410 txDeclareNode* node = self->firstDeclareNode;
1411 while (node) {
1412 if (node->flags & mxDeclareNodeClosureFlag) {
1413 if (!(node->flags & mxDeclareNodeUseClosureFlag)) {
1414 node->index = coder->scopeLevel++;
1415 fxCoderAddVariable(coder, 0, XS_CODE_NEW_CLOSURE, node->symbol, node->index);
1416 if (node->description->token == XS_TOKEN_VAR) {
1417 fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1418 fxCoderAddIndex(coder, 0, XS_CODE_VAR_CLOSURE_1, node->index);
1419 fxCoderAddByte(coder, -1, XS_CODE_POP);
1420 }
1421 }
1422 }
1423 else {
1424 node->index = coder->scopeLevel++;
1425 if (node->symbol)
1426 fxCoderAddVariable(coder, 0, XS_CODE_NEW_LOCAL, node->symbol, node->index);
1427 else
1428 fxCoderAddIndex(coder, 0, XS_CODE_NEW_TEMPORARY, node->index);
1429 if (node->description->token == XS_TOKEN_VAR) {
1430 fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1431 fxCoderAddIndex(coder, 0, XS_CODE_VAR_LOCAL_1, node->index);
1432 fxCoderAddByte(coder, -1, XS_CODE_POP);
1433 }
1434 }
1435 node = node->nextDeclareNode;
1436 }
1437 if (self->flags & mxEvalFlag) {
1438 fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1439 fxCoderAddByte(coder, 0, XS_CODE_WITH);
1440 node = self->firstDeclareNode;
1441 while (node) {
1442 fxCoderAddIndex(coder, 0, XS_CODE_STORE_1, node->index);
1443 node = node->nextDeclareNode;
1444 }
1445 fxCoderAddByte(coder, -1, XS_CODE_POP);
1446 coder->environmentLevel++;
1447 }
1448 }
1449}
1450
1451void fxScopeCodingBody(txScope* self, txCoder* coder)
1452{

Callers 8

fxScopeCodingBodyFunction · 0.85
fxScopeCodingEvalFunction · 0.85
fxBlockNodeCodeFunction · 0.85
fxCatchNodeCodeFunction · 0.85
fxClassNodeCodeFunction · 0.85
fxForNodeCodeFunction · 0.85
fxForInForOfNodeCodeFunction · 0.85
fxSwitchNodeCodeFunction · 0.85

Calls 3

fxCoderAddVariableFunction · 0.85
fxCoderAddByteFunction · 0.85
fxCoderAddIndexFunction · 0.85

Tested by

no test coverage detected