3v4l.org

run code in 300+ PHP versions simultaneously
<?php /*TODO... parse the sql query make a query object or something to put almost everything in an object and make this code simpler return nested name-value pairs in an associative array and convert it to json before sending aa s JSON content type send all changes made from Deletes, Updates and Append (mutations) changes for passive data binding */ $sql = "SELECT * FROM 'main' WHERE 'destination' = 'Helsinki' AND 'price' > 120"; //example of sql query //the following assumes the above SQL query has been parsed into fields and conditions //main header file. Stored as JSON. $main_db_header_contents = '[{"rowlength":60},{"id":{"length":3,"datatype":"integer"}},{"name_sname":{"length":9,"datatype":"String"}},{"identity":{"length":9,"datatype":"integer"}},{"address":{"length":8,"datatype":"String"}},{"region":{"length":7,"datatype":"String"}},{"hours":{"length":5,"datatype":"Time"}},{"destination":{"length":8,"datatype":"String"}},{"price":{"length":3,"datatype":"integer"}}]'; //json string. fairly immutable so it can be cached on server $main_db_header = json_decode($main_db_header_contents,true); //main database file. Columns are fixed length and padded. Stored as strings only. ID field must be sorted alphabetically. //When fields in this file are updated/added to, their respective index file must be too $main_db_file_contents = "001|Al-Farabi|123456789|Baghdad |Iraq |21:02|Ottawa |120;002|Smith |123456788|Ottawa |Canada |22:03|Helsinki|131;003|Locke |123456787|Helsinki|Finland|23:01|Istanbul|122;004|Jones |123456786|Istanbul|Turkey |21:02|Helsinki|123;005|Steinman |123455785|Havana |Cuba |22:03|Havana |104;006|Booker |123456784|Moscow |Russia |23:01|Helsinki|115;"; //fixed-length field values //Destination index file with record id and destination value. Sorted alphabetically. //E.g., The record with the id of 004 has the destination value of 'Moscow '. $destination_index_file_contents = "005|Havana ;002|Helsinki;004|Helsinki;006|Helsinki;003|Istanbul;001|Ottawa "; //Destination index file. Sorted alphabetically despite being numberic. //E.g., The record with the id of 005 has the price value of 104. $price_index_file_contents = "005|104;006|115;001|120;003|122;004|123;002|131"; function apply_condition($index_file_contents, $ptype, $value) { //applies basic logical conditions from the the query //Uses the given index file and checks its value based on given condition and given value $found_matches = []; $index_file_contents_split = explode(";", $index_file_contents); foreach($index_file_contents_split as $key => $props){ $pairs = explode("|",$props); $id = $pairs[0]; $val = trim($pairs[1]); //removes trailing spaces for matching non-fiexed-length input value if ($ptype === "=") { //checks to see if the given value is equal to the value in the index file if ($val === $value) { array_push($found_matches,$id); //add to new array of matches } } elseif ($ptype === ">") { //checks to see if the given value is greater than the value in the index file if ($val > $value) { array_push($found_matches,$id);//add to new array of matches } } } return $found_matches; } $parsed_destinations = apply_condition($destination_index_file_contents, "=", "Helsinki"); $parsed_prices = apply_condition($price_index_file_contents, ">", "120"); $parsed_ids = array_intersect($parsed_destinations, $parsed_prices); sort($parsed_ids); //alphabetically sorts array by ascending (lowest to highest) //now go through $main_db_file_contents and get selected fields in records matching the ids in $parsed_ids. $id_length = $main_db_header[1]['id']['length']; //id, length, datatype $destination_offset = get_field_offset("destination", $main_db_header); $price_offset = get_field_offset("price", $main_db_header); $destination_length = $main_db_header[7]['destination']['length']; //8 $price_length = $main_db_header[8]['price']['length']; //3 $row_length = $main_db_header[0]['rowlength']; //147 $main_file_length = strlen($main_db_file_contents); //can be done on a text file using the OS $total_main_file_rows = ($main_file_length/$row_length); $results =[]; $starting_row = 0; for ($i = 0; $i < count($parsed_ids); $i++){ //Starting row is advanced (increased) with each loop. It advances half as far as the previous advancement $starting_row = get_starting_row($main_db_file_contents, $parsed_ids[$i], $id_length, $row_length, $total_main_file_rows, $starting_row); $destination = get_field_from_row($main_db_file_contents, $starting_row, $row_length, $destination_offset, $destination_length); $price = get_field_from_row($main_db_file_contents, $starting_row, $row_length, $price_offset, $price_length); $result = [$parsed_ids[$i], $destination, $price]; array_push($results, $result); } function get_field_from_row($db, $current_row, $row_length, $field_offset, $field_length) { //gets the row index and uses the field's offset (start) and length (end) to get its value in the database text $value = substr($db, ($current_row * $row_length) + $field_offset, $field_length); return $value; } function get_starting_row($db, $first_id, $id_length, $row_length, $total_main_file_rows, $offset){ //Finds the record that the given ID is located in and returns its row index $start_row = (int)floor($total_main_file_rows / 2) + $offset; //halfway point of file $start_row_id = substr($db, ($start_row) * $row_length , $id_length); //gets current row id while ($start_row > -1 && $start_row <= $total_main_file_rows) { if ( $first_id < $start_row_id){ //go back a bit less $start_row = (int)floor($start_row / 2); $start_row_id = substr($db, ($start_row) * $row_length , $id_length); } elseif($start_row_id < $first_id) { //go forward a bit less $start_row = $start_row + (int)round($start_row / 2); $start_row_id = substr($db, ($start_row) * $row_length , $id_length); } else { //found the row id that matches the given id. Return its index. return $start_row; } } } function get_field_offset($field, $header) { //goes through the JSON file to get length of each field preceding the given field //used to get the start of the field in the row (a row offset is needed too) $total_offset = 0; foreach ($header as $key => $value){ foreach ($value as $k => $val) { if ($k != "rowlength"){ if ($field === (string)$k){ return $total_offset; } $total_offset += $val['length'] +1; //+1 is needed for each single-character delimeter (|) } } } } var_dump($results); //works!!
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 100
Branch analysis from position: 100
2 jumps found. (Code = 44) Position 1 = 103, Position 2 = 63
Branch analysis from position: 103
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
2 jumps found. (Code = 44) Position 1 = 103, Position 2 = 63
Branch analysis from position: 103
Branch analysis from position: 63
filename:       /in/DHSWK
function name:  (null)
number of ops:  107
compiled vars:  !0 = $sql, !1 = $main_db_header_contents, !2 = $main_db_header, !3 = $main_db_file_contents, !4 = $destination_index_file_contents, !5 = $price_index_file_contents, !6 = $parsed_destinations, !7 = $parsed_prices, !8 = $parsed_ids, !9 = $id_length, !10 = $destination_offset, !11 = $price_offset, !12 = $destination_length, !13 = $price_length, !14 = $row_length, !15 = $main_file_length, !16 = $total_main_file_rows, !17 = $results, !18 = $starting_row, !19 = $i, !20 = $destination, !21 = $price, !22 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, 'SELECT+%2A+FROM+%27main%27+WHERE+%27destination%27+%3D+%27Helsinki%27+AND+%27price%27+%3E+120'
   16     1        ASSIGN                                                   !1, '%5B%7B%22rowlength%22%3A60%7D%2C%7B%22id%22%3A%7B%22length%22%3A3%2C%22datatype%22%3A%22integer%22%7D%7D%2C%7B%22name_sname%22%3A%7B%22length%22%3A9%2C%22datatype%22%3A%22String%22%7D%7D%2C%7B%22identity%22%3A%7B%22length%22%3A9%2C%22datatype%22%3A%22integer%22%7D%7D%2C%7B%22address%22%3A%7B%22length%22%3A8%2C%22datatype%22%3A%22String%22%7D%7D%2C%7B%22region%22%3A%7B%22length%22%3A7%2C%22datatype%22%3A%22String%22%7D%7D%2C%7B%22hours%22%3A%7B%22length%22%3A5%2C%22datatype%22%3A%22Time%22%7D%7D%2C%7B%22destination%22%3A%7B%22length%22%3A8%2C%22datatype%22%3A%22String%22%7D%7D%2C%7B%22price%22%3A%7B%22length%22%3A3%2C%22datatype%22%3A%22integer%22%7D%7D%5D'
   18     2        INIT_FCALL                                               'json_decode'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $25     
          6        ASSIGN                                                   !2, $25
   22     7        ASSIGN                                                   !3, '001%7CAl-Farabi%7C123456789%7CBaghdad+%7CIraq+++%7C21%3A02%7COttawa++%7C120%3B002%7CSmith++++%7C123456788%7COttawa++%7CCanada+%7C22%3A03%7CHelsinki%7C131%3B003%7CLocke++++%7C123456787%7CHelsinki%7CFinland%7C23%3A01%7CIstanbul%7C122%3B004%7CJones++++%7C123456786%7CIstanbul%7CTurkey+%7C21%3A02%7CHelsinki%7C123%3B005%7CSteinman+%7C123455785%7CHavana++%7CCuba+++%7C22%3A03%7CHavana++%7C104%3B006%7CBooker+++%7C123456784%7CMoscow++%7CRussia+%7C23%3A01%7CHelsinki%7C115%3B'
   26     8        ASSIGN                                                   !4, '005%7CHavana++%3B002%7CHelsinki%3B004%7CHelsinki%3B006%7CHelsinki%3B003%7CIstanbul%3B001%7COttawa++'
   30     9        ASSIGN                                                   !5, '005%7C104%3B006%7C115%3B001%7C120%3B003%7C122%3B004%7C123%3B002%7C131'
   56    10        INIT_FCALL                                               'apply_condition'
         11        SEND_VAR                                                 !4
         12        SEND_VAL                                                 '%3D'
         13        SEND_VAL                                                 'Helsinki'
         14        DO_FCALL                                      0  $30     
         15        ASSIGN                                                   !6, $30
   57    16        INIT_FCALL                                               'apply_condition'
         17        SEND_VAR                                                 !5
         18        SEND_VAL                                                 '%3E'
         19        SEND_VAL                                                 '120'
         20        DO_FCALL                                      0  $32     
         21        ASSIGN                                                   !7, $32
   58    22        INIT_FCALL                                               'array_intersect'
         23        SEND_VAR                                                 !6
         24        SEND_VAR                                                 !7
         25        DO_ICALL                                         $34     
         26        ASSIGN                                                   !8, $34
   59    27        INIT_FCALL                                               'sort'
         28        SEND_REF                                                 !8
         29        DO_ICALL                                                 
   62    30        FETCH_DIM_R                                      ~37     !2, 1
         31        FETCH_DIM_R                                      ~38     ~37, 'id'
         32        FETCH_DIM_R                                      ~39     ~38, 'length'
         33        ASSIGN                                                   !9, ~39
   63    34        INIT_FCALL_BY_NAME                                       'get_field_offset'
         35        SEND_VAL_EX                                              'destination'
         36        SEND_VAR_EX                                              !2
         37        DO_FCALL                                      0  $41     
         38        ASSIGN                                                   !10, $41
   64    39        INIT_FCALL_BY_NAME                                       'get_field_offset'
         40        SEND_VAL_EX                                              'price'
         41        SEND_VAR_EX                                              !2
         42        DO_FCALL                                      0  $43     
         43        ASSIGN                                                   !11, $43
   65    44        FETCH_DIM_R                                      ~45     !2, 7
         45        FETCH_DIM_R                                      ~46     ~45, 'destination'
         46        FETCH_DIM_R                                      ~47     ~46, 'length'
         47        ASSIGN                                                   !12, ~47
   66    48        FETCH_DIM_R                                      ~49     !2, 8
         49        FETCH_DIM_R                                      ~50     ~49, 'price'
         50        FETCH_DIM_R                                      ~51     ~50, 'length'
         51        ASSIGN                                                   !13, ~51
   67    52        FETCH_DIM_R                                      ~53     !2, 0
         53        FETCH_DIM_R                                      ~54     ~53, 'rowlength'
         54        ASSIGN                                                   !14, ~54
   69    55        STRLEN                                           ~56     !3
         56        ASSIGN                                                   !15, ~56
   70    57        DIV                                              ~58     !15, !14
         58        ASSIGN                                                   !16, ~58
   71    59        ASSIGN                                                   !17, <array>
   72    60        ASSIGN                                                   !18, 0
   74    61        ASSIGN                                                   !19, 0
         62      > JMP                                                      ->100
   76    63    >   INIT_FCALL_BY_NAME                                       'get_starting_row'
         64        SEND_VAR_EX                                              !3
         65        CHECK_FUNC_ARG                                           
         66        FETCH_DIM_FUNC_ARG                               $63     !8, !19
         67        SEND_FUNC_ARG                                            $63
         68        SEND_VAR_EX                                              !9
         69        SEND_VAR_EX                                              !14
         70        SEND_VAR_EX                                              !16
         71        SEND_VAR_EX                                              !18
         72        DO_FCALL                                      0  $64     
         73        ASSIGN                                                   !18, $64
   78    74        INIT_FCALL_BY_NAME                                       'get_field_from_row'
         75        SEND_VAR_EX                                              !3
         76        SEND_VAR_EX                                              !18
         77        SEND_VAR_EX                                              !14
         78        SEND_VAR_EX                                              !10
         79        SEND_VAR_EX                                              !12
         80        DO_FCALL                                      0  $66     
         81        ASSIGN                                                   !20, $66
   79    82        INIT_FCALL_BY_NAME                                       'get_field_from_row'
         83        SEND_VAR_EX                                              !3
         84        SEND_VAR_EX                                              !18
         85        SEND_VAR_EX                                              !14
         86        SEND_VAR_EX                                              !11
         87        SEND_VAR_EX                                              !13
         88        DO_FCALL                                      0  $68     
         89        ASSIGN                                                   !21, $68
   81    90        FETCH_DIM_R                                      ~70     !8, !19
         91        INIT_ARRAY                                       ~71     ~70
         92        ADD_ARRAY_ELEMENT                                ~71     !20
         93        ADD_ARRAY_ELEMENT                                ~71     !21
         94        ASSIGN                                                   !22, ~71
   82    95        INIT_FCALL                                               'array_push'
         96        SEND_REF                                                 !17
         97        SEND_VAR                                                 !22
         98        DO_ICALL                                                 
   74    99        PRE_INC                                                  !19
        100    >   COUNT                                            ~75     !8
        101        IS_SMALLER                                               !19, ~75
        102      > JMPNZ                                                    ~76, ->63
  126   103    >   INIT_FCALL                                               'var_dump'
        104        SEND_VAR                                                 !17
        105        DO_ICALL                                                 
        106      > RETURN                                                   1

Function apply_condition:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 42
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 42
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 33
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 32
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 41
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 41
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 41
Branch analysis from position: 41
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/DHSWK
function name:  apply_condition
number of ops:  45
compiled vars:  !0 = $index_file_contents, !1 = $ptype, !2 = $value, !3 = $found_matches, !4 = $index_file_contents_split, !5 = $props, !6 = $key, !7 = $pairs, !8 = $id, !9 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   35     3        ASSIGN                                                   !3, <array>
   36     4        INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '%3B'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $11     
          8        ASSIGN                                                   !4, $11
   37     9      > FE_RESET_R                                       $13     !4, ->42
         10    > > FE_FETCH_R                                       ~14     $13, !5, ->42
         11    >   ASSIGN                                                   !6, ~14
   38    12        INIT_FCALL                                               'explode'
         13        SEND_VAL                                                 '%7C'
         14        SEND_VAR                                                 !5
         15        DO_ICALL                                         $16     
         16        ASSIGN                                                   !7, $16
   39    17        FETCH_DIM_R                                      ~18     !7, 0
         18        ASSIGN                                                   !8, ~18
   40    19        INIT_FCALL                                               'trim'
         20        FETCH_DIM_R                                      ~20     !7, 1
         21        SEND_VAL                                                 ~20
         22        DO_ICALL                                         $21     
         23        ASSIGN                                                   !9, $21
   41    24        IS_IDENTICAL                                             !1, '%3D'
         25      > JMPZ                                                     ~23, ->33
   43    26    >   IS_IDENTICAL                                             !9, !2
         27      > JMPZ                                                     ~24, ->32
   44    28    >   INIT_FCALL                                               'array_push'
         29        SEND_REF                                                 !3
         30        SEND_VAR                                                 !8
         31        DO_ICALL                                                 
         32    > > JMP                                                      ->41
   46    33    >   IS_IDENTICAL                                             !1, '%3E'
         34      > JMPZ                                                     ~26, ->41
   48    35    >   IS_SMALLER                                               !2, !9
         36      > JMPZ                                                     ~27, ->41
   49    37    >   INIT_FCALL                                               'array_push'
         38        SEND_REF                                                 !3
         39        SEND_VAR                                                 !8
         40        DO_ICALL                                                 
   37    41    > > JMP                                                      ->10
         42    >   FE_FREE                                                  $13
   53    43      > RETURN                                                   !3
   54    44*     > RETURN                                                   null

End of function apply_condition

Function get_field_from_row:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DHSWK
function name:  get_field_from_row
number of ops:  15
compiled vars:  !0 = $db, !1 = $current_row, !2 = $row_length, !3 = $field_offset, !4 = $field_length, !5 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   85     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
   87     5        INIT_FCALL                                               'substr'
          6        SEND_VAR                                                 !0
          7        MUL                                              ~6      !1, !2
          8        ADD                                              ~7      ~6, !3
          9        SEND_VAL                                                 ~7
         10        SEND_VAR                                                 !4
         11        DO_ICALL                                         $8      
         12        ASSIGN                                                   !5, $8
   88    13      > RETURN                                                   !5
   89    14*     > RETURN                                                   null

End of function get_field_from_row

Function get_starting_row:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
2 jumps found. (Code = 46) Position 1 = 57, Position 2 = 59
Branch analysis from position: 57
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 21
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 37
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 54
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
filename:       /in/DHSWK
function name:  get_starting_row
number of ops:  61
compiled vars:  !0 = $db, !1 = $first_id, !2 = $id_length, !3 = $row_length, !4 = $total_main_file_rows, !5 = $offset, !6 = $start_row, !7 = $start_row_id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   91     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
          5        RECV                                             !5      
   93     6        INIT_FCALL                                               'floor'
          7        DIV                                              ~8      !4, 2
          8        SEND_VAL                                                 ~8
          9        DO_ICALL                                         $9      
         10        CAST                                          4  ~10     $9
         11        ADD                                              ~11     ~10, !5
         12        ASSIGN                                                   !6, ~11
   94    13        INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !0
         15        MUL                                              ~13     !6, !3
         16        SEND_VAL                                                 ~13
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                         $14     
         19        ASSIGN                                                   !7, $14
   95    20      > JMP                                                      ->55
   96    21    >   IS_SMALLER                                               !1, !7
         22      > JMPZ                                                     ~16, ->37
   98    23    >   INIT_FCALL                                               'floor'
         24        DIV                                              ~17     !6, 2
         25        SEND_VAL                                                 ~17
         26        DO_ICALL                                         $18     
         27        CAST                                          4  ~19     $18
         28        ASSIGN                                                   !6, ~19
   99    29        INIT_FCALL                                               'substr'
         30        SEND_VAR                                                 !0
         31        MUL                                              ~21     !6, !3
         32        SEND_VAL                                                 ~21
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                         $22     
         35        ASSIGN                                                   !7, $22
         36      > JMP                                                      ->55
  100    37    >   IS_SMALLER                                               !7, !1
         38      > JMPZ                                                     ~24, ->54
  102    39    >   INIT_FCALL                                               'round'
         40        DIV                                              ~25     !6, 2
         41        SEND_VAL                                                 ~25
         42        DO_ICALL                                         $26     
         43        CAST                                          4  ~27     $26
         44        ADD                                              ~28     !6, ~27
         45        ASSIGN                                                   !6, ~28
  103    46        INIT_FCALL                                               'substr'
         47        SEND_VAR                                                 !0
         48        MUL                                              ~30     !6, !3
         49        SEND_VAL                                                 ~30
         50        SEND_VAR                                                 !2
         51        DO_ICALL                                         $31     
         52        ASSIGN                                                   !7, $31
         53      > JMP                                                      ->55
  106    54    > > RETURN                                                   !6
   95    55    >   IS_SMALLER                                       ~33     -1, !6
         56      > JMPZ_EX                                          ~33     ~33, ->59
         57    >   IS_SMALLER_OR_EQUAL                              ~34     !6, !4
         58        BOOL                                             ~33     ~34
         59    > > JMPNZ                                                    ~33, ->21
  109    60    > > RETURN                                                   null

End of function get_starting_row

Function get_field_offset:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 23
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 21
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 21
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 20
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 21
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/DHSWK
function name:  get_field_offset
number of ops:  25
compiled vars:  !0 = $field, !1 = $header, !2 = $total_offset, !3 = $value, !4 = $key, !5 = $val, !6 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  111     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  114     2        ASSIGN                                                   !2, 0
  115     3      > FE_RESET_R                                       $8      !1, ->23
          4    > > FE_FETCH_R                                       ~9      $8, !3, ->23
          5    >   ASSIGN                                                   !4, ~9
  116     6      > FE_RESET_R                                       $11     !3, ->21
          7    > > FE_FETCH_R                                       ~12     $11, !5, ->21
          8    >   ASSIGN                                                   !6, ~12
  117     9        IS_NOT_EQUAL                                             !6, 'rowlength'
         10      > JMPZ                                                     ~14, ->20
  118    11    >   CAST                                          6  ~15     !6
         12        IS_IDENTICAL                                             !0, ~15
         13      > JMPZ                                                     ~16, ->17
  119    14    >   FE_FREE                                                  $11
         15        FE_FREE                                                  $8
         16      > RETURN                                                   !2
  121    17    >   FETCH_DIM_R                                      ~17     !5, 'length'
         18        ADD                                              ~18     ~17, 1
         19        ASSIGN_OP                                     1          !2, ~18
  116    20    > > JMP                                                      ->7
         21    >   FE_FREE                                                  $11
  115    22      > JMP                                                      ->4
         23    >   FE_FREE                                                  $8
  125    24      > RETURN                                                   null

End of function get_field_offset

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.4 ms | 1414 KiB | 35 Q