3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen() { // TODO: HHVM currently does not support yield from (or yield) as // expressions. As such, this test had to be slightly modified. // The original line was: // var_dump(yield from gen($a + 1)); //$b = yield from gen($a + 1); yield 1; yield 2; var_dump('in the middle of gen'); yield 3; yield 4; } function bar($gen) { // TODO: HHVM currently does not support yield from (or yield) as // expressions. As such, this test had to be slightly modified. // The original line was: // var_dump(yield from gen($a + 1)); yield from $gen; } /* Twice a Generator from bar() using yield from on $gen */ $gen = gen(); $gens[] = bar($gen); $gens[] = bar($gen); do { foreach ($gens as $g) { var_dump($g->current()); $g->next(); } } while($gens[0]->valid()); var_dump($gens[1]->valid());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 23
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 23
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 13
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
Branch analysis from position: 23
filename:       /in/MsXZA
function name:  (null)
number of ops:  35
compiled vars:  !0 = $gen, !1 = $gens, !2 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_FCALL                                               'gen'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   26     3        INIT_FCALL                                               'bar'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $6      
          6        ASSIGN_DIM                                               !1
          7        OP_DATA                                                  $6
   27     8        INIT_FCALL                                               'bar'
          9        SEND_VAR                                                 !0
         10        DO_FCALL                                      0  $8      
         11        ASSIGN_DIM                                               !1
         12        OP_DATA                                                  $8
   30    13    > > FE_RESET_R                                       $9      !1, ->23
         14    > > FE_FETCH_R                                               $9, !2, ->23
   31    15    >   INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !2, 'current'
         17        DO_FCALL                                      0  $10     
         18        SEND_VAR                                                 $10
         19        DO_ICALL                                                 
   32    20        INIT_METHOD_CALL                                         !2, 'next'
         21        DO_FCALL                                      0          
   30    22      > JMP                                                      ->14
         23    >   FE_FREE                                                  $9
   34    24        FETCH_DIM_R                                      ~13     !1, 0
         25        INIT_METHOD_CALL                                         ~13, 'valid'
         26        DO_FCALL                                      0  $14     
         27      > JMPNZ                                                    $14, ->13
   35    28    >   INIT_FCALL                                               'var_dump'
         29        FETCH_DIM_R                                      ~15     !1, 1
         30        INIT_METHOD_CALL                                         ~15, 'valid'
         31        DO_FCALL                                      0  $16     
         32        SEND_VAR                                                 $16
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Function gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/MsXZA
function name:  gen
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    9     1        YIELD                                                    1
   10     2        YIELD                                                    2
   11     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAL                                                 'in+the+middle+of+gen'
          5        DO_ICALL                                                 
   12     6        YIELD                                                    3
   13     7        YIELD                                                    4
   14     8      > GENERATOR_RETURN                                         

End of function gen

Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/MsXZA
function name:  bar
number of ops:  5
compiled vars:  !0 = $gen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   21     2        YIELD_FROM                                       ~1      !0
          3        FREE                                                     ~1
   22     4      > GENERATOR_RETURN                                         

End of function bar

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.61 ms | 1402 KiB | 18 Q