fdoc

functionnew_exprprivate

integer function new_expr(c, kind, a, b, third) result(id)

A new expression.

Arguments

NameTypeIntentAttributesDescription
ctype(fypp_t)inout

the state

kindintegerin

what it is

aintegerinoptional

the first operand

bintegerinoptional

the second operand

thirdintegerinoptional

the third operand

Result

NameTypeAttributesDescription
idinteger

Calls

Called by

Source

Show the code
integer function new_expr(c, kind, a, b, third) result(id)
    type(fypp_t), intent(inout) :: c    !! the state
    integer, intent(in) :: kind         !! what it is
    integer, intent(in), optional :: a  !! the first operand
    integer, intent(in), optional :: b  !! the second operand
    integer, intent(in), optional :: third  !! the third operand
    type(expr_t), allocatable :: grown(:)
    integer :: k

    if (c%num_exprs == size(c%exprs)) then
        allocate (grown(2*c%num_exprs))
        do k = 1, c%num_exprs
            call move_expr(c%exprs(k), grown(k))
        end do
        call move_alloc(grown, c%exprs)
    end if
    c%num_exprs = c%num_exprs + 1
    id = c%num_exprs
    c%exprs(id)%kind = kind
    if (present(a)) c%exprs(id)%a = a
    if (present(b)) c%exprs(id)%b = b
    if (present(third)) c%exprs(id)%c = third
end function new_expr