3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen1() { yield 1; yield 2; yield 3; } function yf($iter) { $isSubgenerator = $iter instanceof Generator; foreach($iter as $val) { $x = yield $val; echo "Got $x from a yieldn\n"; } } $g = yf(gen1()); $g->next(); var_dump($g->current()); $g->send(10); var_dump($g->current()); $g->send(20); var_dump($g->current());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7RSGi
function name:  (null)
number of ops:  30
compiled vars:  !0 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'yf'
          1        INIT_FCALL                                               'gen1'
          2        DO_FCALL                                      0  $1      
          3        SEND_VAR                                                 $1
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   18     6        INIT_METHOD_CALL                                         !0, 'next'
          7        DO_FCALL                                      0          
   19     8        INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !0, 'current'
         10        DO_FCALL                                      0  $5      
         11        SEND_VAR                                                 $5
         12        DO_ICALL                                                 
   20    13        INIT_METHOD_CALL                                         !0, 'send'
         14        SEND_VAL_EX                                              10
         15        DO_FCALL                                      0          
   21    16        INIT_FCALL                                               'var_dump'
         17        INIT_METHOD_CALL                                         !0, 'current'
         18        DO_FCALL                                      0  $8      
         19        SEND_VAR                                                 $8
         20        DO_ICALL                                                 
   22    21        INIT_METHOD_CALL                                         !0, 'send'
         22        SEND_VAL_EX                                              20
         23        DO_FCALL                                      0          
   23    24        INIT_FCALL                                               'var_dump'
         25        INIT_METHOD_CALL                                         !0, 'current'
         26        DO_FCALL                                      0  $11     
         27        SEND_VAR                                                 $11
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Function gen1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/7RSGi
function name:  gen1
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        YIELD                                                    1
    5     2        YIELD                                                    2
    6     3        YIELD                                                    3
    7     4      > GENERATOR_RETURN                                         

End of function gen1

Function yf:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 13
filename:       /in/7RSGi
function name:  yf
number of ops:  15
compiled vars:  !0 = $iter, !1 = $isSubgenerator, !2 = $val, !3 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   10     2        INSTANCEOF                                       ~4      !0, 'Generator'
          3        ASSIGN                                                   !1, ~4
   11     4      > FE_RESET_R                                       $6      !0, ->13
          5    > > FE_FETCH_R                                               $6, !2, ->13
   12     6    >   YIELD                                            $7      !2
          7        ASSIGN                                                   !3, $7
   13     8        ROPE_INIT                                     3  ~10     'Got+'
          9        ROPE_ADD                                      1  ~10     ~10, !3
         10        ROPE_END                                      2  ~9      ~10, '+from+a+yieldn%0A'
         11        ECHO                                                     ~9
   11    12      > JMP                                                      ->5
         13    >   FE_FREE                                                  $6
   15    14      > GENERATOR_RETURN                                         

End of function yf

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.02 ms | 1403 KiB | 17 Q