3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace fema\utils; class CharSequence { private $linesBreakIndex; private $chars; private $offset; private $length; private function __construct(array $chars, int $offset, int $length, array $linesBreakIndex) { $this->chars = $chars; $this->offset = $offset; $this->length = $length; $this->linesBreakIndex = $linesBreakIndex; var_dump([$this->toString(), $linesBreakIndex]); if(count($linesBreakIndex) > 0){ echo "line 0"; $this->getLine(0); for($i=0;$i<count($linesBreakIndex); $i++){ echo "line " . ($i+1); $this->getLine($linesBreakIndex[$i]+1); } } } public function length() : int { return $this->length; } public function getLinesCount() : int { return count($this->linesBreakIndex) + 1; } public function getLinesBreakIndex() : int { return $this->linesBreakIndex; } private function getLineBreakIndexIndex(int $charIndex) : int { $arr = $this->linesBreakIndex; $start = 0; $end = count($arr); while($start < $end){ var_dump([$start, $middle, $end]); $middle = ($start + $end) / 2; if($arr[$middle] === $charIndex){ return $middle - 1; }elseif($charIndex > $arr[$middle] && ($middle+1>=count($arr) || $charIndex <= $arr[$middle+1])){ return $middle; }elseif($charIndex < $arr[$middle]){ $end = $middle; }else{ $start = $middle + 1; } } return -1; } public function getLine(int $charIndex) : CharSequence { if($charIndex < 0 || $charIndex >= $this->length) { throw new \InvalidArgumentException("Char index out of bounds [0, $this->length): $charIndex"); } $lineIndexIndex = $this->getLineBreakIndexIndex($charIndex); echo "\n$charIndex => $lineIndexIndex\n"; $start = $lineIndexIndex === -1 ? 0 : $this->linesBreakIndex[$lineIndexIndex]+1; $end = $lineIndexIndex + 1 >= count($this->linesBreakIndex) ? $this->length : $this->linesBreakIndex[$lineIndexIndex+1]; return $this->subCharSequence($start, $end - $start); } public function charAt(int $i) : string { if($i < 0 || $i >= $this->length) { throw new \InvalidArgumentException("Char index out of bounds [0, $this->length): $i"); } else { return $this->chars[$this->offset + $i]; } } public function substring(int $start, ?int $length = null) : string { if($start < 0 || $start >= $this->length) { throw new \InvalidArgumentException("Start out of bounds [0, $this->length): $start"); } elseif($length !== null && $length < 0 || $start + $length > $this->length) { throw new \InvalidArgumentException("Length out of bounds [0, " . ($this->length-$start) . "]: $length"); } else { $ret = ''; for($i = $start; $i<$start+$length; $i++) { $ret .= $this->chars[$this->offset + $i]; } return $ret; } } public function subCharSequence(int $start, ?int $length = null) : CharSequence { if($start < 0 || $start >= $this->length) { throw new \InvalidArgumentException("Start out of bounds [0, $this->length): $start"); } elseif($length !== null && $length < 0 || $start + $length > $this->length) { throw new \InvalidArgumentException("Length out of bounds [0, " . ($this->length-$start) . "]: $length"); } else { if($length === null) { $length = $this->length - $start; } $newLineBreaks = []; $i = $this->getLineBreakIndexIndex($start); if($i === -1 || $this->linesBreakIndex[$i] < $start){ $i++; } for(; $i<count($this->linesBreakIndex) && $this->linesBreakIndex[$i] < $start + $length; $i++){ $newLineBreaks[] = $this->linesBreakIndex[$i] - $start; } return new CharSequence($this->chars, $this->offset + $start, $length, $newLineBreaks); } } public function toString() : string { $ret = ''; for($i = 0; $i < $this->length; $i++){ $ret .= $this->chars[$this->offset + $i]; } return $ret; } public static function getInstance(string $string, bool $normalizeNewLines = false) { $chars = []; $pointer = 0; $length = 0; $linesBreak = []; $prevChar = null; while(($char = static::nextChar($string, $pointer)) !== null) { $realChar = null; if(!$normalizeNewLines) { $realChar = $char; } else { if($char === "\r") { $realChar = "\n"; } elseif($char !== "\n" || $prevChar !== "\r") { $realChar = $char; } } $prevChar = $char; if($realChar !== null) { if($realChar === "\n"){ $linesBreak[] = $length; } $chars[] = $realChar; $length++; } } return new CharSequence($chars, 0, $length, $linesBreak); } private static function nextChar(string $string, int &$pointer) : ?string { if(!isset($string[$pointer])) { return null; } $char = ord($string[$pointer]); if($char < 128){ return $string[$pointer++]; }else{ if($char < 224){ $bytes = 2; }elseif($char < 240){ $bytes = 3; }elseif($char < 248){ $bytes = 4; }elseif($char == 252){ $bytes = 5; }else{ $bytes = 6; } $str = substr($string, $pointer, $bytes); $pointer += $bytes; return $str; } } } echo "Creo stringa originaria\n"; $cs = CharSequence::getInstance("0123456789\n987654321"); echo "\n\nsubstr 10\n"; $cs->subCharSequence(10);

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1lSWU
function name:  (null)
number of ops:  10
compiled vars:  !0 = $cs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  176     0  E >   ECHO                                                     'Creo+stringa+originaria%0A'
  177     1        INIT_STATIC_METHOD_CALL                                  'fema%5Cutils%5CCharSequence', 'getInstance'
          2        SEND_VAL                                                 '0123456789%0A987654321'
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
  179     5        ECHO                                                     '%0A%0Asubstr+10%0A'
  180     6        INIT_METHOD_CALL                                         !0, 'subCharSequence'
          7        SEND_VAL_EX                                              10
          8        DO_FCALL                                      0          
          9      > RETURN                                                   1

Class fema\utils\CharSequence:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 44
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 30
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 30
Branch analysis from position: 44
Branch analysis from position: 30
Branch analysis from position: 44
filename:       /in/1lSWU
function name:  __construct
number of ops:  45
compiled vars:  !0 = $chars, !1 = $offset, !2 = $length, !3 = $linesBreakIndex, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   14     4        ASSIGN_OBJ                                               'chars'
          5        OP_DATA                                                  !0
   15     6        ASSIGN_OBJ                                               'offset'
          7        OP_DATA                                                  !1
   16     8        ASSIGN_OBJ                                               'length'
          9        OP_DATA                                                  !2
   17    10        ASSIGN_OBJ                                               'linesBreakIndex'
         11        OP_DATA                                                  !3
   18    12        INIT_NS_FCALL_BY_NAME                                    'fema%5Cutils%5Cvar_dump'
         13        INIT_METHOD_CALL                                         'toString'
         14        DO_FCALL                                      0  $9      
         15        INIT_ARRAY                                       ~10     $9
         16        ADD_ARRAY_ELEMENT                                ~10     !3
         17        SEND_VAL_EX                                              ~10
         18        DO_FCALL                                      0          
   19    19        INIT_NS_FCALL_BY_NAME                                    'fema%5Cutils%5Ccount'
         20        SEND_VAR_EX                                              !3
         21        DO_FCALL                                      0  $12     
         22        IS_SMALLER                                               0, $12
         23      > JMPZ                                                     ~13, ->44
   20    24    >   ECHO                                                     'line+0'
   21    25        INIT_METHOD_CALL                                         'getLine'
         26        SEND_VAL_EX                                              0
         27        DO_FCALL                                      0          
   22    28        ASSIGN                                                   !4, 0
         29      > JMP                                                      ->39
   23    30    >   ADD                                              ~16     !4, 1
         31        CONCAT                                           ~17     'line+', ~16
         32        ECHO                                                     ~17
   24    33        INIT_METHOD_CALL                                         'getLine'
         34        FETCH_DIM_R                                      ~18     !3, !4
         35        ADD                                              ~19     ~18, 1
         36        SEND_VAL_EX                                              ~19
         37        DO_FCALL                                      0          
   22    38        PRE_INC                                                  !4
         39    >   INIT_NS_FCALL_BY_NAME                                    'fema%5Cutils%5Ccount'
         40        SEND_VAR_EX                                              !3
         41        DO_FCALL                                      0  $22     
         42        IS_SMALLER                                               !4, $22
         43      > JMPNZ                                                    ~23, ->30
   27    44    > > RETURN                                                   null

End of function __construct

Function length:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1lSWU
function name:  length
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   FETCH_OBJ_R                                      ~0      'length'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   31     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function length

Function getlinescount:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1lSWU
function name:  getLinesCount
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_NS_FCALL_BY_NAME                                    'fema%5Cutils%5Ccount'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $0      'linesBreakIndex'
          3        SEND_FUNC_ARG                                            $0
          4        DO_FCALL                                      0  $1      
          5        ADD                                              ~2      $1, 1
          6        VERIFY_RETURN_TYPE                                       ~2
          7      > RETURN                                                   ~2
   35     8*       VERIFY_RETURN_TYPE                                       
          9*     > RETURN                                                   null

End of function getlinescount

Function getlinesbreakindex:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1lSWU
function name:  getLinesBreakIndex
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   FETCH_OBJ_R                                      ~0      'linesBreakIndex'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   39     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getlinesbreakindex

Function getlinebreakindexindex:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 9
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 46) Position 1 = 28, Position 2 = 39
Branch analysis from position: 28
2 jumps found. (Code = 47) Position 1 = 34, Position 2 = 38
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 43
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 48
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 9
Branch analysis from position: 52
Branch analysis from position: 9
Branch analysis from position: 38
Branch analysis from position: 39
filename:       /in/1lSWU
function name:  getLineBreakIndexIndex
number of ops:  55
compiled vars:  !0 = $charIndex, !1 = $arr, !2 = $start, !3 = $end, !4 = $middle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   RECV                                             !0      
   42     1        FETCH_OBJ_R                                      ~5      'linesBreakIndex'
          2        ASSIGN                                                   !1, ~5
   43     3        ASSIGN                                                   !2, 0
   44     4        INIT_NS_FCALL_BY_NAME                                    'fema%5Cutils%5Ccount'
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $8      
          7        ASSIGN                                                   !3, $8
   45     8      > JMP                                                      ->50
   46     9    >   INIT_NS_FCALL_BY_NAME                                    'fema%5Cutils%5Cvar_dump'
         10        INIT_ARRAY                                       ~10     !2
         11        ADD_ARRAY_ELEMENT                                ~10     !4
         12        ADD_ARRAY_ELEMENT                                ~10     !3
         13        SEND_VAL_EX                                              ~10
         14        DO_FCALL                                      0          
   47    15        ADD                                              ~12     !2, !3
         16        DIV                                              ~13     ~12, 2
         17        ASSIGN                                                   !4, ~13
   48    18        FETCH_DIM_R                                      ~15     !1, !4
         19        IS_IDENTICAL                                             !0, ~15
         20      > JMPZ                                                     ~16, ->25
   49    21    >   SUB                                              ~17     !4, 1
         22        VERIFY_RETURN_TYPE                                       ~17
         23      > RETURN                                                   ~17
   48    24*       JMP                                                      ->50
   50    25    >   FETCH_DIM_R                                      ~18     !1, !4
         26        IS_SMALLER                                       ~19     ~18, !0
         27      > JMPZ_EX                                          ~19     ~19, ->39
         28    >   ADD                                              ~20     !4, 1
         29        INIT_NS_FCALL_BY_NAME                                    'fema%5Cutils%5Ccount'
         30        SEND_VAR_EX                                              !1
         31        DO_FCALL                                      0  $21     
         32        IS_SMALLER_OR_EQUAL                              ~22     $21, ~20
         33      > JMPNZ_EX                                         ~22     ~22, ->38
         34    >   ADD                                              ~23     !4, 1
         35        FETCH_DIM_R                                      ~24     !1, ~23
         36        IS_SMALLER_OR_EQUAL                              ~25     !0, ~24
         37        BOOL                                             ~22     ~25
         38    >   BOOL                                             ~19     ~22
         39    > > JMPZ                                                     ~19, ->43
   51    40    >   VERIFY_RETURN_TYPE                                       !4
         41      > RETURN                                                   !4
   50    42*       JMP                                                      ->50
   52    43    >   FETCH_DIM_R                                      ~26     !1, !4
         44        IS_SMALLER                                               !0, ~26
         45      > JMPZ                                                     ~27, ->48
   53    46    >   ASSIGN                                                   !3, !4
   52    47      > JMP                                                      ->50
   55    48    >   ADD                                              ~29     !4, 1
         49        ASSIGN                                                   !2, ~29
   45    50    >   IS_SMALLER                                               !2, !3
         51      > JMPNZ                                                    ~31, ->9
   58    52    > > RETURN                                                   -1
   59    53*       VERIFY_RETURN_TYPE                                       
         54*     > RETURN                                                   null

End of function getlinebreakindexindex

Function getline:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 46
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 46
Branch analysis from position: 43
Branch analysis from position: 46
Branch analysis from position: 6
filename:       /in/1lSWU
function name:  getLine
number of ops:  60
compiled vars:  !0 = $charIndex, !1 = $lineIndexIndex, !2 = $start, !3 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   61     0  E >   RECV                                             !0      
   62     1        IS_SMALLER                                       ~4      !0, 0
          2      > JMPNZ_EX                                         ~4      ~4, ->6
          3    >   FETCH_OBJ_R                                      ~5      'length'
          4        IS_SMALLER_OR_EQUAL                              ~6      ~5, !0
          5        BOOL                                             ~4      ~6
          6    > > JMPZ                                                     ~4, ->16
   63     7    >   NEW                                              $7      'InvalidArgumentException'
          8        ROPE_INIT                                     4  ~10     'Char+index+out+of+bounds+%5B0%2C+'
          9        FETCH_OBJ_R                                      ~8      'length'
         10        ROPE_ADD                                      1  ~10     ~10, ~8
         11        ROPE_ADD                                      2  ~10     ~10, '%29%3A+'
         12        ROPE_END                                      3  ~9      ~10, !0
         13        SEND_VAL_EX                                              ~9
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $7
   65    16    >   INIT_METHOD_CALL                                         'getLineBreakIndexIndex'
         17        SEND_VAR                                                 !0
         18        DO_FCALL                                      0  $13     
         19        ASSIGN                                                   !1, $13
   66    20        ROPE_INIT                                     5  ~16     '%0A'
         21        ROPE_ADD                                      1  ~16     ~16, !0
         22        ROPE_ADD                                      2  ~16     ~16, '+%3D%3E+'
         23        ROPE_ADD                                      3  ~16     ~16, !1
         24        ROPE_END                                      4  ~15     ~16, '%0A'
         25        ECHO                                                     ~15
   67    26        IS_IDENTICAL                                             !1, -1
         27      > JMPZ                                                     ~19, ->30
         28    >   QM_ASSIGN                                        ~20     0
         29      > JMP                                                      ->34
         30    >   FETCH_OBJ_R                                      ~21     'linesBreakIndex'
         31        FETCH_DIM_R                                      ~22     ~21, !1
         32        ADD                                              ~23     ~22, 1
         33        QM_ASSIGN                                        ~20     ~23
         34    >   ASSIGN                                                   !2, ~20
   68    35        ADD                                              ~25     !1, 1
         36        INIT_NS_FCALL_BY_NAME                                    'fema%5Cutils%5Ccount'
         37        CHECK_FUNC_ARG                                           
         38        FETCH_OBJ_FUNC_ARG                               $26     'linesBreakIndex'
         39        SEND_FUNC_ARG                                            $26
         40        DO_FCALL                                      0  $27     
         41        IS_SMALLER_OR_EQUAL                                      $27, ~25
         42      > JMPZ                                                     ~28, ->46
         43    >   FETCH_OBJ_R                                      ~29     'length'
         44        QM_ASSIGN                                        ~30     ~29
         45      > JMP                                                      ->50
         46    >   ADD                                              ~32     !1, 1
         47        FETCH_OBJ_R                                      ~31     'linesBreakIndex'
         48        FETCH_DIM_R                                      ~33     ~31, ~32
         49        QM_ASSIGN                                        ~30     ~33
         50    >   ASSIGN                                                   !3, ~30
   69    51        INIT_METHOD_CALL                                         'subCharSequence'
         52        SEND_VAR_EX                                              !2
         53        SUB                                              ~35     !3, !2
         54        SEND_VAL_EX                                              ~35
         55        DO_FCALL                                      0  $36     
         56        VERIFY_RETURN_TYPE                                       $36
         57      > RETURN                                                   $36
   70    58*       VERIFY_RETURN_TYPE                                       
         59*     > RETURN                                                   null

End of function getline

Function charat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 17
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/1lSWU
function name:  charAt
number of ops:  25
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   72     0  E >   RECV                                             !0      
   73     1        IS_SMALLER                                       ~1      !0, 0
          2      > JMPNZ_EX                                         ~1      ~1, ->6
          3    >   FETCH_OBJ_R                                      ~2      'length'
          4        IS_SMALLER_OR_EQUAL                              ~3      ~2, !0
          5        BOOL                                             ~1      ~3
          6    > > JMPZ                                                     ~1, ->17
   74     7    >   NEW                                              $4      'InvalidArgumentException'
          8        ROPE_INIT                                     4  ~7      'Char+index+out+of+bounds+%5B0%2C+'
          9        FETCH_OBJ_R                                      ~5      'length'
         10        ROPE_ADD                                      1  ~7      ~7, ~5
         11        ROPE_ADD                                      2  ~7      ~7, '%29%3A+'
         12        ROPE_END                                      3  ~6      ~7, !0
         13        SEND_VAL_EX                                              ~6
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $4
   73    16*       JMP                                                      ->23
   76    17    >   FETCH_OBJ_R                                      ~11     'offset'
         18        ADD                                              ~12     ~11, !0
         19        FETCH_OBJ_R                                      ~10     'chars'
         20        FETCH_DIM_R                                      ~13     ~10, ~12
         21        VERIFY_RETURN_TYPE                                       ~13
         22      > RETURN                                                   ~13
   78    23*       VERIFY_RETURN_TYPE                                       
         24*     > RETURN                                                   null

End of function charat

Function substring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
2 jumps found. (Code = 47) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 39
Branch analysis from position: 28
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 42
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 42
Branch analysis from position: 51
Branch analysis from position: 42
Branch analysis from position: 27
Branch analysis from position: 22
Branch analysis from position: 7
filename:       /in/1lSWU
function name:  substring
number of ops:  55
compiled vars:  !0 = $start, !1 = $length, !2 = $ret, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   80     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   81     2        IS_SMALLER                                       ~4      !0, 0
          3      > JMPNZ_EX                                         ~4      ~4, ->7
          4    >   FETCH_OBJ_R                                      ~5      'length'
          5        IS_SMALLER_OR_EQUAL                              ~6      ~5, !0
          6        BOOL                                             ~4      ~6
          7    > > JMPZ                                                     ~4, ->18
   82     8    >   NEW                                              $7      'InvalidArgumentException'
          9        ROPE_INIT                                     4  ~10     'Start+out+of+bounds+%5B0%2C+'
         10        FETCH_OBJ_R                                      ~8      'length'
         11        ROPE_ADD                                      1  ~10     ~10, ~8
         12        ROPE_ADD                                      2  ~10     ~10, '%29%3A+'
         13        ROPE_END                                      3  ~9      ~10, !0
         14        SEND_VAL_EX                                              ~9
         15        DO_FCALL                                      0          
         16      > THROW                                         0          $7
   81    17*       JMP                                                      ->53
   83    18    >   TYPE_CHECK                                  1020  ~13     !1
         19      > JMPZ_EX                                          ~13     ~13, ->22
         20    >   IS_SMALLER                                       ~14     !1, 0
         21        BOOL                                             ~13     ~14
         22    > > JMPNZ_EX                                         ~13     ~13, ->27
         23    >   ADD                                              ~15     !0, !1
         24        FETCH_OBJ_R                                      ~16     'length'
         25        IS_SMALLER                                       ~17     ~16, ~15
         26        BOOL                                             ~13     ~17
         27    > > JMPZ                                                     ~13, ->39
   84    28    >   NEW                                              $18     'InvalidArgumentException'
         29        FETCH_OBJ_R                                      ~19     'length'
         30        SUB                                              ~20     ~19, !0
         31        CONCAT                                           ~21     'Length+out+of+bounds+%5B0%2C+', ~20
         32        NOP                                                      
         33        FAST_CONCAT                                      ~22     '%5D%3A+', !1
         34        CONCAT                                           ~23     ~21, ~22
         35        SEND_VAL_EX                                              ~23
         36        DO_FCALL                                      0          
         37      > THROW                                         0          $18
   83    38*       JMP                                                      ->53
   86    39    >   ASSIGN                                                   !2, ''
   87    40        ASSIGN                                                   !3, !0
         41      > JMP                                                      ->48
   88    42    >   FETCH_OBJ_R                                      ~28     'offset'
         43        ADD                                              ~29     ~28, !3
         44        FETCH_OBJ_R                                      ~27     'chars'
         45        FETCH_DIM_R                                      ~30     ~27, ~29
         46        ASSIGN_OP                                     8          !2, ~30
   87    47        PRE_INC                                                  !3
         48    >   ADD                                              ~33     !0, !1
         49        IS_SMALLER                                               !3, ~33
         50      > JMPNZ                                                    ~34, ->42
   90    51    >   VERIFY_RETURN_TYPE                                       !2
         52      > RETURN                                                   !2
   92    53*       VERIFY_RETURN_TYPE                                       
         54*     > RETURN                                                   null

End of function substring

Function subcharsequence:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
2 jumps found. (Code = 47) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 39
Branch analysis from position: 28
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 44
Branch analysis from position: 41
2 jumps found. (Code = 47) Position 1 = 51, Position 2 = 55
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 57
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
2 jumps found. (Code = 46) Position 1 = 71, Position 2 = 76
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 58
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
2 jumps found. (Code = 46) Position 1 = 71, Position 2 = 76
Branch analysis from position: 71
Branch analysis from position: 76
Branch analysis from position: 76
Branch analysis from position: 57
Branch analysis from position: 55
Branch analysis from position: 44
Branch analysis from position: 27
Branch analysis from position: 22
Branch analysis from position: 7
filename:       /in/1lSWU
function name:  subCharSequence
number of ops:  91
compiled vars:  !0 = $start, !1 = $length, !2 = $newLineBreaks, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   94     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   95     2        IS_SMALLER                                       ~4      !0, 0
          3      > JMPNZ_EX                                         ~4      ~4, ->7
          4    >   FETCH_OBJ_R                                      ~5      'length'
          5       

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
258.35 ms | 1044 KiB | 15 Q