subroutineevaluate_callrecursiveprivate
recursive subroutine evaluate_call(c, id, v)
A call of a macro or a builtin function.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| c | type(fypp_t) | inout | the state | |
| id | integer | in | the expression | |
| v | type(value_t) | out | the result |
Calls
Source
Show the code
recursive subroutine evaluate_call(c, id, v)
type(fypp_t), intent(inout) :: c !! the state
integer, intent(in) :: id !! the expression
type(value_t), intent(out) :: v !! the result
type(value_t), allocatable :: positional(:), by_keyword(:)
integer, allocatable :: keywords(:)
type(value_t) :: target
integer :: n, name
logical :: found
if (c%exprs(c%exprs(id)%a)%kind /= E_NAME) then
call fail(c, 'only names can be called')
return
end if
name = c%exprs(c%exprs(id)%a)%name
call evaluate_args(c, id, positional, n, keywords, by_keyword)
if (allocated(c%error)) return
call lookup(c, name, target, found)
if (found) then
if (target%kind /= V_MACRO) then
call fail(c, c%names(name)%s//' is not a macro')
return
end if
call call_macro(c, target%number, positional(:n), keywords, by_keyword, v)
else
call call_builtin(c, c%names(name)%s, positional(:n), v)
end if
end subroutine evaluate_call