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

Function fxDefineNodeHoist

xs/sources/xsScope.c:614–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

612}
613
614void fxDefineNodeHoist(void* it, void* param)
615{
616 txDefineNode* self = it;
617 txHoister* hoister = param;
618 txDeclareNode* node;
619 if (self->flags & mxStrictFlag) {
620 if ((self->symbol == hoister->parser->argumentsSymbol) || (self->symbol == hoister->parser->evalSymbol) || (self->symbol == hoister->parser->yieldSymbol))
621 fxReportParserError(hoister->parser, self->line, "invalid definition %s", self->symbol->string);
622 }
623 if ((hoister->scope == hoister->bodyScope) && (hoister->scope->token != XS_TOKEN_MODULE)) {
624 node = fxScopeGetDeclareNode(hoister->bodyScope, self->symbol);
625 if (node) {
626 if ((node->description->token == XS_TOKEN_CONST) || (node->description->token == XS_TOKEN_LET))
627 fxReportParserError(hoister->parser, self->line, "duplicate variable %s", self->symbol->string);
628 }
629 else {
630 if (hoister->functionScope != hoister->bodyScope)
631 node = fxScopeGetDeclareNode(hoister->functionScope, self->symbol);
632 if (!node)
633 fxScopeAddDeclareNode(hoister->bodyScope, (txDeclareNode*)self);
634 }
635 fxScopeAddDefineNode(hoister->bodyScope, self);
636 }
637 else {
638 node = fxScopeGetDeclareNode(hoister->scope, self->symbol);
639 if (node)
640 fxReportParserError(hoister->parser, self->line, "duplicate variable %s", self->symbol->string);
641 else
642 fxScopeAddDeclareNode(hoister->scope, (txDeclareNode*)self);
643 fxScopeAddDefineNode(hoister->scope, self);
644 }
645 ((txFunctionNode*)(self->initializer))->symbol = C_NULL;
646 fxNodeDispatchHoist(self->initializer, param);
647 ((txFunctionNode*)(self->initializer))->symbol = self->symbol;
648}
649
650void fxExportNodeHoist(void* it, void* param)
651{

Callers

nothing calls this directly

Calls 5

fxReportParserErrorFunction · 0.85
fxScopeGetDeclareNodeFunction · 0.85
fxScopeAddDeclareNodeFunction · 0.85
fxScopeAddDefineNodeFunction · 0.85
fxNodeDispatchHoistFunction · 0.85

Tested by

no test coverage detected