Browse Source

prepare for use()

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@780 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 11 years ago
parent
commit
b5ecc94497
  1. 28
      Decompiler.class.php
  2. 1
      decompilesample.php
  3. 26
      xcache.c

28
Decompiler.class.php

@ -736,6 +736,8 @@ class Decompiler
$EX['arg_types_stack'] = array();
$EX['last'] = count($opcodes) - 1;
$EX['silence'] = 0;
$EX['recvs'] = array();
$EX['uses'] = array();
for ($next = 0, $last = $EX['last'];
$loop = $this->outputCode($EX, $next, $last, $indent, true);
@ -1139,6 +1141,14 @@ class Decompiler
break;
}
$resvar = "$lvalue = " . str($rvalue, $EX);
if (0) {
if ($op2['op_type'] == XC_IS_VAR) {
$resvar .= ' /* isvar */';
}
else if ($op2['op_type'] == XC_IS_TMP_VAR) {
$resvar .= ' /* istmp */';
}
}
break;
// }}}
case XC_ASSIGN_REF: // {{{
@ -1841,6 +1851,19 @@ class Decompiler
}
}
// }}}
function duses(&$EX, $indent) // {{{
{
if (!$EX['uses']) {
return;
}
$uses = array();
foreach ($EX['uses'] as $name => $value) {
$uses = '$' . $name;
}
echo ' use(', implode(', ', $uses), ')';
}
// }}}
function dfunction($func, $indent = '', $nobody = false) // {{{
{
$this->detectNamespace($func['op_array']['function_name']);
@ -1849,15 +1872,13 @@ class Decompiler
$EX = array();
$EX['op_array'] = &$func['op_array'];
$EX['recvs'] = array();
$EX['uses'] = array();
}
else {
ob_start();
$newindent = INDENT . $indent;
$EX = &$this->dop_array($func['op_array'], $newindent);
$body = ob_get_clean();
if (!isset($EX['recvs'])) {
$EX['recvs'] = array();
}
}
$functionName = $this->stripNamespace($func['op_array']['function_name']);
@ -1867,6 +1888,7 @@ class Decompiler
echo 'function ', $functionName, '(';
$this->dargs($EX, $indent);
echo ")";
$this->duses($EX, $indent);
if ($nobody) {
echo ";\n";
}

1
decompilesample.php

@ -362,6 +362,7 @@ $tax = 1;
$callback = function ($quantity, $product) use ($tax, &$total) {
static $static = array(1);
$tax = 'tax';
$tax = --$tax;
$pricePerItem = constant('PRICE_' . strtoupper($product));
$total += $pricePerItem * $quantity * ($tax + 1);
};

26
xcache.c

@ -2874,6 +2874,30 @@ PHP_FUNCTION(xcache_dec)
xc_var_inc_dec(-1, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto int xcache_get_refcount(mixed variable)
Get reference count of variable */
PHP_FUNCTION(xcache_get_refcount)
{
zval *variable;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &variable) == FAILURE) {
RETURN_NULL();
}
RETURN_LONG(Z_REFCOUNT_P(variable));
}
/* }}} */
/* {{{ proto bool xcache_get_isref(mixed variable)
check if variable data is marked referenced */
PHP_FUNCTION(xcache_get_isref)
{
zval *variable;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &variable) == FAILURE) {
RETURN_NULL();
}
RETURN_BOOL(Z_ISREF_P(variable));
}
/* }}} */
#ifdef HAVE_XCACHE_DPRINT
/* {{{ proto bool xcache_dprint(mixed value)
Prints variable (or value) internal struct (debug only) */
@ -3115,6 +3139,8 @@ static zend_function_entry xcache_functions[] = /* {{{ */
PHP_FE(xcache_isset, NULL)
PHP_FE(xcache_unset, NULL)
PHP_FE(xcache_unset_by_prefix, NULL)
PHP_FE(xcache_get_refcount, NULL)
PHP_FE(xcache_get_isref, NULL)
#ifdef HAVE_XCACHE_DPRINT
PHP_FE(xcache_dprint, NULL)
#endif

Loading…
Cancel
Save