3v4l.org

run code in 300+ PHP versions simultaneously
<?PHP if (!class_exists('RuntimeException')) { class RuntimeException extends Exception { } } class InvalidStateException extends RuntimeException { } class Compiler { private $ptr; private $arr; private $code; private $commands = array('>', '<', '+', '-', '.', ',', '[', ']'); private $call_stack = array(); private $cellsize = 8; public function parseString($code, $throwException = true) { $this->code = $code; for ($i=0;$i<strlen($this->code);$i++) { $c = substr($this->code, $i, 1); if (!in_array($c, $this->commands)) { continue; } } } public function execute($code) { $this->arr = array(0 => 0); $this->ptr = 0; $this->code = $code; for ($this->i=0;$this->i<strlen($this->code);$this->i++) { $c = $this->c = substr($this->code, $this->i, 1); if (!in_array($c, $this->commands)) { continue; } elseif ($c == '>') { $this->increment_pointer(); } elseif ($c == '<') { $this->decrement_pointer(); } elseif ($c == '+') { $this->increment_val(); } elseif ($c == '-') { $this->decrement_val(); } elseif ($c == '.') { $this->output_val(); } elseif ($c == ',') { $this->store_val($this->input_val()); } elseif ($c == '[') { $this->loop($this->i); } } } private function stack($func=null) { if (is_null($func)) { if (count($this->call_stack) == 0) { throw new InvalidStateException("Trying to pop empty call stack"); return false; } array_pop($this->call_stack); return true; } else { $info = array('command' => $this->c, 'pos' => $this->i, 'internal_function' => $func); array_push($this->call_stack, $info); return true; } } public function minimum_cellsize() { return (-1*(pow(2, $this->cellsize-1))); } public function maximum_cellsize() { return pow(2, $this->cellsize-1)-1; } private function increment_pointer() { $this->stack(__FUNCTION__); $this->ptr++; if (!isset($this->arr[$this->ptr])) $this->arr[$this->ptr] = 0; $this->stack(); return true; } private function decrement_pointer() { $this->stack(__FUNCTION__); $this->ptr--; if ($this->ptr < 0) { throw new InvalidStateException("The data pointer is less than 0"); return false; } $this->stack(); return true; } private function increment_val() { $x = $this->arr[$this->ptr]++; if ($x < $this->minimum_cellsize()) { $this->arr[$this->ptr] = $this->maximum_cellsize(); } elseif ($x > $this->maximum_cellsize()) { $this->arr[$this->ptr] = $this->minimum_cellsize(); } return true; } private function decrement_val() { $x = $this->arr[$this->ptr]--; if ($x < $this->minimum_cellsize()) { $this->arr[$this->ptr] = $this->maximum_cellsize(); } elseif ($x > $this->maximum_cellsize()) { $this->arr[$this->ptr] = $this->minimum_cellsize(); } return true; } private function output_val() { $c = $this->arr[$this->ptr]; echo 'hey'.chr($c); } private function store_val($chr) { $x = ord($chr); $this->arr[$this->ptr] = $x; } private function input_val() { return fgets(STDIN); } public function getCallStack() { return $this->call_stack; } public function getCells() { return $this->arr; } public function getPointer() { return $this->ptr; } } $c = new Compiler(); $bf = '>+>++>+++>++++'; try { echo "{ "; $c->execute($bf); echo " }"; } catch (Exception $e) { echo PHP_EOL."An exception was thrown whilst processing your BF program.".PHP_EOL; echo $e->getMessage().":".PHP_EOL; } echo "The pointer was set to ".$c->getPointer()." and the cell array resembled:".PHP_EOL; echo "[".implode(", ", $c->getCells())."]".PHP_EOL; echo "The current stack trace was:".PHP_EOL; $i = 0; foreach ($c->getCallStack() as $call) { echo '#'.$i.' '.$call['command'].' ('.$call['internal_function'],') on pos '.$call['pos'].PHP_EOL; } echo PHP_EOL.'Finished.'.PHP_EOL; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 44, Position 2 = 58
Branch analysis from position: 44
2 jumps found. (Code = 78) Position 1 = 45, Position 2 = 58
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
Branch analysis from position: 6
Found catch point at position: 16
Branch analysis from position: 16
2 jumps found. (Code = 107) Position 1 = 17, Position 2 = -2
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 44, Position 2 = 58
Branch analysis from position: 44
Branch analysis from position: 58
filename:       /in/a2gIW
function name:  (null)
number of ops:  61
compiled vars:  !0 = $c, !1 = $bf, !2 = $e, !3 = $i, !4 = $call
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'class_exists'
          1        SEND_VAL                                                 'RuntimeException'
          2        DO_ICALL                                         $5      
          3        BOOL_NOT                                         ~6      $5
          4      > JMPZ                                                     ~6, ->6
    4     5    >   DECLARE_CLASS                                            'runtimeexception', 'exception'
  152     6    >   NEW                                              $7      'Compiler'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !0, $7
  154     9        ASSIGN                                                   !1, '%3E%2B%3E%2B%2B%3E%2B%2B%2B%3E%2B%2B%2B%2B'
  157    10        ECHO                                                     '%7B+'
  158    11        INIT_METHOD_CALL                                         !0, 'execute'
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0          
  159    14        ECHO                                                     '+%7D'
         15      > JMP                                                      ->23
  161    16  E > > CATCH                                       last         'Exception'
  162    17    >   ECHO                                                     '%0AAn+exception+was+thrown+whilst+processing+your+BF+program.%0A'
  163    18        INIT_METHOD_CALL                                         !2, 'getMessage'
         19        DO_FCALL                                      0  $12     
         20        CONCAT                                           ~13     $12, '%3A'
         21        CONCAT                                           ~14     ~13, '%0A'
         22        ECHO                                                     ~14
  165    23    >   INIT_METHOD_CALL                                         !0, 'getPointer'
         24        DO_FCALL                                      0  $15     
         25        CONCAT                                           ~16     'The+pointer+was+set+to+', $15
         26        CONCAT                                           ~17     ~16, '+and+the+cell+array+resembled%3A'
         27        CONCAT                                           ~18     ~17, '%0A'
         28        ECHO                                                     ~18
  166    29        INIT_FCALL                                               'implode'
         30        SEND_VAL                                                 '%2C+'
         31        INIT_METHOD_CALL                                         !0, 'getCells'
         32        DO_FCALL                                      0  $19     
         33        SEND_VAR                                                 $19
         34        DO_ICALL                                         $20     
         35        CONCAT                                           ~21     '%5B', $20
         36        CONCAT                                           ~22     ~21, '%5D'
         37        CONCAT                                           ~23     ~22, '%0A'
         38        ECHO                                                     ~23
  167    39        ECHO                                                     'The+current+stack+trace+was%3A%0A'
  168    40        ASSIGN                                                   !3, 0
  169    41        INIT_METHOD_CALL                                         !0, 'getCallStack'
         42        DO_FCALL                                      0  $25     
         43      > FE_RESET_R                                       $26     $25, ->58
         44    > > FE_FETCH_R                                               $26, !4, ->58
  170    45    >   CONCAT                                           ~27     '%23', !3
         46        CONCAT                                           ~28     ~27, '+'
         47        FETCH_DIM_R                                      ~29     !4, 'command'
         48        CONCAT                                           ~30     ~28, ~29
         49        CONCAT                                           ~31     ~30, '+%28'
         50        FETCH_DIM_R                                      ~32     !4, 'internal_function'
         51        CONCAT                                           ~33     ~31, ~32
         52        ECHO                                                     ~33
         53        FETCH_DIM_R                                      ~34     !4, 'pos'
         54        CONCAT                                           ~35     '%29+on+pos+', ~34
         55        CONCAT                                           ~36     ~35, '%0A'
         56        ECHO                                                     ~36
  169    57      > JMP                                                      ->44
         58    >   FE_FREE                                                  $26
  172    59        ECHO                                                     '%0AFinished.%0A'
  173    60      > RETURN                                                   1

Class RuntimeException: [no user functions]
Class InvalidStateException: [no user functions]
Class Compiler:
Function parsestring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 6
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 21
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 6
Branch analysis from position: 26
Branch analysis from position: 6
Branch analysis from position: 21
filename:       /in/a2gIW
function name:  parseString
number of ops:  27
compiled vars:  !0 = $code, !1 = $throwException, !2 = $i, !3 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <true>
   17     2        ASSIGN_OBJ                                               'code'
          3        OP_DATA                                                  !0
   18     4        ASSIGN                                                   !2, 0
          5      > JMP                                                      ->22
   19     6    >   INIT_FCALL                                               'substr'
          7        FETCH_OBJ_R                                      ~6      'code'
          8        SEND_VAL                                                 ~6
          9        SEND_VAR                                                 !2
         10        SEND_VAL                                                 1
         11        DO_ICALL                                         $7      
         12        ASSIGN                                                   !3, $7
   20    13        INIT_FCALL                                               'in_array'
         14        SEND_VAR                                                 !3
         15        FETCH_OBJ_R                                      ~9      'commands'
         16        SEND_VAL                                                 ~9
         17        DO_ICALL                                         $10     
         18        BOOL_NOT                                         ~11     $10
         19      > JMPZ                                                     ~11, ->21
   21    20    > > JMP                                                      ->21
   18    21    >   PRE_INC                                                  !2
         22    >   FETCH_OBJ_R                                      ~13     'code'
         23        STRLEN                                           ~14     ~13
         24        IS_SMALLER                                               !2, ~14
         25      > JMPNZ                                                    ~15, ->6
   24    26    > > RETURN                                                   null

End of function parsestring

Function execute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 75, Position 2 = 10
Branch analysis from position: 75
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
2 jumps found. (Code = 44) Position 1 = 75, Position 2 = 10
Branch analysis from position: 75
Branch analysis from position: 10
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 34
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 39
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 44
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 49
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 54
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 62
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 62
2 jumps found. (Code = 43) Position 1 = 64, Position 2 = 69
Branch analysis from position: 64
2 jumps found. (Code = 44) Position 1 = 75, Position 2 = 10
Branch analysis from position: 75
Branch analysis from position: 10
Branch analysis from position: 69
filename:       /in/a2gIW
function name:  execute
number of ops:  76
compiled vars:  !0 = $code, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        ASSIGN_OBJ                                               'arr'
          2        OP_DATA                                                  <array>
   28     3        ASSIGN_OBJ                                               'ptr'
          4        OP_DATA                                                  0
   29     5        ASSIGN_OBJ                                               'code'
          6        OP_DATA                                                  !0
   31     7        ASSIGN_OBJ                                               'i'
          8        OP_DATA                                                  0
          9      > JMP                                                      ->70
   32    10    >   INIT_FCALL                                               'substr'
         11        FETCH_OBJ_R                                      ~7      'code'
         12        SEND_VAL                                                 ~7
         13        FETCH_OBJ_R                                      ~8      'i'
         14        SEND_VAL                                                 ~8
         15        SEND_VAL                                                 1
         16        DO_ICALL                                         $9      
         17        ASSIGN_OBJ                                       ~6      'c'
         18        OP_DATA                                                  $9
         19        ASSIGN                                                   !1, ~6
   33    20        INIT_FCALL                                               'in_array'
         21        SEND_VAR                                                 !1
         22        FETCH_OBJ_R                                      ~11     'commands'
         23        SEND_VAL                                                 ~11
         24        DO_ICALL                                         $12     
         25        BOOL_NOT                                         ~13     $12
         26      > JMPZ                                                     ~13, ->29
   34    27    > > JMP                                                      ->69
         28*       JMP                                                      ->69
   36    29    >   IS_EQUAL                                                 !1, '%3E'
         30      > JMPZ                                                     ~14, ->34
   37    31    >   INIT_METHOD_CALL                                         'increment_pointer'
         32        DO_FCALL                                      0          
         33      > JMP                                                      ->69
   39    34    >   IS_EQUAL                                                 !1, '%3C'
         35      > JMPZ                                                     ~16, ->39
   40    36    >   INIT_METHOD_CALL                                         'decrement_pointer'
         37        DO_FCALL                                      0          
         38      > JMP                                                      ->69
   42    39    >   IS_EQUAL                                                 !1, '%2B'
         40      > JMPZ                                                     ~18, ->44
   43    41    >   INIT_METHOD_CALL                                         'increment_val'
         42        DO_FCALL                                      0          
         43      > JMP                                                      ->69
   45    44    >   IS_EQUAL                                                 !1, '-'
         45      > JMPZ                                                     ~20, ->49
   46    46    >   INIT_METHOD_CALL                                         'decrement_val'
         47        DO_FCALL                                      0          
         48      > JMP                                                      ->69
   48    49    >   IS_EQUAL                                                 !1, '.'
         50      > JMPZ                                                     ~22, ->54
   49    51    >   INIT_METHOD_CALL                                         'output_val'
         52        DO_FCALL                                      0          
         53      > JMP                                                      ->69
   51    54    >   IS_EQUAL                                                 !1, '%2C'
         55      > JMPZ                                                     ~24, ->62
   52    56    >   INIT_METHOD_CALL                                         'store_val'
         57        INIT_METHOD_CALL                                         'input_val'
         58        DO_FCALL                                      0  $25     
         59        SEND_VAR_NO_REF_EX                                       $25
         60        DO_FCALL                                      0          
         61      > JMP                                                      ->69
   54    62    >   IS_EQUAL                                                 !1, '%5B'
         63      > JMPZ                                                     ~27, ->69
   55    64    >   INIT_METHOD_CALL                                         'loop'
         65        CHECK_FUNC_ARG                                           
         66        FETCH_OBJ_FUNC_ARG                               $28     'i'
         67        SEND_FUNC_ARG                                            $28
         68        DO_FCALL                                      0          
   31    69    >   PRE_INC_OBJ                                              'i'
         70    >   FETCH_OBJ_R                                      ~31     'i'
         71        FETCH_OBJ_R                                      ~32     'code'
         72        STRLEN                                           ~33     ~32
         73        IS_SMALLER                                               ~31, ~33
         74      > JMPNZ                                                    ~34, ->10
   58    75    > > RETURN                                                   null

End of function execute

Function stack:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a2gIW
function name:  stack
number of ops:  31
compiled vars:  !0 = $func, !1 = $info
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   RECV_INIT                                        !0      null
   61     1        TYPE_CHECK                                    2          !0
          2      > JMPZ                                                     ~2, ->18
   62     3    >   FETCH_OBJ_R                                      ~3      'call_stack'
          4        COUNT                                            ~4      ~3
          5        IS_EQUAL                                                 ~4, 0
          6      > JMPZ                                                     ~5, ->12
   63     7    >   NEW                                              $6      'InvalidStateException'
          8        SEND_VAL_EX                                              'Trying+to+pop+empty+call+stack'
          9        DO_FCALL                                      0          
         10      > THROW                                         0          $6
   64    11*       RETURN                                                   <false>
   66    12    >   INIT_FCALL                                               'array_pop'
         13        FETCH_OBJ_W                                      $8      'call_stack'
         14        SEND_REF                                                 $8
         15        DO_ICALL                                                 
   67    16      > RETURN                                                   <true>
         17*       JMP                                                      ->30
   70    18    >   FETCH_OBJ_R                                      ~10     'c'
         19        INIT_ARRAY                                       ~11     ~10, 'command'
         20        FETCH_OBJ_R                                      ~12     'i'
         21        ADD_ARRAY_ELEMENT                                ~11     ~12, 'pos'
         22        ADD_ARRAY_ELEMENT                                ~11     !0, 'internal_function'
         23        ASSIGN                                                   !1, ~11
   71    24        INIT_FCALL                                               'array_push'
         25        FETCH_OBJ_W                                      $14     'call_stack'
         26        SEND_REF                                                 $14
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                                 
   72    29      > RETURN                                                   <true>
   74    30*     > RETURN                                                   null

End of function stack

Function minimum_cellsize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a2gIW
function name:  minimum_cellsize
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   77     0  E >   INIT_FCALL                                               'pow'
          1        SEND_VAL                                                 2
          2        FETCH_OBJ_R                                      ~0      'cellsize'
          3        SUB                                              ~1      ~0, 1
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6        MUL                                              ~3      $2, -1
          7      > RETURN                                                   ~3
   78     8*     > RETURN                                                   null

End of function minimum_cellsize

Function maximum_cellsize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a2gIW
function name:  maximum_cellsize
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   81     0  E >   INIT_FCALL                                               'pow'
          1        SEND_VAL                                                 2
          2        FETCH_OBJ_R                                      ~0      'cellsize'
          3        SUB                                              ~1      ~0, 1
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6        SUB                                              ~3      $2, 1
          7      > RETURN                                                   ~3
   82     8*     > RETURN                                                   null

End of function maximum_cellsize

Function increment_pointer:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/a2gIW
function name:  increment_pointer
number of ops:  17
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   85     0  E >   INIT_METHOD_CALL                                         'stack'
          1        SEND_VAL                                                 'increment_pointer'
          2        DO_FCALL                                      0          
   86     3        PRE_INC_OBJ                                              'ptr'
   87     4        FETCH_OBJ_R                                      ~3      'ptr'
          5        FETCH_OBJ_IS                                     ~2      'arr'
          6        ISSET_ISEMPTY_DIM_OBJ                         0  ~4      ~2, ~3
          7        BOOL_NOT                                         ~5      ~4
          8      > JMPZ                                                     ~5, ->13
          9    >   FETCH_OBJ_R                                      ~7      'ptr'
         10        FETCH_OBJ_W                                      $6      'arr'
         11        ASSIGN_DIM                                               $6, ~7
         12        OP_DATA                                                  0
   88    13    >   INIT_METHOD_CALL                                         'stack'
         14        DO_FCALL                                      0          
   89    15      > RETURN                                                   <true>
   90    16*     > RETURN                                                   null

End of function increment_pointer

Function decrement_pointer:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a2gIW
function name:  decrement_pointer
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   93     0  E >   INIT_METHOD_CALL                                         'stack'
          1        SEND_VAL                                                 'decrement_pointer'
          2        DO_FCALL                                      0          
   94     3        PRE_DEC_OBJ                                              'ptr'
   95     4        FETCH_OBJ_R                                      ~2      'ptr'
          5        IS_SMALLER                                               ~2, 0
          6      > JMPZ                                                     ~3, ->12
   96     7    >   NEW                                              $4      'InvalidStateException'
          8        SEND_VAL_EX                                              'The+data+pointer+is+less+than+0'
          9        DO_FCALL                                      0          
         10      > THROW                                         0          $4
   97    11*       RETURN                                                   <false>
   99    12    >   INIT_METHOD_CALL                                         'stack'
         13        DO_FCALL                                      0          
  100    14      > RETURN                                                   <true>
  101    15*     > RETURN                                                   null

End of function decrement_pointer

Function increment_val:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/a2gIW
function name:  increment_val
number of ops:  28
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  104     0  E >   FETCH_OBJ_R                                      ~2      'ptr'
          1        FETCH_OBJ_RW                                     $1      'arr'
          2        FETCH_DIM_RW                                     $3      $1, ~2
          3        POST_INC                                         ~4      $3
          4        ASSIGN                                                   !0, ~4
  105     5        INIT_METHOD_CALL                                         'minimum_cellsize'
          6        DO_FCALL                                      0  $6      
          7        IS_SMALLER                                               !0, $6
          8      > JMPZ                                                     ~7, ->16
  106     9    >   FETCH_OBJ_R                                      ~9      'ptr'
         10        INIT_METHOD_CALL                                         'maximum_cellsize'
         11        DO_FCALL                                      0  $11     
         12        FETCH_OBJ_W                                      $8      'arr'
         13        ASSIGN_DIM                                               $8, ~9
         14        OP_DATA                                                  $11
         15      > JMP                                                      ->26
  108    16    >   INIT_METHOD_CALL                                         'maximum_cellsize'
         17        DO_FCALL                                      0  $12     
         18        IS_SMALLER                                               $12, !0
         19      > JMPZ                                                     ~13, ->26
  109    20    >   FETCH_OBJ_R                                      ~15     'ptr'
         21        INIT_METHOD_CALL                                         'minimum_cellsize'
         22        DO_FCALL                                      0  $17     
         23        FETCH_OBJ_W                                      $14     'arr'
         24        ASSIGN_DIM                                               $14, ~15
         25        OP_DATA                                                  $17
  111    26    > > RETURN                                                   <true>
  112    27*     > RETURN                                                   null

End of function increment_val

Function decrement_val:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/a2gIW
function name:  decrement_val
number of ops:  28
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  115     0  E >   FETCH_OBJ_R                                      ~2      'ptr'
          1        FETCH_OBJ_RW                                     $1      'arr'
          2        FETCH_DIM_RW                                     $3      $1, ~2
          3        POST_DEC                                         ~4      $3
          4        ASSIGN                                                   !0, ~4
  116     5        INIT_METHOD_CALL                                         'minimum_cellsize'
          6        DO_FCALL                                      0  $6      
          7        IS_SMALLER                                               !0, $6
          8      > JMPZ         

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
286.71 ms | 1428 KiB | 28 Q