3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function g1() { yield 1; yield 2; } function g2() { $a = yield; yield "a"; var_dump($a); $b = yield; yield "b"; var_dump($b); } $g1=g1(); $g2=g2(); foreach($g1 as $v) { var_dump($g2->send($v)); }
based on 7Ufga
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
Jump found. Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
Jump found. Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 17
Jump found. Position 1 = -2
Branch analysis from position: 17
filename:       /in/E8bnn
function name:  (null)
number of ops:  19
compiled vars:  !0 = $g1, !1 = $g2, !2 = $v
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   NOP                                                      
   7     1        NOP                                                      
  17     2        INIT_FCALL                                               'g1'
         3        DO_FCALL                                      0  $3      
         4        ASSIGN                                                   !0, $3
  18     5        INIT_FCALL                                               'g2'
         6        DO_FCALL                                      0  $5      
         7        ASSIGN                                                   !1, $5
  20     8      > FE_RESET_R                                       $7      !0, ->17
         9    > > FE_FETCH_R                                               $7, !2, ->17
  22    10    >   INIT_FCALL                                               'var_dump'
        11        INIT_METHOD_CALL                                         !1, 'send'
        12        SEND_VAR_EX                                              !2
        13        DO_FCALL                                      0  $8      
        14        SEND_VAR                                                 $8
        15        DO_ICALL                                                 
        16      > JMP                                                      ->9
        17    >   FE_FREE                                                  $7
        18      > RETURN                                                   1

Function g1:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/E8bnn
function name:  g1
number of ops:  3
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   YIELD                                                    1
   4     1        YIELD                                                    2
   5     2      > GENERATOR_RETURN                                         

End of function g1

Function g2:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/E8bnn
function name:  g2
number of ops:  13
compiled vars:  !0 = $a, !1 = $b
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   8     0  E >   YIELD                                            $2      
         1        ASSIGN                                                   !0, $2
   9     2        YIELD                                                    'a'
  10     3        INIT_FCALL                                               'var_dump'
         4        SEND_VAR                                                 !0
         5        DO_ICALL                                                 
  12     6        YIELD                                            $6      
         7        ASSIGN                                                   !1, $6
  13     8        YIELD                                                    'b'
  14     9        INIT_FCALL                                               'var_dump'
        10        SEND_VAR                                                 !1
        11        DO_ICALL                                                 
  15    12      > GENERATOR_RETURN                                         

End of function g2

Generated using Vulcan Logic Dumper, using php 7.3.0