3v4l.org

run code in 300+ PHP versions simultaneously
<?php /*************************************************************************** * template.php * ------------------- * begin : Saturday, Feb 13, 2001 * copyright : (C) 2001 The phpBB Group * email : support@phpbb.com * * $Id: template.php 66 2010-09-23 11:49:44Z guob7366 $ * * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ /** * Template class. By Nathan Codding of the phpBB group. * The interface was originally inspired by PHPLib templates, * and the template file formats are quite similar. * */ class Template { var $classname = "Template"; // variable that holds all the data we'll be substituting into // the compiled templates. // ... // This will end up being a multi-dimensional array like this: // $this->_tpldata[block.][iteration#][child.][iteration#][child2.][iteration#][variablename] == value // if it's a root-level variable, it'll be like this: // $this->_tpldata[.][0][varname] == value var $_tpldata = array(); // Hash of filenames for each template handle. var $files = array(); // Root template directory. var $root = ""; // this will hash handle names to the compiled code for that handle. var $compiled_code = array(); // This will hold the uncompiled code for that handle. var $uncompiled_code = array(); /** * Constructor. Simply sets the root dir. * */ function Template($root = ".") { $this->set_rootdir($root); } /** * Destroys this template object. Should be called when you're done with it, in order * to clear out the template data so you can load/parse a new template set. */ function destroy() { $this->_tpldata = array(); } /** * Sets the template root directory for this Template object. */ function set_rootdir($dir) { if (!is_dir($dir)) { return false; } $this->root = $dir; return true; } /** * Sets the template filenames for handles. $filename_array * should be a hash of handle => filename pairs. */ function set_filenames($filename_array) { if (!is_array($filename_array)) { return false; } reset($filename_array); while(list($handle, $filename) = each($filename_array)) { $this->files[$handle] = $this->make_filename($filename); } return true; } /** * Load the file for the handle, compile the file, * and run the compiled code. This will print out * the results of executing the template. */ function pparse($handle) { if (!$this->loadfile($handle)) { die("Template->pparse(): Couldn't load template file for handle $handle"); } // actually compile the template now. if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle])) { // Actually compile the code now. $this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]); } // Run the compiled code. eval($this->compiled_code[$handle]); return true; } /** * Inserts the uncompiled code for $handle as the * value of $varname in the root-level. This can be used * to effectively include a template in the middle of another * template. * Note that all desired assignments to the variables in $handle should be done * BEFORE calling this function. */ function assign_var_from_handle($varname, $handle) { if (!$this->loadfile($handle)) { die("Template->assign_var_from_handle(): Couldn't load template file for handle $handle"); } // Compile it, with the "no echo statements" option on. $_str = ""; $code = $this->compile($this->uncompiled_code[$handle], true, '_str'); // evaluate the variable assignment. eval($code); // assign the value of the generated variable to the given varname. $this->assign_var($varname, $_str); return true; } /** * Block-level variable assignment. Adds a new block iteration with the given * variable assignments. Note that this should only be called once per block * iteration. */ function assign_block_vars($blockname, $vararray) { if (strstr($blockname, '.')) { // Nested block. $blocks = explode('.', $blockname); $blockcount = sizeof($blocks) - 1; $str = '$this->_tpldata'; for ($i = 0; $i < $blockcount; $i++) { $str .= '[\'' . $blocks[$i] . '.\']'; eval('$lastiteration = sizeof(' . $str . ') - 1;'); $str .= '[' . $lastiteration . ']'; } // Now we add the block that we're actually assigning to. // We're adding a new iteration to this block with the given // variable assignments. $str .= '[\'' . $blocks[$blockcount] . '.\'][] = $vararray;'; // Now we evaluate this assignment we've built up. eval($str); } else { // Top-level block. // Add a new iteration to this block with the variable assignments // we were given. $this->_tpldata[$blockname . '.'][] = $vararray; } return true; } /** * Root-level variable assignment. Adds to current assignments, overriding * any existing variable assignment with the same name. */ function assign_vars($vararray) { reset ($vararray); while (list($key, $val) = each($vararray)) { $this->_tpldata['.'][0][$key] = $val; } return true; } /** * Root-level variable assignment. Adds to current assignments, overriding * any existing variable assignment with the same name. */ function assign_var($varname, $varval) { $this->_tpldata['.'][0][$varname] = $varval; return true; } /** * Generates a full path+filename for the given filename, which can either * be an absolute name, or a name relative to the rootdir for this Template * object. */ function make_filename($filename) { // Check if it's an absolute or relative path. if (substr($filename, 0, 1) != '/') { $filename = ($rp_filename = realpath($this->root . '/' . $filename)) ? $rp_filename : $filename; } if (!file_exists($filename)) { die("Template->make_filename(): Error - file $filename does not exist"); } return $filename; } /** * If not already done, load the file for the given handle and populate * the uncompiled_code[] hash with its code. Do not compile. */ function loadfile($handle) { // If the file for this handle is already loaded and compiled, do nothing. if (isset($this->uncompiled_code[$handle]) && !empty($this->uncompiled_code[$handle])) { return true; } // If we don't have a file assigned to this handle, die. if (!isset($this->files[$handle])) { die("Template->loadfile(): No file specified for handle $handle"); } $filename = $this->files[$handle]; $str = implode("", @file($filename)); if (empty($str)) { die("Template->loadfile(): File $filename for handle $handle is empty"); } $this->uncompiled_code[$handle] = $str; return true; } /** * Compiles the given string of code, and returns * the result in a string. * If "do_not_echo" is true, the returned code will not be directly * executable, but can be used as part of a variable assignment * for use in assign_code_from_handle(). */ function compile($code, $do_not_echo = false, $retvar = '') { // replace \ with \\ and then ' with \'. $code = str_replace('\\', '\\\\', $code); $code = str_replace('\'', '\\\'', $code); // change template varrefs into PHP varrefs // This one will handle varrefs WITH namespaces $varrefs = array(); preg_match_all('#\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}#is', $code, $varrefs); $varcount = sizeof($varrefs[1]); for ($i = 0; $i < $varcount; $i++) { $namespace = $varrefs[1][$i]; $varname = $varrefs[3][$i]; $new = $this->generate_block_varref($namespace, $varname); $code = str_replace($varrefs[0][$i], $new, $code); } // This will handle the remaining root-level varrefs $code = preg_replace('#\{([a-z0-9\-_]*?)\}#is', '\' . ( ( isset($this->_tpldata[\'.\'][0][\'\1\']) ) ? $this->_tpldata[\'.\'][0][\'\1\'] : \'\' ) . \'', $code); // Break it up into lines. $code_lines = explode("\n", $code); $block_nesting_level = 0; $block_names = array(); $block_names[0] = "."; // Second: prepend echo ', append ' . "\n"; to each line. $line_count = sizeof($code_lines); for ($i = 0; $i < $line_count; $i++) { $code_lines[$i] = chop($code_lines[$i]); if (preg_match('#<!-- BEGIN (.*?) -->#', $code_lines[$i], $m)) { $n[0] = $m[0]; $n[1] = $m[1]; // Added: dougk_ff7-Keeps templates from bombing if begin is on the same line as end.. I think. :) if ( preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $n) ) { $block_nesting_level++; $block_names[$block_nesting_level] = $m[1]; if ($block_nesting_level < 2) { // Block is not nested. $code_lines[$i] = '$_' . $n[1] . '_count = ( isset($this->_tpldata[\'' . $n[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $n[1] . '.\']) : 0;'; $code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)'; $code_lines[$i] .= "\n" . '{'; } else { // This block is nested. // Generate a namespace string for this block. $namespace = implode('.', $block_names); // strip leading period from root level.. $namespace = substr($namespace, 2); // Get a reference to the data array for this block that depends on the // current indices of all parent blocks. $varref = $this->generate_block_data_ref($namespace, false); // Create the for loop code to iterate over this block. $code_lines[$i] = '$_' . $n[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;'; $code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)'; $code_lines[$i] .= "\n" . '{'; } // We have the end of a block. unset($block_names[$block_nesting_level]); $block_nesting_level--; $code_lines[$i] .= '} // END ' . $n[1]; $m[0] = $n[0]; $m[1] = $n[1]; } else { // We have the start of a block. $block_nesting_level++; $block_names[$block_nesting_level] = $m[1]; if ($block_nesting_level < 2) { // Block is not nested. $code_lines[$i] = '$_' . $m[1] . '_count = ( isset($this->_tpldata[\'' . $m[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $m[1] . '.\']) : 0;'; $code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)'; $code_lines[$i] .= "\n" . '{'; } else { // This block is nested. // Generate a namespace string for this block. $namespace = implode('.', $block_names); // strip leading period from root level.. $namespace = substr($namespace, 2); // Get a reference to the data array for this block that depends on the // current indices of all parent blocks. $varref = $this->generate_block_data_ref($namespace, false); // Create the for loop code to iterate over this block. $code_lines[$i] = '$_' . $m[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;'; $code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)'; $code_lines[$i] .= "\n" . '{'; } } } else if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $m)) { // We have the end of a block. unset($block_names[$block_nesting_level]); $block_nesting_level--; $code_lines[$i] = '} // END ' . $m[1]; } else { // We have an ordinary line of code. if (!$do_not_echo) { $code_lines[$i] = 'echo \'' . $code_lines[$i] . '\' . "\\n";'; } else { $code_lines[$i] = '$' . $retvar . '.= \'' . $code_lines[$i] . '\' . "\\n";'; } } } // Bring it back into a single string of lines of code. $code = implode("\n", $code_lines); return $code ; } /** * Generates a reference to the given variable inside the given (possibly nested) * block namespace. This is a string of the form: * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . ' * It's ready to be inserted into an "echo" line in one of the templates. * NOTE: expects a trailing "." on the namespace. */ function generate_block_varref($namespace, $varname) { // Strip the trailing period. $namespace = substr($namespace, 0, strlen($namespace) - 1); // Get a reference to the data block for this namespace. $varref = $this->generate_block_data_ref($namespace, true); // Prepend the necessary code to stick this in an echo line. // Append the variable reference. $varref .= '[\'' . $varname . '\']'; $varref = '\' . ( ( isset(' . $varref . ') ) ? ' . $varref . ' : \'\' ) . \''; return $varref; } /** * Generates a reference to the array of data values for the given * (possibly nested) block namespace. This is a string of the form: * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] * * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. * NOTE: does not expect a trailing "." on the blockname. */ function generate_block_data_ref($blockname, $include_last_iterator) { // Get an array of the blocks involved. $blocks = explode(".", $blockname); $blockcount = sizeof($blocks) - 1; $varref = '$this->_tpldata'; // Build up the string with everything but the last child. for ($i = 0; $i < $blockcount; $i++) { $varref .= '[\'' . $blocks[$i] . '.\'][$_' . $blocks[$i] . '_i]'; } // Add the block reference for the last child. $varref .= '[\'' . $blocks[$blockcount] . '.\']'; // Add the iterator for the last child if requried. if ($include_last_iterator) { $varref .= '[$_' . $blocks[$blockcount] . '_i]'; } return $varref; } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TL5ae
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  479     0  E >   ECHO                                                     '%0A'
  480     1      > RETURN                                                   1

Class Template:
Function template:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TL5ae
function name:  Template
number of ops:  5
compiled vars:  !0 = $root
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   58     0  E >   RECV_INIT                                        !0      '.'
   60     1        INIT_METHOD_CALL                                         'set_rootdir'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   61     4      > RETURN                                                   null

End of function template

Function destroy:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TL5ae
function name:  destroy
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   69     0  E >   ASSIGN_OBJ                                               '_tpldata'
          1        OP_DATA                                                  <array>
   70     2      > RETURN                                                   null

End of function destroy

Function set_rootdir:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TL5ae
function name:  set_rootdir
number of ops:  11
compiled vars:  !0 = $dir
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   75     0  E >   RECV                                             !0      
   77     1        INIT_FCALL                                               'is_dir'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        BOOL_NOT                                         ~2      $1
          5      > JMPZ                                                     ~2, ->7
   79     6    > > RETURN                                                   <false>
   82     7    >   ASSIGN_OBJ                                               'root'
          8        OP_DATA                                                  !0
   83     9      > RETURN                                                   <true>
   84    10*     > RETURN                                                   null

End of function set_rootdir

Function set_filenames:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 9
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 9
Branch analysis from position: 23
Branch analysis from position: 9
filename:       /in/TL5ae
function name:  set_filenames
number of ops:  25
compiled vars:  !0 = $filename_array, !1 = $handle, !2 = $filename
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   90     0  E >   RECV                                             !0      
   92     1        TYPE_CHECK                                  128  ~3      !0
          2        BOOL_NOT                                         ~4      ~3
          3      > JMPZ                                                     ~4, ->5
   94     4    > > RETURN                                                   <false>
   97     5    >   INIT_FCALL                                               'reset'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                                 
   98     8      > JMP                                                      ->15
  100     9    >   INIT_METHOD_CALL                                         'make_filename'
         10        SEND_VAR_EX                                              !2
         11        DO_FCALL                                      0  $8      
         12        FETCH_OBJ_W                                      $6      'files'
         13        ASSIGN_DIM                                               $6, !1
         14        OP_DATA                                                  $8
   98    15    >   INIT_FCALL_BY_NAME                                       'each'
         16        SEND_VAR_EX                                              !0
         17        DO_FCALL                                      0  $9      
         18        FETCH_LIST_R                                     $10     $9, 0
         19        ASSIGN                                                   !1, $10
         20        FETCH_LIST_R                                     $12     $9, 1
         21        ASSIGN                                                   !2, $12
         22      > JMPNZ                                                    $9, ->9
  103    23    > > RETURN                                                   <true>
  104    24*     > RETURN                                                   null

End of function set_filenames

Function pparse:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 47) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 16
filename:       /in/TL5ae
function name:  pparse
number of ops:  31
compiled vars:  !0 = $handle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  112     0  E >   RECV                                             !0      
  114     1        INIT_METHOD_CALL                                         'loadfile'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4        BOOL_NOT                                         ~2      $1
          5      > JMPZ                                                     ~2, ->9
  116     6    >   NOP                                                      
          7        FAST_CONCAT                                      ~3      'Template-%3Epparse%28%29%3A+Couldn%27t+load+template+file+for+handle+', !0
          8      > EXIT                                                     ~3
  120     9    >   FETCH_OBJ_IS                                     ~4      'compiled_code'
         10        ISSET_ISEMPTY_DIM_OBJ                         0  ~5      ~4, !0
         11        BOOL_NOT                                         ~6      ~5
         12      > JMPNZ_EX                                         ~6      ~6, ->16
         13    >   FETCH_OBJ_IS                                     ~7      'compiled_code'
         14        ISSET_ISEMPTY_DIM_OBJ                         1  ~8      ~7, !0
         15        BOOL                                             ~6      ~8
         16    > > JMPZ                                                     ~6, ->26
  123    17    >   INIT_METHOD_CALL                                         'compile'
         18        CHECK_FUNC_ARG                                           
         19        FETCH_OBJ_FUNC_ARG                               $11     'uncompiled_code'
         20        FETCH_DIM_FUNC_ARG                               $12     $11, !0
         21        SEND_FUNC_ARG                                            $12
         22        DO_FCALL                                      0  $13     
         23        FETCH_OBJ_W                                      $9      'compiled_code'
         24        ASSIGN_DIM                                               $9, !0
         25        OP_DATA                                                  $13
  127    26    >   FETCH_OBJ_R                                      ~14     'compiled_code'
         27        FETCH_DIM_R                                      ~15     ~14, !0
         28        INCLUDE_OR_EVAL                                          ~15, EVAL
  128    29      > RETURN                                                   <true>
  129    30*     > RETURN                                                   null

End of function pparse

Function assign_var_from_handle:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TL5ae
function name:  assign_var_from_handle
number of ops:  27
compiled vars:  !0 = $varname, !1 = $handle, !2 = $_str, !3 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  139     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  141     2        INIT_METHOD_CALL                                         'loadfile'
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0  $4      
          5        BOOL_NOT                                         ~5      $4
          6      > JMPZ                                                     ~5, ->10
  143     7    >   NOP                                                      
          8        FAST_CONCAT                                      ~6      'Template-%3Eassign_var_from_handle%28%29%3A+Couldn%27t+load+template+file+for+handle+', !1
          9      > EXIT                                                     ~6
  147    10    >   ASSIGN                                                   !2, ''
  148    11        INIT_METHOD_CALL                                         'compile'
         12        CHECK_FUNC_ARG                                           
         13        FETCH_OBJ_FUNC_ARG                               $8      'uncompiled_code'
         14        FETCH_DIM_FUNC_ARG                               $9      $8, !1
         15        SEND_FUNC_ARG                                            $9
         16        SEND_VAL_EX                                              <true>
         17        SEND_VAL_EX                                              '_str'
         18        DO_FCALL                                      0  $10     
         19        ASSIGN                                                   !3, $10
  151    20        INCLUDE_OR_EVAL                                          !3, EVAL
  153    21        INIT_METHOD_CALL                                         'assign_var'
         22        SEND_VAR_EX                                              !0
         23        SEND_VAR_EX                                              !2
         24        DO_FCALL                                      0          
  155    25      > RETURN                                                   <true>
  156    26*     > RETURN                                                   null

End of function assign_var_from_handle

Function assign_block_vars:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 37
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 18
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 18
Branch analysis from position: 31
Branch analysis from position: 18
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TL5ae
function name:  assign_block_vars
number of ops:  44
compiled vars:  !0 = $blockname, !1 = $vararray, !2 = $blocks, !3 = $blockcount, !4 = $str, !5 = $i, !6 = $lastiteration
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  163     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  165     2        INIT_FCALL                                               'strstr'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 '.'
          5        DO_ICALL                                         $7      
          6      > JMPZ                                                     $7, ->37
  168     7    >   INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '.'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !2, $8
  169    12        COUNT                                            ~10     !2
         13        SUB                                              ~11     ~10, 1
         14        ASSIGN                                                   !3, ~11
  170    15        ASSIGN                                                   !4, '%24this-%3E_tpldata'
  171    16        ASSIGN                                                   !5, 0
         17      > JMP                                                      ->29
  173    18    >   FETCH_DIM_R                                      ~15     !2, !5
         19        CONCAT                                           ~16     '%5B%27', ~15
         20        CONCAT                                           ~17     ~16, '.%27%5D'
         21        ASSIGN_OP                                     8          !4, ~17
  174    22        CONCAT                                           ~19     '%24lastiteration+%3D+sizeof%28', !4
         23        CONCAT                                           ~20     ~19, '%29+-+1%3B'
         24        INCLUDE_OR_EVAL                                          ~20, EVAL
  175    25        CONCAT                                           ~22     '%5B', !6
         26        CONCAT                                           ~23     ~22, '%5D'
         27        ASSIGN_OP                                     8          !4, ~23
  171    28        PRE_INC                                                  !5
         29    >   IS_SMALLER                                               !5, !3
         30      > JMPNZ                                                    ~26, ->18
  180    31    >   FETCH_DIM_R                                      ~27     !2, !3
         32        CONCAT                                           ~28     '%5B%27', ~27
         33        CONCAT                                           ~29     ~28, '.%27%5D%5B%5D+%3D+%24vararray%3B'
         34        ASSIGN_OP                                     8          !4, ~29
  183    35        INCLUDE_OR_EVAL                                          !4, EVAL
         36      > JMP                                                      ->42
  190    37    >   CONCAT                                           ~33     !0, '.'
         38        FETCH_OBJ_W                                      $32     '_tpldata'
         39        FETCH_DIM_W                                      $34     $32, ~33
         40        ASSIGN_DIM                                               $34
         41        OP_DATA                                                  !1
  193    42    > > RETURN                                                   <true>
  194    43*     > RETURN                                                   null

End of function assign_block_vars

Function assign_vars:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 5
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 5
Branch analysis from position: 18
Branch analysis from position: 5
filename:       /in/TL5ae
function name:  assign_vars
number of ops:  20
compiled vars:  !0 = $vararray, !1 = $key, !2 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  200     0  E >   RECV                                             !0      
  202     1        INIT_FCALL                                               'reset'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
  203     4      > JMP                                                      ->10
  205     5    >   FETCH_OBJ_W                                      $4      '_tpldata'
          6        FETCH_DIM_W                                      $5      $4, '.'
          7        FETCH_DIM_W                                      $6      $5, 0
          8        ASSIGN_DIM                                               $6, !1
          9        OP_DATA                                                  !2
  203    10    >   INIT_FCALL_BY_NAME                                       'each'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0  $8      
         13        FETCH_LIST_R                                     $9      $8, 0
         14        ASSIGN                                                   !1, $9
         15        FETCH_LIST_R                                     $11     $8, 1
         16        ASSIGN                                                   !2, $11
         17      > JMPNZ                                                    $8, ->5
  208    18    > > RETURN                                                   <true>
  209    19*     > RETURN                                                   null

End of function assign_vars

Function assign_var:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TL5ae
function name:  assign_var
number of ops:  9
compiled vars:  !0 = $varname, !1 = $varval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  215     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  217     2        FETCH_OBJ_W                                      $2      '_tpldata'
          3        FETCH_DIM_W                                      $3      $2, '.'
          4        FETCH_DIM_W                                      $4      $3, 0
          5        ASSIGN_DIM                                               $4, !0
          6        OP_DATA                                                  !1
  219     7      > RETURN                                                   <true>
  220     8*     > RETURN                                                   null

End of function assign_var

Function make_filename:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
Branch analysis from position: 29
Branch analysis from position: 20
filename:       /in/TL5ae
function name:  make_filename
number of ops:  31
compiled vars:  !0 = $filename, !1 = $rp_filename
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  228     0  E >   RECV                                             !0      
  231     1        INIT_FCALL                                               'substr'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 0
          4        SEND_VAL                                                 1
          5        DO_ICALL                                         $2      
          6        IS_NOT_EQUAL                                             $2, '%2F'
          7      > JMPZ                                                     ~3, ->20
  233     8    >   INIT_FCALL                                               'realpath'
          9        FETCH_OBJ_R                                      ~4      'root'
         10        CONCAT                                           ~5      ~4, '%2F'
         11        CONCAT                                           ~6      ~5, !0
         12        SEND_VAL                                                 ~6
         13        DO_ICALL                                         $7      
         14        ASSIGN                                           ~8      !1, $7
         15      > JMPZ                                                     ~8, ->18
         16    >   QM_ASSIGN                                        ~9      !1
         17      > JMP                                                      ->19
         18    >   QM_ASSIGN                                        ~9      !0
         19    >   ASSIGN                                                   !0, ~9
  236    20    >   INIT_FCALL                                               'file_exists'
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $11     
         23        BOOL_NOT                                         ~12     $11
         24      > JMPZ                                                     ~12, ->29
  238    25    >   ROPE_INIT                                     3  ~14     'Template-%3Emake_filename%28%29%3A+Error+-+file+'
         26        ROPE_ADD                                      1  ~14     ~14, !0
         27        ROPE_END                                      2  ~13     ~14, '+does+not+exist'
         28      > EXIT                                                     ~13
  241    29    > > RETURN                                                   !0
  242    30*     > RETURN                                                   null

End of function make_filename

Function loadfile:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 38
Branch analysis from position: 32
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/TL5ae
function name:  loadfile
number of ops:  43
compiled vars:  !0 = $handle, !1 = $filename, !2 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  249     0  E >   RECV                                             !0      
  252     1        FETCH_OBJ_IS                                     ~3      'uncompiled_code'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~4      ~3, !0
          3      > JMPZ_EX                                          ~4      ~4, ->8
          4    >   FETCH_OBJ_IS                                     ~5      'uncompiled_code'
          5        ISSET_ISEMPTY_DIM_OBJ                         1  ~6      ~5, !0
          6        BOOL_NOT                                         ~7      ~6
          7        BOOL                                             ~4      ~7
          8    > > JMPZ                                                     ~4, ->10
  254     9    > > RETURN                                                   <true>
  258    10    >   FETCH_OBJ_IS                                     ~8      'files'
         11        ISSET_ISEMPTY_DIM_OBJ                         0  ~9      ~8, !0
         12        BOOL_NOT                                         ~10     ~9
         13      > JMPZ                                                     ~10, ->17
  260    14    >   NOP                                                      
         15        FAST_CONCAT                                      ~11     'Template-%3Eloadfile%28%29%3A+No+file+specified+for+handle+', !0
         16      > EXIT                                                     ~11
  263    17    >   FETCH_OBJ_R                                      ~12     'files'
         18        FETCH_DIM_R                                      ~13     ~12, !0
         19        ASSIGN                                                   !1, ~13
  265    20        INIT_FCALL                                               'implode'
         21        SEND_VAL                                                 ''
         22        BEGIN_SILENCE                                    ~15     
         23        INIT_FCALL                                               'file'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $16     
         26        END_SILENCE                                              ~15
         27        SEND_VAR                                                 $16
         28        DO_ICALL                                         $17     
         29        ASSIGN                                                   !2, $17
  266    30        ISSET_ISEMPTY_CV                                         !2
         31      > JMPZ                                                     ~19, ->38
  268    32    >   ROPE_INIT                                     5  ~21     'Template-%3Eloadfile%28%29%3A+File+'
         33        ROPE_ADD                                      1  ~21     ~21, !1
         34        ROPE_ADD                                      2  ~21     ~21, '+for+handle+'
         35        ROPE_ADD                                      3  ~21     ~21, !0
         36        ROPE_END                                      4  ~20     ~21, '+is+empty'
         37      > EXIT                                                     ~20
  271    38    >   FETCH_OBJ_W                                      $24     'uncompiled_code'
         39        ASSIGN_DIM                                               $24, !0
         40        OP_DATA                                                  !2
  273    41      > RETURN                                                   <true>
  274    42*     > RETURN                                                   null

End of function loadfile

Function compile:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 26
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 285
Branch analysis from position: 285
2 jumps found. (Code = 44) Position 1 = 287, Position 2 = 67
Branch analysis from position: 287
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
2 jumps found. (Code = 43) Position 1 = 80, Position 2 = 255
Branch analysis from position: 80
2 jumps found. (Code = 43) Position 1 = 93, Position 2 = 180
Branch analysis from position: 93
2 jumps found. (Code = 43) Position 1 = 99, Position 2 = 127
Branch analysis from position: 99
1 jumps found. (Code = 42) Position 1 = 167
Branch analysis from position: 167
1 jumps found. (Code = 42) Position 1 = 254
Branch analysis from position: 254
1 jumps found. (Code = 42) Position 1 = 284
Branch analysis from position: 284
2 jumps found. (Code = 44) Position 1 = 287, Position 2 = 67
Branch analysis from position: 287
Branch analysis from position: 67
Branch analysis from position: 127
1 jumps found. (Code = 42) Position 1 = 254
Branch analysis from position: 254
Branch analysis from position: 180
2 jumps found. (Code = 43) Position 1 = 186, Position 2 = 214
Branch analysis from position: 186
1 jumps found. (Code = 42) Position 1 = 254
Branch analysis from position: 254
Branch analysis from position: 214
1 jumps found. (Code = 42) Position 1 = 284
Branch analysis from position: 284
Branch analysis from position: 255
2 jumps found. (Code = 43) Position 1 = 262, Position 2 = 269
Branch analysis from position: 262
1 jumps found. (Code = 42) Position 1 = 284
Branch analysis from position: 284
Branch analysis from position: 269
2 jumps found. (Code = 43) Position 1 = 271, Position 2 = 277
Branch analysis from position: 271
1 jumps found. (Code = 42) Position 1 = 284
Branch analysis from position: 284
Branch analysis from position: 277
2 jumps found. (Code = 44) Position 1 = 287, Position 2 = 67
Branch analysis from position: 287
Branch analysis from position: 67
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 26
Branch analysis from position: 48
Branch analysis from position: 26
filename:       /in/TL5ae
function name:  compile
number of ops:  294
compiled vars:  !0 = $code, !1 = $do_not_echo, !2 = $retvar, !3 = $varrefs, !4 = $varcount, !5 = $i, !6 = $namespace, !7 = $varname, !8 = $new, !9 = $code_lines, !10 = $block_nesting_level, !11 = $block_names, !12 = $line_count, !13 = $m, !14 = $n, !15 = $varref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  285     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
          2        RECV_INIT                                        !2      ''
  

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
203.36 ms | 1428 KiB | 31 Q