source: trunk/processor/processor.m4 @ 1487

Last change on this file since 1487 was 1487, checked in by moo, 2 months ago

PHP_5_6: finish support for zend_ast

  • Property svn:eol-style set to native
File size: 33.8 KB
Line 
1dnl ================
2/* {{{ Pre-declare */
3DECL_STRUCT_P_FUNC(`zval')
4DECL_STRUCT_P_FUNC(`zval_ptr')
5DECL_STRUCT_P_FUNC(`zval_ptr_nullable')
6DECL_STRUCT_P_FUNC(`zend_op_array')
7DECL_STRUCT_P_FUNC(`zend_class_entry')
8#ifdef HAVE_XCACHE_CONSTANT
9DECL_STRUCT_P_FUNC(`zend_constant')
10#endif
11DECL_STRUCT_P_FUNC(`zend_function')
12DECL_STRUCT_P_FUNC(`xc_entry_var_t')
13DECL_STRUCT_P_FUNC(`xc_entry_php_t')
14#ifdef ZEND_ENGINE_2
15DECL_STRUCT_P_FUNC(`zend_property_info')
16#endif
17/* }}} */
18dnl ====================================================
19#ifdef IS_CV
20DEF_STRUCT_P_FUNC(`zend_compiled_variable', , `dnl {{{
21    PROCESS(int, name_len)
22    PROC_ZSTRING_L(, name, name_len)
23    PROCESS(ulong, hash_value)
24')
25dnl }}}
26#endif
27DEF_STRUCT_P_FUNC(`zend_uint', , `dnl {{{
28    IFCOPY(`DST()[0] = SRC()[0];')
29    IFDPRINT(`
30        INDENT()
31        fprintf(stderr, "%u\n", SRC()[0]);
32    ')
33    DONE_SIZE(sizeof(SRC()[0]))
34')
35dnl }}}
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
48DEF_STRUCT_P_FUNC(`zend_try_catch_element', , `dnl {{{
49    PROCESS(zend_uint, try_op)
50    PROCESS(zend_uint, catch_op)
51#ifdef ZEND_ENGINE_2_5
52    PROCESS(zend_uint, finally_op)
53    PROCESS(zend_uint, finally_end)
54#endif
55')
56dnl }}}
57#endif
58DEF_STRUCT_P_FUNC(`zend_brk_cont_element', , `dnl {{{
59#ifdef ZEND_ENGINE_2_2
60    PROCESS(int, start)
61#endif
62    PROCESS(int, cont)
63    PROCESS(int, brk)
64    PROCESS(int, parent)
65')
66dnl }}}
67DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr',           `zval_ptr')
68DEF_HASH_TABLE_FUNC(`HashTable_zend_function',      `zend_function')
69#ifdef ZEND_ENGINE_2
70DEF_HASH_TABLE_FUNC(`HashTable_zend_property_info', `zend_property_info')
71#endif
72#ifdef IS_CONSTANT_AST
73define(`ZEND_AST_HELPER', `dnl {{{
74{
75    IFCALCCOPY(`
76        size_t zend_ast_size = ($1->kind == ZEND_CONST)
77         ? sizeof(zend_ast) + sizeof(zval)
78         : sizeof(zend_ast) + sizeof(zend_ast *) * ($1->children - 1);
79    ')
80
81    pushdef(`ALLOC_SIZE_HELPER', `zend_ast_size')
82    $2
83    popdef(`ALLOC_SIZE_HELPER')
84}
85')
86dnl }}}
87DEF_STRUCT_P_FUNC(`zend_ast', , `dnl {{{
88        zend_ushort i;
89        PROCESS(zend_ushort, kind)
90        PROCESS(zend_ushort, children)
91        DONE(u)
92        DISABLECHECK(`
93            if (SRC()->kind == ZEND_CONST) {
94                assert(SRC()->u.val);
95                IFCOPY(`
96                    DST()->u.val = (zval *) (DST() + 1);
97                    memcpy(DST()->u.val, SRC()->u.val, sizeof(zval));
98                ')
99                STRUCT_P_EX(zval, DST()->u.val, SRC()->u.val, `', `', ` ')
100                RELOCATE_EX(zval, DST()->u.val)
101            }
102            else {
103                for (i = 0; i < SRC()->children; ++i) {
104                    zend_ast *src_ast = (&SRC()->u.child)[i];
105                    if (src_ast) {
106                        ZEND_AST_HELPER(`src_ast', `
107                            ALLOC(`(&DST()->u.child)[i]', zend_ast)
108                            STRUCT_P_EX(zend_ast, (&DST()->u.child)[i], src_ast, `[i]', `', ` ')
109                        ')
110                        RELOCATE_EX(zend_ast, (&DST()->u.child)[i])
111                    }
112                    else {
113                        COPYNULL_EX(`(&DST()->u.child)[i]')
114                    }
115                }
116            }
117        ')
118')
119dnl }}}
120#endif
121DEF_STRUCT_P_FUNC(`zval', , `dnl {{{
122    IFDASM(`do {
123        zval_dtor(DST());
124        *DST() = *SRC();
125        zval_copy_ctor(DST());
126        Z_SET_REFCOUNT(*DST(), 1);
127        DONE(value)
128        DONE(type)
129#ifdef ZEND_ENGINE_2_3
130        DONE(is_ref__gc)
131        DONE(refcount__gc)
132#else
133        DONE(is_ref)
134        DONE(refcount)
135#endif
136    } while(0);
137    ', `
138        dnl IFDASM else
139        /* Variable information */
140dnl {{{ zvalue_value
141        DISABLECHECK(`
142        switch ((Z_TYPE_P(SRC()) & IS_CONSTANT_TYPE_MASK)) {
143            case IS_LONG:
144            case IS_RESOURCE:
145            case IS_BOOL:
146                PROCESS(long, value.lval)
147                break;
148            case IS_DOUBLE:
149                PROCESS(double, value.dval)
150                break;
151            case IS_NULL:
152                IFDPRINT(`INDENT()`'fprintf(stderr, "\tNULL\n");')
153                break;
154
155            case IS_CONSTANT:
156#ifdef IS_UNICODE
157                if (UG(unicode)) {
158                    goto proc_unicode;
159                }
160#endif
161            case IS_STRING:
162#ifdef FLAG_IS_BC
163            case FLAG_IS_BC:
164#endif
165                PROCESS(int, value.str.len)
166                PROC_STRING_L(value.str.val, value.str.len)
167                break;
168#ifdef IS_UNICODE
169            case IS_UNICODE:
170proc_unicode:
171                PROCESS(int32_t, value.uni.len)
172                PROC_ZSTRING_L(1, value.uni.val, value.uni.len)
173                break;
174#endif
175
176            case IS_ARRAY:
177#ifdef IS_CONSTANT_ARRAY
178            case IS_CONSTANT_ARRAY:
179#endif
180                assert(SRC()->value.ht);
181                STRUCT_P(HashTable, value.ht, HashTable_zval_ptr)
182                break;
183
184#ifdef IS_CONSTANT_AST
185            case IS_CONSTANT_AST:
186                assert(SRC()->value.ast);
187                ZEND_AST_HELPER(`SRC()->value.ast', `STRUCT_P(zend_ast, value.ast)')
188                break;
189#endif
190
191            case IS_OBJECT:
192                IFNOTMEMCPY(`IFCOPY(`memcpy(DST(), SRC(), sizeof(SRC()[0]));')')
193                dnl STRUCT(value.obj)
194#ifndef ZEND_ENGINE_2
195                STRUCT_P(zend_class_entry, value.obj.ce)
196                STRUCT_P(HashTable, value.obj.properties, HashTable_zval_ptr)
197#endif
198                break;
199
200            default:
201                assert(0);
202        }
203        ')
204dnl }}}
205        DONE(value)
206        PROCESS(xc_zval_type_t, type)
207#ifdef ZEND_ENGINE_2_3
208        PROCESS(zend_uchar, is_ref__gc)
209#else
210        PROCESS(zend_uchar, is_ref)
211#endif
212
213#ifdef ZEND_ENGINE_2_3
214        PROCESS(zend_uint, refcount__gc)
215#elif defined(ZEND_ENGINE_2)
216        PROCESS(zend_uint, refcount)
217#else
218        PROCESS(zend_ushort, refcount)
219#endif
220    ')dnl IFDASM
221')
222dnl }}}
223DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{
224    IFDASM(`
225        pushdefFUNC_NAME(`zval')
226        FUNC_NAME (dasm, DST(), SRC()[0] TSRMLS_CC);
227        popdef(`FUNC_NAME')
228    ', `
229        do {
230            IFCALCCOPY(`
231                if (processor->handle_reference) {
232                    zval_ptr *ppzv;
233                    if (zend_hash_find(&processor->zvalptrs, (char *) &SRC()[0], sizeof(SRC()[0]), (void **) &ppzv) == SUCCESS) {
234                        IFCOPY(`
235                            DST()[0] = *ppzv;
236                            /* *DST() is updated */
237                            dnl fprintf(stderr, "*DST() is set to %p, PROCESSOR_TYPE is_shm %d\n", DST()[0], xc_is_shm(DST()[0]));
238                        ')
239                        IFCALCSTORE(`processor->have_references = 1;')
240                        IFSTORE(`assert(xc_is_shm(DST()[0]));')
241                        IFRESTORE(`assert(!xc_is_shm(DST()[0]));')
242                        break;
243                    }
244                }
245            ')
246           
247            ALLOC(DST()[0], zval)
248            IFCALCCOPY(`
249                if (processor->handle_reference) {
250                    IFCALC(`
251                        /* make dummy */
252                        zval_ptr pzv = (zval_ptr)-1;
253                    ', `
254                        zval_ptr pzv = DST()[0];
255                        RELOCATE_EX(zval, pzv)
256                    ')
257                    if (zend_hash_add(&processor->zvalptrs, (char *) &SRC()[0], sizeof(SRC()[0]), (void *) &pzv, sizeof(pzv), NULL) == SUCCESS) { /* first add, go on */
258                        dnl fprintf(stderr, "mark[%p] = %p\n", SRC()[0], pzv);
259                    }
260                    else {
261                        assert(0);
262                    }
263                }
264            ')
265            IFCOPY(`
266                dnl fprintf(stderr, "copy from %p to %p\n", SRC()[0], DST()[0]);
267            ')
268            IFDPRINT(`INDENT()`'fprintf(stderr, "[%p] ", (void *) SRC()[0]);')
269            STRUCT_P_EX(zval, DST()[0], SRC()[0], `[0]', `', ` ')
270            RELOCATE_EX(zval, DST()[0])
271        } while (0);
272    ')
273    DONE_SIZE(sizeof(zval_ptr))
274')
275dnl }}}
276DEF_STRUCT_P_FUNC(`zval_ptr_nullable', , `dnl {{{
277    if (SRC()[0]) {
278        pushdef(`DASM_STRUCT_DIRECT')
279        STRUCT_P_EX(zval_ptr, DST(), SRC(), `', `', ` ')
280        popdef(`DASM_STRUCT_DIRECT')
281    }
282    else {
283        IFCOPY(`COPYNULL_EX(DST()[0], SRC())')
284    }
285    DONE_SIZE(sizeof(zval_ptr_nullable))
286')
287dnl }}}
288#ifdef ZEND_ENGINE_2
289DEF_STRUCT_P_FUNC(`zend_arg_info', , `dnl {{{
290    PROCESS(zend_uint, name_len)
291    PROC_ZSTRING_L(, name, name_len)
292    PROCESS(zend_uint, class_name_len)
293    PROC_ZSTRING_L(, class_name, class_name_len)
294#ifdef ZEND_ENGINE_2_4
295    PROCESS(zend_uchar, type_hint)
296#elif defined(ZEND_ENGINE_2_1)
297    PROCESS(zend_bool, array_type_hint)
298#endif
299#ifdef ZEND_ENGINE_2_6
300    PROCESS(zend_uchar, pass_by_reference)
301#endif
302    PROCESS(zend_bool, allow_null)
303
304#ifdef ZEND_ENGINE_2_6
305    PROCESS(zend_bool, is_variadic)
306#else
307    PROCESS(zend_bool, pass_by_reference)
308#endif
309
310#ifndef ZEND_ENGINE_2_4
311    PROCESS(zend_bool, return_reference)
312    PROCESS(int, required_num_args)
313#endif
314')
315dnl }}}
316#endif
317#ifdef HAVE_XCACHE_CONSTANT
318DEF_STRUCT_P_FUNC(`zend_constant', , `dnl {{{
319    STRUCT(zval, value)
320    PROCESS(int, flags)
321    PROCESS(uint, name_len)
322    pushdef(`estrndup', `zend_strndup')
323    PROC_ZSTRING_N(, name, name_len)
324    popdef(`estrndup')
325    PROCESS(int, module_number)
326')
327dnl }}}
328#endif
329DEF_STRUCT_P_FUNC(`zend_function', , `dnl {{{
330    DISABLECHECK(`
331    switch (SRC(`type')) {
332    case ZEND_INTERNAL_FUNCTION:
333    case ZEND_OVERLOADED_FUNCTION:
334        IFNOTMEMCPY(`IFCOPY(`memcpy(DST(), SRC(), sizeof(SRC()[0]));')')
335        break;
336
337    case ZEND_USER_FUNCTION:
338    case ZEND_EVAL_CODE:
339        DONE(type)
340        STRUCT(zend_op_array, op_array)
341        break;
342
343    default:
344        assert(0);
345    }
346    ')
347    DONE_SIZE(sizeof(SRC()[0]))
348')
349dnl }}}
350#ifdef ZEND_ENGINE_2
351DEF_STRUCT_P_FUNC(`zend_property_info', , `dnl {{{
352    PROCESS(zend_uint, flags)
353    PROCESS(int, name_length)
354    PROC_ZSTRING_L(, name, name_length)
355    PROCESS(ulong, h)
356#ifdef ZEND_ENGINE_2_4
357    PROCESS(int, offset)
358#endif
359#ifdef ZEND_ENGINE_2_1
360    PROCESS(int, doc_comment_len)
361    PROC_ZSTRING_L(, doc_comment, doc_comment_len)
362#endif
363    dnl isnt in php6 yet
364#if defined(ZEND_ENGINE_2_2)
365    PROC_CLASS_ENTRY_P(ce)
366#endif
367')
368dnl }}}
369#endif
370#ifdef ZEND_ENGINE_2_4
371DEF_STRUCT_P_FUNC(`zend_trait_method_reference', , `dnl {{{
372    PROCESS(unsigned int, mname_len)
373    PROC_STRING_L(method_name, mname_len)
374    COPYNULL(ce)
375    PROCESS(unsigned int, cname_len)
376    PROC_STRING_L(class_name, cname_len)
377')
378dnl }}}
379DEF_STRUCT_P_FUNC(`zend_trait_alias', , `dnl {{{
380    STRUCT_P(zend_trait_method_reference, trait_method)
381    PROCESS(unsigned int, alias_len)
382    PROC_STRING_L(alias, alias_len)
383    PROCESS(zend_uint, modifiers)
384#ifndef ZEND_ENGINE_2_5
385    COPYNULL(function)
386#endif
387')
388dnl }}}
389DEF_STRUCT_P_FUNC(`zend_trait_precedence', , `dnl {{{
390    STRUCT_P(zend_trait_method_reference, trait_method)
391    PROCESS_ARRAY(, xc_ztstring, exclude_from_classes, zend_class_entry*)
392#ifndef ZEND_ENGINE_2_5
393    COPYNULL(function)
394#endif
395')
396dnl }}}
397DEF_STRUCT_P_FUNC(`zend_trait_alias_ptr', , `dnl {{{
398    IFDASM(`
399        pushdefFUNC_NAME(`zend_trait_alias')
400        FUNC_NAME (dasm, DST(), SRC()[0] TSRMLS_CC);
401        popdef(`FUNC_NAME')
402    ', `
403        ALLOC(DST()[0], zend_trait_alias)
404        STRUCT_P_EX(zend_trait_alias, DST()[0], SRC()[0], `[0]', `', ` ')
405        RELOCATE_EX(zend_trait_alias, DST()[0])
406    ')
407    DONE_SIZE(sizeof(zend_trait_alias))
408')
409dnl }}}
410DEF_STRUCT_P_FUNC(`zend_trait_precedence_ptr', , `dnl {{{
411    IFDASM(`
412        pushdefFUNC_NAME(`zend_trait_precedence')
413        FUNC_NAME (dasm, DST(), SRC()[0] TSRMLS_CC);
414        popdef(`FUNC_NAME')
415    ', `
416        ALLOC(DST()[0], zend_trait_precedence)
417        STRUCT_P_EX(zend_trait_precedence, DST()[0], SRC()[0], `[0]', `', ` ')
418        RELOCATE_EX(zend_trait_precedence, DST()[0])
419    ')
420    DONE_SIZE(sizeof(zend_trait_precedence))
421')
422dnl }}}
423#endif
424DEF_STRUCT_P_FUNC(`zend_class_entry', , `dnl {{{
425    IFCALCCOPY(`
426        processor->active_class_entry_src = SRC();
427        IFCOPY(`processor->active_class_entry_dst = DST();')
428    ')
429    PROCESS(char, type)
430    PROCESS(zend_uint, name_length)
431    PROC_ZSTRING_L(, name, name_length)
432    IFRESTORE(`
433#ifndef ZEND_ENGINE_2
434        /* just copy parent and resolve on install_class */
435        COPYPOINTER(parent)
436#else
437        PROC_CLASS_ENTRY_P(parent)
438#endif
439    ', `
440        PROC_CLASS_ENTRY_P(parent)
441    ')
442#ifdef ZEND_ENGINE_2
443    PROCESS(int, refcount)
444#else
445    STRUCT_P(int, refcount)
446#endif
447#ifndef ZEND_ENGINE_2_4
448    PROCESS(zend_bool, constants_updated)
449#endif
450#ifdef ZEND_ENGINE_2
451    PROCESS(zend_uint, ce_flags)
452#endif
453
454#ifdef ZEND_ENGINE_2
455    STRUCT(HashTable, properties_info, HashTable_zend_property_info)
456#endif
457
458#ifdef ZEND_ENGINE_2_4
459    STRUCT_ARRAY(int, default_properties_count, zval_ptr_nullable, default_properties_table)
460    PROCESS(int, default_properties_count)
461    STRUCT_ARRAY(int, default_static_members_count, zval_ptr_nullable, default_static_members_table)
462    PROCESS(int, default_static_members_count)
463    IFCOPY(`DST(`static_members_table') = DST(`default_static_members_table');')
464    DONE(static_members_table)
465#else
466    IFCOPY(`DST(`builtin_functions') = SRC(`builtin_functions');')
467    DONE(builtin_functions)
468    STRUCT(HashTable, default_properties, HashTable_zval_ptr)
469#   ifdef ZEND_ENGINE_2_1
470    STRUCT(HashTable, default_static_members, HashTable_zval_ptr)
471    IFCOPY(`DST(`static_members') = &DST(`default_static_members');')
472    DONE(static_members)
473#   elif defined(ZEND_ENGINE_2)
474    STRUCT_P(HashTable, static_members, HashTable_zval_ptr)
475#   endif
476#endif /* ZEND_ENGINE_2_4 */
477
478#ifdef ZEND_ENGINE_2
479    STRUCT(HashTable, constants_table, HashTable_zval_ptr)
480
481#ifdef ZEND_ENGINE_2_2
482    dnl runtime binding: ADD_INTERFACE will deal with it
483    COPYNULL(`interfaces')
484    COPYZERO(`num_interfaces')
485
486#   ifdef ZEND_ENGINE_2_4
487    dnl runtime binding: ADD_TRAIT will deal with it
488    COPYNULL(traits)
489    COPYZERO(num_traits)
490    STRUCT_ARRAY(, , zend_trait_alias_ptr, trait_aliases)
491    STRUCT_ARRAY(, , zend_trait_precedence_ptr, trait_precedences)
492#   endif
493#else
494    IFRESTORE(`
495        if (SRC(`num_interfaces')) {
496            CALLOC(DST(`interfaces'), zend_class_entry*, SRC(`num_interfaces'))
497            DONE(`interfaces')
498        }
499        else {
500            COPYNULL(`interfaces')
501        }
502    ', `
503        DONE(`interfaces')
504    ')
505    PROCESS(zend_uint, num_interfaces)
506#endif
507
508#   ifdef ZEND_ENGINE_2_4
509    DISABLECHECK(`
510    IFRESTORE(`DST(`info.user.filename') = processor->entry_php_src->filepath;', `PROC_STRING(info.user.filename)')
511    PROCESS(zend_uint, info.user.line_start)
512    PROCESS(zend_uint, info.user.line_end)
513    PROCESS(zend_uint, info.user.doc_comment_len)
514    PROC_ZSTRING_L(, info.user.doc_comment, info.user.doc_comment_len)
515    ')
516    DONE(info)
517#   else
518    IFRESTORE(`DST(`filename') = processor->entry_php_src->filepath;DONE(filename)', `PROC_STRING(filename)')
519    PROCESS(zend_uint, line_start)
520    PROCESS(zend_uint, line_end)
521    PROCESS(zend_uint, doc_comment_len)
522    PROC_ZSTRING_L(, doc_comment, doc_comment_len)
523#   endif
524
525    /* # NOT DONE */
526#   ifdef ZEND_ENGINE_2_1
527    PROCESS_CTEXTPOINTER(serialize_func)
528    PROCESS_CTEXTPOINTER(unserialize_func)
529#   endif
530    PROCESS_CTEXTPOINTER(iterator_funcs)
531    PROCESS_CTEXTPOINTER(create_object)
532    PROCESS_CTEXTPOINTER(get_iterator)
533    PROCESS_CTEXTPOINTER(interface_gets_implemented)
534#   ifdef ZEND_ENGINE_2_3
535    PROCESS_CTEXTPOINTER(get_static_method)
536#   endif
537#   ifdef ZEND_ENGINE_2_1
538    PROCESS_CTEXTPOINTER(serialize)
539    PROCESS_CTEXTPOINTER(unserialize)
540#   endif
541    /* deal with it inside xc_fix_method */
542    SETNULL(constructor)
543    PROCESS_CTEXTPOINTER(destructor)
544    PROCESS_CTEXTPOINTER(clone)
545    PROCESS_CTEXTPOINTER(__get)
546    PROCESS_CTEXTPOINTER(__set)
547/* should be >5.1 */
548#   ifdef ZEND_ENGINE_2_1
549    PROCESS_CTEXTPOINTER(__unset)
550    PROCESS_CTEXTPOINTER(__isset)
551#   endif
552# if defined(ZEND_ENGINE_2_2) || PHP_MAJOR_VERSION >= 6
553    PROCESS_CTEXTPOINTER(__tostring)
554# endif
555# if defined(ZEND_ENGINE_2_6)
556    PROCESS_CTEXTPOINTER(__debugInfo)
557# endif
558    PROCESS_CTEXTPOINTER(__call)
559#   ifdef ZEND_CALLSTATIC_FUNC_NAME
560    PROCESS_CTEXTPOINTER(__callstatic)
561#   endif
562#   ifndef ZEND_ENGINE_2_4
563    /* # NOT DONE */
564    PROCESS_CTEXTPOINTER(module)
565#   endif
566#else /* ZEND_ENGINE_2 */
567    PROCESS_CTEXTPOINTER(handle_function_call)
568    PROCESS_CTEXTPOINTER(handle_property_get)
569    PROCESS_CTEXTPOINTER(handle_property_set)
570#endif
571    dnl must do after SETNULL(constructor) and DST()->parent
572    STRUCT(HashTable, function_table, HashTable_zend_function)
573    IFRESTORE(`DST(`function_table.pDestructor') = ZEND_FUNCTION_DTOR;')
574    IFCALCCOPY(`
575        processor->active_class_entry_src = NULL;
576        IFCOPY(`processor->active_class_entry_dst = NULL;')
577    ')
578')
579dnl }}}
580#ifdef ZEND_ENGINE_2_4
581undefine(`UNION_znode_op')
582define(`UNION_znode_op', `dnl {{{
583#ifndef NDEBUG
584    switch ((SRC(`$1_type') ifelse($1, `result', & ~EXT_TYPE_UNUSED))) {
585    case IS_CONST:
586    case IS_VAR:
587    case IS_CV:
588    case IS_TMP_VAR:
589    case IS_UNUSED:
590        break;
591
592    default:
593        assert(0);
594    }
595#endif
596
597    dnl dirty dispatch
598    DISABLECHECK(`
599    switch ((SRC(`$1_type') ifelse($1, `result', & ~EXT_TYPE_UNUSED))) {
600        case IS_CONST:
601            ifelse($1, `result', `
602                PROCESS(zend_uint, $1.constant)
603            ', `
604                IFDASM(`{
605                    zval *zv;
606                    ALLOC_INIT_ZVAL(zv);
607                    *zv = dasm->active_op_array_src->literals[SRC(`$1.constant')].constant;
608                    zval_copy_ctor(zv);
609                    add_assoc_zval_ex(DST(), XCACHE_STRS("$1.constant"), zv);
610                }
611                ', `
612                    IFCOPY(`
613                        DST(`$1') = SRC(`$1');
614                    ', `
615                        PROCESS(zend_uint, $1.constant)
616                    ')
617                ')
618            ')
619            break;
620        IFCOPY(`
621            IFNOTMEMCPY(`
622                default:
623                    DST(`$1') = SRC(`$1');
624            ')
625        ', `
626        case IS_VAR:
627        case IS_TMP_VAR:
628        case IS_CV:
629            PROCESS(zend_uint, $1.var)
630            break;
631        case IS_UNUSED:
632            IFDASM(`PROCESS(zend_uint, $1.var)')
633            PROCESS(zend_uint, $1.opline_num)
634            break;
635        ')
636    }
637    ')
638    DONE($1)
639')
640dnl }}}
641#else
642DEF_STRUCT_P_FUNC(`znode', , `dnl {{{
643    PROCESS(xc_op_type, op_type)
644
645#ifdef IS_CV
646#   define XCACHE_IS_CV IS_CV
647#else
648/* compatible with zend optimizer */
649#   define XCACHE_IS_CV 16
650#endif
651    assert(SRC(`op_type') == IS_CONST ||
652        SRC(`op_type') == IS_VAR ||
653        SRC(`op_type') == XCACHE_IS_CV ||
654        SRC(`op_type') == IS_TMP_VAR ||
655        SRC(`op_type') == IS_UNUSED);
656    dnl dirty dispatch
657    DISABLECHECK(`
658    switch (SRC(`op_type')) {
659        case IS_CONST:
660            STRUCT(zval, u.constant)
661            break;
662        IFCOPY(`
663            IFNOTMEMCPY(`
664                default:
665                    DST(`u') = SRC(`u');
666            ')
667        ', `
668        case IS_VAR:
669        case IS_TMP_VAR:
670        case XCACHE_IS_CV:
671            PROCESS(zend_uint, u.var)
672            PROCESS(zend_uint, u.EA.type)
673            break;
674        case IS_UNUSED:
675            IFDASM(`PROCESS(zend_uint, u.var)')
676            PROCESS(zend_uint, u.opline_num)
677#ifndef ZEND_ENGINE_2
678            PROCESS(zend_uint, u.fetch_type)
679#endif
680            PROCESS(zend_uint, u.EA.type)
681            break;
682        ')
683    }
684    ')
685    DONE(u)
686#if 0
687    DONE(EA)
688#endif
689#undef XCACHE_IS_CV
690')
691dnl }}}
692#endif
693DEF_STRUCT_P_FUNC(`zend_op', , `dnl {{{
694    PROCESS(xc_opcode, opcode)
695#ifdef ZEND_ENGINE_2_4
696    IFRESTORE(`', `
697    switch (SRC(`opcode')) {
698    case ZEND_BIND_TRAITS:
699        ((zend_op *) SRC())->op2_type = IS_UNUSED;
700        break;
701    }
702    ')
703    UNION_znode_op(result)
704    UNION_znode_op(op1)
705    UNION_znode_op(op2)
706#else
707    STRUCT(znode, result)
708    STRUCT(znode, op1)
709    STRUCT(znode, op2)
710#endif
711    PROCESS(ulong, extended_value)
712    PROCESS(uint, lineno)
713#ifdef ZEND_ENGINE_2_4
714    PROCESS(zend_uchar, op1_type)
715    PROCESS(zend_uchar, op2_type)
716    PROCESS(zend_uchar, result_type)
717#endif
718    IFCOPY(`
719        assert(processor->active_op_array_src);
720        assert(processor->active_op_array_dst);
721#ifdef ZEND_ENGINE_2_4
722        pushdef(`UNION_znode_op_literal', `
723            if (SRC(`$1_type') == IS_CONST) {
724                DST(`$1').constant = SRC(`$1.literal') - processor->active_op_array_src->literals;
725                DST(`$1').literal = &processor->active_op_array_dst->literals[DST(`$1').constant];
726            }
727        ')
728        UNION_znode_op_literal(op1)
729        UNION_znode_op_literal(op2)
730#endif
731        popdef(`UNION_znode_op_literal')
732#ifdef ZEND_ENGINE_2
733        switch (SRC(`opcode')) {
734#   ifdef ZEND_GOTO
735            case ZEND_GOTO:
736#   endif
737            case ZEND_JMP:
738#   ifdef ZEND_FAST_CALL
739            case ZEND_FAST_CALL:
740#   endif
741                assert(Z_OP(SRC(`op1')).jmp_addr >= processor->active_op_array_src->opcodes);
742                assert(Z_OP(SRC(`op1')).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
743                Z_OP(DST(`op1')).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(SRC(`op1')).jmp_addr - processor->active_op_array_src->opcodes);
744                assert(Z_OP(DST(`op1')).jmp_addr >= processor->active_op_array_dst->opcodes);
745                assert(Z_OP(DST(`op1')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
746                RELOCATE_EX(zend_op, `Z_OP(DST(`op1')).jmp_addr')
747                break;
748
749            case ZEND_JMPZ:
750            case ZEND_JMPNZ:
751            case ZEND_JMPZ_EX:
752            case ZEND_JMPNZ_EX:
753#   ifdef ZEND_JMP_SET
754            case ZEND_JMP_SET:
755#   endif
756#   ifdef ZEND_JMP_SET_VAR
757            case ZEND_JMP_SET_VAR:
758#   endif
759                assert(Z_OP(SRC(`op2')).jmp_addr >= processor->active_op_array_src->opcodes);
760                assert(Z_OP(SRC(`op2')).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
761                Z_OP(DST(`op2')).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(SRC(`op2')).jmp_addr - processor->active_op_array_src->opcodes);
762                assert(Z_OP(DST(`op2')).jmp_addr >= processor->active_op_array_dst->opcodes);
763                assert(Z_OP(DST(`op2')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
764                RELOCATE_EX(zend_op, `Z_OP(DST(`op2')).jmp_addr')
765                break;
766
767            default:
768                break;
769        }
770#   endif
771    ')
772#ifdef ZEND_ENGINE_2
773    PROCESS(opcode_handler_t, handler)
774#endif
775')
776dnl }}}
777#ifdef ZEND_ENGINE_2_4
778DEF_STRUCT_P_FUNC(`zend_literal', , `dnl {{{
779    STRUCT(zval, constant)
780    PROCESS(zend_ulong, hash_value)
781    PROCESS(zend_uint,  cache_slot)
782')
783dnl }}}
784#endif
785DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{
786    IFCOPY(`
787        processor->active_op_array_dst = DST();
788        processor->active_op_array_src = SRC();
789    ')
790    IFDASM(`
791        dasm->active_op_array_src = SRC();
792    ')
793    {
794    IFRESTORE(`
795    const xc_op_array_info_t *op_array_info = &processor->active_op_array_infos_src[processor->active_op_array_index++];
796    dnl shadow copy must NOT meet:
797    dnl readonly_protection=on
798    dnl main op_array && have early binding
799#ifdef ZEND_COMPILE_DELAYED_BINDING
800    zend_bool need_early_binding = 0;
801#else
802    zend_bool need_early_binding = processor->php_src->have_early_binding;
803#endif
804    zend_bool shallow_copy = !processor->readonly_protection && !(SRC() == processor->php_src->op_array && need_early_binding);
805    if (shallow_copy) {
806        zend_bool gc_arg_info = 0;
807        zend_bool gc_opcodes  = 0;
808#ifdef ZEND_ENGINE_2_4
809        zend_bool gc_literals = 0;
810#endif
811        /* really fast shallow copy */
812        memcpy(DST(), SRC(), sizeof(SRC()[0]));
813        DST(`refcount') = &XG(op_array_dummy_refcount_holder);
814        XG(op_array_dummy_refcount_holder) = ((zend_uint) -1) / 2;
815#ifdef ZEND_ACC_ALIAS
816        if ((processor->active_class_entry_src && (processor->active_class_entry_src->ce_flags & ZEND_ACC_TRAIT))) {
817            PROC_ZSTRING(, function_name)
818        }
819#endif
820        /* deep */
821        STRUCT_P(HashTable, static_variables, HashTable_zval_ptr)
822#ifdef ZEND_ENGINE_2
823        if (SRC(`arg_info')) {
824            gc_arg_info = 1;
825            STRUCT_ARRAY(zend_uint, num_args, zend_arg_info, arg_info)
826        }
827#endif
828        DST(`filename') = processor->entry_php_src->filepath;
829
830#ifdef ZEND_ENGINE_2_4
831        if (SRC(`literals') && op_array_info->literalinfo_cnt) {
832            gc_opcodes = 1;
833            gc_literals = 1;
834        }
835#else
836        if (op_array_info->oplineinfo_cnt) {
837            gc_opcodes = 1;
838        }
839#endif
840
841#ifdef ZEND_ENGINE_2_4
842        if (gc_literals) {
843            dnl used when copying opcodes
844            COPY_N_EX(last_literal, zend_literal, literals)
845        }
846#endif
847        if (gc_opcodes) {
848            zend_op *opline, *end;
849            COPY_N_EX(last, zend_op, opcodes)
850
851            for (opline = DST(`opcodes'), end = opline + SRC(`last'); opline < end; ++opline) {
852#ifdef ZEND_ENGINE_2_4
853                pushdef(`UNION_znode_op_literal', `
854                    if (opline->$1_type == IS_CONST) {
855                        opline->$1.literal = &DST(`literals[opline->$1.literal - SRC(`literals')]');
856                    }
857                ')
858                UNION_znode_op_literal(op1)
859                UNION_znode_op_literal(op2)
860                popdef(`UNION_znode_op_literal')
861#endif
862
863                switch (opline->opcode) {
864#ifdef ZEND_GOTO
865                    case ZEND_GOTO:
866#endif
867                    case ZEND_JMP:
868#ifdef ZEND_FAST_CALL
869                    case ZEND_FAST_CALL:
870#endif
871#ifdef ZEND_ENGINE_2
872                        Z_OP(opline->op1).jmp_addr = &DST(`opcodes[Z_OP(opline->op1).jmp_addr') - SRC(`opcodes')];
873#endif
874                        break;
875
876                    case ZEND_JMPZ:
877                    case ZEND_JMPNZ:
878                    case ZEND_JMPZ_EX:
879                    case ZEND_JMPNZ_EX:
880#ifdef ZEND_JMP_SET
881                    case ZEND_JMP_SET:
882#endif
883#ifdef ZEND_JMP_SET_VAR
884            case ZEND_JMP_SET_VAR:
885#endif
886#ifdef ZEND_ENGINE_2
887                        Z_OP(opline->op2).jmp_addr = &DST(`opcodes[Z_OP(opline->op2).jmp_addr') - SRC(`opcodes')];
888#endif
889                        break;
890
891                    default:
892                        break;
893                }
894            }
895        }
896        if (gc_arg_info || gc_opcodes
897#ifdef ZEND_ENGINE_2_4
898         || gc_literals
899#endif
900        ) {
901            xc_gc_op_array_t gc_op_array;
902#ifdef ZEND_ENGINE_2
903            gc_op_array.num_args = gc_arg_info ? DST(`num_args') : 0;
904            gc_op_array.arg_info = gc_arg_info ? DST(`arg_info') : NULL;
905#endif
906            gc_op_array.opcodes  = gc_opcodes ? DST(`opcodes') : NULL;
907#ifdef ZEND_ENGINE_2_4
908            gc_op_array.literals = gc_literals ? DST(`literals') : NULL;
909#endif
910            xc_gc_add_op_array(&gc_op_array TSRMLS_CC);
911        }
912        IFAUTOCHECK(`xc_autocheck_skip = 1;')
913    }
914    else
915    ')
916    do {
917    dnl RESTORE is done above!
918
919    /* Common elements */
920    PROCESS(zend_uchar, type)
921    PROC_ZSTRING(, function_name)
922#ifdef ZEND_ENGINE_2
923    PROCESS(zend_uint, fn_flags)
924    STRUCT_ARRAY(zend_uint, num_args, zend_arg_info, arg_info)
925    PROCESS(zend_uint, num_args)
926    PROCESS(zend_uint, required_num_args)
927#   ifndef ZEND_ENGINE_2_4
928    PROCESS(zend_bool, pass_rest_by_reference)
929#   endif
930#else
931    if (SRC(`arg_types')) {
932        ALLOC(`DST(`arg_types')', zend_uchar, SRC(`arg_types[0]') + 1)
933        IFCOPY(`memcpy(DST(`arg_types'), SRC(`arg_types'), sizeof(SRC(`arg_types[0]')) * (SRC(`arg_types[0]')+1));')
934        IFDASM(`do {
935            int i;
936            zval *zv;
937            ALLOC_INIT_ZVAL(zv);
938            array_init(zv);
939            for (i = 0; i < SRC(`arg_types[0]'); i ++) {
940                add_next_index_long(zv, SRC(`arg_types[i + 1]'));
941            }
942            add_assoc_zval_ex(DST(), ZEND_STRS("arg_types"), zv);
943        } while (0);')
944        DONE(arg_types)
945    }
946    else {
947        COPYNULL(arg_types)
948    }
949#endif
950#ifndef ZEND_ENGINE_2_4
951    PROCESS(unsigned char, return_reference)
952#endif
953    /* END of common elements */
954#ifdef IS_UNICODE
955    dnl SETNULL(u_twin)
956#endif
957
958    IFSTORE(`pushdef(`RELOCATE_EX')')
959    STRUCT_P(zend_uint, refcount)
960    IFSTORE(`
961        popdef(`RELOCATE_EX')
962        DST(`refcount[0]') = 1;
963        RELOCATE(zend_uint, refcount)
964    ')
965
966#ifdef ZEND_ENGINE_2_4
967    dnl used when copying opcodes
968    STRUCT_ARRAY(int, last_literal, zend_literal, literals)
969    PROCESS(int, last_literal)
970#endif
971
972    dnl uses literals
973    STRUCT_ARRAY(zend_uint, last, zend_op, opcodes)
974    PROCESS(zend_uint, last)
975#ifndef ZEND_ENGINE_2_4
976    IFCOPY(`DST(`size') = SRC(`last');DONE(size)', `PROCESS(zend_uint, size)')
977#endif
978
979#ifdef IS_CV
980    STRUCT_ARRAY(int, last_var, zend_compiled_variable, vars)
981    PROCESS(int, last_var)
982#   ifndef ZEND_ENGINE_2_4
983    IFCOPY(`DST(`size_var') = SRC(`last_var');DONE(size_var)', `PROCESS(zend_uint, size_var)')
984#   endif
985#else
986    dnl zend_cv.m4 is illegal to be made public, don not ask me for it
987    IFDASM(`
988        sinclude(__dir__`/zend_cv.m4')
989        ')
990#endif
991
992    PROCESS(zend_uint, T)
993
994#ifdef ZEND_ENGINE_2_5
995    PROCESS(zend_uint, nested_calls)
996    PROCESS(zend_uint, used_stack)
997#endif
998
999    STRUCT_ARRAY(last_brk_cont_t, last_brk_cont, zend_brk_cont_element, brk_cont_array)
1000    PROCESS(last_brk_cont_t, last_brk_cont)
1001#ifndef ZEND_ENGINE_2_4
1002    PROCESS(zend_uint, current_brk_cont)
1003#endif
1004#ifndef ZEND_ENGINE_2
1005    PROCESS(zend_bool, uses_globals)
1006#endif
1007
1008#ifdef ZEND_ENGINE_2
1009    STRUCT_ARRAY(int, last_try_catch, zend_try_catch_element, try_catch_array)
1010    PROCESS(int, last_try_catch)
1011#endif
1012#ifdef ZEND_ENGINE_2_5
1013    PROCESS(zend_bool, has_finally_block)
1014#endif
1015
1016    STRUCT_P(HashTable, static_variables, HashTable_zval_ptr)
1017
1018#ifndef ZEND_ENGINE_2_4
1019    COPYPOINTER(start_op)
1020    PROCESS(int, backpatch_count)
1021#endif
1022#ifdef ZEND_ENGINE_2_3
1023    PROCESS(zend_uint, this_var)
1024#endif
1025
1026#ifndef ZEND_ENGINE_2_4
1027    PROCESS(zend_bool, done_pass_two)
1028#endif
1029    /* 5.0 <= ver < 5.3 */
1030#if defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_3)
1031    PROCESS(zend_bool, uses_this)
1032#endif
1033
1034    IFRESTORE(`DST(`filename') = processor->entry_php_src->filepath;DONE(filename)', `PROC_STRING(filename)')
1035#ifdef IS_UNICODE
1036    IFRESTORE(`
1037        COPYPOINTER(script_encoding)
1038    ', `
1039        PROC_STRING(script_encoding)
1040    ')
1041#endif
1042#ifdef ZEND_ENGINE_2
1043    PROCESS(zend_uint, line_start)
1044    PROCESS(zend_uint, line_end)
1045    PROCESS(int, doc_comment_len)
1046    PROC_ZSTRING_L(, doc_comment, doc_comment_len)
1047#endif
1048#ifdef ZEND_COMPILE_DELAYED_BINDING
1049    PROCESS(zend_uint, early_binding);
1050#endif
1051
1052    /* reserved */
1053    DONE(reserved)
1054#if defined(HARDENING_PATCH) && HARDENING_PATCH
1055    PROCESS(zend_bool, created_by_eval)
1056#endif
1057#ifdef ZEND_ENGINE_2_4
1058    SETNULL(run_time_cache)
1059    PROCESS(int, last_cache_slot)
1060#endif
1061    } while (0);
1062    IFRESTORE(`xc_fix_op_array_info(processor->entry_php_src, processor->php_src, DST(), shallow_copy, op_array_info TSRMLS_CC);')
1063
1064#ifdef ZEND_ENGINE_2
1065    dnl mark it as -1 on store, and lookup parent on restore
1066    IFSTORE(`DST(`prototype') = (processor->active_class_entry_src && SRC(`prototype')) ? (zend_function *) -1 : NULL;', `
1067        IFRESTORE(`do {
1068            zend_function *parent;
1069            if (SRC(`prototype') != NULL
1070             && zend_u_hash_find(&(processor->active_class_entry_dst->parent->function_table),
1071                    UG(unicode) ? IS_UNICODE : IS_STRING,
1072                    SRC(`function_name'), xc_zstrlen(UG(unicode) ? IS_UNICODE : IS_STRING, SRC(`function_name')) + 1,
1073                    (void **) &parent) == SUCCESS) {
1074                /* see do_inherit_method_check() */
1075                if ((parent->common.fn_flags & ZEND_ACC_ABSTRACT)) {
1076                    DST(`prototype') = parent;
1077                } else if (!(parent->common.fn_flags & ZEND_ACC_CTOR) || (parent->common.prototype && (parent->common.prototype->common.scope->ce_flags & ZEND_ACC_INTERFACE))) {
1078                    /* ctors only have a prototype if it comes from an interface */
1079                    DST(`prototype') = parent->common.prototype ? parent->common.prototype : parent;
1080                }
1081                else {
1082                    DST(`prototype') = NULL;
1083                }
1084            }
1085            else {
1086                DST(`prototype') = NULL;
1087            }
1088        } while (0);
1089        ')
1090    ')
1091    DONE(prototype)
1092
1093#endif
1094
1095#ifdef ZEND_ENGINE_2
1096    PROC_CLASS_ENTRY_P(scope)
1097    IFCOPY(`
1098        if (SRC(`scope')) {
1099            xc_fix_method(processor, DST() TSRMLS_CC);
1100        }
1101    ')
1102#endif
1103
1104    IFRESTORE(`
1105        if (xc_have_op_array_ctor) {
1106            zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) xc_zend_extension_op_array_ctor_handler, DST() TSRMLS_CC);
1107        }
1108    ')
1109    }
1110    IFCOPY(`
1111        processor->active_op_array_dst = NULL;
1112        processor->active_op_array_src = NULL;
1113    ')
1114    IFDASM(`
1115        dasm->active_op_array_src = NULL;
1116    ')
1117')
1118dnl }}}
1119
1120#ifdef HAVE_XCACHE_CONSTANT
1121DEF_STRUCT_P_FUNC(`xc_constinfo_t', , `dnl {{{
1122    PROCESS(zend_uint, key_size)
1123#ifdef IS_UNICODE
1124    PROCESS(zend_uchar, type)
1125#endif
1126    IFRESTORE(`COPYPOINTER(key)', `
1127        PROC_ZSTRING_N(type, key, key_size)
1128    ')
1129    PROCESS(ulong, h)
1130    STRUCT(zend_constant, constant)
1131')
1132dnl }}}
1133#endif
1134IFRESTORE(`', `
1135DEF_STRUCT_P_FUNC(`xc_op_array_info_detail_t', , `dnl {{{
1136    PROCESS(zend_uint, index)
1137    PROCESS(zend_uint, info)
1138')
1139dnl }}}
1140DEF_STRUCT_P_FUNC(`xc_op_array_info_t', , `dnl {{{
1141#ifdef ZEND_ENGINE_2_4
1142    PROCESS(zend_uint, literalinfo_cnt)
1143    STRUCT_ARRAY(zend_uint, literalinfo_cnt, xc_op_array_info_detail_t, literalinfos)
1144#else
1145    PROCESS(zend_uint, oplineinfo_cnt)
1146    STRUCT_ARRAY(zend_uint, oplineinfo_cnt, xc_op_array_info_detail_t, oplineinfos)
1147#endif
1148')
1149dnl }}}
1150')
1151DEF_STRUCT_P_FUNC(`xc_funcinfo_t', , `dnl {{{
1152    PROCESS(zend_uint, key_size)
1153#ifdef IS_UNICODE
1154    PROCESS(zend_uchar, type)
1155#endif
1156    IFRESTORE(`COPYPOINTER(key)', `
1157        PROC_ZSTRING_N(type, key, key_size)
1158    ')
1159    PROCESS(ulong, h)
1160    IFRESTORE(`COPYPOINTER(op_array_info)', `
1161        STRUCT(xc_op_array_info_t, op_array_info)
1162    ')
1163    IFRESTORE(`
1164        processor->active_op_array_infos_src = &SRC(`op_array_info');
1165        processor->active_op_array_index = 0;
1166    ')
1167    STRUCT(zend_function, func)
1168')
1169dnl }}}
1170DEF_STRUCT_P_FUNC(`xc_classinfo_t', , `dnl {{{
1171    PROCESS(zend_uint, key_size)
1172#ifdef IS_UNICODE
1173    PROCESS(zend_uchar, type)
1174#endif
1175    IFRESTORE(`COPYPOINTER(key)', `
1176        PROC_ZSTRING_N(type, key, key_size)
1177    ')
1178    PROCESS(ulong, h)
1179    PROCESS(zend_uint, methodinfo_cnt)
1180    IFRESTORE(`COPYPOINTER(methodinfos)', `
1181        STRUCT_ARRAY(zend_uint, methodinfo_cnt, xc_op_array_info_t, methodinfos)
1182    ')
1183    IFRESTORE(`
1184        processor->active_op_array_infos_src = SRC(`methodinfos');
1185        processor->active_op_array_index = 0;
1186    ')
1187#ifdef ZEND_ENGINE_2
1188    STRUCT_P(zend_class_entry, cest)
1189#else
1190    STRUCT(zend_class_entry, cest)
1191#endif
1192#ifndef ZEND_COMPILE_DELAYED_BINDING
1193    PROCESS(int, oplineno)
1194#endif
1195')
1196dnl }}}
1197IFRESTORE(`', `
1198#ifdef ZEND_ENGINE_2_1
1199DEF_STRUCT_P_FUNC(`xc_autoglobal_t', , `dnl {{{
1200    PROCESS(zend_uint, key_len)
1201#ifdef IS_UNICODE
1202    PROCESS(zend_uchar, type)
1203#endif
1204    IFRESTORE(`COPYPOINTER(key)', `
1205        PROC_ZSTRING_L(type, key, key_len)
1206    ')
1207    PROCESS(ulong, h)
1208')
1209dnl }}}
1210#endif
1211')
1212IFRESTORE(`', `
1213#ifdef XCACHE_ERROR_CACHING
1214DEF_STRUCT_P_FUNC(`xc_compilererror_t', , `dnl {{{
1215    PROCESS(int, type)
1216    PROCESS(uint, lineno)
1217    PROCESS(int, error_len)
1218    PROC_STRING_L(error, error_len)
1219')
1220dnl }}}
1221#endif
1222')
1223DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{
1224    IFCOPY(`
1225        processor->php_dst = DST();
1226        processor->php_src = SRC();
1227    ')
1228
1229    /* skip */
1230    DONE(next)
1231    PROCESS(xc_hash_value_t, hvalue)
1232    PROCESS(xc_md5sum_t, md5)
1233    PROCESS(zend_ulong, refcount)
1234
1235    PROCESS(zend_ulong, hits)
1236    PROCESS(size_t, size)
1237
1238    IFRESTORE(`COPYPOINTER(op_array_info)', `
1239        STRUCT(xc_op_array_info_t, op_array_info)
1240    ')
1241    IFRESTORE(`
1242        processor->active_op_array_infos_src = &DST(`op_array_info');
1243        processor->active_op_array_index = 0;
1244    ')
1245    STRUCT_P(zend_op_array, op_array)
1246
1247#ifdef HAVE_XCACHE_CONSTANT
1248    PROCESS(zend_uint, constinfo_cnt)
1249    STRUCT_ARRAY(zend_uint, constinfo_cnt, xc_constinfo_t, constinfos)
1250#endif
1251
1252    PROCESS(zend_uint, funcinfo_cnt)
1253    STRUCT_ARRAY(zend_uint, funcinfo_cnt, xc_funcinfo_t, funcinfos)
1254
1255    PROCESS(zend_uint, classinfo_cnt)
1256    STRUCT_ARRAY(zend_uint, classinfo_cnt, xc_classinfo_t, classinfos, , IFCOPY(`processor->active_class_index'))
1257#ifdef ZEND_ENGINE_2_1
1258    PROCESS(zend_uint, autoglobal_cnt)
1259    IFRESTORE(`
1260        COPYPOINTER(autoglobals)
1261    ', `
1262        STRUCT_ARRAY(zend_uint, autoglobal_cnt, xc_autoglobal_t, autoglobals)
1263    ')
1264#endif
1265#ifdef XCACHE_ERROR_CACHING
1266    PROCESS(zend_uint, compilererror_cnt)
1267    IFRESTORE(`
1268        COPYPOINTER(compilererrors)
1269    ', `
1270        STRUCT_ARRAY(zend_uint, compilererror_cnt, xc_compilererror_t, compilererrors)
1271    ')
1272#endif
1273#ifndef ZEND_COMPILE_DELAYED_BINDING
1274    PROCESS(zend_bool, have_early_binding)
1275#endif
1276    PROCESS(zend_bool, have_references)
1277')
1278dnl }}}
1279DEF_STRUCT_P_FUNC(`xc_entry_t', , `dnl {{{
1280    /* skip */
1281    DONE(next)
1282    PROCESS(size_t, size)
1283
1284    PROCESS(time_t, ctime)
1285    PROCESS(time_t, atime)
1286    PROCESS(time_t, dtime)
1287    PROCESS(long, ttl)
1288    PROCESS(zend_ulong, hits)
1289    DONE(name) dnl handle in xc_entry_php_t and xc_entry_var_t
1290')
1291dnl }}}
1292DEF_STRUCT_P_FUNC(`xc_entry_php_t', , `dnl {{{
1293    STRUCT(xc_entry_t, entry)
1294    DISABLECHECK(`
1295        PROCESS(int, entry.name.str.len)
1296        IFRESTORE(`COPYPOINTER(entry.name.str.val)', `
1297            PROC_STRING_L(entry.name.str.val, entry.name.str.len)
1298        ')
1299    ')
1300
1301    IFCALCCOPY(`COPYPOINTER(php)', `STRUCT_P(xc_entry_data_php_t, php)')
1302
1303    IFSTORE(`DST(`refcount') = 0; DONE(refcount)', `PROCESS(long, refcount)')
1304    PROCESS(time_t, file_mtime)
1305    PROCESS(size_t, file_size)
1306    PROCESS(size_t, file_device)
1307    PROCESS(size_t, file_inode)
1308
1309    PROCESS(size_t, filepath_len)
1310    IFRESTORE(`COPYPOINTER(filepath)', `PROC_STRING_L(filepath, filepath_len)')
1311    PROCESS(size_t, dirpath_len)
1312    IFRESTORE(`COPYPOINTER(dirpath)', `PROC_STRING_L(dirpath, dirpath_len)')
1313#ifdef IS_UNICODE
1314    PROCESS(int, ufilepath_len)
1315    IFRESTORE(`COPYPOINTER(ufilepath)', `PROC_USTRING_L(ufilepath, ufilepath_len)')
1316    PROCESS(int, udirpath_len)
1317    IFRESTORE(`COPYPOINTER(udirpath)', `PROC_USTRING_L(udirpath, udirpath_len)')
1318#endif
1319')
1320dnl }}}
1321DEF_STRUCT_P_FUNC(`xc_entry_var_t', , `dnl {{{
1322    STRUCT(xc_entry_t, entry)
1323
1324#ifdef IS_UNICODE
1325    PROCESS(zend_uchar, name_type)
1326#endif
1327    dnl {{{ entry.name
1328    DISABLECHECK(`
1329#ifdef IS_UNICODE
1330        if (SRC(`name_type') == IS_UNICODE) {
1331            PROCESS(int32_t, entry.name.ustr.len)
1332        }
1333        else {
1334            PROCESS(int, entry.name.str.len)
1335        }
1336#else
1337        PROCESS(int, entry.name.str.len)
1338#endif
1339        IFRESTORE(`COPYPOINTER(entry.name.str.val)', `
1340#ifdef IS_UNICODE
1341            PROC_ZSTRING_L(name_type, entry.name.uni.val, entry.name.uni.len)
1342#else
1343            PROC_STRING_L(entry.name.str.val, entry.name.str.len)
1344#endif
1345        ')
1346    ')
1347    dnl }}}
1348
1349    IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");')
1350    STRUCT_P_EX(zval_ptr, DST(`value'), SRC(`value'), `value', `', `&')
1351    PROCESS(zend_bool, have_references)
1352    DONE(value)
1353')
1354dnl }}}
1355dnl ====================================================
Note: See TracBrowser for help on using the repository browser.