3v4l.org

run code in 300+ PHP versions simultaneously
<?php function createGen() { for ($i = 0; $i< 10; $i++) { $a = (yield $i); if ($a == 'stop') { return; } } } $gen = createGen(); foreach ($gen as $value) { if ($value === 5) { $value->send('stop'); } echo $value . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/Rg4Ie
function name:  (null)
number of ops:  15
compiled vars:  !0 = $gen, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'creategen'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   16     3      > FE_RESET_R                                       $4      !0, ->13
          4    > > FE_FETCH_R                                               $4, !1, ->13
   17     5    >   IS_IDENTICAL                                             !1, 5
          6      > JMPZ                                                     ~5, ->10
   18     7    >   INIT_METHOD_CALL                                         !1, 'send'
          8        SEND_VAL_EX                                              'stop'
          9        DO_FCALL                                      0          
   20    10    >   CONCAT                                           ~7      !1, '%0A'
         11        ECHO                                                     ~7
   16    12      > JMP                                                      ->4
         13    >   FE_FREE                                                  $4
   21    14      > RETURN                                                   1

Function creategen:
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 = 3
Branch analysis from position: 11
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
Branch analysis from position: 3
filename:       /in/Rg4Ie
function name:  createGen
number of ops:  12
compiled vars:  !0 = $i, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    5     1        ASSIGN                                                   !0, 0
          2      > JMP                                                      ->9
    6     3    >   YIELD                                            $3      !0
          4        ASSIGN                                                   !1, $3
    8     5        IS_EQUAL                                                 !1, 'stop'
          6      > JMPZ                                                     ~5, ->8
    9     7    > > GENERATOR_RETURN                                         
    5     8    >   PRE_INC                                                  !0
          9    >   IS_SMALLER                                               !0, 10
         10      > JMPNZ                                                    ~7, ->3
   12    11    > > GENERATOR_RETURN                                         

End of function creategen

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.17 ms | 1399 KiB | 14 Q