3v4l.org

run code in 300+ PHP versions simultaneously
<?php function g1() { echo "g1 yield 1\n"; yield 1; echo "g1 yield 2\n"; yield 2; echo "g1 end\n"; } function g2($g1) { echo "g2 yield from g1\n"; yield from $g1; echo "g2 yield 3\n"; yield 3; echo "g2 end\n"; } echo "get g1\n"; $g1 = g1(); echo "get g2\n"; $g2 = g2($g1); echo "g2 valid\n"; while ($g2->valid()) { echo "g2 current\n"; var_dump($g2->current()); echo "g1 next\n"; $g1->next(); } echo "end\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 11
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 11
Branch analysis from position: 23
Branch analysis from position: 11
filename:       /in/ctuUn
function name:  (null)
number of ops:  25
compiled vars:  !0 = $g1, !1 = $g2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ECHO                                                     'get+g1%0A'
   20     1        INIT_FCALL                                               'g1'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   21     4        ECHO                                                     'get+g2%0A'
   22     5        INIT_FCALL                                               'g2'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $4      
          8        ASSIGN                                                   !1, $4
   24     9        ECHO                                                     'g2+valid%0A'
   25    10      > JMP                                                      ->20
   26    11    >   ECHO                                                     'g2+current%0A'
   27    12        INIT_FCALL                                               'var_dump'
         13        INIT_METHOD_CALL                                         !1, 'current'
         14        DO_FCALL                                      0  $6      
         15        SEND_VAR                                                 $6
         16        DO_ICALL                                                 
   28    17        ECHO                                                     'g1+next%0A'
   29    18        INIT_METHOD_CALL                                         !0, 'next'
         19        DO_FCALL                                      0          
   25    20    >   INIT_METHOD_CALL                                         !1, 'valid'
         21        DO_FCALL                                      0  $9      
         22      > JMPNZ                                                    $9, ->11
   31    23    >   ECHO                                                     'end%0A'
         24      > RETURN                                                   1

Function g1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/ctuUn
function name:  g1
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        ECHO                                                     'g1+yield+1%0A'
    5     2        YIELD                                                    1
    6     3        ECHO                                                     'g1+yield+2%0A'
    7     4        YIELD                                                    2
    8     5        ECHO                                                     'g1+end%0A'
    9     6      > GENERATOR_RETURN                                         

End of function g1

Function g2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/ctuUn
function name:  g2
number of ops:  9
compiled vars:  !0 = $g1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   12     2        ECHO                                                     'g2+yield+from+g1%0A'
   13     3        YIELD_FROM                                       ~1      !0
          4        FREE                                                     ~1
   14     5        ECHO                                                     'g2+yield+3%0A'
   15     6        YIELD                                                    3
   16     7        ECHO                                                     'g2+end%0A'
   17     8      > GENERATOR_RETURN                                         

End of function g2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.67 ms | 1407 KiB | 17 Q