3v4l.org

run code in 300+ PHP versions simultaneously
<?php $generator = function() { $current = A; while (true) { $current++;; yield $current; } }; function seek($generator, $offset, $count = 1) { return new LimitIterator(new IteratorIterator($generator()), $offset, $count); } $test = seek($generator, 10, 3); foreach($test as $current) { echo $current, "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/DVUCs
function name:  (null)
number of ops:  15
compiled vars:  !0 = $generator, !1 = $test, !2 = $current
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FDVUCs%3A3%240'
          1        ASSIGN                                                   !0, ~3
   15     2        INIT_FCALL                                               'seek'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 10
          5        SEND_VAL                                                 3
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !1, $5
   16     8      > FE_RESET_R                                       $7      !1, ->13
          9    > > FE_FETCH_R                                               $7, !2, ->13
   17    10    >   ECHO                                                     !2
         11        ECHO                                                     '%0A'
   16    12      > JMP                                                      ->9
         13    >   FE_FREE                                                  $7
   18    14      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FDVUCs%3A3%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 4
Branch analysis from position: 7
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 4
Branch analysis from position: 7
Branch analysis from position: 4
filename:       /in/DVUCs
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $current
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        FETCH_CONSTANT                                   ~1      'A'
          2        ASSIGN                                                   !0, ~1
    5     3      > JMP                                                      ->6
    6     4    >   PRE_INC                                                  !0
    7     5        YIELD                                                    !0
    5     6    > > JMPNZ                                                    <true>, ->4
    9     7    > > GENERATOR_RETURN                                         

End of function %00%7Bclosure%7D%2Fin%2FDVUCs%3A3%240

Function seek:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DVUCs
function name:  seek
number of ops:  15
compiled vars:  !0 = $generator, !1 = $offset, !2 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      1
   12     3        NEW                                              $3      'LimitIterator'
          4        NEW                                              $4      'IteratorIterator'
          5        INIT_DYNAMIC_CALL                                        !0
          6        DO_FCALL                                      0  $5      
          7        SEND_VAR_NO_REF_EX                                       $5
          8        DO_FCALL                                      0          
          9        SEND_VAR_NO_REF_EX                                       $4
         10        SEND_VAR_EX                                              !1
         11        SEND_VAR_EX                                              !2
         12        DO_FCALL                                      0          
         13      > RETURN                                                   $3
   13    14*     > RETURN                                                   null

End of function seek

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.96 ms | 1403 KiB | 14 Q