functionequalpurerecursiveprivate
pure recursive logical function equal(a, b) result(same)
True if a equals b.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| a | type(value_t) | in | a value | |
| b | type(value_t) | in | another |
Result
| Name | Type | Attributes | Description |
|---|---|---|---|
| same | logical |
Calls
Source
Show the code
pure recursive logical function equal(a, b) result(same)
type(value_t), intent(in) :: a !! a value
type(value_t), intent(in) :: b !! another
integer :: k
logical :: a_number, b_number
a_number = a%kind == V_BOOL .or. a%kind == V_INT
b_number = b%kind == V_BOOL .or. b%kind == V_INT
same = .false.
if (a_number .and. b_number) then
same = a%number == b%number
else if (a%kind /= b%kind) then
return
else if (a%kind == V_NONE) then
same = .true.
else if (a%kind == V_STR) then
same = len(a%text) == len(b%text)
if (same) same = a%text == b%text
else if (a%kind == V_MACRO) then
same = a%number == b%number
else
if (size(a%items) /= size(b%items)) return
do k = 1, size(a%items)
if (.not. equal(a%items(k), b%items(k))) return
end do
same = .true.
end if
end function equal