| 722 | }; |
| 723 | |
| 724 | ProgramPtr parseDaScript ( const string & fileName, |
| 725 | const string & moduleName, |
| 726 | const FileAccessPtr & access, |
| 727 | TextWriter & logs, |
| 728 | ModuleGroup & libGroup, |
| 729 | bool exportAll, |
| 730 | bool isDep, |
| 731 | CodeOfPolicies policies ) { |
| 732 | CompilationCallbackGuard compilationCallbackGuard(moduleName, fileName); |
| 733 | ProgramPtr program = make_smart<Program>(); |
| 734 | // The module's own root is the working/active root for the whole compile, so live |
| 735 | // nodes land on module_gc_root and per-pass collects can swap it O(1). The scope |
| 736 | // restores the previous active root on exit without sweeping (the module owns it). |
| 737 | gc_active_scope parse_gc_scope(program->thisModule->module_gc_root.get()); |
| 738 | ModuleGcFinalize parse_gc_collect(program.get()); |
| 739 | parse_gc_collect.logs = &logs; |
| 740 | program->library.renameModule(program->thisModule.get(), moduleName); |
| 741 | ReuseCacheGuard rcg; |
| 742 | auto time0 = ref_time_ticks(); |
| 743 | // Per-module timing snapshots, used by log_module_compile_time. We still |
| 744 | // accumulate into *totParse/*totInfer/*totOpt/*totM for the top-level summary. |
| 745 | uint64_t myParseT = 0, myInferT = 0, myOptT = 0, myMacroModT = 0; |
| 746 | auto macroTicks0 = daScriptEnvironment::getBound()->macroTimeTicks; |
| 747 | program->inferPassesUsed = 0; // reset once per module; inferTypesDirty accumulates across all inferTypes legs (incl. restartInfer) |
| 748 | |
| 749 | if ( trySerializeProgramModule(program, access, fileName, libGroup, logs) ) { |
| 750 | return program; |
| 751 | } else { |
| 752 | // Serialization failed and the program changed, so set it for proper GC collection on exit. |
| 753 | parse_gc_collect.prog = program.get(); |
| 754 | } |
| 755 | |
| 756 | int err; |
| 757 | daScriptEnvironment::getBound()->g_Program = program; |
| 758 | daScriptEnvironment::getBound()->g_compilerLog = &logs; |
| 759 | daScriptEnvironment::getBound()->g_compilingFileName = fileName.c_str(); |
| 760 | daScriptEnvironment::getBound()->g_compilingModuleName = moduleName.c_str(); |
| 761 | program->promoteToBuiltin = false; |
| 762 | program->isCompiling = true; |
| 763 | program->isDependency = isDep; |
| 764 | program->needMacroModule = false; |
| 765 | program->policies = policies; |
| 766 | program->thisModuleGroup = &libGroup; |
| 767 | program->thisModule->fileName = fileName; |
| 768 | program->thisModuleName = program->thisModule->name; |
| 769 | libGroup.foreach([&](Module * pm){ |
| 770 | program->library.addModule(pm); |
| 771 | return true; |
| 772 | },"*"); |
| 773 | DasParserState parserState; |
| 774 | parserState.g_Access = access; |
| 775 | parserState.g_Program = program; |
| 776 | parserState.das_def_tab_size = daScriptEnvironment::getBound()->das_def_tab_size; |
| 777 | parserState.das_gen2_make_syntax = policies.gen2_make_syntax; |
| 778 | yyscan_t scanner = nullptr; |
| 779 | int64_t file_mtime = access->getFileMtime(fileName.c_str()); |
| 780 | if ( auto fi = access->getFileInfo(fileName) ) { |
| 781 | callCompilationCallback(moduleName, fileName, "parse"); |
no test coverage detected