subroutinestatement_callsprivate
subroutine statement_calls(v, info, e, associations, level)
Add the procedures that a statement refers to to e%more%calls.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| v | type(statement_view_t) | in | the statement's tokens | |
| info | type(stmt_info_t) | in | its classification | |
| e | type(entity_t) | inout | the entity it is in | |
| associations | type(association_t) | inout | allocatabledimension(:) | the names in scope |
| level | integer | inout | how many |
Calls
Source
Show the code
subroutine statement_calls(v, info, e, associations, level)
type(statement_view_t), intent(in) :: v !! the statement's tokens
type(stmt_info_t), intent(in) :: info !! its classification
type(entity_t), intent(inout) :: e !! the entity it is in
type(association_t), allocatable, intent(inout) :: associations(:) !! the names in scope
integer, intent(inout) :: level !! how many `associate` constructs are open
character(len=80) :: first
integer :: j, call_at, last, target
if (info%role == ROLE_CLOSE .and. info%construct == C_ASSOCIATE) then
associations = pack(associations, associations%level /= level)
level = max(0, level - 1)
return
end if
if (v%n == 0) return
first = leading_text(v, v%first)
if (.not. is_executable(v, info, trim(first))) return
! a computed `go to` looks like a function reference
do j = v%first, v%n - 1
if (v%is(j + 1, '(') .and. (v%is(j, 'goto') .or. (v%is(j, 'to') .and. v%is(j - 1, 'go')))) return
end do
! `call` may follow a logical `if`
call_at = 0
do j = v%first, v%n
if (v%depth(j) == 0 .and. v%is(j, 'call')) then
if (j == v%first .or. v%is(j - 1, ')')) then
call_at = j
exit
end if
end if
end do
target = 0
if (call_at > 0) then
last = call_at + 1
target = chain_end(v, last)
if (target > 0) call add_call(v, target, e, associations)
end if
do j = v%first, v%n - 1
if (v%kind_of(j) /= TK_NAME .or. .not. v%is(j + 1, '(')) cycle
if (call_at > 0 .and. j > call_at .and. v%depth(j) == 0) cycle
if (v%closing(j + 1) > 0) then
if (v%is(v%closing(j + 1) + 1, '%')) cycle
end if
call add_call(v, j, e, associations)
end do
if (info%role == ROLE_OPEN .and. info%construct == C_ASSOCIATE) call read_associations(v, associations, level)
end subroutine statement_calls