fdoc

subroutineload_project_sources

subroutine load_project_sources(s, p, stat, errmsg)

Find, load and parse the source files, and merge the results into p.

Arguments

NameTypeIntentAttributesDescription
stype(settings_t)in

the settings

ptype(project_t)out

the project

statintegerout

nonzero on failure

errmsgcharacter(len=:)outallocatable

what is wrong

Calls

Source

Show the code
subroutine load_project_sources(s, p, stat, errmsg)
    type(settings_t), intent(in) :: s                   !! the settings
    type(project_t), intent(out) :: p                   !! the project
    integer, intent(out) :: stat                        !! nonzero on failure
    character(len=:), allocatable, intent(out) :: errmsg  !! what is wrong
    type(string_t), allocatable :: paths(:), texts(:), raws(:)
    type(entity_list_t), allocatable :: lists(:)
    integer :: k

    stat = 0
    call find_sources(s, paths)
    if (size(paths) == 0) then
        stat = 1
        errmsg = 'No source files with appropriate extension found in specified directory.'
        return
    end if
    allocate (texts(size(paths)), lists(size(paths)), raws(size(paths)))
    ! files that go through an external command share its temporary files, so they take turns
    call progress_start('Reading files', size(paths))
    !$omp parallel do schedule(dynamic) num_threads(max(1, s%parallel)) default(shared) private(k)
    do k = 1, size(paths)
        if (.not. runs_command(s, paths(k)%s)) call read_source(s, paths(k)%s, raws(k)%s, texts(k)%s)
        call progress_tick()
    end do
    !$omp end parallel do
    do k = 1, size(paths)
        if (runs_command(s, paths(k)%s)) call read_source(s, paths(k)%s, raws(k)%s, texts(k)%s)
        call expand_includes(s%include, parent_directory(paths(k)%s), texts(k)%s, 1)
    end do
    call progress_finish()

    call progress_start('Parsing files', size(paths))
    !$omp parallel do schedule(dynamic) num_threads(max(1, s%parallel)) default(shared)
    do k = 1, size(paths)
        call parse_file(paths(k)%s, texts(k)%s, s, lists(k))
        call progress_tick()
    end do
    !$omp end parallel do
    call progress_finish()

    do k = 1, size(lists)
        call move_alloc(raws(k)%s, lists(k)%box(1)%e%source_text)
        call merge_list(p, lists(k))
    end do
end subroutine load_project_sources

Graphs

Calls

load_project_sourcesfind_sourcesprogress_startread_sourceruns_commandprogress_tickexpand_includesprogress_finishparse_filemerge_liststarts_withglob_matchescontains_stringextension_ofwarnpushsort_stringsdrawload_sourceneeds_fyppsplit_linesinclude_namelocateread_whole_filejoinseconds_textcollect_docslist_addentity_list_tset_docinherit_displayclose_unitnearest_callerstatement_callsstatement_textopen_unitparse_statementpush_intbar_textfypp_sourcepreprocessstarts_wordstriphas_markstrip_trailingdoxygen_metaparse_metadataparse_boolapply_attributesattach_argumentsclose_interfaceleading_textis_executablechain_endadd_callread_associationsread_submoduleopen_procedureinherited_permissionread_type_statementread_useread_bindingread_finalread_module_proceduresread_namelistread_commonis_attribute_statementread_attribute_statementis_type_declarationread_declarationfypp_processtemporary_directoryunique_tagpreprocessor_commandrun_commandquoted_pathremove_fileword_atfirst_word_ofis_markermatch_keyadd_valueleading_blanksapply_onemark_common_membersimplicit_variabledoxygen_paramsis_procedureremove_childis_intrinsicends_withchain_startremove_blanksparse_procedure_headerparse_typeset_typetop_indextop_splitclosing_parensplit_attributesreplace_commastype_keywordparse_declaratorinterncompilenew_nodeadd_bodyparse_fileevaluaterender_bodytakefold_outputis_windowsquotedsplit_wordsoriginal_prefixselector_lengthfind_nameindex_findnext_tokenparse_listfailindex_setmove_nodepush_idwithout_carriage_returnsparse_textlookuparithmeticmake_intmake_booltruth_ofcompareevaluate_callcall_methodsubscriptevaluate_slicerun_clausemove_valueevaluate_fstringrender_nodeaddfold_regionname_hashis_blankread_stringread_namestarts_nameis_digitparse_testat_wordnew_exprskip_blanksflush_textend_of_lineread_line_directivehandle_directivetrim_rightmake_stringcompare_twoevaluate_argscall_macrocall_builtinequalformat_stringitems_ofwrite_valueis_spacesplit_stringcopy_itemsbind_targetsrecord_spanrender_loopassign_targetsdefine_macrorender_callfold_linein_nameparse_orexpectmove_exprappendtrim_lengthcontrol_directiveopen_scopedefineclose_scopemake_rangemake_zipdigits_valueint_textcopy_valuevalue_tbind_onefold_positionparse_andopen_blockclose_blockfor_directiveset_directivedef_directivecall_directiveinclude_directiveframe_roomparse_notread_targetsparse_argumentslast_separatorparse_compareparse_comprehensionparse_sumparse_productparse_unaryparse_postfixparse_primaryparse_subscriptparse_fstringparse_items

Called by