3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generate_ints($n){ foreach ( range(0,$n-1) as $number) { $number = (yield $number); yield $number; } } $gen = generate_ints(3); echo $gen->current(); $gen->next(); echo $gen->current(); $gen->send(99); // injecting a value; echo $gen->current(); $gen->next(); echo $gen->current(); $gen->next(); echo $gen->current();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TROXk
function name:  (null)
number of ops:  29
compiled vars:  !0 = $gen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'generate_ints'
          1        SEND_VAL                                                 3
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   13     4        INIT_METHOD_CALL                                         !0, 'current'
          5        DO_FCALL                                      0  $3      
          6        ECHO                                                     $3
   14     7        INIT_METHOD_CALL                                         !0, 'next'
          8        DO_FCALL                                      0          
   15     9        INIT_METHOD_CALL                                         !0, 'current'
         10        DO_FCALL                                      0  $5      
         11        ECHO                                                     $5
   17    12        INIT_METHOD_CALL                                         !0, 'send'
         13        SEND_VAL_EX                                              99
         14        DO_FCALL                                      0          
   18    15        INIT_METHOD_CALL                                         !0, 'current'
         16        DO_FCALL                                      0  $7      
         17        ECHO                                                     $7
   20    18        INIT_METHOD_CALL                                         !0, 'next'
         19        DO_FCALL                                      0          
   21    20        INIT_METHOD_CALL                                         !0, 'current'
         21        DO_FCALL                                      0  $9      
         22        ECHO                                                     $9
   22    23        INIT_METHOD_CALL                                         !0, 'next'
         24        DO_FCALL                                      0          
   23    25        INIT_METHOD_CALL                                         !0, 'current'
         26        DO_FCALL                                      0  $11     
         27        ECHO                                                     $11
         28      > RETURN                                                   1

Function generate_ints:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 13
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 13
filename:       /in/TROXk
function name:  generate_ints
number of ops:  15
compiled vars:  !0 = $n, !1 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    4     2        INIT_FCALL                                               'range'
          3        SEND_VAL                                                 0
          4        SUB                                              ~2      !0, 1
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7      > FE_RESET_R                                       $4      $3, ->13
          8    > > FE_FETCH_R                                               $4, !1, ->13
    5     9    >   YIELD                                            $5      !1
         10        ASSIGN                                                   !1, $5
    6    11        YIELD                                                    !1
    4    12      > JMP                                                      ->8
         13    >   FE_FREE                                                  $4
    9    14      > GENERATOR_RETURN                                         

End of function generate_ints

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.54 ms | 1403 KiB | 16 Q