3v4l.org

run code in 300+ PHP versions simultaneously
<?php class GenClass { function __construct() { echo "Making GenClass\n"; } function __destruct() { echo "Destroying GenClass\n"; } function genInner() { throw new Exception; yield 5; } } function genOuter() { $x = (new GenClass)->genInner(); // $x is now a generator containing the only reference to a GenClass try { yield from $x; } catch (Exception $ex) { echo "Caught Exception (outer)\n"; } } $o = genOuter(); try { $o->next(); } catch (Exception $ex) { echo "Caught Exception (main)\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
1 jumps found. (Code = 62) 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 = 62) Position 1 = -2
filename:       /in/EHSD4
function name:  (null)
number of ops:  9
compiled vars:  !0 = $o, !1 = $ex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'genouter'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   20     3        INIT_METHOD_CALL                                         !0, 'next'
          4        DO_FCALL                                      0          
          5      > JMP                                                      ->8
   21     6  E > > CATCH                                       last         'Exception'
   22     7    >   ECHO                                                     'Caught+Exception+%28main%29%0A'
   23     8    > > RETURN                                                   1

Function genouter:
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: 9
Branch analysis from position: 9
2 jumps found. (Code = 107) Position 1 = 10, Position 2 = -2
Branch analysis from position: 10
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/EHSD4
function name:  genOuter
number of ops:  12
compiled vars:  !0 = $x, !1 = $ex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   GENERATOR_CREATE                                         
   10     1        NEW                                              $2      'GenClass'
          2        DO_FCALL                                      0          
          3        INIT_METHOD_CALL                                         $2, 'genInner'
          4        DO_FCALL                                      0  $4      
          5        ASSIGN                                                   !0, $4
   12     6        YIELD_FROM                                       ~6      !0
          7        FREE                                                     ~6
          8      > JMP                                                      ->11
   13     9  E > > CATCH                                       last         'Exception'
   14    10    >   ECHO                                                     'Caught+Exception+%28outer%29%0A'
   16    11    > > GENERATOR_RETURN                                         

End of function genouter

Class GenClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EHSD4
function name:  __construct
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ECHO                                                     'Making+GenClass%0A'
          1      > RETURN                                                   null

End of function __construct

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EHSD4
function name:  __destruct
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ECHO                                                     'Destroying+GenClass%0A'
          1      > RETURN                                                   null

End of function __destruct

Function geninner:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/EHSD4
function name:  genInner
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   GENERATOR_CREATE                                         
          1        NEW                                              $0      'Exception'
          2        DO_FCALL                                      0          
          3      > THROW                                         0          $0
          4*       YIELD                                                    5
          5*     > GENERATOR_RETURN                                         

End of function geninner

End of class GenClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.23 ms | 1403 KiB | 14 Q