MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / visitModule

Method visitModule

src/ast/ast_program.cpp:510–615  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

508 }
509
510 void Program::visitModule(Visitor & vis, Module * thatModule, bool visitGenerics, bool sortStructures) {
511 vis.preVisitModule(thatModule);
512 // enumerations
513 thatModule->enumerations.foreach([&](auto & penum){
514 if ( vis.canVisitEnumeration(penum) ) {
515 auto penumn = visitEnumeration(vis, penum);
516 if ( penumn != penum ) {
517 thatModule->enumerations.replace(penum->name, penumn);
518 penum = penumn;
519 }
520 }
521 });
522 // structures
523 if ( sortStructures ) {
524 // collect, topologically sort, then visit
525 vector<StructurePtr> allStructs;
526 thatModule->structures.foreach([&](auto & spst){
527 if ( vis.canVisitStructure(spst) ) {
528 allStructs.push_back(spst);
529 }
530 });
531 topoSortStructures(allStructs);
532 for ( auto & spst : allStructs ) {
533 Structure * pst = spst;
534 StructurePtr pstn = visitStructure(vis, pst);
535 if ( pstn != pst ) {
536 thatModule->structures.replace(pst->name, pstn);
537 }
538 }
539 } else {
540 thatModule->structures.foreach([&](auto & spst){
541 Structure * pst = spst;
542 if ( vis.canVisitStructure(pst) ) {
543 StructurePtr pstn = visitStructure(vis, pst);
544 if ( pstn != pst ) {
545 thatModule->structures.replace(pst->name, pstn);
546 spst = pstn;
547 }
548 }
549 });
550 }
551 // aliases
552 thatModule->aliasTypes.foreach([&](auto & alsv){
553 vis.preVisitAlias(alsv, alsv->alias);
554 vis.preVisit(alsv);
555 auto alssv = alsv->visit(vis);
556 if ( alssv ) alssv = vis.visit(alssv);
557 if ( alssv ) alssv = vis.visitAlias(alssv, alssv->alias);
558 if ( alssv!=alsv ) {
559 thatModule->aliasTypes.replace(alssv->alias, alssv);
560 alsv = alssv;
561 }
562 });
563 // real things
564 vis.preVisitProgramBody(this,thatModule);
565 // globals
566 vis.preVisitGlobalLetBody(this);
567 thatModule->globals.foreach([&](auto & var){

Callers

nothing calls this directly

Calls 15

visitEnumerationFunction · 0.85
topoSortStructuresFunction · 0.85
visitStructureFunction · 0.85
replaceMethod · 0.80
preVisitModuleMethod · 0.45
foreachMethod · 0.45
canVisitEnumerationMethod · 0.45
canVisitStructureMethod · 0.45
push_backMethod · 0.45
preVisitAliasMethod · 0.45
preVisitMethod · 0.45
visitMethod · 0.45

Tested by

no test coverage detected