File: class_64.f90

package info (click to toggle)
lfortran 0.58.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 54,512 kB
  • sloc: cpp: 162,179; f90: 68,251; python: 17,476; ansic: 6,278; yacc: 2,334; sh: 1,317; fortran: 892; makefile: 33; javascript: 15
file content (47 lines) | stat: -rw-r--r-- 1,053 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
module class_64_mod_1
    type, abstract :: toml_value
        integer :: x = 0
    contains
        procedure :: accept
    end type toml_value
contains
    subroutine accept(self)
        class(toml_value), intent(inout) :: self
        self%x = self%x + 1
    end subroutine accept
end module


module class_64_mod_2
    use class_64_mod_1
    type, extends(toml_value) :: toml_keyval
    end type toml_keyval
contains
subroutine temp(visitor, l1)
    class(toml_value), intent(inout), target :: visitor
    class(toml_value), pointer :: ptr
    logical :: l1
    ptr => visitor
    if (l1) then
        select type(ptr)
        class is(toml_keyval)
            call ptr%accept()
        end select
    end if

    select type(ptr)
    class is(toml_keyval)
        call ptr%accept()
    end select
end subroutine

end module class_64_mod_2

program class_64
    use class_64_mod_2
    type(toml_keyval) :: key
    call temp(key, .true.)
    if (key%x /= 2) error stop
    call temp(key, .false.)
    if (key%x /= 3) error stop
end program class_64