subroutinemerge_listprivate
subroutine merge_list(p, from)
Move the entities of from to the end of p%list, adjusting their indices.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| p | type(project_t) | inout | the project | |
| from | type(entity_list_t) | inout | the entities of a file |
Calls
Source
Show the code
subroutine merge_list(p, from)
type(project_t), intent(inout) :: p !! the project
type(entity_list_t), intent(inout) :: from !! the entities of a file
type(entity_box_t), allocatable :: grown(:)
integer :: offset, k, needed
offset = p%list%n
needed = offset + from%n
if (.not. allocated(p%list%box)) allocate (p%list%box(max(needed, 64)))
if (needed > size(p%list%box)) then
allocate (grown(2*needed))
do k = 1, offset
call move_alloc(p%list%box(k)%e, grown(k)%e)
end do
call move_alloc(grown, p%list%box)
end if
do k = 1, from%n
call move_alloc(from%box(k)%e, p%list%box(offset + k)%e)
associate (e => p%list%box(offset + k)%e)
if (e%parent > 0) e%parent = e%parent + offset
e%file = e%file + offset
e%children = e%children + offset
if (e%result > 0) e%result = e%result + offset
if (allocated(e%more%arg_ids)) e%more%arg_ids = e%more%arg_ids + offset
if (e%kind == E_MODULE) call push_int(p%modules, offset + k)
if (e%kind == E_SUBMODULE) call push_int(p%submodules, offset + k)
if (e%kind == E_FILE) call push_int(p%files, offset + k)
end associate
end do
p%list%n = needed
end subroutine merge_list