make sample work for all beside decompiler
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1441 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
This commit is contained in:
parent
9563ceb3c1
commit
e3f86745b0
52
devel/run
52
devel/run
|
@ -129,7 +129,7 @@ hiecho "Loading config devel/run.cfg"
|
|||
PHPSDIR=${PHPSDIR:-$HOME/test}
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
set -- $action "${args[@]}"
|
||||
set -- "${args[@]}"
|
||||
fi
|
||||
|
||||
basename=$(basename $(pwd))
|
||||
|
@ -233,31 +233,15 @@ run() {
|
|||
# }}}1
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
set -- devel.php
|
||||
set -- devel/sample.cpp.php
|
||||
fi
|
||||
|
||||
cmd=()
|
||||
phpApp=()
|
||||
tracer=()
|
||||
|
||||
# run utils {{{1
|
||||
case "$1" in
|
||||
dc)
|
||||
shift
|
||||
case "$1" in
|
||||
*.cpp.php)
|
||||
< "$1" \
|
||||
sed -r -e 's#__#____#g' \
|
||||
| cpp -C -P -traditional-cpp -DPHP_VERSION=$phpVersion \
|
||||
| sed -r -e 's#^ +##g' -e 's#\t +#\t#g' -e 's#____#__#g' > sample.php || exit $?
|
||||
shift
|
||||
./php-cli -c devel.ini ./bin/phpdc.phpr sample.php "$@" | tee decompiled.php
|
||||
;;
|
||||
*)
|
||||
./php-cli -c devel.ini ./bin/phpdc.phpr "$@" | tee decompiled.php
|
||||
;;
|
||||
esac
|
||||
return
|
||||
;;
|
||||
retest)
|
||||
shift
|
||||
lastResult=$(ls php_test_results_*.txt | LANG=C sort | tail -n1)
|
||||
|
@ -318,10 +302,15 @@ run() {
|
|||
;;
|
||||
*)
|
||||
case "$1" in
|
||||
dc)
|
||||
shift
|
||||
cmd=(./php-cli -c devel.ini)
|
||||
phpApp=(./bin/phpdc.phpr)
|
||||
;;
|
||||
dop)
|
||||
shift
|
||||
cmd=(./php-cli -c devel.ini)
|
||||
set -- ./bin/phpdop.phpr "$@"
|
||||
phpApp=(./bin/phpdop.phpr)
|
||||
;;
|
||||
fcgi)
|
||||
shift
|
||||
|
@ -341,22 +330,35 @@ run() {
|
|||
"${cmd[@]}" -v || true
|
||||
esac
|
||||
|
||||
# hack sample.cpp.php {{{1
|
||||
case "$1" in
|
||||
*.cpp.php)
|
||||
< "$1" \
|
||||
sed -r -e 's#__#____#g' \
|
||||
| cpp -C -P -traditional-cpp -DPHP_VERSION=$phpVersion \
|
||||
| sed -r -e 's#^ +##g' -e 's#\t +#\t#g' -e 's#____#__#g' > devel.php || exit $?
|
||||
shift
|
||||
set -- devel.php "$@"
|
||||
;;
|
||||
esac
|
||||
|
||||
# run {{{1
|
||||
commandLine=("${tracer[@]}" "${cmd[@]}" "$@")
|
||||
set -- "${tracer[@]}" "${cmd[@]}" "${phpApp[@]}" "$@"
|
||||
|
||||
case "${cmd[0]}" in
|
||||
*php-fpm*)
|
||||
stopfpm
|
||||
hiecho Starting fpm "${commandLine[@]}" ...
|
||||
"${commandLine[@]}"
|
||||
hiecho Starting fpm "$@" ...
|
||||
"$@" | tee output.php
|
||||
echo -n "Ctrl-C to stop"
|
||||
trap cleanfpm SIGINT SIGTERM exit
|
||||
cat > /dev/null || true
|
||||
stopfpm
|
||||
return
|
||||
;;
|
||||
*)
|
||||
hiecho "${commandLine[@]}"
|
||||
"${commandLine[@]}"
|
||||
hiecho "$@"
|
||||
"$@" | tee output.php
|
||||
;;
|
||||
esac
|
||||
# }}}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#if PHP_VERSION >= 530
|
||||
|
||||
namespace ns;
|
||||
#define _Exception \Exception
|
||||
#endif
|
||||
|
||||
abstract class ClassName
|
||||
|
@ -30,6 +31,7 @@ abstract class ClassName
|
|||
1 => 'str',
|
||||
CONST_VALUE => CONST_VALUE
|
||||
);
|
||||
static public $classProp;
|
||||
static public $static_const1 = CONST_VALUE;
|
||||
static public $static_const2 = self::CONST_VALUE;
|
||||
static public $static_const3 = ClassName::CONST_VALUE;
|
||||
|
@ -61,6 +63,7 @@ abstract class ClassName
|
|||
private $private_property = array(2, 'str');
|
||||
/** doc */
|
||||
protected $protected_property = array(2, 'str');
|
||||
public $array = array();
|
||||
#else
|
||||
var $property = array(
|
||||
array('array'),
|
||||
|
@ -71,31 +74,42 @@ abstract class ClassName
|
|||
#if PHP_VERSION >= 500
|
||||
/** doc */
|
||||
#endif
|
||||
PublicMethod function __construct($a, $b)
|
||||
PublicMethod function f1()
|
||||
{
|
||||
}
|
||||
|
||||
PublicMethod function f2()
|
||||
{
|
||||
}
|
||||
|
||||
PublicMethod function __construct($arg1, $arg2)
|
||||
{
|
||||
static $array = array(
|
||||
0 => array('array'),
|
||||
1 => 'str',
|
||||
CONST_VALUE => CONST_VALUE
|
||||
);
|
||||
static $a = 1;
|
||||
static $static = 1;
|
||||
static $str = 'string';
|
||||
echo CONST_VALUE;
|
||||
#if PHP_VERSION >= 500
|
||||
echo ClassName::CONST_VALUE;
|
||||
empty(ClassName::$classProp);
|
||||
isset(ClassName::$classProp);
|
||||
unset(ClassName::$classProp);
|
||||
ClassName::$classProp = 1;
|
||||
echo ClassName::$classProp;
|
||||
#endif
|
||||
empty($obj->objProp);
|
||||
isset($obj->objProp);
|
||||
$object = $this;
|
||||
$object->a = 1;
|
||||
$object->b = 2;
|
||||
$object->prop = 'prop';
|
||||
empty($object->objProp);
|
||||
isset($object->objProp);
|
||||
#if PHP_VERSION >= 500
|
||||
unset($obj->objProp);
|
||||
unset($object->objProp);
|
||||
#endif
|
||||
$obj->objProp = 1;
|
||||
echo $obj->objProp;
|
||||
$object->objProp = 1;
|
||||
echo $object->objProp;
|
||||
empty($this->thisProp);
|
||||
isset($this->thisProp);
|
||||
#if PHP_VERSION >= 500
|
||||
|
@ -106,7 +120,7 @@ abstract class ClassName
|
|||
#if PHP_VERSION >= 500
|
||||
unset($array['index']->valueProp);
|
||||
#endif
|
||||
unset($obj->array['index']);
|
||||
unset($object->array['index']);
|
||||
unset($this->array['index']);
|
||||
empty($_GET['get']);
|
||||
isset($_GET['get']);
|
||||
|
@ -128,8 +142,10 @@ abstract class ClassName
|
|||
#if PHP_VERSION >= 500
|
||||
unset($array['index']->indexProp);
|
||||
#endif
|
||||
$array['index'] = $object;
|
||||
$array['index']->indexProp = 1;
|
||||
echo $array['index']->indexProp;
|
||||
$GLOBALS['var'] = $object;
|
||||
empty($GLOBALS['var']->indexProp);
|
||||
isset($GLOBALS['var']->indexProp);
|
||||
#if PHP_VERSION >= 500
|
||||
|
@ -137,21 +153,156 @@ abstract class ClassName
|
|||
#endif
|
||||
$GLOBALS['var']->indexProp = 1;
|
||||
echo $GLOBALS['var']->indexProp;
|
||||
ClassName::__construct();
|
||||
ClassName::$func();
|
||||
|
||||
if (0) {
|
||||
ClassName::__construct();
|
||||
}
|
||||
|
||||
$method = 'method';
|
||||
ClassName::$method();
|
||||
echo __CLASS__;
|
||||
echo __METHOD__;
|
||||
echo __FUNCTION__;
|
||||
$this->methodCall();
|
||||
$this->method();
|
||||
#if PHP_VERSION >= 500
|
||||
throw new Exception();
|
||||
new Exception();
|
||||
try {
|
||||
throw new _Exception();
|
||||
new _Exception();
|
||||
}
|
||||
catch (_Exception $e) {
|
||||
}
|
||||
#endif
|
||||
|
||||
$a = 1;
|
||||
$b = $c = 2;
|
||||
$a = $b + $c;
|
||||
$a = $b + 1;
|
||||
$a = 1 + $b;
|
||||
$a = $b - $c;
|
||||
$a = $b * $c;
|
||||
$a = $b / $c;
|
||||
$a = $b % $c;
|
||||
$a = $b . $c;
|
||||
$a = $b = $c;
|
||||
$a = $b & $c;
|
||||
$a = $b | $c;
|
||||
$a = $b ^ $c;
|
||||
$a = ~$b;
|
||||
$a = -$b;
|
||||
$a = +$b;
|
||||
$a = $b >> $c;
|
||||
$a = $b >> $c;
|
||||
$a = $b == $c;
|
||||
$a = $b === $c;
|
||||
$a = $b != $c;
|
||||
$a = $b < $c;
|
||||
$a = $b <= $c;
|
||||
$a = $b <= $c;
|
||||
$a = $b++;
|
||||
$a = ++$b;
|
||||
$a = $object->b++;
|
||||
$a = ++$object->b;
|
||||
$a = $b--;
|
||||
$a = --$b;
|
||||
$a = $object->b--;
|
||||
$a = --$object->b;
|
||||
$a = !$b;
|
||||
$a = $b === $c;
|
||||
$a = $b !== $c;
|
||||
$a = $b << 2;
|
||||
$a = $b >> 3;
|
||||
$a += $b;
|
||||
$a -= $b;
|
||||
$a *= $b;
|
||||
$a /= $b;
|
||||
$a <<= $b;
|
||||
$a >>= $b;
|
||||
$a &= $b;
|
||||
$a |= $b;
|
||||
$a .= $b;
|
||||
$a %= $b;
|
||||
$a ^= $b;
|
||||
$a = 'a' . 'b';
|
||||
$a = 'a' . 'abc';
|
||||
@f1();
|
||||
print('1');
|
||||
$array = array('index' => 1);
|
||||
$a = $array['index'];
|
||||
$a = $object->prop;
|
||||
$a = $this->prop;
|
||||
$array['index'] = 1;
|
||||
$object->prop = 1;
|
||||
$this->prop = 1;
|
||||
$a = isset($b);
|
||||
$a = empty($b);
|
||||
unset($b);
|
||||
$b = 1;
|
||||
$a = isset($array['index']);
|
||||
$a = empty($array['index']);
|
||||
unset($array['index']);
|
||||
$a = isset($object->prop);
|
||||
$a = empty($object->prop);
|
||||
#if PHP_VERSION >= 500
|
||||
unset($object->prop);
|
||||
#endif
|
||||
$a = isset($this->prop);
|
||||
$a = empty($this->prop);
|
||||
#if PHP_VERSION >= 500
|
||||
unset($this->prop);
|
||||
$a = isset(ClassName::$prop);
|
||||
$a = empty(ClassName::$prop);
|
||||
#endif
|
||||
$a = (int) $b;
|
||||
$a = (double) $b;
|
||||
$a = (string) $b;
|
||||
$a = (array) $b;
|
||||
$a = (object) $b;
|
||||
$a = (bool) $b;
|
||||
$a = (unset) $b;
|
||||
$a = (array) $b;
|
||||
$a = (object) $b;
|
||||
$a = ($b ? $c : $d);
|
||||
$a = (f1() ? f2() : f3());
|
||||
($a = $b) xor $c;
|
||||
($a = $b) and $c;
|
||||
($a = $b) or $c;
|
||||
$a = $b && $c;
|
||||
$a = $b || $c;
|
||||
#if PHP_VERSION >= 530
|
||||
echo $this::CONST_VALUE;
|
||||
echo $object::CONST_VALUE;
|
||||
echo CONST_VALUE;
|
||||
$this::method();
|
||||
$object::method();
|
||||
$a = $b ?: $d;
|
||||
$a = ($b ?: $d) + $c;
|
||||
$a = f1() ?: f2();
|
||||
$a = ClassName::f1() ?: ClassName::f2();
|
||||
$a = ($b ? $c : $d);
|
||||
$a = ($b ? $c : $d) + $c;
|
||||
$a = (f1() ? f3() : f2());
|
||||
|
||||
if ($b ?: $d) {
|
||||
echo 'if ($b ?: $d)';
|
||||
}
|
||||
|
||||
if (($b ?: $d) + $c) {
|
||||
echo 'if (($b ?: $d) + $c)';
|
||||
}
|
||||
|
||||
if (f1() ?: f2()) {
|
||||
echo 'if (f1() ?: f2())';
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
}
|
||||
#if PHP_VERSION >= 500
|
||||
|
||||
/** doc */
|
||||
abstract public function abastractMethod();
|
||||
abstract public function abstractMethod();
|
||||
#endif
|
||||
|
||||
#if PHP_VERSION >= 500
|
||||
|
@ -194,7 +345,19 @@ interface IInterface
|
|||
}
|
||||
#endif
|
||||
|
||||
function f1($f)
|
||||
function f1()
|
||||
{
|
||||
}
|
||||
|
||||
function f2()
|
||||
{
|
||||
}
|
||||
|
||||
function f3()
|
||||
{
|
||||
}
|
||||
|
||||
function generator($f)
|
||||
{
|
||||
echo __FUNCTION__;
|
||||
echo $f;
|
||||
|
@ -213,13 +376,12 @@ final class Child extends ClassName implements IInterface
|
|||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
parent::__construct('a', 'b');
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
parent::__destruct();
|
||||
functionCall();
|
||||
}
|
||||
|
||||
static public function __callStatic($name, $args)
|
||||
|
@ -227,6 +389,14 @@ final class Child extends ClassName implements IInterface
|
|||
parent::__callStatic($name, $args);
|
||||
}
|
||||
|
||||
public function abstractMethod()
|
||||
{
|
||||
}
|
||||
|
||||
public function nothing()
|
||||
{
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
parent::__toString();
|
||||
|
@ -263,6 +433,9 @@ final class Child extends ClassName implements IInterface
|
|||
}
|
||||
#endif
|
||||
|
||||
define('CONST_VALUE', 'const value');
|
||||
$late = isset($_ENV['LATE']);
|
||||
|
||||
if ($late) {
|
||||
class LateBindingClass
|
||||
{
|
||||
|
@ -281,106 +454,14 @@ if ($late) {
|
|||
echo "\r\n";
|
||||
echo "\r";
|
||||
echo "\n";
|
||||
echo str_replace(array('a' => 'a', 'b' => 'c'), 'b');
|
||||
$object = new ClassName();
|
||||
var_dump(array('a' => 'a', 'b' => 'c'), 'b');
|
||||
$object = new Child();
|
||||
$className = 'ns\\Child';
|
||||
$object = new $className();
|
||||
#if PHP_VERSION >= 500
|
||||
$result = $object instanceof ClassName;
|
||||
$result = $object instanceof Child;
|
||||
$cloned = clone $object;
|
||||
#endif
|
||||
$a = 1;
|
||||
$a = $b + $c;
|
||||
$a = $b + 1;
|
||||
$a = 1 + $b;
|
||||
$a = $b - $c;
|
||||
$a = $b * $c;
|
||||
$a = $b / $c;
|
||||
$a = $b % $c;
|
||||
$a = $b . $c;
|
||||
$a = $b = $c;
|
||||
$a = $b & $c;
|
||||
$a = $b | $c;
|
||||
$a = $b ^ $c;
|
||||
$a = ~$b;
|
||||
$a = -$b;
|
||||
$a = +$b;
|
||||
$a = $b >> $c;
|
||||
$a = $b >> $c;
|
||||
$a = $b == $c;
|
||||
$a = $b === $c;
|
||||
$a = $b != $c;
|
||||
$a = $b < $c;
|
||||
$a = $b <= $c;
|
||||
$a = $b <= $c;
|
||||
$a = $b++;
|
||||
$a = ++$b;
|
||||
$a = $obj->b++;
|
||||
$a = ++$obj->b;
|
||||
$a = $b--;
|
||||
$a = --$b;
|
||||
$a = $obj->b--;
|
||||
$a = --$obj->b;
|
||||
$a = !$b;
|
||||
$a = $b === $c;
|
||||
$a = $b !== $c;
|
||||
$a = $b << 2;
|
||||
$a = $b >> 3;
|
||||
$a += $b;
|
||||
$a -= $b;
|
||||
$a *= $b;
|
||||
$a /= $b;
|
||||
$a <<= $b;
|
||||
$a >>= $b;
|
||||
$a &= $b;
|
||||
$a |= $b;
|
||||
$a .= $b;
|
||||
$a %= $b;
|
||||
$a ^= $b;
|
||||
$a = 'a' . 'b';
|
||||
$a = 'a' . 'abc';
|
||||
@f1();
|
||||
print('1');
|
||||
$a = $array['index'];
|
||||
$a = $object->prop;
|
||||
$a = $this->prop;
|
||||
$array['index'] = 1;
|
||||
$object->prop = 1;
|
||||
$this->prop = 1;
|
||||
$a = isset($b);
|
||||
$a = empty($b);
|
||||
unset($b);
|
||||
$a = isset($array['index']);
|
||||
$a = empty($array['index']);
|
||||
unset($array['index']);
|
||||
$a = isset($object->prop);
|
||||
$a = empty($object->prop);
|
||||
#if PHP_VERSION >= 500
|
||||
unset($object->prop);
|
||||
#endif
|
||||
$a = isset($this->prop);
|
||||
$a = empty($this->prop);
|
||||
#if PHP_VERSION >= 500
|
||||
unset($this->prop);
|
||||
$a = isset(ClassName::$prop);
|
||||
$a = empty(ClassName::$prop);
|
||||
unset(ClassName::$prop);
|
||||
#endif
|
||||
$a = (int) $b;
|
||||
$a = (double) $b;
|
||||
$a = (string) $b;
|
||||
$a = (array) $b;
|
||||
$a = (object) $b;
|
||||
$a = (bool) $b;
|
||||
$a = (unset) $b;
|
||||
$a = (array) $b;
|
||||
$a = (object) $b;
|
||||
$a = ($b ? $c : $d);
|
||||
$a = (f1() ? f2() : f3());
|
||||
($a = $b) xor $c;
|
||||
($a = $b) and $c;
|
||||
($a = $b) or $c;
|
||||
$a = $b && $c;
|
||||
$a = $b || $c;
|
||||
#if PHP_VERSION >= 500
|
||||
|
||||
do {
|
||||
|
@ -418,22 +499,22 @@ do {
|
|||
} while (0);
|
||||
#endif
|
||||
|
||||
if (if_()) {
|
||||
if ('if()') {
|
||||
echo 'if';
|
||||
|
||||
if (innerIf_()) {
|
||||
if ('innerIf()') {
|
||||
echo 'if innerIf';
|
||||
}
|
||||
}
|
||||
else if (elseif_()) {
|
||||
else if ('elseif_()') {
|
||||
echo 'else if';
|
||||
|
||||
if (innerIf_()) {
|
||||
if ('innerIf_()') {
|
||||
echo 'if innerIf';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (innerIf_()) {
|
||||
if ('innerIf_()') {
|
||||
echo 'if innerIf';
|
||||
}
|
||||
|
||||
|
@ -455,6 +536,9 @@ for (; $i < 10; ++$i) {
|
|||
break;
|
||||
}
|
||||
|
||||
$array = array(
|
||||
array('a' => 'b')
|
||||
);
|
||||
foreach ($array as $value) {
|
||||
foreach ($value as $key => $value) {
|
||||
echo $key . ' = ' . $value . "\n";
|
||||
|
@ -463,11 +547,11 @@ foreach ($array as $value) {
|
|||
}
|
||||
}
|
||||
|
||||
switch ($normalSwitch) {
|
||||
switch ('$normalSwitch') {
|
||||
case 'case1':
|
||||
echo 'case1';
|
||||
|
||||
switch ($nestedSwitch) {
|
||||
switch ('$nestedSwitch') {
|
||||
case 1:
|
||||
}
|
||||
|
||||
|
@ -478,7 +562,7 @@ case 'case2':
|
|||
break;
|
||||
|
||||
default:
|
||||
switch ($nestedSwitch) {
|
||||
switch ('$nestedSwitch') {
|
||||
case 1:
|
||||
}
|
||||
|
||||
|
@ -486,7 +570,7 @@ default:
|
|||
break;
|
||||
}
|
||||
|
||||
switch ($switchWithoutDefault) {
|
||||
switch ('$switchWithoutDefault') {
|
||||
case 'case1':
|
||||
echo 'case1';
|
||||
break;
|
||||
|
@ -496,7 +580,7 @@ case 'case2':
|
|||
break;
|
||||
}
|
||||
|
||||
switch ($switchWithMiddleDefault) {
|
||||
switch ('$switchWithMiddleDefault') {
|
||||
case 'case1':
|
||||
echo 'case1';
|
||||
break;
|
||||
|
@ -510,7 +594,7 @@ case 'case2':
|
|||
break;
|
||||
}
|
||||
|
||||
switch ($switchWithInitialDefault) {
|
||||
switch ('$switchWithInitialDefault') {
|
||||
default:
|
||||
echo 'default';
|
||||
break;
|
||||
|
@ -524,10 +608,10 @@ case 'case2':
|
|||
break;
|
||||
}
|
||||
|
||||
switch (emptySwitch()) {
|
||||
switch ('emptySwitch()') {
|
||||
}
|
||||
|
||||
switch (defaultSwitch()) {
|
||||
switch ('defaultSwitch()') {
|
||||
default:
|
||||
}
|
||||
|
||||
|
@ -535,10 +619,12 @@ declare (ticks=1) {
|
|||
echo 1;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
$a = true;
|
||||
while ($a) {
|
||||
declare (ticks=1) {
|
||||
echo 2;
|
||||
}
|
||||
$a = false;
|
||||
}
|
||||
|
||||
require 'require.php';
|
||||
|
@ -548,33 +634,6 @@ include_once 'include_once.php';
|
|||
echo __FILE__;
|
||||
echo __LINE__;
|
||||
#if PHP_VERSION >= 530
|
||||
echo 'PHP 5.3+ code testing';
|
||||
const CONST_VALUE = 1;
|
||||
echo $this::CONST_VALUE;
|
||||
echo $a::CONST_VALUE;
|
||||
echo CONST_VALUE;
|
||||
$this::__construct();
|
||||
$obj::__construct();
|
||||
$a = $b ?: $d;
|
||||
$a = ($b ?: $d) + $c;
|
||||
$a = f1() ?: f2();
|
||||
$a = C::f1() ?: C::f2();
|
||||
$a = ($b ? $c : $d);
|
||||
$a = ($b ? $c : $d) + $c;
|
||||
$a = (f1() ? f3() : f2());
|
||||
|
||||
if ($b ?: $d) {
|
||||
echo 'if ($b ?: $d)';
|
||||
}
|
||||
|
||||
if (($b ?: $d) + $c) {
|
||||
echo 'if (($b ?: $d) + $c)';
|
||||
}
|
||||
|
||||
if (f1() ?: f2()) {
|
||||
echo 'if (f1() ?: f2())';
|
||||
}
|
||||
|
||||
echo 'goto a';
|
||||
goto a;
|
||||
|
Loading…
Reference in New Issue