3v4l.org

run code in 300+ PHP versions simultaneously
<?php exit(); $countMap = (function(){ yield "a" => 5; yield "b" => 2; yield "c" => 3; })(); // emits "C" times the element "K" from the given Iterator<K, C> $iterator = new MultiplyIterator($countMap); // better name for this? $iterator->rewind(); assert($iterator->current() === "a"); $iterator->next(); assert($iterator->current() === "a"); $iterator->next(); assert($iterator->current() === "a"); $iterator->next(); assert($iterator->current() === "a"); $iterator->next(); assert($iterator->current() === "a"); $iterator->next(); assert($iterator->current() === "b"); $iterator->next(); assert($iterator->current() === "b"); $iterator->next(); assert($iterator->current() === "c"); $iterator->next(); assert($iterator->current() === "c"); $iterator->next(); assert($iterator->current() === "c"); $iterator->next();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/c98pt
function name:  (null)
number of ops:  112
compiled vars:  !0 = $countMap, !1 = $iterator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E > > EXIT                                                     
    3     1*       DECLARE_LAMBDA_FUNCTION                          ~2      [0]
    7     2*       INIT_DYNAMIC_CALL                                        ~2
          3*       DO_FCALL                                      0  $3      
    3     4*       ASSIGN                                                   !0, $3
   10     5*       NEW                                              $5      'MultiplyIterator'
          6*       SEND_VAR_EX                                              !0
          7*       DO_FCALL                                      0          
          8*       ASSIGN                                                   !1, $5
   11     9*       INIT_METHOD_CALL                                         !1, 'rewind'
         10*       DO_FCALL                                      0          
   13    11*       ASSERT_CHECK                                             
         12*       INIT_FCALL                                               'assert'
         13*       INIT_METHOD_CALL                                         !1, 'current'
         14*       DO_FCALL                                      0  $9      
         15*       IS_IDENTICAL                                     ~10     $9, 'a'
         16*       SEND_VAL                                                 ~10
         17*       SEND_VAL                                                 'assert%28%24iterator-%3Ecurrent%28%29+%3D%3D%3D+%27a%27%29'
         18*       DO_ICALL                                                 
         19*       INIT_METHOD_CALL                                         !1, 'next'
         20*       DO_FCALL                                      0          
   14    21*       ASSERT_CHECK                                             
         22*       INIT_FCALL                                               'assert'
         23*       INIT_METHOD_CALL                                         !1, 'current'
         24*       DO_FCALL                                      0  $13     
         25*       IS_IDENTICAL                                     ~14     $13, 'a'
         26*       SEND_VAL                                                 ~14
         27*       SEND_VAL                                                 'assert%28%24iterator-%3Ecurrent%28%29+%3D%3D%3D+%27a%27%29'
         28*       DO_ICALL                                                 
         29*       INIT_METHOD_CALL                                         !1, 'next'
         30*       DO_FCALL                                      0          
   15    31*       ASSERT_CHECK                                             
         32*       INIT_FCALL                                               'assert'
         33*       INIT_METHOD_CALL                                         !1, 'current'
         34*       DO_FCALL                                      0  $17     
         35*       IS_IDENTICAL                                     ~18     $17, 'a'
         36*       SEND_VAL                                                 ~18
         37*       SEND_VAL                                                 'assert%28%24iterator-%3Ecurrent%28%29+%3D%3D%3D+%27a%27%29'
         38*       DO_ICALL                                                 
         39*       INIT_METHOD_CALL                                         !1, 'next'
         40*       DO_FCALL                                      0          
   16    41*       ASSERT_CHECK                                             
         42*       INIT_FCALL                                               'assert'
         43*       INIT_METHOD_CALL                                         !1, 'current'
         44*       DO_FCALL                                      0  $21     
         45*       IS_IDENTICAL                                     ~22     $21, 'a'
         46*       SEND_VAL                                                 ~22
         47*       SEND_VAL                                                 'assert%28%24iterator-%3Ecurrent%28%29+%3D%3D%3D+%27a%27%29'
         48*       DO_ICALL                                                 
         49*       INIT_METHOD_CALL                                         !1, 'next'
         50*       DO_FCALL                                      0          
   17    51*       ASSERT_CHECK                                             
         52*       INIT_FCALL                                               'assert'
         53*       INIT_METHOD_CALL                                         !1, 'current'
         54*       DO_FCALL                                      0  $25     
         55*       IS_IDENTICAL                                     ~26     $25, 'a'
         56*       SEND_VAL                                                 ~26
         57*       SEND_VAL                                                 'assert%28%24iterator-%3Ecurrent%28%29+%3D%3D%3D+%27a%27%29'
         58*       DO_ICALL                                                 
         59*       INIT_METHOD_CALL                                         !1, 'next'
         60*       DO_FCALL                                      0          
   19    61*       ASSERT_CHECK                                             
         62*       INIT_FCALL                                               'assert'
         63*       INIT_METHOD_CALL                                         !1, 'current'
         64*       DO_FCALL                                      0  $29     
         65*       IS_IDENTICAL                                     ~30     $29, 'b'
         66*       SEND_VAL                                                 ~30
         67*       SEND_VAL                                                 'assert%28%24iterator-%3Ecurrent%28%29+%3D%3D%3D+%27b%27%29'
         68*       DO_ICALL                                                 
         69*       INIT_METHOD_CALL                                         !1, 'next'
         70*       DO_FCALL                                      0          
   20    71*       ASSERT_CHECK                                             
         72*       INIT_FCALL                                               'assert'
         73*       INIT_METHOD_CALL                                         !1, 'current'
         74*       DO_FCALL                                      0  $33     
         75*       IS_IDENTICAL                                     ~34     $33, 'b'
         76*       SEND_VAL                                                 ~34
         77*       SEND_VAL                                                 'assert%28%24iterator-%3Ecurrent%28%29+%3D%3D%3D+%27b%27%29'
         78*       DO_ICALL                                                 
         79*       INIT_METHOD_CALL                                         !1, 'next'
         80*       DO_FCALL                                      0          
   22    81*       ASSERT_CHECK                                             
         82*       INIT_FCALL                                               'assert'
         83*       INIT_METHOD_CALL                                         !1, 'current'
         84*       DO_FCALL                                      0  $37     
         85*       IS_IDENTICAL                                     ~38     $37, 'c'
         86*       SEND_VAL                                                 ~38
         87*       SEND_VAL                                                 'assert%28%24iterator-%3Ecurrent%28%29+%3D%3D%3D+%27c%27%29'
         88*       DO_ICALL                                                 
         89*       INIT_METHOD_CALL                                         !1, 'next'
         90*       DO_FCALL                                      0          
   23    91*       ASSERT_CHECK                                             
         92*       INIT_FCALL                                               'assert'
         93*       INIT_METHOD_CALL                                         !1, 'current'
         94*       DO_FCALL                                      0  $41     
         95*       IS_IDENTICAL                                     ~42     $41, 'c'
         96*       SEND_VAL                                                 ~42
         97*       SEND_VAL                                                 'assert%28%24iterator-%3Ecurrent%28%29+%3D%3D%3D+%27c%27%29'
         98*       DO_ICALL                                                 
         99*       INIT_METHOD_CALL                                         !1, 'next'
        100*       DO_FCALL                                      0          
   24   101*       ASSERT_CHECK                                             
        102*       INIT_FCALL                                               'assert'
        103*       INIT_METHOD_CALL                                         !1, 'current'
        104*       DO_FCALL                                      0  $45     
        105*       IS_IDENTICAL                                     ~46     $45, 'c'
        106*       SEND_VAL                                                 ~46
        107*       SEND_VAL                                                 'assert%28%24iterator-%3Ecurrent%28%29+%3D%3D%3D+%27c%27%29'
        108*       DO_ICALL                                                 
        109*       INIT_METHOD_CALL                                         !1, 'next'
        110*       DO_FCALL                                      0          
        111*     > RETURN                                                   1


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

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
120.31 ms | 1009 KiB | 14 Q