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

Function fxModuleNodeCode

xs/sources/xsCode.c:3755–3861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3753}
3754
3755void fxModuleNodeCode(void* it, void* param)
3756{
3757 txModuleNode* self = it;
3758 txCoder* coder = param;
3759 txTargetCode* target = fxCoderCreateTarget(param);
3760 txDeclareNode* declaration;
3761 txInteger count;
3762 txSymbol* name = /*(coder->parser->flags & mxDebugFlag) ? self->path :*/ C_NULL;
3763 txFlag flag = 0;
3764
3765 coder->line = -1;
3766 coder->programFlag = 0;
3767 coder->scopeLevel = 0;
3768 coder->firstBreakTarget = NULL;
3769 coder->firstContinueTarget = NULL;
3770
3771 count = 0;
3772 declaration = self->scope->firstDeclareNode;
3773 while (declaration) {
3774 if ((declaration->description->token == XS_TOKEN_DEFINE) || (declaration->description->token == XS_TOKEN_VAR))
3775 count++;
3776 declaration = declaration->nextDeclareNode;
3777 }
3778 if (count) {
3779 fxCoderAddSymbol(param, 1, XS_CODE_FUNCTION, name);
3780 if (coder->parser->flags & mxDebugFlag)
3781 fxCoderAddByte(param, 0, XS_CODE_PROFILE);
3782 fxCoderAddBranch(param, 0, XS_CODE_CODE_1, target);
3783 fxCoderAddIndex(param, 0, XS_CODE_BEGIN_STRICT, 0);
3784 coder->path = C_NULL;
3785 if (self->line >= 0)
3786 fxCoderAddLine(coder, 0, XS_CODE_LINE, it);
3787 if (self->scopeCount)
3788 fxCoderAddIndex(param, 0, XS_CODE_RESERVE_1, self->scopeCount);
3789 fxScopeCodeRetrieve(self->scope, param);
3790 declaration = self->scope->firstDeclareNode;
3791 while (declaration) {
3792 if (declaration->description->token == XS_TOKEN_VAR) {
3793 fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
3794 fxCoderAddIndex(coder, 0, XS_CODE_VAR_CLOSURE_1, declaration->index);
3795 fxCoderAddByte(coder, -1, XS_CODE_POP);
3796 }
3797 declaration = declaration->nextDeclareNode;
3798 }
3799 fxScopeCodeDefineNodes(self->scope, param);
3800 fxCoderAddByte(param, 0, XS_CODE_END);
3801 fxCoderAdd(param, 0, target);
3802 fxCoderAddByte(param, 1, XS_CODE_ENVIRONMENT);
3803 fxCoderAddByte(param, -1, XS_CODE_POP);
3804
3805 target = fxCoderCreateTarget(param);
3806 coder->line = -1;
3807 coder->programFlag = 0;
3808 coder->scopeLevel = 0;
3809 coder->firstBreakTarget = NULL;
3810 coder->firstContinueTarget = NULL;
3811 }
3812 else {

Callers

nothing calls this directly

Calls 14

fxCoderCreateTargetFunction · 0.85
fxCoderAddSymbolFunction · 0.85
fxCoderAddByteFunction · 0.85
fxCoderAddBranchFunction · 0.85
fxCoderAddIndexFunction · 0.85
fxCoderAddLineFunction · 0.85
fxScopeCodeRetrieveFunction · 0.85
fxScopeCodeDefineNodesFunction · 0.85
fxCoderAddFunction · 0.85
fxScopeCodeUsingFunction · 0.85
fxNodeDispatchCodeFunction · 0.85
fxScopeCodeUsedFunction · 0.85

Tested by

no test coverage detected