fdoc

functionnearest_callerpureprivate

pure integer function nearest_caller(list, stack, top) result(caller)

The innermost entity on stack that can call procedures, or 0 if there is none or a declaration scope such as a type is inside it.

Arguments

NameTypeIntentAttributesDescription
listtype(entity_list_t)in

the entities

stackintegerindimension(0:top)

the open constructs

topintegerin

the top of the stack

Result

NameTypeAttributesDescription
callerinteger

Source

Show the code
pure integer function nearest_caller(list, stack, top) result(caller)
    type(entity_list_t), intent(in) :: list !! the entities
    integer, intent(in) :: top              !! the top of the stack
    integer, intent(in) :: stack(0:top)     !! the open constructs
    integer :: k

    caller = 0
    do k = top, 0, -1
        if (stack(k) == 0) cycle
        select case (list%box(stack(k))%e%kind)
        case (E_SUBROUTINE, E_FUNCTION, E_MODPROC, E_PROGRAM)
            caller = stack(k)
        end select
        return
    end do
end function nearest_caller

Graphs

Called by