subroutinerender_looprecursiveprivate
recursive subroutine render_loop(c, id, out, top)
Render a loop.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| c | type(fypp_t) | inout | the state | |
| id | integer | in | the node | |
| out | type(buffer_t) | inout | the output | |
| top | logical | in | true if this is not going into a macro's result |
Calls
Source
Show the code
recursive subroutine render_loop(c, id, out, top)
type(fypp_t), intent(inout) :: c !! the state
integer, intent(in) :: id !! the node
type(buffer_t), intent(inout) :: out !! the output
logical, intent(in) :: top !! true if this is not going into a macro's result
type(value_t) :: iterable
type(value_t), allocatable :: list(:)
integer :: k, j
call evaluate(c, c%nodes(id)%expr, iterable)
if (allocated(c%error)) return
call items_of(c, iterable, list)
if (allocated(c%error)) return
do k = 1, size(list)
if (size(c%nodes(id)%block%targets) == 1) then
call define(c, c%nodes(id)%block%targets(1), list(k))
else if (list(k)%kind == V_LIST .or. list(k)%kind == V_TUPLE) then
! like Fypp, ignore items beyond the variables
do j = 1, min(size(c%nodes(id)%block%targets), size(list(k)%items))
call define(c, c%nodes(id)%block%targets(j), list(k)%items(j))
end do
else
call fail(c, 'a value cannot be unpacked')
end if
call render_body(c, c%nodes(id)%block%bodies(1), out, top)
if (allocated(c%error)) return
end do
end subroutine render_loop