3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen1() { $x = yield 1; yield 2; yield $x; } function gen2() { yield from gen1(); yield from gen1(); } function gen3() { yield from gen2(); } $g = gen3(); var_dump($g->current()); $g->send(100); foreach($g as $val) { var_dump($val); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/pH7l0
function name:  (null)
number of ops:  19
compiled vars:  !0 = $g, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'gen3'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   19     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'current'
          5        DO_FCALL                                      0  $4      
          6        SEND_VAR                                                 $4
          7        DO_ICALL                                                 
   20     8        INIT_METHOD_CALL                                         !0, 'send'
          9        SEND_VAL_EX                                              100
         10        DO_FCALL                                      0          
   21    11      > FE_RESET_R                                       $7      !0, ->17
         12    > > FE_FETCH_R                                               $7, !1, ->17
   22    13    >   INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                                 
   21    16      > JMP                                                      ->12
         17    >   FE_FREE                                                  $7
   23    18      > RETURN                                                   1

Function gen1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/pH7l0
function name:  gen1
number of ops:  6
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        YIELD                                            $1      1
          2        ASSIGN                                                   !0, $1
    5     3        YIELD                                                    2
    6     4        YIELD                                                    !0
    7     5      > GENERATOR_RETURN                                         

End of function gen1

Function gen2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/pH7l0
function name:  gen2
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   GENERATOR_CREATE                                         
   10     1        INIT_FCALL                                               'gen1'
          2        DO_FCALL                                      0  $0      
          3        YIELD_FROM                                       ~1      $0
          4        FREE                                                     ~1
   11     5        INIT_FCALL                                               'gen1'
          6        DO_FCALL                                      0  $2      
          7        YIELD_FROM                                       ~3      $2
          8        FREE                                                     ~3
   12     9      > GENERATOR_RETURN                                         

End of function gen2

Function gen3:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/pH7l0
function name:  gen3
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   GENERATOR_CREATE                                         
   15     1        INIT_FCALL                                               'gen2'
          2        DO_FCALL                                      0  $0      
          3        YIELD_FROM                                       ~1      $0
          4        FREE                                                     ~1
   16     5      > GENERATOR_RETURN                                         

End of function gen3

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
204.58 ms | 1403 KiB | 19 Q