Changeset 1333 in svn for trunk


Ignore:
Timestamp:
2013-07-19T06:26:11+02:00 (2 years ago)
Author:
Xuefer
Message:

Decompiler: support for yield generator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Decompiler.class.php

    r1330 r1333  
    745745                --$last;
    746746            }
    747             if ($opcodes[$last]['opcode'] == XC_RETURN) {
     747            if ($opcodes[$last]['opcode'] == XC_RETURN
     748             || $opcodes[$last]['opcode'] == XC_GENERATOR_RETURN) {
    748749                $op1 = $opcodes[$last]['op1'];
    749750                if ($op1['op_type'] == XC_IS_CONST && array_key_exists('constant', $op1) && $op1['constant'] === $defaultReturnValue) {
     
    967968        }
    968969        if ($firstOp['opcode'] == XC_JMPZ && !empty($firstOp['jmpouts'])
    969          && $firstOp['jmpouts'][0] - 1 == $range[1] && $opcodes[$firstOp['jmpouts'][0] - 1]['opcode'] == XC_RETURN) {
     970         && $firstOp['jmpouts'][0] - 1 == $range[1]
     971         && ($opcodes[$firstOp['jmpouts'][0] - 1]['opcode'] == XC_RETURN || $opcodes[$firstOp['jmpouts'][0] - 1]['opcode'] == XC_GENERATOR_RETURN)) {
    970972            $this->beginComplexBlock($EX);
    971973            $this->removeJmpInfo($EX, $range[0]);
     
    20462048                break;
    20472049                // }}}
     2050            case XC_GENERATOR_RETURN:
    20482051            case XC_RETURN: // {{{
    20492052                $resvar = "return " . str($this->getOpVal($op1, $EX));
     
    20792082
    20802083                $resvar = $fe;
     2084                break;
     2085                // }}}
     2086            case XC_YIELD: // {{{
     2087                $resvar = 'yield ' . str($this->getOpVal($op1, $EX));
    20812088                break;
    20822089                // }}}
     
    29162923    'XC_DO_FCALL_BY_FUNC' => -1,
    29172924    'XC_FETCH_CLASS' => -1,
     2925    'XC_GENERATOR_RETURN' => -1,
    29182926    'XC_GOTO' => -1,
    29192927    'XC_HANDLE_EXCEPTION' => -1,
     
    29442952    'XC_USER_OPCODE' => -1,
    29452953    'XC_VERIFY_ABSTRACT_CLASS' => -1,
     2954    'XC_YIELD' => -1,
    29462955) as $k => $v) {
    29472956    if (!defined($k)) {
Note: See TracChangeset for help on using the changeset viewer.