subroutinemerge_separate_proceduresprivate
subroutine merge_separate_procedures(p)
Make one entity of each separate module procedure whose interface is shown on a page of its own: its
body is hidden, and what the body has that the interface doesn't, its calls, use statements and
state, goes to the interface. Calls to any hidden body go to its interface.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| p | type(project_t) | inout | the project |
Calls
Called by
Source
Show the code
subroutine merge_separate_procedures(p)
type(project_t), intent(inout) :: p !! the project
integer :: k, j, m, body
do k = 1, p%list%n
if (.not. is_separate_interface(p%list, k)) cycle
! only an interface with a page of its own, not a specific procedure of a generic one
if (p%list%box(k)%e%iface == IFACE_NONE) cycle
if (.not. is_shown(p%list, k)) cycle
body = p%list%box(k)%e%implements
if (.not. is_separate_body(p%list, body)) cycle
p%list%box(body)%e%visible = .false.
associate (e => p%list%box(k)%e, from => p%list%box(body)%e)
if (allocated(from%call_ids)) then
if (.not. allocated(e%call_ids)) allocate (e%call_ids(0))
do j = 1, size(from%call_ids)
if (from%call_ids(j) /= k .and. all(e%call_ids /= from%call_ids(j))) &
call push_int(e%call_ids, from%call_ids(j))
end do
end if
if (.not. associated(e%more, no_more) .and. .not. associated(from%more, no_more)) then
if (allocated(from%more%uses)) then
if (.not. allocated(e%more%uses)) allocate (e%more%uses(0))
do j = 1, size(from%more%uses)
if (.not. any([(e%more%uses(m)%module == from%more%uses(j)%module, m=1, size(e%more%uses))])) &
e%more%uses = [e%more%uses, from%more%uses(j)]
end do
end if
e%more%saved_state = e%more%saved_state .or. from%more%saved_state
e%more%common_block = e%more%common_block .or. from%more%common_block
end if
end associate
end do
! calls to a hidden body are calls to its interface
do k = 1, p%list%n
if (.not. allocated(p%list%box(k)%e%call_ids)) cycle
do j = 1, size(p%list%box(k)%e%call_ids)
body = p%list%box(k)%e%call_ids(j)
if (body <= 0) cycle
if (p%list%box(body)%e%visible .or. .not. is_separate_body(p%list, body)) cycle
if (is_shown(p%list, p%list%box(body)%e%implements)) p%list%box(k)%e%call_ids(j) = p%list%box(body)%e%implements
end do
end do
end subroutine merge_separate_procedures