subroutineadd_symbolprivate
subroutine add_symbol(list, name, id)
Add name for entity id to list, replacing any entity it has.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| list | type(symbol_list_t) | inout | the names | |
| name | character(len=*) | in | the name | |
| id | integer | in | the entity |
Calls
Source
Show the code
subroutine add_symbol(list, name, id)
type(symbol_list_t), intent(inout) :: list !! the names
character(len=*), intent(in) :: name !! the name
integer, intent(in) :: id !! the entity
type(symbol_t), allocatable :: grown(:)
integer :: k, at
at = index_find(list%index, name)
if (at > 0) then
list%s(at)%id = id
return
end if
if (list%n == size(list%s)) then
allocate (grown(2*list%n))
do k = 1, list%n
call move_alloc(list%s(k)%name, grown(k)%name)
grown(k)%id = list%s(k)%id
end do
call move_alloc(grown, list%s)
end if
list%n = list%n + 1
list%s(list%n)%name = name
list%s(list%n)%id = id
call index_set(list%index, name, list%n)
end subroutine add_symbol