3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generate_ints($n){ $range = range(0,$n-1); for ($i=0, $max = count($range); $i < $max; $i++) { $i = (yield $i); yield $i; } } $gen = generate_ints(3); echo $gen->current(); $gen->next(); echo $gen->current(); $gen->send(99); // injecting a value to stop the generator;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NLsCS
function name:  (null)
number of ops:  16
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
   15     7        INIT_METHOD_CALL                                         !0, 'next'
          8        DO_FCALL                                      0          
   16     9        INIT_METHOD_CALL                                         !0, 'current'
         10        DO_FCALL                                      0  $5      
         11        ECHO                                                     $5
   18    12        INIT_METHOD_CALL                                         !0, 'send'
         13        SEND_VAL_EX                                              99
         14        DO_FCALL                                      0          
         15      > RETURN                                                   1

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

End of function generate_ints

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.8 ms | 1398 KiB | 16 Q