Ignore:
Timestamp:
2013-07-15T19:37:57+02:00 (23 months ago)
Author:
moo
Message:

add back PHP_4 code for disassembler

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/processor/processor.m4

    r1313 r1321  
    1212DECL_STRUCT_P_FUNC(`xc_entry_var_t')
    1313DECL_STRUCT_P_FUNC(`xc_entry_php_t')
     14#ifdef ZEND_ENGINE_2
    1415DECL_STRUCT_P_FUNC(`zend_property_info')
     16#endif
    1517/* }}} */
    1618dnl ====================================================
     
    3234')
    3335dnl }}}
     36#ifndef ZEND_ENGINE_2
     37DEF_STRUCT_P_FUNC(`int', , `dnl {{{
     38    IFCOPY(`*dst = *src;')
     39    IFDPRINT(`
     40        INDENT()
     41        fprintf(stderr, "%d\n", src[0]);
     42    ')
     43    DONE_SIZE(sizeof(src[0]))
     44')
     45dnl }}}
     46#endif
     47#ifdef ZEND_ENGINE_2
    3448DEF_STRUCT_P_FUNC(`zend_try_catch_element', , `dnl {{{
    3549    PROCESS(zend_uint, try_op)
     
    4155')
    4256dnl }}}
     57#endif
    4358DEF_STRUCT_P_FUNC(`zend_brk_cont_element', , `dnl {{{
    4459#ifdef ZEND_ENGINE_2_2
     
    5267DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr',           `zval_ptr')
    5368DEF_HASH_TABLE_FUNC(`HashTable_zend_function',      `zend_function')
     69#ifdef ZEND_ENGINE_2
    5470DEF_HASH_TABLE_FUNC(`HashTable_zend_property_info', `zend_property_info')
     71#endif
    5572DEF_STRUCT_P_FUNC(`zval', , `dnl {{{
    5673    IFDASM(`do {
     
    116133                IFNOTMEMCPY(`IFCOPY(`memcpy(dst, src, sizeof(src[0]));')')
    117134                dnl STRUCT(value.obj)
     135#ifndef ZEND_ENGINE_2
     136                STRUCT_P(zend_class_entry, value.obj.ce)
     137                STRUCT_P(HashTable, value.obj.properties, HashTable_zval_ptr)
     138#endif
    118139                break;
    119140
     
    133154#ifdef ZEND_ENGINE_2_3
    134155        PROCESS(zend_uint, refcount__gc)
    135 #else
     156#elif defined(ZEND_ENGINE_2)
    136157        PROCESS(zend_uint, refcount)
     158#else
     159        PROCESS(zend_ushort, refcount)
    137160#endif
    138161    ')dnl IFDASM
     
    185208                dnl fprintf(stderr, "copy from %p to %p\n", src[0], dst[0]);
    186209            ')
    187             IFDPRINT(`INDENT()`'fprintf(stderr, "[%p] ", src[0]);')
     210            IFDPRINT(`INDENT()`'fprintf(stderr, "[%p] ", (void *) src[0]);')
    188211            STRUCT_P_EX(zval, dst[0], src[0], `[0]', `', ` ')
    189212            FIXPOINTER_EX(zval, dst[0])
     
    205228')
    206229dnl }}}
     230#ifdef ZEND_ENGINE_2
    207231DEF_STRUCT_P_FUNC(`zend_arg_info', , `dnl {{{
    208232    PROCESS(zend_uint, name_len)
     
    223247')
    224248dnl }}}
     249#endif
    225250#ifdef HAVE_XCACHE_CONSTANT
    226251DEF_STRUCT_P_FUNC(`zend_constant', , `dnl {{{
     
    256281')
    257282dnl }}}
     283#ifdef ZEND_ENGINE_2
    258284DEF_STRUCT_P_FUNC(`zend_property_info', , `dnl {{{
    259285    PROCESS(zend_uint, flags)
     
    274300')
    275301dnl }}}
     302#endif
    276303#ifdef ZEND_ENGINE_2_4
    277304DEF_STRUCT_P_FUNC(`zend_trait_method_reference', , `dnl {{{
     
    336363    PROCESS(zend_uint, name_length)
    337364    PROC_ZSTRING_L(, name, name_length)
    338     PROC_CLASS_ENTRY_P(parent)
     365    IFRESTORE(`
     366#ifndef ZEND_ENGINE_2
     367        /* just copy parent and resolve on install_class */
     368        COPY(parent)
     369#else
     370        PROC_CLASS_ENTRY_P(parent)
     371#endif
     372    ', `
     373        PROC_CLASS_ENTRY_P(parent)
     374    ')
     375#ifdef ZEND_ENGINE_2
    339376    PROCESS(int, refcount)
     377#else
     378    STRUCT_P(int, refcount)
     379#endif
    340380#ifndef ZEND_ENGINE_2_4
    341381    PROCESS(zend_bool, constants_updated)
    342382#endif
     383#ifdef ZEND_ENGINE_2
    343384    PROCESS(zend_uint, ce_flags)
    344 
     385#endif
     386
     387#ifdef ZEND_ENGINE_2
    345388    STRUCT(HashTable, properties_info, HashTable_zend_property_info)
     389#endif
    346390
    347391#ifdef ZEND_ENGINE_2_4
     
    360404    IFCOPY(`dst->static_members = &dst->default_static_members;')
    361405    DONE(static_members)
    362 #   else
     406#   elif defined(ZEND_ENGINE_2)
    363407    STRUCT_P(HashTable, static_members, HashTable_zval_ptr)
    364408#   endif
    365409#endif /* ZEND_ENGINE_2_4 */
    366410
     411#ifdef ZEND_ENGINE_2
    367412    STRUCT(HashTable, constants_table, HashTable_zval_ptr)
    368413
     
    449494    COPY(module)
    450495#   endif
     496#else /* ZEND_ENGINE_2 */
     497    COPY(handle_function_call)
     498    COPY(handle_property_get)
     499    COPY(handle_property_set)
     500#endif
    451501    dnl must do after SETNULL(constructor) and dst->parent
    452502    STRUCT(HashTable, function_table, HashTable_zend_function)
     
    555605            IFDASM(`PROCESS(zend_uint, u.var)')
    556606            PROCESS(zend_uint, u.opline_num)
     607#ifndef ZEND_ENGINE_2
     608            PROCESS(zend_uint, u.fetch_type)
     609#endif
    557610            PROCESS(zend_uint, u.EA.type)
    558611            break;
     
    607660#endif
    608661        popdef(`UNION_znode_op_literal')
     662#ifdef ZEND_ENGINE_2
    609663        switch (src->opcode) {
    610 #ifdef ZEND_GOTO
     664#   ifdef ZEND_GOTO
    611665            case ZEND_GOTO:
    612 #endif
     666#   endif
    613667            case ZEND_JMP:
    614 #ifdef ZEND_FAST_CALL
     668#   ifdef ZEND_FAST_CALL
    615669            case ZEND_FAST_CALL:
    616 #endif
     670#   endif
    617671                assert(Z_OP(src->op1).jmp_addr >= processor->active_op_array_src->opcodes && Z_OP(src->op1).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
    618672                Z_OP(dst->op1).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(src->op1).jmp_addr - processor->active_op_array_src->opcodes);
     
    624678            case ZEND_JMPZ_EX:
    625679            case ZEND_JMPNZ_EX:
    626 #ifdef ZEND_JMP_SET
     680#   ifdef ZEND_JMP_SET
    627681            case ZEND_JMP_SET:
    628 #endif
    629 #ifdef ZEND_JMP_SET_VAR
     682#   endif
     683#   ifdef ZEND_JMP_SET_VAR
    630684            case ZEND_JMP_SET_VAR:
    631 #endif
     685#   endif
    632686                assert(Z_OP(src->op2).jmp_addr >= processor->active_op_array_src->opcodes && Z_OP(src->op2).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
    633687                Z_OP(dst->op2).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(src->op2).jmp_addr - processor->active_op_array_src->opcodes);
     
    638692                break;
    639693        }
    640     ')
     694#   endif
     695    ')
     696#ifdef ZEND_ENGINE_2
    641697    PROCESS(opcode_handler_t, handler)
     698#endif
    642699')
    643700dnl }}}
     
    686743        /* deep */
    687744        STRUCT_P(HashTable, static_variables, HashTable_zval_ptr)
     745#ifdef ZEND_ENGINE_2
    688746        STRUCT_ARRAY(zend_uint, num_args, zend_arg_info, arg_info)
    689747        gc_arg_info = 1;
     748#endif
    690749        dst->filename = processor->entry_php_src->filepath;
    691750#ifdef ZEND_ENGINE_2_4
     
    731790                    case ZEND_FAST_CALL:
    732791#endif
     792#ifdef ZEND_ENGINE_2
    733793                        Z_OP(opline->op1).jmp_addr = &dst->opcodes[Z_OP(opline->op1).jmp_addr - src->opcodes];
     794#endif
    734795                        break;
    735796
     
    744805            case ZEND_JMP_SET_VAR:
    745806#endif
     807#ifdef ZEND_ENGINE_2
    746808                        Z_OP(opline->op2).jmp_addr = &dst->opcodes[Z_OP(opline->op2).jmp_addr - src->opcodes];
     809#endif
    747810                        break;
    748811
     
    758821        ) {
    759822            xc_gc_op_array_t gc_op_array;
     823#ifdef ZEND_ENGINE_2
    760824            gc_op_array.num_args = gc_arg_info ? dst->num_args : 0;
    761825            gc_op_array.arg_info = gc_arg_info ? dst->arg_info : NULL;
     826#endif
    762827            gc_op_array.opcodes  = gc_opcodes ? dst->opcodes : NULL;
    763828#ifdef ZEND_ENGINE_2_4
     
    776841    PROCESS(zend_uchar, type)
    777842    PROC_ZSTRING(, function_name)
     843#ifdef ZEND_ENGINE_2
    778844    PROCESS(zend_uint, fn_flags)
    779845    STRUCT_ARRAY(zend_uint, num_args, zend_arg_info, arg_info)
     
    783849    PROCESS(zend_bool, pass_rest_by_reference)
    784850#   endif
     851#else
     852    if (src->arg_types) {
     853        ALLOC(dst->arg_types, zend_uchar, src->arg_types[0] + 1)
     854        IFCOPY(`memcpy(dst->arg_types, src->arg_types, sizeof(src->arg_types[0]) * (src->arg_types[0]+1));')
     855        IFDASM(`do {
     856            int i;
     857            zval *zv;
     858            ALLOC_INIT_ZVAL(zv);
     859            array_init(zv);
     860            for (i = 0; i < src->arg_types[0]; i ++) {
     861                add_next_index_long(zv, src->arg_types[i + 1]);
     862            }
     863            add_assoc_zval_ex(dst, ZEND_STRS("arg_types"), zv);
     864        } while (0);')
     865        DONE(arg_types)
     866    }
     867    else {
     868        COPYNULL(arg_types)
     869    }
     870#endif
    785871#ifndef ZEND_ENGINE_2_4
    786872    PROCESS(unsigned char, return_reference)
     
    833919    PROCESS(zend_uint, current_brk_cont)
    834920#endif
    835 
     921#ifndef ZEND_ENGINE_2
     922    PROCESS(zend_bool, uses_globals)
     923#endif
     924
     925#ifdef ZEND_ENGINE_2
    836926    STRUCT_ARRAY(int, last_try_catch, zend_try_catch_element, try_catch_array)
    837927    PROCESS(int, last_try_catch)
     928#endif
    838929#ifdef ZEND_ENGINE_2_5
    839930    PROCESS(zend_bool, has_finally_block)
     
    866957    ')
    867958#endif
     959#ifdef ZEND_ENGINE_2
    868960    PROCESS(zend_uint, line_start)
    869961    PROCESS(zend_uint, line_end)
    870962    PROCESS(int, doc_comment_len)
    871963    PROC_ZSTRING_L(, doc_comment, doc_comment_len)
     964#endif
    872965#ifdef ZEND_COMPILE_DELAYED_BINDING
    873966    PROCESS(zend_uint, early_binding);
     
    886979    IFRESTORE(`xc_fix_op_array_info(processor->entry_php_src, processor->php_src, dst, shallow_copy, op_array_info TSRMLS_CC);')
    887980
     981#ifdef ZEND_ENGINE_2
    888982    dnl mark it as -1 on store, and lookup parent on restore
    889983    IFSTORE(`dst->prototype = (processor->active_class_entry_src && src->prototype) ? (zend_function *) -1 : NULL;', `
     
    9141008    DONE(prototype)
    9151009
     1010#endif
     1011
     1012#ifdef ZEND_ENGINE_2
    9161013    PROC_CLASS_ENTRY_P(scope)
    9171014    IFCOPY(`
     
    9201017        }
    9211018    ')
     1019#endif
    9221020
    9231021    IFRESTORE(`
     
    10041102        processor->active_op_array_index = 0;
    10051103    ')
    1006     STRUCT_P(zend_class_entry, class_entry)
     1104#ifdef ZEND_ENGINE_2
     1105    STRUCT_P(zend_class_entry, cest)
     1106#else
     1107    STRUCT(zend_class_entry, cest)
     1108#endif
    10071109#ifndef ZEND_COMPILE_DELAYED_BINDING
    10081110    PROCESS(int, oplineno)
Note: See TracChangeset for help on using the changeset viewer.