From 489be67bd9448f7e73b9f7bc2db763caadade078 Mon Sep 17 00:00:00 2001 From: Xuefer Date: Sun, 17 Apr 2011 04:00:31 +0000 Subject: [PATCH] decompiler: improvements late binding function, sample code organize git-svn-id: svn://svn.lighttpd.net/xcache/trunk@751 c26eb9a1-5813-0410-bd6c-c2e55f420ca7 --- Decompiler.class.php | 7 ++++++- decompilesample.php | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/Decompiler.class.php b/Decompiler.class.php index cc6b90a..0dc123b 100644 --- a/Decompiler.class.php +++ b/Decompiler.class.php @@ -1275,7 +1275,9 @@ class Decompiler exit; } $class = &$this->dc['class_table'][$key]; - $class['name'] = unquoteName($this->getOpVal($op2, $EX), $EX); + if (!isset($class['name'])) { + $class['name'] = unquoteName($this->getOpVal($op2, $EX), $EX); + } if ($opc == XC_DECLARE_INHERITED_CLASS || $opc == XC_DECLARE_INHERITED_CLASS_DELAYED) { $ext /= XC_SIZEOF_TEMP_VARIABLE; $class['parent'] = $T[$ext]; @@ -1563,6 +1565,9 @@ class Decompiler case XC_EXT_FCALL_END: case XC_EXT_NOP: break; + case XC_DECLARE_FUNCTION: + $this->dfunction($this->dc['function_table'][$op1['constant']], $EX['indent']); + break; case XC_DECLARE_LAMBDA_FUNCTION: ob_start(); $this->dfunction($this->dc['function_table'][$op1['constant']], $EX['indent']); diff --git a/decompilesample.php b/decompilesample.php index 9be454d..1179f82 100644 --- a/decompilesample.php +++ b/decompilesample.php @@ -89,6 +89,7 @@ interface IInterface function f1($f) { + echo __FUNCTION__; echo $f; } @@ -148,18 +149,23 @@ final class Child extends ClassName implements IInterface } } +if ($late) { +class LateBindingClass +{} + +function lateBindingFunction($arg) +{ + echo 'lateFunction'; +} +} + echo "\r\n"; echo "\r"; echo "\n"; echo str_replace(array('a' => 'a', 'b' => 'c'), 'b'); $object = new ClassName(); $object = new $className(); -try { - echo 'code being try'; -} -catch (Exception $e) { - echo $e; -} +$result = $object instanceof ClassName; $cloned = clone $object; $a = 1; $a = $b + $c; @@ -191,15 +197,28 @@ $a = $b--; $a = --$b; $a = $obj->b--; $a = --$obj->b; -$a = $b and $c; -$a = $b or $c; $a = $b xor $c; $a = !$b; +$a = $b and $c; +$a = $b or $c; $a = $b && $c; $a = $b || $c; $a = $b ? $c : $d; $a = f1() ? f2() : f3(); -$a = $b instanceof ClassName; + +try { + echo 'outer try 1'; + try { + echo 'inner try'; + } + catch (InnerException $e) { + echo $e; + } + echo 'outer try 2'; +} +catch (OuterException $e) { + echo $e; +} if ($a) { echo 'if ($a)'; @@ -252,6 +271,8 @@ require 'require.php'; require_once 'require_once.php'; include 'include.php'; include_once 'include_once.php'; +echo __FILE__; +echo __LINE__; //* >= PHP 5.3 echo $this::CONST_VALUE;