3v4l.org

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

Function gen1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 4
Branch analysis from position: 11
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 4
Branch analysis from position: 11
Branch analysis from position: 4
filename:       /in/SpcTK
function name:  gen1
number of ops:  14
compiled vars:  !0 = $a, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      0
          1        GENERATOR_CREATE                                         
    4     2        ASSIGN                                                   !1, 0
    5     3      > JMP                                                      ->9
    6     4    >   YIELD                                                    !0
    7     5        ADD                                              ~4      !0, 1
          6        ASSIGN                                                   !0, ~4
    8     7        ADD                                              ~6      !1, 1
          8        ASSIGN                                                   !1, ~6
    5     9    >   IS_SMALLER                                               !1, 5
         10      > JMPNZ                                                    ~8, ->4
   10    11    >   MUL                                              ~9      !0, 5
         12      > GENERATOR_RETURN                                         
   11    13*     > GENERATOR_RETURN                                         

End of function gen1

Function yf:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/SpcTK
function name:  yf
number of ops:  12
compiled vars:  !0 = $res, !1 = $oth
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   GENERATOR_CREATE                                         
   14     1        INIT_FCALL                                               'gen1'
          2        DO_FCALL                                      0  $2      
          3        YIELD_FROM                                       ~3      $2
          4        ASSIGN                                                   !0, ~3
   15     5        INIT_FCALL                                               'gen1'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $5      
          8        YIELD_FROM                                       ~6      $5
          9        ASSIGN                                                   !1, ~6
   16    10      > GENERATOR_RETURN                                         
   17    11*     > GENERATOR_RETURN                                         

End of function yf

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.46 ms | 1403 KiB | 18 Q