stack_push Subroutine

private pure subroutine stack_push(self, sc)

Open construct sc, growing the storage as needed.

Type Bound

scope_stack_t

Arguments

Type IntentOptional Attributes Name
class(scope_stack_t), intent(inout) :: self

the stack

type(scope_t), intent(in) :: sc

the construct to open


Called by

proc~~stack_push~~CalledByGraph proc~stack_push scope_stack_t%stack_push proc~analyze_structure analyze_structure proc~analyze_structure->proc~stack_push proc~stack_restore scope_stack_t%stack_restore proc~analyze_structure->proc~stack_restore proc~stack_restore->proc~stack_push proc~format_pass format_pass proc~format_pass->proc~analyze_structure proc~format_text format_text proc~format_text->proc~format_pass proc~relayout relayout proc~format_text->proc~relayout proc~relayout->proc~format_pass proc~process_text process_text proc~process_text->proc~format_text proc~process_file process_file proc~process_file->proc~process_text proc~process_stdin process_stdin proc~process_stdin->proc~process_text proc~run run proc~run->proc~process_file proc~run->proc~process_stdin

Source Code

pure subroutine stack_push(self, sc)
    !! Open construct `sc`, growing the storage as needed.
    class(scope_stack_t), intent(inout) :: self  !! the stack
    type(scope_t), intent(in) :: sc               !! the construct to open
    type(scope_t), allocatable :: tmp(:)
    if (.not. allocated(self%s)) allocate (self%s(16))
    if (self%top == size(self%s)) then
        allocate (tmp(2*self%top))
        tmp(1:self%top) = self%s(1:self%top)
        call move_alloc(tmp, self%s)
    end if
    self%top = self%top + 1
    self%s(self%top) = sc
end subroutine stack_push