functionfind_symbolrecursive
recursive integer function find_symbol(p, scope, name, category) result(id)
What name means in scope scope for category category (see in_category), or 0.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| p | type(project_t) | in | the project | |
| scope | integer | in | the entity to look in | |
| name | character(len=*) | in | the name, in lowercase | |
| category | integer | in | the category |
Result
| Name | Type | Attributes | Description |
|---|---|---|---|
| id | integer |
Calls
Source
Show the code
recursive integer function find_symbol(p, scope, name, category) result(id)
type(project_t), intent(in) :: p !! the project
integer, intent(in) :: scope !! the entity to look in
character(len=*), intent(in) :: name !! the name, in lowercase
integer, intent(in) :: category !! the category
integer :: c, b, child, u, j, used, target
id = 0
associate (e => p%list%box(scope)%e)
do c = 1, size(e%children)
child = e%children(c)
associate (item => p%list%box(child)%e)
if (.not. allocated(item%name)) cycle
if (in_category(item, category)) then
if (lowercase(item%name) == name) then
id = child
return
end if
end if
if (category == 1 .and. item%kind == E_INTERFACE) then
do b = 1, size(item%children)
associate (body => p%list%box(item%children(b))%e)
if (.not. allocated(body%name)) cycle
if (body%kind /= E_VARIABLE .and. lowercase(body%name) == name) then
id = item%children(b)
return
end if
end associate
end do
end if
if (category == 1 .and. item%kind == E_VARIABLE) then
if (item%vartype == 'procedure' .and. lowercase(item%name) == name) then
id = child
return
end if
end if
end associate
end do
if (allocated(e%more%uses)) then
do u = 1, size(e%more%uses)
target = e%more%uses(u)%target
if (target == 0) cycle
used = module_position(p, target)
if (used == 0) cycle
if (e%more%uses(u)%only) then
do j = 1, size(e%more%uses(u)%renames)
if (e%more%uses(u)%renames(j)%local /= name) cycle
id = public_symbol(p, used, e%more%uses(u)%renames(j)%used, category)
if (id > 0) return
end do
else
id = public_symbol(p, used, name, category)
if (id > 0) return
end if
end do
end if
if (e%kind == E_SUBMODULE) then
if (e%parent_submodule_id > 0) then
id = find_symbol(p, e%parent_submodule_id, name, category)
else if (e%ancestor_id > 0) then
id = find_symbol(p, e%ancestor_id, name, category)
end if
if (id > 0) return
end if
if (e%parent > 0) id = find_symbol(p, e%parent, name, category)
end associate
end function find_symbol