fdoc

functionlist_addprivate

integer function list_add(self, kind, parent) result(id)

Add an entity of kind kind inside parent, returning its index.

Arguments

NameTypeIntentAttributesDescription
selfclass(entity_list_t)inout

the list

kindintegerin

one of the E_* constants

parentintegerin

the containing entity, or 0

Result

NameTypeAttributesDescription
idinteger

Calls

Source

Show the code
integer function list_add(self, kind, parent) result(id)
    class(entity_list_t), intent(inout) :: self     !! the list
    integer, intent(in) :: kind                     !! one of the `E_*` constants
    integer, intent(in) :: parent                   !! the containing entity, or 0
    type(entity_box_t), allocatable :: grown(:)
    integer :: k

    if (.not. allocated(self%box)) allocate (self%box(64))
    if (self%n == size(self%box)) then
        allocate (grown(2*self%n))
        do k = 1, self%n
            call move_alloc(self%box(k)%e, grown(k)%e)
        end do
        call move_alloc(grown, self%box)
    end if
    self%n = self%n + 1
    id = self%n
    allocate (self%box(id)%e)
    self%box(id)%e%kind = kind
    if (kind == E_VARIABLE) then
        self%box(id)%e%more => no_more
    else
        allocate (self%box(id)%e%more)
    end if
    self%box(id)%e%parent = parent
    allocate (self%box(id)%e%children(0))
    if (parent > 0) then
        self%box(id)%e%file = self%box(parent)%e%file
        call push_int(self%box(parent)%e%children, id)
    end if
end function list_add

Graphs

Calls

Called by