fdoc

subroutinepublic_namesrecursiveprivate

recursive subroutine public_names(p, which)

Compute the public names of module which, after those of the modules it uses.

Arguments

NameTypeIntentAttributesDescription
ptype(project_t)inout

the project

whichintegerin

position in p%modules

Calls

Source

Show the code
recursive subroutine public_names(p, which)
    type(project_t), intent(inout) :: p     !! the project
    integer, intent(in) :: which            !! position in `p%modules`
    integer :: id, c, child, u, used

    if (p%pub(which)%state /= 0) return
    p%pub(which)%state = 1
    id = p%modules(which)
    allocate (p%pub(which)%procs%s(16), p%pub(which)%absints%s(16), p%pub(which)%types%s(16), p%pub(which)%vars%s(16))
    do c = 1, size(p%list%box(id)%e%more%public_list)
        call index_set(p%pub(which)%public_list, p%list%box(id)%e%more%public_list(c)%s, c)
    end do

    associate (m => p%list%box(id)%e)
        do c = 1, size(m%children)
            child = m%children(c)
            associate (e => p%list%box(child)%e)
                if (.not. allocated(e%permission)) cycle
                if (e%permission /= 'public' .and. e%permission /= 'protected') cycle
                select case (e%kind)
                case (E_TYPE)
                    call add_symbol(p%pub(which)%types, lowercase(e%name), child)
                case (E_VARIABLE)
                    if (e%var_role == VAR_HIDDEN) cycle
                    call add_symbol(p%pub(which)%vars, lowercase(e%name), child)
                    if (e%vartype == 'procedure') call add_symbol(p%pub(which)%procs, lowercase(e%name), child)
                case (E_SUBROUTINE, E_FUNCTION)
                    if (e%iface == IFACE_ABSTRACT) then
                        call add_symbol(p%pub(which)%absints, lowercase(e%name), child)
                    else
                        call add_symbol(p%pub(which)%procs, lowercase(e%name), child)
                    end if
                case (E_INTERFACE)
                    call add_symbol(p%pub(which)%procs, lowercase(e%name), child)
                end select
            end associate
        end do
    end associate
    call generic_bodies(p, which, id)

    do u = 1, size(p%list%box(id)%e%more%uses)
        used = module_position(p, p%list%box(id)%e%more%uses(u)%target)
        if (used == 0) cycle
        if (p%pub(used)%state == 1) cycle
        call public_names(p, used)
        call import_names(p, which, used, p%list%box(id)%e%more%uses(u)%spec)
    end do
    p%pub(which)%state = 2
end subroutine public_names

Graphs

Calls

Called by