3v4l.org

run code in 300+ PHP versions simultaneously
<?php //Source: https://wiki.php.net/rfc/generators function gen() { echo "Foo\n"; try { yield; } catch (Exception $e) { echo "Exception: {$e->getMessage()}\n"; } echo "Bar\n"; } $gen = gen(); $gen->rewind(); // echos "Foo" $gen->throw(new Exception('Test')); // echos "Exception: Test" // and "Bar"
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KNgmT
function name:  (null)
number of ops:  12
compiled vars:  !0 = $gen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'gen'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   15     3        INIT_METHOD_CALL                                         !0, 'rewind'
          4        DO_FCALL                                      0          
   16     5        INIT_METHOD_CALL                                         !0, 'throw'
          6        NEW                                              $4      'Exception'
          7        SEND_VAL_EX                                              'Test'
          8        DO_FCALL                                      0          
          9        SEND_VAR_NO_REF_EX                                       $4
         10        DO_FCALL                                      0          
   17    11      > RETURN                                                   1

Function gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 161) Position 1 = -2
Found catch point at position: 4
Branch analysis from position: 4
2 jumps found. (Code = 107) Position 1 = 5, Position 2 = -2
Branch analysis from position: 5
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/KNgmT
function name:  gen
number of ops:  13
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   GENERATOR_CREATE                                         
    5     1        ECHO                                                     'Foo%0A'
    7     2        YIELD                                                    
          3      > JMP                                                      ->11
    8     4  E > > CATCH                                       last         'Exception'
    9     5    >   ROPE_INIT                                     3  ~4      'Exception%3A+'
          6        INIT_METHOD_CALL                                         !0, 'getMessage'
          7        DO_FCALL                                      0  $2      
          8        ROPE_ADD                                      1  ~4      ~4, $2
          9        ROPE_END                                      2  ~3      ~4, '%0A'
         10        ECHO                                                     ~3
   11    11    >   ECHO                                                     'Bar%0A'
   12    12      > GENERATOR_RETURN                                         

End of function gen

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.72 ms | 1403 KiB | 14 Q