3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen1() { yield 1; echo "Sup from gen1\n"; yield 2; yield 3; } function gen2() { try { yield from gen1(); } catch (Exception $e) { echo "Sup from gen2!\n"; yield 10; } } function gen3() { yield from gen2(); } $g = gen3(); // Prime the generator var_dump($g->current()); $g->next(); $g->throw(new Exception("Whoa there lassie")); var_dump($g->current());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CkJ3t
function name:  (null)
number of ops:  22
compiled vars:  !0 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'gen3'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   25     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'current'
          5        DO_FCALL                                      0  $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                                 
   26     8        INIT_METHOD_CALL                                         !0, 'next'
          9        DO_FCALL                                      0          
   27    10        INIT_METHOD_CALL                                         !0, 'throw'
         11        NEW                                              $6      'Exception'
         12        SEND_VAL_EX                                              'Whoa+there+lassie'
         13        DO_FCALL                                      0          
         14        SEND_VAR_NO_REF_EX                                       $6
         15        DO_FCALL                                      0          
   28    16        INIT_FCALL                                               'var_dump'
         17        INIT_METHOD_CALL                                         !0, 'current'
         18        DO_FCALL                                      0  $9      
         19        SEND_VAR                                                 $9
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

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

End of function gen1

Function gen2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 161) Position 1 = -2
Found catch point at position: 6
Branch analysis from position: 6
2 jumps found. (Code = 107) Position 1 = 7, Position 2 = -2
Branch analysis from position: 7
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/CkJ3t
function name:  gen2
number of ops:  10
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   GENERATOR_CREATE                                         
   12     1        INIT_FCALL                                               'gen1'
          2        DO_FCALL                                      0  $1      
          3        YIELD_FROM                                       ~2      $1
          4        FREE                                                     ~2
          5      > JMP                                                      ->9
   13     6  E > > CATCH                                       last         'Exception'
   14     7    >   ECHO                                                     'Sup+from+gen2%21%0A'
   15     8        YIELD                                                    10
   17     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/CkJ3t
function name:  gen3
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   GENERATOR_CREATE                                         
   20     1        INIT_FCALL                                               'gen2'
          2        DO_FCALL                                      0  $0      
          3        YIELD_FROM                                       ~1      $0
          4        FREE                                                     ~1
   21     5      > GENERATOR_RETURN                                         

End of function gen3

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.37 ms | 1394 KiB | 18 Q