Changeset 735 for trunk/Decompiler.class.php
- Timestamp:
- 04/10/2011 04:09:17 PM (2 years ago)
- Files:
-
- 1 modified
-
trunk/Decompiler.class.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Decompiler.class.php
r733 r735 252 252 $exp = "array("; 253 253 $indent = $indent . INDENT; 254 $assoc len= 0;254 $assocWidth = 0; 255 255 $multiline = 0; 256 256 $i = 0; 257 257 foreach ($this->value as $k => $v) { 258 258 if ($i !== $k) { 259 $assocWidth = 1; 260 } 261 ++$i; 262 } 263 foreach ($this->value as $k => $v) { 264 if ($assocWidth) { 259 265 $len = strlen($k); 260 if ($assoc len< $len) {261 $assoc len= $len;266 if ($assocWidth < $len) { 267 $assocWidth = $len; 262 268 } 263 269 } … … 266 272 $multiline ++; 267 273 } 268 ++ $i; 269 } 270 if ($assoclen) { 271 $assoclen += 2; 274 } 275 if ($assocWidth) { 276 $assocWidth += 2; 272 277 } 273 278 … … 289 294 290 295 $k = var_export($k, true); 291 if ($multiline) { 292 $exp .= sprintf("%{$assoclen}s => ", $k); 293 } 294 else if ($assoclen) { 295 $exp .= $k . ' => '; 296 if ($assocWidth) { 297 if ($multiline) { 298 $exp .= sprintf("%{$assocWidth}s => ", $k); 299 } 300 else { 301 $exp .= $k . ' => '; 302 } 296 303 } 297 304 … … 447 454 } 448 455 // }}} 449 function &fixOpcode($opcodes, $removeTailing = false) // {{{ 450 { 451 if ($removeTailing) { 452 $last = count($opcodes) - 1; 453 if ($opcodes[$last]['opcode'] == XC_HANDLE_EXCEPTION) { 454 unset($opcodes[$last]); 455 } 456 } 456 function &fixOpcode($opcodes, $removeTailing = false, $defaultReturnValue = null) // {{{ 457 { 457 458 for ($i = 0, $cnt = count($opcodes); $i < $cnt; $i ++) { 458 459 if (function_exists('xcache_get_fixed_opcode')) { … … 486 487 } 487 488 } 489 490 if ($removeTailing) { 491 $last = count($opcodes) - 1; 492 if ($opcodes[$last]['opcode'] == XC_HANDLE_EXCEPTION) { 493 unset($opcodes[$last]); 494 --$last; 495 } 496 if ($opcodes[$last]['opcode'] == XC_RETURN) { 497 $op1 = $opcodes[$last]['op1']; 498 if ($op1['op_type'] == XC_IS_CONST && array_key_exists('constant', $op1) && $op1['constant'] === $defaultReturnValue) { 499 unset($opcodes[$last]); 500 --$last; 501 } 502 } 503 } 488 504 return $opcodes; 489 505 } … … 491 507 function &dop_array($op_array, $indent = '') // {{{ 492 508 { 493 $op_array['opcodes'] = $this->fixOpcode($op_array['opcodes'], true );509 $op_array['opcodes'] = $this->fixOpcode($op_array['opcodes'], true, $indent == '' ? 1 : null); 494 510 $opcodes = &$op_array['opcodes']; 495 511 $EX['indent'] = '';

