1 // BEGIN INCLUDED FILES
2 /* The difference between zend_symtable_X and zend_hash_X is that
3 * the _symtable version will check if the key is a string of an
4 * integer, and if so, use the int version instead. We can use the
5 * zend_hash_X versions safely for symbol tables, since
6 * variables cant be integer strings, but we cant safely use
7 * zend_hash_X versions for hashtable lookups. Well-named, they are.
10 /* An important note of zval*s and zval**s. Frequently, zval** are
11 * fetched from arrays and symbol tables. The zval** will point into
12 * the array, and so updating it will update the relevant array
13 * entry. It is normally not the same to dereference it to a local
14 * variable, and pass a reference to that.
19 // Some common functions
23 * The runtime needs its own initialization and finalization. phc is
24 * responsible for generating calls to these functions.
38 ht_debug (HashTable
* ht
)
46 for (zend_hash_internal_pointer_reset (ht
);
47 zend_hash_has_more_elements (ht
) == SUCCESS
;
48 zend_hash_move_forward (ht
))
57 type
= zend_hash_get_current_key_ex (ht
, &key
, &keylen
, &idx
, 0, NULL
);
58 zend_hash_get_current_data (ht
, (void **) &ppzval
);
62 if (type
== HASH_KEY_IS_STRING
)
71 printf (": addr = %08lX, refcount = %d, is_ref = %d ",
72 (long unsigned int) (*ppzval
), (*ppzval
)->refcount
,
74 switch (Z_TYPE_P (zvp
))
80 printf ("(%ldL)", Z_LVAL_P (zvp
));
83 printf ("(%lff)", Z_DVAL_P (zvp
));
86 printf (Z_BVAL_P (zvp
) ? "(true)" : "(false)");
89 printf ("(array(%d))", Z_ARRVAL_P (zvp
)->nNumOfElements
);
95 printf ("(\"%s\")", Z_STRVAL_P (zvp
));
98 printf ("(Resource)");
101 printf ("(Invalid: %d)", Z_TYPE_P (zvp
));
107 printf ("END HASH\n");
110 // Call ht_debug on the named var in the given symbol table
112 ht_var_debug (HashTable
* st
, char *name
)
115 if (zend_symtable_find (st
, name
, strlen (name
) + 1,
116 (void **) &p_zvp
) != SUCCESS
)
118 printf ("VAR NOT IN SYMBOL TABLE: '%s'\n", name
);
122 if (Z_TYPE_P (*p_zvp
) != IS_ARRAY
)
124 printf ("NOT HASH\n");
128 ht_debug ((*p_zvp
)->value
.ht
);
131 static zval
* counters
;
133 static void init_counters ()
135 ALLOC_INIT_ZVAL (counters
);
136 array_init (counters
);
139 // Dump and cleanup memory
140 static void finalize_counters ()
142 HashTable
* ht
= Z_ARRVAL_P (counters
);
143 for (zend_hash_internal_pointer_reset (ht
);
144 zend_hash_has_more_elements (ht
) == SUCCESS
;
145 zend_hash_move_forward (ht
))
150 zend_hash_get_current_key_ex (ht
, &key
, NULL
, NULL
, 0, NULL
);
151 zend_hash_get_current_data (ht
, (void **) &p_zvp
);
153 fprintf (stderr
, "COUNTER:%s:%ld\n", key
, Z_LVAL_P (*p_zvp
));
156 zval_ptr_dtor (&counters
);
159 static void increment_counter (char* name
, int length
, ulong hashval
)
162 int success
= zend_hash_quick_find (Z_ARRVAL_P (counters
),
168 if (success
== SUCCESS
)
176 ALLOC_INIT_ZVAL (new_val
);
177 ZVAL_LONG (new_val
, 1);
179 zend_hash_quick_add (Z_ARRVAL_P (counters
),
191 /* Make a copy of *P_ZVP, storing it in *P_ZVP. */
193 zvp_clone_ex (zval
* zvp
)
195 // TODO: use INIT_PZVAL_COPY
197 MAKE_STD_ZVAL (clone
);
198 clone
->value
= zvp
->value
;
199 clone
->type
= zvp
->type
;
200 zval_copy_ctor (clone
);
206 in_copy_on_write (zval
* zvp
)
208 return (zvp
->refcount
> 1 && !zvp
->is_ref
);
212 in_change_on_write (zval
* zvp
)
214 return (zvp
->refcount
> 1 && zvp
->is_ref
);
217 /* If *P_ZVP is in a copy-on-write set, separate it by overwriting
218 * *P_ZVP with a clone of itself, and lowering the refcount on the
221 sep_copy_on_write (zval
** p_zvp
)
223 if (!in_copy_on_write (*p_zvp
))
228 *p_zvp
= zvp_clone_ex (*p_zvp
);
230 zval_ptr_dtor (&old
);
233 /* If *P_ZVP is in a copy-on-write set, separate it by overwriting
234 * *P_ZVP with a clone of itself, and lowering the refcount on the
237 sep_change_on_write (zval
** p_zvp
)
239 assert (in_change_on_write (*p_zvp
));
243 *p_zvp
= zvp_clone_ex (*p_zvp
);
245 zval_ptr_dtor (&old
);
248 /* Assign RHS into LHS, by reference. After this, LHS will point to the same
251 copy_into_ref (zval
** lhs
, zval
** rhs
)
260 // Overwrite one zval with another
262 overwrite_lhs (zval
* lhs
, zval
* rhs
)
264 // First, call the destructor to remove any data structures
265 // associated with lhs that will now be overwritten
268 lhs
->value
= rhs
->value
;
269 lhs
->type
= rhs
->type
;
270 zval_copy_ctor (lhs
);
273 // Overwrite one zval with another
275 overwrite_lhs_no_copy (zval
* lhs
, zval
* rhs
)
277 // First, call the destructor to remove any data structures
278 // associated with lhs that will now be overwritten
281 lhs
->value
= rhs
->value
;
282 lhs
->type
= rhs
->type
;
285 /* Write P_RHS into the symbol table as a variable named VAR_NAME. */
286 // NOTE: We do not alter p_rhs's refcount, unless p_lhs joins its
287 // Copy-on-write set.
288 // TODO: this is crying out to be inlined.
290 write_var (zval
** p_lhs
, zval
* rhs
)
292 if (!(*p_lhs
)->is_ref
)
294 zval_ptr_dtor (p_lhs
);
295 // Take a copy of RHS for LHS.
298 *p_lhs
= zvp_clone_ex (rhs
);
308 overwrite_lhs (*p_lhs
, rhs
);
312 // TODO: this functino does too much, and much might be redundant
314 get_st_entry (HashTable
* st
, char *name
, int length
, ulong hashval TSRMLS_DC
)
317 if (zend_hash_quick_find
318 (st
, name
, length
, hashval
, (void **) &p_zvp
) == SUCCESS
)
320 assert (p_zvp
!= NULL
);
324 // If we dont find it, put EG (uninitialized_zval_ptr) into the
325 // hashtable, and return a pointer to its container.
326 EG (uninitialized_zval_ptr
)->refcount
++;
327 int result
= zend_hash_quick_add (st
, name
, length
, hashval
,
328 &EG (uninitialized_zval_ptr
),
329 sizeof (zval
*), (void **) &p_zvp
);
330 assert (result
== SUCCESS
);
331 assert (p_zvp
!= NULL
);
336 /* Read the variable named VAR_NAME from the local symbol table and
337 * return it. If the variable doent exist, a new one is created and
340 read_var (HashTable
* st
, char *name
, int length
, ulong hashval TSRMLS_DC
)
343 if (zend_hash_quick_find
344 (st
, name
, length
, hashval
, (void **) &p_zvp
) == SUCCESS
)
347 return EG (uninitialized_zval_ptr
);
351 get_integer_index (zval
* ind TSRMLS_DC
)
354 switch (Z_TYPE_P (ind
))
357 return (long) Z_DVAL_P (ind
);
361 return Z_LVAL_P (ind
);
367 php_error_docref (NULL TSRMLS_CC
, E_WARNING
, "Illegal offset type");
372 read_string_index (zval
* var
, zval
* ind TSRMLS_DC
)
374 // This must always allocate memory, since we cant return the
376 assert (Z_TYPE_P (var
) == IS_STRING
);
377 long index
= get_integer_index (ind TSRMLS_CC
);
380 ALLOC_INIT_ZVAL (result
);
382 if (index
>= Z_STRLEN_P (var
) || index
< 0)
384 // this is 1 byte long, must be copied
385 ZVAL_STRINGL (result
, "", 0, 1);
389 char *string
= Z_STRVAL_P (var
);
390 ZVAL_STRINGL (result
, &string
[index
], 1, 1);
396 /* Given a string (p_lhs), write into it for $x[i] = $y; */
398 write_string_index (zval
** p_lhs
, zval
* ind
, zval
* rhs TSRMLS_DC
)
400 assert (Z_TYPE_P (*p_lhs
) == IS_STRING
);
402 long index
= get_integer_index (ind TSRMLS_CC
);
404 // Get the appropriate character
406 if (Z_TYPE_P (rhs
) != IS_STRING
)
408 // TODO: remove allocate
409 zval
*copy
= zvp_clone_ex (rhs
);
410 convert_to_string (copy
);
411 new_char
= Z_STRVAL_P (copy
)[0];
412 zval_ptr_dtor (©
);
416 new_char
= Z_STRVAL_P (rhs
)[0];
422 php_error_docref (NULL TSRMLS_CC
, E_WARNING
,
423 "Illegal string offset: %ld", index
);
427 // We overwrite if it's change-on-write
428 sep_copy_on_write (p_lhs
);
430 if (index
> Z_STRLEN_PP (p_lhs
))
433 int len
= Z_STRLEN_PP (p_lhs
);
434 int new_length
= index
+ 1; // space for the new character
435 Z_STRVAL_PP (p_lhs
) = erealloc (Z_STRVAL_PP (p_lhs
), new_length
+ 1);
438 memset (&Z_STRVAL_PP (p_lhs
)[len
], ' ', index
- len
);
441 Z_STRLEN_PP (p_lhs
) = new_length
;
443 // add a null terminator
444 Z_STRVAL_PP (p_lhs
)[new_length
] = '\0';
447 // write in the first character of the new value
448 Z_STRVAL_PP (p_lhs
)[index
] = new_char
;
451 // index < 0: E_WARNING illegal string offset
454 // Extract the hashtable from a hash-valued zval
456 extract_ht_ex (zval
* arr TSRMLS_DC
)
458 // TODO: this likely should be inlined somewhere.
459 assert (!in_copy_on_write (arr
));
460 if (Z_TYPE_P (arr
) == IS_NULL
)
464 else if (Z_TYPE_P (arr
) != IS_ARRAY
)
466 php_error_docref (NULL TSRMLS_CC
, E_WARNING
,
467 "Cannot use a scalar value as an array");
470 return Z_ARRVAL_P (arr
);
474 /* P_VAR points into a symbol table, at a variable which we wish to index as a hashtable. */
476 extract_ht (zval
** p_var TSRMLS_DC
)
478 sep_copy_on_write (p_var
);
480 return extract_ht_ex (*p_var TSRMLS_CC
);
483 /* Using IND as a key to HT, call the appropriate zend_index_X
484 * function with data as a parameter, and return its result. This
485 * updates the zval** pointed to by DATA. */
487 ht_find (HashTable
* ht
, zval
* ind
, zval
*** data
)
490 if (Z_TYPE_P (ind
) == IS_LONG
|| Z_TYPE_P (ind
) == IS_BOOL
)
492 result
= zend_hash_index_find (ht
, Z_LVAL_P (ind
), (void **) data
);
494 else if (Z_TYPE_P (ind
) == IS_DOUBLE
)
496 result
= zend_hash_index_find (ht
, (long) Z_DVAL_P (ind
),
499 else if (Z_TYPE_P (ind
) == IS_NULL
)
501 result
= zend_hash_find (ht
, "", sizeof (""), (void **)data
);
503 else if (Z_TYPE_P (ind
) == IS_STRING
)
505 result
= zend_symtable_find (ht
, Z_STRVAL_P (ind
),
506 Z_STRLEN_P (ind
) + 1, (void **) data
);
510 // TODO: I believe this might need a warning.
513 // use a string index for other types
515 MAKE_STD_ZVAL (string_index
);
516 string_index
->value
= ind
->value
;
517 string_index
->type
= ind
->type
;
518 zval_copy_ctor (string_index
);
519 convert_to_string (string_index
);
521 result
= zend_symtable_find (ht
, Z_STRVAL_P (string_index
),
522 Z_STRLEN_P (string_index
) + 1,
524 zval_ptr_dtor (&string_index
);
531 check_array_index_type (zval
* ind TSRMLS_DC
)
533 if (Z_TYPE_P (ind
) == IS_OBJECT
|| Z_TYPE_P (ind
) == IS_ARRAY
)
535 php_error_docref (NULL TSRMLS_CC
, E_WARNING
, "Illegal offset type");
542 // Update a hashtable using a zval* index
544 ht_update (HashTable
* ht
, zval
* ind
, zval
* val
, zval
*** dest
)
547 if (Z_TYPE_P (ind
) == IS_LONG
|| Z_TYPE_P (ind
) == IS_BOOL
)
549 result
= zend_hash_index_update (ht
, Z_LVAL_P (ind
), &val
,
550 sizeof (zval
*), (void **) dest
);
552 else if (Z_TYPE_P (ind
) == IS_DOUBLE
)
554 result
= zend_hash_index_update (ht
, (long) Z_DVAL_P (ind
),
555 &val
, sizeof (zval
*), (void **) dest
);
557 else if (Z_TYPE_P (ind
) == IS_NULL
)
559 result
= zend_hash_update (ht
, "", sizeof (""), &val
,
560 sizeof (zval
*), (void **) dest
);
562 else if (Z_TYPE_P (ind
) == IS_STRING
)
564 result
= zend_symtable_update (ht
, Z_STRVAL_P (ind
),
565 Z_STRLEN_P (ind
) + 1,
566 &val
, sizeof (zval
*), (void **) dest
);
572 MAKE_STD_ZVAL (string_index
);
573 string_index
->value
= ind
->value
;
574 string_index
->type
= ind
->type
;
575 zval_copy_ctor (string_index
);
576 convert_to_string (string_index
);
577 result
= zend_symtable_update (ht
, Z_STRVAL_P (string_index
),
578 Z_STRLEN_P (string_index
) + 1,
579 &val
, sizeof (zval
*), (void **) dest
);
581 zval_ptr_dtor (&string_index
);
583 assert (result
== SUCCESS
);
586 // Delete from a hashtable using a zval* index
588 ht_delete (HashTable
* ht
, zval
* ind
)
590 // This may fail if the index doesnt exist, which is fine.
591 if (Z_TYPE_P (ind
) == IS_LONG
|| Z_TYPE_P (ind
) == IS_BOOL
)
593 zend_hash_index_del (ht
, Z_LVAL_P (ind
));
595 else if (Z_TYPE_P (ind
) == IS_DOUBLE
)
597 zend_hash_index_del (ht
, (long) Z_DVAL_P (ind
));
599 else if (Z_TYPE_P (ind
) == IS_NULL
)
601 zend_hash_del (ht
, "", sizeof (""));
603 else if (Z_TYPE_P (ind
) == IS_STRING
)
605 zend_hash_del (ht
, Z_STRVAL_P (ind
), Z_STRLEN_P (ind
) + 1);
611 MAKE_STD_ZVAL (string_index
);
612 string_index
->value
= ind
->value
;
613 string_index
->type
= ind
->type
;
614 zval_copy_ctor (string_index
);
615 convert_to_string (string_index
);
616 zend_hash_del (ht
, Z_STRVAL_P (string_index
),
617 Z_STRLEN_P (string_index
) + 1);
619 zval_ptr_dtor (&string_index
);
623 // Check if a key exists in a hashtable
625 ht_exists (HashTable
* ht
, zval
* ind
)
627 if (Z_TYPE_P (ind
) == IS_LONG
|| Z_TYPE_P (ind
) == IS_BOOL
)
629 return zend_hash_index_exists (ht
, Z_LVAL_P (ind
));
631 else if (Z_TYPE_P (ind
) == IS_DOUBLE
)
633 return zend_hash_index_exists (ht
, (long) Z_DVAL_P (ind
));
635 else if (Z_TYPE_P (ind
) == IS_NULL
)
637 return zend_hash_exists (ht
, "", sizeof (""));
639 else if (Z_TYPE_P (ind
) == IS_STRING
)
641 return zend_hash_exists (ht
, Z_STRVAL_P (ind
), Z_STRLEN_P (ind
) + 1);
648 MAKE_STD_ZVAL (string_index
);
649 string_index
->value
= ind
->value
;
650 string_index
->type
= ind
->type
;
651 zval_copy_ctor (string_index
);
652 convert_to_string (string_index
);
653 result
= zend_hash_exists (ht
, Z_STRVAL_P (string_index
),
654 Z_STRLEN_P (string_index
) + 1);
655 zval_ptr_dtor (&string_index
);
662 get_ht_entry (zval
** p_var
, zval
* ind TSRMLS_DC
)
664 if (Z_TYPE_P (*p_var
) == IS_STRING
)
666 if (Z_STRLEN_PP (p_var
) > 0)
668 php_error_docref (NULL TSRMLS_CC
, E_ERROR
,
669 "Cannot create references to/from string offsets nor overloaded objects");
673 if (Z_TYPE_P (*p_var
) != IS_ARRAY
)
675 zval_ptr_dtor (p_var
);
676 ALLOC_INIT_ZVAL (*p_var
);
680 HashTable
*ht
= extract_ht (p_var TSRMLS_CC
);
683 if (ht_find (ht
, ind
, &data
) == SUCCESS
)
685 assert (data
!= NULL
);
689 // If we dont find it, put EG (uninitialized_zval_ptr) into the
690 // hashtable, and return a pointer to its container.
691 EG (uninitialized_zval_ptr
)->refcount
++;
692 ht_update (ht
, ind
, EG (uninitialized_zval_ptr
), &data
);
694 assert (data
!= NULL
);
700 // Like extract_ht_ex, but for objects
702 extract_field_ex (zval
* obj TSRMLS_DC
)
704 // TODO: this likely should be inlined somewhere.
705 assert (!in_copy_on_write (obj
));
706 if (Z_TYPE_P (obj
) == IS_NULL
)
709 // TODO: implement initialization
711 else if (Z_TYPE_P (obj
) != IS_OBJECT
)
713 // TODO: test if this is the right error message
714 php_error_docref (NULL TSRMLS_CC
, E_WARNING
,
715 "Cannot use a scalar value as an object");
716 // TODO: implement initialization
719 return Z_OBJPROP_P (obj
);
722 // Like extract_ht, but for objects
724 extract_field (zval
** p_var TSRMLS_DC
)
726 sep_copy_on_write (p_var
);
728 return extract_field_ex (*p_var TSRMLS_CC
);
731 // Like get_ht_entry, but for objects
733 get_field (zval
** p_var
, char *ind TSRMLS_DC
)
735 if (Z_TYPE_P (*p_var
) != IS_OBJECT
)
737 // TODO: implement initialization
741 HashTable
*ht
= extract_field (p_var TSRMLS_CC
);
744 if (zend_symtable_find (ht
, ind
, strlen (ind
) + 1, (void **) &data
) ==
747 assert (data
!= NULL
);
751 // If we dont find it, put EG (uninitialized_zval_ptr) into the
752 // hashtable, and return a pointer to its container.
753 EG (uninitialized_zval_ptr
)->refcount
++;
754 zend_symtable_update (ht
, ind
, strlen (ind
) + 1,
755 &EG (uninitialized_zval_ptr
), sizeof (zval
*),
758 assert (data
!= NULL
);
764 read_array (zval
** result
, zval
* array
, zval
* ind TSRMLS_DC
)
766 // Memory can be allocated in read_string_index
767 if (array
== EG (uninitialized_zval_ptr
))
773 // Since we know its an array, and we dont write to it, we dont need
775 HashTable
*ht
= Z_ARRVAL_P (array
);
779 if (ht_find (ht
, ind
, &p_result
) == SUCCESS
)
785 *result
= EG (uninitialized_zval_ptr
);
788 /* If its not an array, convert it into an array. */
790 check_array_type (zval
** p_var TSRMLS_DC
)
792 if ((Z_TYPE_P (*p_var
) == IS_BOOL
&& !Z_BVAL_PP (p_var
))
793 || Z_TYPE_P (*p_var
) == IS_NULL
794 || (Z_TYPE_P (*p_var
) == IS_STRING
&& Z_STRLEN_PP (p_var
) == 0))
796 // Non ref use new values
797 if (!PZVAL_IS_REF (*p_var
))
799 zval_ptr_dtor (p_var
);
800 ALLOC_INIT_ZVAL (*p_var
);
803 // Refs are just replaced
808 else if (Z_TYPE_PP (p_var
) != IS_STRING
&& Z_TYPE_PP (p_var
) != IS_ARRAY
)
810 // TODO: why are these different types than pushing
811 php_error_docref (NULL TSRMLS_CC
, E_WARNING
,
812 "Cannot use a scalar value as an array");
816 /* If its not an array, convert it into an object. */
818 check_object_type (zval
** p_var TSRMLS_DC
)
823 /* Push EG (uninitialized_zval_ptr) and return a pointer into the ht
826 * Converted to array automatically:
831 * Warning, no conversion:
836 * Error, no conversion:
837 * strings other than ""
839 // TODO: objects, resources, etc
841 push_and_index_ht (zval
** p_var TSRMLS_DC
)
843 // Check for errors conditions
845 if (Z_TYPE_P (*p_var
) == IS_STRING
&& Z_STRLEN_PP (p_var
) > 0)
847 php_error_docref (NULL TSRMLS_CC
, E_ERROR
,
848 "[] operator not supported for strings");
849 assert (0); // unreachable
852 if (Z_TYPE_P (*p_var
) == IS_BOOL
&& Z_BVAL_PP (p_var
)
853 || Z_TYPE_P (*p_var
) == IS_LONG
|| Z_TYPE_P (*p_var
) == IS_DOUBLE
)
855 php_error_docref (NULL TSRMLS_CC
, E_WARNING
,
856 "Cannot use a scalar value as an array");
860 if (Z_TYPE_P (*p_var
) != IS_ARRAY
)
862 zval_ptr_dtor (p_var
);
863 ALLOC_INIT_ZVAL (*p_var
);
867 // if its not an array, make it an array
868 HashTable
*ht
= extract_ht (p_var TSRMLS_CC
);
871 EG (uninitialized_zval_ptr
)->refcount
++;
872 int result
= zend_hash_next_index_insert (ht
, &EG (uninitialized_zval_ptr
),
873 sizeof (zval
*), (void **) &data
);
874 assert (result
== SUCCESS
);
886 isset_var (HashTable
* st
, char *name
, int length
)
888 return zend_hash_exists (st
, name
, length
);
892 isset_array (zval
** p_var
, zval
* ind
)
894 if (Z_TYPE_P (*p_var
) == IS_STRING
)
896 ind
= zvp_clone_ex (ind
);
897 convert_to_long (ind
);
898 int result
= (Z_LVAL_P (ind
) >= 0
899 && Z_LVAL_P (ind
) < Z_STRLEN_PP (p_var
));
900 assert (ind
->refcount
== 1);
901 zval_ptr_dtor (&ind
);
905 // NO error required; return false
906 if (Z_TYPE_P (*p_var
) != IS_ARRAY
)
909 // if its not an array, make it an array
910 HashTable
*ht
= Z_ARRVAL_P (*p_var
);
913 if (ht_find (ht
, ind
, &data
) == SUCCESS
)
915 return !ZVAL_IS_NULL (*data
);
923 fetch_var_arg_by_ref (zval
** p_arg
)
925 // We are passing by reference
926 sep_copy_on_write (p_arg
);
928 // We don't need to restore ->is_ref afterwards,
929 // because the called function will reduce the
930 // refcount of arg on return, and will reset is_ref to
931 // 0 when refcount drops to 1. If the refcount does
932 // not drop to 1 when the function returns, but we did
933 // set is_ref to 1 here, that means that is_ref must
934 // already have been 1 to start with (since if it had
935 // not, that means that the variable would have been
936 // in a copy-on-write set, and would have been
938 (*p_arg
)->is_ref
= 1;
943 /* Dont pass-by-ref */
945 fetch_var_arg (zval
* arg
, int *is_arg_new
)
949 // We dont separate since we don't own one of ARG's references.
950 arg
= zvp_clone_ex (arg
);
953 // It seems we get incorrect refcounts without this.
954 // TODO This decreases the refcount to zero, which seems wrong,
955 // but gives the right answer. We should look at how zend does
963 // TODO dont overwrite line numbers if we're compiling an extension
965 phc_setup_error (int init
, char *filename
, int line_number
,
966 zend_function
* function TSRMLS_DC
)
968 static int old_in_compilation
;
969 static int old_in_execution
;
970 static char *old_filename
;
971 static int old_lineno
;
972 static zend_function
*old_function
;
975 if (filename
== NULL
)
976 filename
= "[phc_compiled_file]";
978 old_in_compilation
= CG (in_compilation
);
979 old_in_execution
= EG (in_execution
);
980 old_filename
= CG (compiled_filename
);
981 old_lineno
= CG (zend_lineno
);
982 old_function
= EG (function_state_ptr
)->function
;
984 CG (in_compilation
) = 1;
985 EG (in_execution
) = 1;
986 CG (compiled_filename
) = filename
;
987 CG (zend_lineno
) = line_number
;
989 EG (function_state_ptr
)->function
= function
;
993 CG (in_compilation
) = old_in_compilation
;
994 EG (in_execution
) = old_in_execution
;
995 CG (compiled_filename
) = old_filename
;
996 CG (zend_lineno
) = old_lineno
;
997 EG (function_state_ptr
)->function
= old_function
;
1002 initialize_function_call (zend_fcall_info
* fci
, zend_fcall_info_cache
* fcic
,
1003 char *function_name
, char *filename
,
1004 int line_number TSRMLS_DC
)
1006 if (fcic
->initialized
)
1011 ZVAL_STRING (&fn
, function_name
, 0);
1012 int result
= zend_fcall_info_init (&fn
, fci
, fcic TSRMLS_CC
);
1013 if (result
!= SUCCESS
)
1015 phc_setup_error (1, filename
, line_number
, NULL TSRMLS_CC
);
1016 php_error_docref (NULL TSRMLS_CC
, E_ERROR
,
1017 "Call to undefined function %s()", function_name
);
1022 * Initialize zend_fcall_info for a method lookup
1024 * Implementation partly based on zend_call_method in Zend/zend_interfaces.c
1025 * Main difference is that we use Z_OBJ_HTT_PP(obj)->get_method to retrieve
1026 * the function handler for the method instead of looking it up directly;
1027 * this means that we correctly deal with __call.
1031 initialize_method_call (zend_fcall_info
* fci
, zend_fcall_info_cache
* fcic
,
1032 zval
** obj
, char *function_name
,
1033 char *filename
, int line_number TSRMLS_DC
)
1035 if (fcic
->initialized
)
1038 zend_class_entry
*obj_ce
;
1039 obj_ce
= Z_OBJCE_PP (obj
);
1042 * we do not initialize fci.
1043 * function_table -- not initialized by zend_call_method
1044 * function_name -- zend_call_method initializes this to a pointer to
1045 * a zval 'z_fname', but does not initialize z_fname
1046 * in case of a method invocation
1047 * retval_ptr_ptr -- should be initialized by caller
1048 * param_count -- should be initialized by caller
1049 * params -- should be initialized by caller
1051 fci
->size
= sizeof (*fci
);
1052 fci
->object_pp
= obj
;
1053 fci
->no_separation
= 1;
1054 fci
->symbol_table
= NULL
;
1056 fcic
->initialized
= 1;
1057 fcic
->calling_scope
= obj_ce
;
1058 fcic
->object_pp
= obj
;
1059 fcic
->function_handler
1060 = Z_OBJ_HT_PP (obj
)->get_method (obj
,
1062 strlen (function_name
) TSRMLS_CC
);
1064 if (fcic
->function_handler
== NULL
)
1066 phc_setup_error (1, filename
, line_number
, NULL TSRMLS_CC
);
1067 php_error_docref (NULL TSRMLS_CC
, E_ERROR
,
1068 "Call to undefined method %s::%s",
1069 obj_ce
->name
, function_name
);
1074 * Like initialize_method_call, but return 0 if no constructor is defined
1075 * rather than giving an error.
1079 initialize_constructor_call (zend_fcall_info
* fci
,
1080 zend_fcall_info_cache
* fcic
, zval
** obj
,
1081 char *filename
, int line_number TSRMLS_DC
)
1083 if (fcic
->initialized
)
1086 zend_class_entry
*obj_ce
;
1087 obj_ce
= Z_OBJCE_PP (obj
);
1090 * we do not initialize fci.
1091 * function_table -- not initialized by zend_call_method
1092 * function_name -- zend_call_method initializes this to a pointer to
1093 * a zval 'z_fname', but does not initialize z_fname
1094 * in case of a method invocation
1095 * retval_ptr_ptr -- should be initialized by caller
1096 * param_count -- should be initialized by caller
1097 * params -- should be initialized by caller
1099 fci
->size
= sizeof (*fci
);
1100 fci
->object_pp
= obj
;
1101 fci
->no_separation
= 1;
1102 fci
->symbol_table
= NULL
;
1104 fcic
->initialized
= 1;
1105 fcic
->calling_scope
= obj_ce
;
1106 fcic
->object_pp
= obj
;
1107 fcic
->function_handler
1108 = Z_OBJ_HT_PP (obj
)->get_constructor (*obj TSRMLS_CC
);
1110 return (fcic
->function_handler
!= NULL
);
1115 * Creates a copy of *in using persistent memory, optionally destroying *in
1117 * Does not work for objects/resources and will loop on self-recursive arrays.
1121 persistent_clone (zval
* in
, int destroy_in TSRMLS_DC
)
1123 zval
*out
= pemalloc (sizeof (zval
), 1);
1126 switch (Z_TYPE_P (in
))
1132 /* nothing more to be done */
1135 Z_STRVAL_P (out
) = pemalloc (Z_STRLEN_P (in
) + 1, 1);
1136 memcpy (Z_STRVAL_P (out
), Z_STRVAL_P (in
), Z_STRLEN_P (in
) + 1);
1140 HashTable
*old_arr
= Z_ARRVAL_P (in
);
1141 HashTable
*new_arr
= pemalloc (sizeof (HashTable
), 1);
1142 zend_hash_init (new_arr
, old_arr
->nNumOfElements
, NULL
, ZVAL_PTR_DTOR
,
1143 /* persistent */ 1);
1145 for (zend_hash_internal_pointer_reset (old_arr
);
1146 zend_hash_has_more_elements (old_arr
) == SUCCESS
;
1147 zend_hash_move_forward (old_arr
))
1153 zval
**old_elem
, *new_elem
;
1156 zend_hash_get_current_key_ex (old_arr
, &key
, &keylen
, &idx
, 0,
1158 assert (zend_hash_get_current_data
1159 (old_arr
, (void **) &old_elem
) == SUCCESS
);
1161 new_elem
= persistent_clone (*old_elem
, destroy_in TSRMLS_CC
);
1163 if (type
== HASH_KEY_IS_STRING
)
1164 zend_hash_add (new_arr
, key
, keylen
, &new_elem
, sizeof (zval
*),
1167 zend_hash_index_update (new_arr
, idx
, &new_elem
,
1168 sizeof (zval
*), NULL
);
1172 Z_ARRVAL_P (out
) = new_arr
;
1176 /* other types are not supported */
1180 zval_ptr_dtor (&in
);
1185 * Wrapper around zend_declare_property which
1187 * - Asserts that the ZEND_INTERNAL_CLASS flag is cleared
1188 * (otherwise we cannot add complex (i.e., array) properties)
1189 * - Creates a persistent clone of the property to be added before
1190 * calling zend_declare_property, since the memory for this property
1191 * should only be deallocated when the module is shut down
1192 * (and not when the request finishes)
1193 * - Cleans up after zend_declare_property by re-allocating the name of
1194 * the property using persistent memory, for much the same reason
1198 phc_declare_property (zend_class_entry
* ce
, char *name
, int name_length
,
1199 zval
* property
, int access_type TSRMLS_DC
)
1201 assert (!(ce
->type
& ZEND_INTERNAL_CLASS
));
1202 assert (zend_declare_property
1203 (ce
, name
, name_length
, persistent_clone (property
, 1 TSRMLS_CC
),
1204 access_type TSRMLS_CC
) == SUCCESS
);
1206 zend_property_info
*property_info
;
1207 assert (zend_hash_find
1208 (&ce
->properties_info
, name
, name_length
+ 1,
1209 (void **) &property_info
) == SUCCESS
);
1210 efree (property_info
->name
);
1211 property_info
->name
= name
;
1220 cast_var (zval
** p_zvp
, int type
)
1222 assert (type
>= 0 && type
<= 6);
1223 if ((*p_zvp
)->type
== type
)
1226 sep_copy_on_write (p_zvp
);
1232 convert_to_null (zvp
);
1235 convert_to_boolean (zvp
);
1238 convert_to_long (zvp
);
1241 convert_to_double (zvp
);
1244 convert_to_string (zvp
);
1247 convert_to_array (zvp
);
1250 convert_to_object (zvp
);
1253 assert (0); // TODO unimplemented
1258 /* Copies a constant into ZVP. Note that LENGTH does not include the NULL-terminating byte. */
1260 get_constant (char *name
, int length
, zval
** p_zvp TSRMLS_DC
)
1262 MAKE_STD_ZVAL (*p_zvp
);
1263 // zend_get_constant returns 1 for success, not SUCCESS
1264 int result
= zend_get_constant (name
, length
, *p_zvp TSRMLS_CC
);
1266 ZVAL_STRINGL (*p_zvp
, name
, length
, 1);
1269 /* The function call mechanism deals specially with EG(uninitialize_zval_ptr)
1270 * (or sometime EG(uninitialize_zval)), so we need to use this too. This
1271 * particular zval can also be set, but there is an implicit guarantee
1272 * of the information below.
1274 * If assertions are off, this should be inlined to nothing.
1277 phc_check_invariants (TSRMLS_D
)
1279 assert (EG (uninitialized_zval_ptr
) == &EG (uninitialized_zval
));
1280 assert (EG (uninitialized_zval
).refcount
>= 1);
1281 assert (EG (uninitialized_zval
).value
.lval
== 0);
1282 assert (EG (uninitialized_zval
).type
== IS_NULL
);
1283 assert (EG (uninitialized_zval
).is_ref
== 0);
1288 check_unset_index_type (zval
* ind TSRMLS_DC
)
1290 if (Z_TYPE_P (ind
) == IS_OBJECT
|| Z_TYPE_P (ind
) == IS_ARRAY
)
1292 php_error_docref (NULL TSRMLS_CC
, E_WARNING
,
1293 "Illegal offset type in unset");
1307 unset_var (HashTable
* st
, char *name
, int length
)
1309 zend_hash_del (st
, name
, length
);
1313 unset_array (zval
** p_var
, zval
* ind TSRMLS_DC
)
1315 // NO error required
1316 if (Z_TYPE_PP (p_var
) != IS_ARRAY
)
1318 if (Z_TYPE_PP (p_var
) == IS_STRING
)
1320 php_error_docref (NULL TSRMLS_CC
, E_ERROR
,
1321 "Cannot unset string offsets");
1323 else if (Z_TYPE_PP (p_var
) != IS_NULL
)
1325 php_error_docref (NULL TSRMLS_CC
, E_WARNING
,
1326 "Cannot unset offsets in a non-array variable");
1332 // if its not an array, make it an array
1333 HashTable
*ht
= Z_ARRVAL_P (*p_var
);
1335 ht_delete (ht
, ind
);
1339 * Lookup variable whose name is var_var in st. We do not call
1340 * ht_find because ht_find uses zend_symtable_find to search for strings
1341 * rather than zend_hash_find. The difference is that zend_symtable_find
1342 * will convert strings to integers where possible: arrays are always
1343 * integer-indexed if at all possible. Variable names however should
1344 * _always_ be treated as strings.
1349 * If the parameter is a string, returns the parameter, with the refcount
1350 * incremented. If its not a string, returns a new zval, with a refcount of
1351 * 1. Either way, zval_dtor_ptr must be run by the caller on the return
1355 get_string_val (zval
* zvp
)
1357 if (Z_TYPE_P (zvp
) == IS_STRING
)
1364 zval
* clone
= zvp_clone_ex (zvp
);
1365 convert_to_string (clone
);
1371 get_var_var (HashTable
* st
, zval
* index TSRMLS_DC
)
1373 zval
* str_index
= get_string_val (index
);
1374 char* name
= Z_STRVAL_P (str_index
);
1375 int length
= Z_STRLEN_P (str_index
) + 1;
1376 unsigned long hash
= zend_get_hash_value (name
, length
);
1378 zval
** result
= get_st_entry (st
, name
, length
, hash TSRMLS_CC
);
1379 zval_ptr_dtor (&str_index
);
1384 * Read the variable described by var_var from symbol table st
1385 * See comments for get_var_var
1388 read_var_var (HashTable
* st
, zval
* index TSRMLS_DC
)
1390 zval
* str_index
= get_string_val (index
);
1391 char* name
= Z_STRVAL_P (str_index
);
1392 int length
= Z_STRLEN_P (str_index
) + 1;
1393 unsigned long hash
= zend_get_hash_value (name
, length
);
1395 zval
* result
= read_var (st
, name
, length
, hash TSRMLS_CC
);
1396 zval_ptr_dtor (&str_index
);
1401 phc_builtin_eval (zval
* arg
, zval
** p_result
, char *filename TSRMLS_DC
)
1403 // If the user wrote "return ..", we need to store the
1404 // return value; however, in that case, zend_eval_string
1405 // will slap an extra "return" onto the front of the string,
1406 // so we must remove the "return" from the string the user
1407 // wrote. If the user did not write "return", he is not
1408 // interested in the return value, and we must pass NULL
1409 // instead or rhs to avoid zend_eval_string adding "return".
1411 // convert to a string
1412 // TODO avoid allocation
1413 zval
*copy
= zvp_clone_ex (arg
);
1414 convert_to_string (copy
);
1416 if (*p_result
&& !strncmp (Z_STRVAL_P (copy
), "return ", 7))
1418 zend_eval_string (Z_STRVAL_P (copy
) + 7, *p_result
,
1419 "eval'd code" TSRMLS_CC
);
1423 zend_eval_string (Z_STRVAL_P (copy
), NULL
, "eval'd code" TSRMLS_CC
);
1427 assert (copy
->refcount
== 1);
1428 zval_ptr_dtor (©
);
1432 phc_builtin_exit (zval
* arg
, zval
** p_result
, char *filename TSRMLS_DC
)
1434 if (Z_TYPE_P (arg
) == IS_LONG
)
1435 EG (exit_status
) = Z_LVAL_P (arg
);
1437 zend_print_variable (arg
);
1443 phc_builtin_die (zval
* arg
, zval
** p_result
, char *filename TSRMLS_DC
)
1445 phc_builtin_exit (arg
, p_result
, filename TSRMLS_CC
);
1449 phc_builtin_echo (zval
* arg
, zval
** p_result TSRMLS_DC
)
1451 assert (*p_result
== NULL
);
1452 zend_print_variable (arg
);
1456 phc_builtin_print (zval
* arg
, zval
** p_result
, char *filename TSRMLS_DC
)
1458 zval
*echo_arg
= NULL
;
1459 phc_builtin_echo (arg
, &echo_arg TSRMLS_CC
);
1462 ZVAL_LONG (*p_result
, 1);
1465 // TODO is there a memory leak here is result has a value?
1466 // TOOD isnt this just the same as isset
1468 phc_builtin_empty (zval
* arg
, zval
** p_result
, char *filename TSRMLS_DC
)
1471 ZVAL_BOOL (*p_result
, !zend_is_true (arg
));
1474 // For require, include, require_once and include_once.
1477 // return 1 for success
1478 // Warning, and return false for failure
1480 // return 1 for success
1483 // Return true if already included
1484 // Return 1 for success
1485 // Warning and return false for failure
1487 // Return true if already included
1488 // return 1 for success
1492 include_backend (zval
* arg
, zval
** p_result
, char *filename
, int type
, int is_once
, char* error
, char* error_function TSRMLS_DC
)
1494 // In the event that the Zend engine cannot find the file, after checking the
1495 // include path, it tries the current directory. It does this only if the
1496 // interpreter is executing, and it checks the interpreters opcodes for a
1497 // filename (see streams/plain_wrapper.c:1352)
1499 // An alternative is to add the directory to include_path, but its
1500 // semantically incorrect (get_included_path() would give the wrong answer),
1501 // and error prone (if people overwrite include_path).
1502 // TODO: though we could add it for this function only
1504 assert (EG (active_op_array
) == NULL
);
1505 assert (filename
!= NULL
);
1507 zval
*arg_file
= arg
;
1508 // Check we have a string
1509 if (Z_TYPE_P (arg_file
) != IS_STRING
)
1511 arg_file
= zvp_clone_ex (arg_file
);
1512 convert_to_string (arg_file
);
1515 zend_file_handle handle
;
1516 zend_op_array
* new_op_array
;
1519 // Check the _ONCE varieties (based on zend_vm_def.h)
1522 if (IS_ABSOLUTE_PATH (Z_STRVAL_P (arg_file
), Z_STRLEN_P (arg_file
)))
1524 // Get the proper path name for require
1527 state
.cwd_length
= 0;
1528 state
.cwd
= malloc(1);
1530 int success
= !virtual_file_ex(&state
, Z_STRVAL_P(arg_file
), NULL
, 1)
1531 && zend_hash_exists(&EG(included_files
), state
.cwd
,
1532 state
.cwd_length
+1);
1543 // Pretend the interpreter is running
1544 EG (in_execution
) = 1;
1546 int success
= zend_stream_open (Z_STRVAL_P (arg_file
), &handle TSRMLS_CC
);
1549 EG (in_execution
) = 0;
1550 EG (active_op_array
) = NULL
;
1552 if (success
!= SUCCESS
)
1558 // Check it hadnt been included already
1559 int once_success
= zend_hash_add_empty_element(&EG(included_files
),
1561 strlen (handle
.opened_path
)+1);
1563 if (once_success
!= SUCCESS
)
1565 ZVAL_BOOL (*p_result
, 1);
1570 if (!handle
.opened_path
)
1571 handle
.opened_path
= estrndup (Z_STRVAL_P(arg_file
), Z_STRLEN_P (arg_file
));
1574 success
= zend_execute_scripts (type TSRMLS_CC
, p_result
, 1, &handle
);
1575 assert (success
== SUCCESS
);
1576 zend_stream_close (&handle
);
1580 ZVAL_LONG (*p_result
, 1);
1588 php_error_docref (error_function
1590 (type
== ZEND_INCLUDE
) ? E_WARNING
: E_ERROR
,
1592 php_strip_url_passwd (Z_STRVAL_P (arg_file
)),
1593 STR_PRINT (PG (include_path
)));
1598 ZVAL_BOOL (*p_result
, 0);
1602 if (handle
.opened_path
)
1603 efree (handle
.opened_path
);
1604 zend_destroy_file_handle (&handle TSRMLS_CC
);
1607 if (arg
!= arg_file
)
1608 zval_ptr_dtor (&arg_file
);
1612 phc_builtin_include (zval
* arg
, zval
** p_result
, char *filename TSRMLS_DC
)
1614 include_backend ( arg
,
1619 "Failed opening '%s' for inclusion (include_path='%s')",
1625 phc_builtin_require (zval
* arg
, zval
** p_result
, char *filename TSRMLS_DC
)
1627 include_backend ( arg
,
1632 "Failed opening required '%s' (include_path='%s')",
1638 phc_builtin_include_once (zval
* arg
, zval
** p_result
, char *filename TSRMLS_DC
)
1640 include_backend ( arg
,
1645 "Failed opening '%s' for inclusion (include_path='%s')",
1646 "function.include_once"
1651 phc_builtin_require_once (zval
* arg
, zval
** p_result
, char *filename TSRMLS_DC
)
1653 include_backend ( arg
,
1658 "Failed opening required '%s' (include_path='%s')",
1659 "function.require_once"
1663 // END INCLUDED FILES
1665 static zend_fcall_info fclose_fci
;
1666 static zend_fcall_info_cache fclose_fcic
= {0,NULL
,NULL
,NULL
};
1667 static zend_fcall_info feof_fci
;
1668 static zend_fcall_info_cache feof_fcic
= {0,NULL
,NULL
,NULL
};
1669 static zend_fcall_info fgets_fci
;
1670 static zend_fcall_info_cache fgets_fcic
= {0,NULL
,NULL
,NULL
};
1671 static zend_fcall_info function_exists_fci
;
1672 static zend_fcall_info_cache function_exists_fcic
= {0,NULL
,NULL
,NULL
};
1673 static zend_fcall_info fwrite_fci
;
1674 static zend_fcall_info_cache fwrite_fcic
= {0,NULL
,NULL
,NULL
};
1675 static zend_fcall_info is_null_fci
;
1676 static zend_fcall_info_cache is_null_fcic
= {0,NULL
,NULL
,NULL
};
1677 static zend_fcall_info is_resource_fci
;
1678 static zend_fcall_info_cache is_resource_fcic
= {0,NULL
,NULL
,NULL
};
1679 static zend_fcall_info mwtidy_execexternaltidy_fci
;
1680 static zend_fcall_info_cache mwtidy_execexternaltidy_fcic
= {0,NULL
,NULL
,NULL
};
1681 static zend_fcall_info mwtidy_execinternaltidy_fci
;
1682 static zend_fcall_info_cache mwtidy_execinternaltidy_fcic
= {0,NULL
,NULL
,NULL
};
1683 static zend_fcall_info proc_close_fci
;
1684 static zend_fcall_info_cache proc_close_fcic
= {0,NULL
,NULL
,NULL
};
1685 static zend_fcall_info proc_open_fci
;
1686 static zend_fcall_info_cache proc_open_fcic
= {0,NULL
,NULL
,NULL
};
1687 static zend_fcall_info str_replace_fci
;
1688 static zend_fcall_info_cache str_replace_fcic
= {0,NULL
,NULL
,NULL
};
1689 static zend_fcall_info tidy_get_output_fci
;
1690 static zend_fcall_info_cache tidy_get_output_fcic
= {0,NULL
,NULL
,NULL
};
1691 static zend_fcall_info wfdebug_fci
;
1692 static zend_fcall_info_cache wfdebug_fcic
= {0,NULL
,NULL
,NULL
};
1693 static zend_fcall_info wfgetnull_fci
;
1694 static zend_fcall_info_cache wfgetnull_fcic
= {0,NULL
,NULL
,NULL
};
1695 static zend_fcall_info wfprofilein_fci
;
1696 static zend_fcall_info_cache wfprofilein_fcic
= {0,NULL
,NULL
,NULL
};
1697 static zend_fcall_info wfprofileout_fci
;
1698 static zend_fcall_info_cache wfprofileout_fcic
= {0,NULL
,NULL
,NULL
};
1701 // public static function tidy($text)
1703 // global $wgTidyInternal;
1704 // $TLE11 = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>test</title></head><body>';
1705 // $TLE12 = ($TLE11 . $text);
1706 // $TLE13 = '</body></html>';
1707 // $wrappedtext = ($TLE12 . $TLE13);
1710 // $wrappedtext = str_replace($TLE14, $TLE15, $wrappedtext);
1711 // if (wgTidyInternal) goto L107 else goto L108;
1713 // $correctedtext = mwtidy::execinternaltidy($wrappedtext);
1716 // $correctedtext = mwtidy::execexternaltidy($wrappedtext);
1719 // $TLE16 = is_null($correctedtext);
1720 // if (TLE16) goto L110 else goto L111;
1722 // $TLE17 = 'Tidy error detected!
1726 // <!-- Tidy found serious XHTML errors -->
1728 // $TLE19 = ($text . $TLE18);
1736 // $correctedtext = str_replace($TLE20, $TLE21, $correctedtext);
1737 // return $correctedtext;
1739 // public static function checkerrors($text, &$errorStr = NULL)
1741 // global $wgTidyInternal;
1743 // if (wgTidyInternal) goto L113 else goto L114;
1746 // $errorStr = mwtidy::execinternaltidy($text, $TLE22, $retval);
1750 // $errorStr = mwtidy::execexternaltidy($text, $TLE23, $retval);
1754 // $TLE0 = ($retval < $TLE24);
1755 // if (TLE0) goto L116 else goto L117;
1758 // $TEF1 = ($errorStr == $TLE25);
1764 // $TLE2 = (bool) $TEF1;
1765 // if (TLE2) goto L119 else goto L120;
1771 // $TEF3 = ($retval == $TLE26);
1774 // $TLE27 = (bool) $TEF3;
1777 // private static function execexternaltidy($text, $stderr = False, &$retval = NULL)
1779 // global $wgTidyConf;
1780 // global $wgTidyBin;
1781 // global $wgTidyOpts;
1782 // $TLE28 = 'MWTidy::execExternalTidy';
1783 // wfprofilein($TLE28);
1784 // $cleansource = '';
1785 // $opts = ' -utf8';
1786 // if (stderr) goto L122 else goto L123;
1792 // $TSa32 = (array) $TSa32;
1793 // $TSa32[] = $TLE30;
1794 // $TSa32[] = $TLE31;
1797 // $TLE35 = wfgetnull();
1800 // $TSa37 = (array) $TSa37;
1801 // $TSa37[] = $TLE34;
1802 // $TSa37[] = $TLE35;
1803 // $TSa37[] = $TLE36;
1808 // $TSa41 = (array) $TSa41;
1809 // $TSa41[] = $TLE39;
1810 // $TSa41[] = $TLE40;
1812 // $TSa42 = (array) $TSa42;
1813 // $TSa42[$TLE29] = $TSa32;
1814 // $TSa42[$TLE33] = $TSa37;
1815 // $TSa42[$TLE38] = $TSa41;
1816 // $descriptorspec = $TSa42;
1823 // $TSa46 = (array) $TSa46;
1824 // $TSa46[] = $TLE44;
1825 // $TSa46[] = $TLE45;
1830 // $TSa50 = (array) $TSa50;
1831 // $TSa50[] = $TLE48;
1832 // $TSa50[] = $TLE49;
1835 // $TLE53 = wfgetnull();
1838 // $TSa55 = (array) $TSa55;
1839 // $TSa55[] = $TLE52;
1840 // $TSa55[] = $TLE53;
1841 // $TSa55[] = $TLE54;
1843 // $TSa56 = (array) $TSa56;
1844 // $TSa56[$TLE43] = $TSa46;
1845 // $TSa56[$TLE47] = $TSa50;
1846 // $TSa56[$TLE51] = $TSa55;
1847 // $descriptorspec = $TSa56;
1850 // if (stderr) goto L125 else goto L126;
1858 // $readpipe = $TEF4;
1860 // $TSa57 = (array) $TSa57;
1862 // $TLE58 = 'proc_open';
1863 // $TLE59 = function_exists($TLE58);
1864 // if (TLE59) goto L151 else goto L152;
1866 // $TLE60 = ' -config ';
1867 // $TLE61 = ($wgTidyBin . $TLE60);
1868 // $TLE62 = ($TLE61 . $wgTidyConf);
1870 // $TLE64 = ($TLE62 . $TLE63);
1871 // $TLE65 = ($TLE64 . $wgTidyOpts);
1872 // $TLE66 = ($TLE65 . $opts);
1873 // $process = proc_open($TLE66, $descriptorspec, $pipes);
1874 // $TLE67 = is_resource($process);
1875 // if (TLE67) goto L148 else goto L149;
1878 // $TLE96 = param_is_ref (NULL, "fwrite", 0);
1880 // if (TLE96) goto L128 else goto L129;
1882 // $TMIi95 =& $pipes[$TLE68];
1885 // $TMIi95 = $pipes[$TLE68];
1888 // fwrite($TMIi95, $text);
1890 // $TLE98 = param_is_ref (NULL, "fclose", 0);
1892 // if (TLE98) goto L131 else goto L132;
1894 // $TMIi97 =& $pipes[$TLE69];
1897 // $TMIi97 = $pipes[$TLE69];
1902 // $TLE100 = param_is_ref (NULL, "feof", 0);
1904 // if (TLE100) goto L134 else goto L135;
1906 // $TMIi99 =& $pipes[$readpipe];
1909 // $TMIi99 = $pipes[$readpipe];
1912 // $TLE70 = feof($TMIi99);
1913 // $TLE71 = !$TLE70;
1914 // $TLE72 = !$TLE71;
1915 // if (TLE72) goto L138 else goto L139;
1923 // $TLE102 = param_is_ref (NULL, "fgets", 0);
1925 // if (TLE102) goto L141 else goto L142;
1927 // $TMIi101 =& $pipes[$readpipe];
1930 // $TMIi101 = $pipes[$readpipe];
1933 // $TLE74 = fgets($TMIi101, $TLE73);
1934 // $cleansource = ($cleansource . $TLE74);
1937 // $TLE104 = param_is_ref (NULL, "fclose", 0);
1939 // if (TLE104) goto L145 else goto L146;
1941 // $TMIi103 =& $pipes[$readpipe];
1944 // $TMIi103 = $pipes[$readpipe];
1947 // fclose($TMIi103);
1948 // $retval = proc_close($process);
1959 // $TLE75 = 'MWTidy::execExternalTidy';
1960 // wfprofileout($TLE75);
1961 // $TLE5 = !$stderr;
1962 // if (TLE5) goto L154 else goto L155;
1965 // $TEF6 = ($cleansource == $TLE76);
1971 // $TLE7 = (bool) $TEF6;
1972 // if (TLE7) goto L157 else goto L158;
1975 // $TEF8 = ($text != $TLE77);
1981 // $TLE78 = (bool) $TEF8;
1982 // if (TLE78) goto L160 else goto L161;
1988 // return $cleansource;
1992 // private static function execinternaltidy($text, $stderr = False, &$retval = NULL)
1994 // global $wgTidyConf;
1996 // global $wgDebugTidy;
1997 // $TLE80 = 'MWTidy::execInternalTidy';
1998 // wfprofilein($TLE80);
1999 // $tidy = new tidy();
2001 // $tidy->parsestring($text, $wgTidyConf, $TLE81);
2002 // if (stderr) goto L175 else goto L176;
2004 // $retval = $tidy->getstatus();
2005 // $TSt82 = $tidy->errorBuffer;
2009 // $tidy->cleanrepair();
2010 // $retval = $tidy->getstatus();
2012 // $TLE84 = ($retval == $TLE83);
2013 // if (TLE84) goto L163 else goto L164;
2015 // $cleansource = NULL;
2018 // $cleansource = tidy_get_output($tidy);
2021 // $TLE9 = $wgDebugTidy;
2022 // if (TLE9) goto L166 else goto L167;
2025 // $TEF10 = ($TLE85 < $retval);
2031 // $TLE86 = (bool) $TEF10;
2032 // if (TLE86) goto L172 else goto L173;
2038 // $TLE89 = '-->';
2039 // $TLE106 = param_is_ref (NULL, "str_replace", 0);
2041 // if (TLE106) goto L169 else goto L170;
2043 // $TMIt105 =& $tidy->errorBuffer;
2046 // $TMIt105 = $tidy->errorBuffer;
2049 // $TLE90 = str_replace($TLE88, $TLE89, $TMIt105);
2050 // $TLE91 = ($TLE87 . $TLE90);
2053 // $TLE93 = ($TLE91 . $TLE92);
2054 // $cleansource = ($cleansource . $TLE93);
2059 // $TLE94 = 'MWTidy::execInternalTidy';
2060 // wfprofileout($TLE94);
2061 // return $cleansource;
2066 // public static function tidy($text)
2068 // global $wgTidyInternal;
2069 // $TLE11 = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>test</title></head><body>';
2070 // $TLE12 = ($TLE11 . $text);
2071 // $TLE13 = '</body></html>';
2072 // $wrappedtext = ($TLE12 . $TLE13);
2075 // $wrappedtext = str_replace($TLE14, $TLE15, $wrappedtext);
2076 // if (wgTidyInternal) goto L107 else goto L108;
2078 // $correctedtext = mwtidy::execinternaltidy($wrappedtext);
2081 // $correctedtext = mwtidy::execexternaltidy($wrappedtext);
2084 // $TLE16 = is_null($correctedtext);
2085 // if (TLE16) goto L110 else goto L111;
2087 // $TLE17 = 'Tidy error detected!
2091 // <!-- Tidy found serious XHTML errors -->
2093 // $TLE19 = ($text . $TLE18);
2101 // $correctedtext = str_replace($TLE20, $TLE21, $correctedtext);
2102 // return $correctedtext;
2104 PHP_METHOD(MWTidy
, tidy
)
2106 zval
* local_TLE11
= NULL
;
2107 zval
* local_TLE12
= NULL
;
2108 zval
* local_TLE13
= NULL
;
2109 zval
* local_TLE14
= NULL
;
2110 zval
* local_TLE15
= NULL
;
2111 zval
* local_TLE16
= NULL
;
2112 zval
* local_TLE17
= NULL
;
2113 zval
* local_TLE18
= NULL
;
2114 zval
* local_TLE19
= NULL
;
2115 zval
* local_TLE20
= NULL
;
2116 zval
* local_TLE21
= NULL
;
2117 zval
* local_correctedtext
= NULL
;
2118 zval
* local_text
= NULL
;
2119 zval
* local_wgTidyInternal
= NULL
;
2120 zval
* local_wrappedtext
= NULL
;
2121 // Add all parameters as local variables
2123 int num_args
= ZEND_NUM_ARGS ();
2125 zend_get_parameters_array(0, num_args
, params
);
2127 params
[0]->refcount
++;
2128 if (local_text
!= NULL
)
2130 zval_ptr_dtor (&local_text
);
2132 local_text
= params
[0];
2135 // global $wgTidyInternal;
2137 if (local_wgTidyInternal
== NULL
)
2139 local_wgTidyInternal
= EG (uninitialized_zval_ptr
);
2140 local_wgTidyInternal
->refcount
++;
2142 zval
** p_local
= &local_wgTidyInternal
;
2144 zval
** p_global
= get_st_entry (&EG(symbol_table
), "wgTidyInternal", 14 + 1, 125132442u TSRMLS_CC
);
2146 sep_copy_on_write (p_global
);
2147 copy_into_ref (p_local
, p_global
);
2148 phc_check_invariants (TSRMLS_C
);
2150 // $TLE11 = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>test</title></head><body>';
2152 if (local_TLE11
== NULL
)
2154 local_TLE11
= EG (uninitialized_zval_ptr
);
2155 local_TLE11
->refcount
++;
2157 zval
** p_lhs
= &local_TLE11
;
2160 if ((*p_lhs
)->is_ref
)
2162 // Always overwrite the current value
2168 ALLOC_INIT_ZVAL (value
);
2169 zval_ptr_dtor (p_lhs
);
2173 ZVAL_STRINGL(value
, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html><head><title>test</title></head><body>", 165, 1);
2175 phc_check_invariants (TSRMLS_C
);
2177 // $TLE12 = ($TLE11 . $text);
2179 if (local_TLE12
== NULL
)
2181 local_TLE12
= EG (uninitialized_zval_ptr
);
2182 local_TLE12
->refcount
++;
2184 zval
** p_lhs
= &local_TLE12
;
2187 if (local_TLE11
== NULL
)
2188 left
= EG (uninitialized_zval_ptr
);
2193 if (local_text
== NULL
)
2194 right
= EG (uninitialized_zval_ptr
);
2198 if (in_copy_on_write (*p_lhs
))
2200 zval_ptr_dtor (p_lhs
);
2201 ALLOC_INIT_ZVAL (*p_lhs
);
2205 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
2206 concat_function (*p_lhs
, left
, right TSRMLS_CC
);
2208 // If the result is one of the operands, the operator function
2209 // will already have cleaned up the result
2210 if (!result_is_operand
)
2212 phc_check_invariants (TSRMLS_C
);
2214 // $TLE13 = '</body></html>';
2216 if (local_TLE13
== NULL
)
2218 local_TLE13
= EG (uninitialized_zval_ptr
);
2219 local_TLE13
->refcount
++;
2221 zval
** p_lhs
= &local_TLE13
;
2224 if ((*p_lhs
)->is_ref
)
2226 // Always overwrite the current value
2232 ALLOC_INIT_ZVAL (value
);
2233 zval_ptr_dtor (p_lhs
);
2237 ZVAL_STRINGL(value
, "</body></html>", 14, 1);
2239 phc_check_invariants (TSRMLS_C
);
2241 // $wrappedtext = ($TLE12 . $TLE13);
2243 if (local_wrappedtext
== NULL
)
2245 local_wrappedtext
= EG (uninitialized_zval_ptr
);
2246 local_wrappedtext
->refcount
++;
2248 zval
** p_lhs
= &local_wrappedtext
;
2251 if (local_TLE12
== NULL
)
2252 left
= EG (uninitialized_zval_ptr
);
2257 if (local_TLE13
== NULL
)
2258 right
= EG (uninitialized_zval_ptr
);
2260 right
= local_TLE13
;
2262 if (in_copy_on_write (*p_lhs
))
2264 zval_ptr_dtor (p_lhs
);
2265 ALLOC_INIT_ZVAL (*p_lhs
);
2269 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
2270 concat_function (*p_lhs
, left
, right TSRMLS_CC
);
2272 // If the result is one of the operands, the operator function
2273 // will already have cleaned up the result
2274 if (!result_is_operand
)
2276 phc_check_invariants (TSRMLS_C
);
2280 if (local_TLE14
== NULL
)
2282 local_TLE14
= EG (uninitialized_zval_ptr
);
2283 local_TLE14
->refcount
++;
2285 zval
** p_lhs
= &local_TLE14
;
2288 if ((*p_lhs
)->is_ref
)
2290 // Always overwrite the current value
2296 ALLOC_INIT_ZVAL (value
);
2297 zval_ptr_dtor (p_lhs
);
2301 ZVAL_STRINGL(value
, "\011", 1, 1);
2303 phc_check_invariants (TSRMLS_C
);
2307 if (local_TLE15
== NULL
)
2309 local_TLE15
= EG (uninitialized_zval_ptr
);
2310 local_TLE15
->refcount
++;
2312 zval
** p_lhs
= &local_TLE15
;
2315 if ((*p_lhs
)->is_ref
)
2317 // Always overwrite the current value
2323 ALLOC_INIT_ZVAL (value
);
2324 zval_ptr_dtor (p_lhs
);
2328 ZVAL_STRINGL(value
, "	", 4, 1);
2330 phc_check_invariants (TSRMLS_C
);
2332 // $wrappedtext = str_replace($TLE14, $TLE15, $wrappedtext);
2334 initialize_function_call (&str_replace_fci
, &str_replace_fcic
, "str_replace", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 30 TSRMLS_CC
);
2335 zend_function
* signature
= str_replace_fcic
.function_handler
;
2336 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
2340 // TODO: find names to replace index
2343 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
2347 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
2350 // TODO: find names to replace index
2353 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
2357 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
2360 // TODO: find names to replace index
2363 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
2367 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
2372 // Setup array of arguments
2373 // TODO: i think arrays of size 0 is an error
2376 zval
** args_ind
[3];
2379 destruct
[af_index
] = 0;
2380 if (by_ref
[af_index
])
2382 if (local_TLE14
== NULL
)
2384 local_TLE14
= EG (uninitialized_zval_ptr
);
2385 local_TLE14
->refcount
++;
2387 zval
** p_arg
= &local_TLE14
;
2389 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
2390 assert (!in_copy_on_write (*args_ind
[af_index
]));
2391 args
[af_index
] = *args_ind
[af_index
];
2396 if (local_TLE14
== NULL
)
2397 arg
= EG (uninitialized_zval_ptr
);
2401 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
2402 args_ind
[af_index
] = &args
[af_index
];
2405 destruct
[af_index
] = 0;
2406 if (by_ref
[af_index
])
2408 if (local_TLE15
== NULL
)
2410 local_TLE15
= EG (uninitialized_zval_ptr
);
2411 local_TLE15
->refcount
++;
2413 zval
** p_arg
= &local_TLE15
;
2415 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
2416 assert (!in_copy_on_write (*args_ind
[af_index
]));
2417 args
[af_index
] = *args_ind
[af_index
];
2422 if (local_TLE15
== NULL
)
2423 arg
= EG (uninitialized_zval_ptr
);
2427 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
2428 args_ind
[af_index
] = &args
[af_index
];
2431 destruct
[af_index
] = 0;
2432 if (by_ref
[af_index
])
2434 if (local_wrappedtext
== NULL
)
2436 local_wrappedtext
= EG (uninitialized_zval_ptr
);
2437 local_wrappedtext
->refcount
++;
2439 zval
** p_arg
= &local_wrappedtext
;
2441 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
2442 assert (!in_copy_on_write (*args_ind
[af_index
]));
2443 args
[af_index
] = *args_ind
[af_index
];
2448 if (local_wrappedtext
== NULL
)
2449 arg
= EG (uninitialized_zval_ptr
);
2451 arg
= local_wrappedtext
;
2453 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
2454 args_ind
[af_index
] = &args
[af_index
];
2459 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 30, NULL TSRMLS_CC
);
2461 // save existing parameters, in case of recursion
2462 int param_count_save
= str_replace_fci
.param_count
;
2463 zval
*** params_save
= str_replace_fci
.params
;
2464 zval
** retval_save
= str_replace_fci
.retval_ptr_ptr
;
2469 str_replace_fci
.params
= args_ind
;
2470 str_replace_fci
.param_count
= 3;
2471 str_replace_fci
.retval_ptr_ptr
= &rhs
;
2473 // call the function
2474 int success
= zend_call_function (&str_replace_fci
, &str_replace_fcic TSRMLS_CC
);
2475 assert(success
== SUCCESS
);
2478 str_replace_fci
.params
= params_save
;
2479 str_replace_fci
.param_count
= param_count_save
;
2480 str_replace_fci
.retval_ptr_ptr
= retval_save
;
2483 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
2486 for (i
= 0; i
< 3; i
++)
2490 assert (destruct
[i
]);
2491 zval_ptr_dtor (args_ind
[i
]);
2496 // When the Zend engine returns by reference, it allocates a zval into
2497 // retval_ptr_ptr. To return by reference, the callee writes into the
2498 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
2499 // not actually return anything). So the zval returned - whether we return
2500 // it, or it is the allocated zval - has a refcount of 1.
2502 // The caller is responsible for cleaning that up (note, this is unaffected
2503 // by whether it is added to some COW set).
2505 // For reasons unknown, the Zend API resets the refcount and is_ref fields
2506 // of the return value after the function returns (unless the callee is
2507 // interpreted). If the function is supposed to return by reference, this
2508 // loses the refcount. This only happens when non-interpreted code is
2509 // called. We work around it, when compiled code is called, by saving the
2510 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
2511 // that we may create an error if our code is called by a callback, and
2512 // returns by reference, and the callback returns by reference. At least
2513 // this is an obscure case.
2514 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
2516 assert (rhs
!= EG(uninitialized_zval_ptr
));
2518 if (saved_refcount
!= 0)
2520 rhs
->refcount
= saved_refcount
;
2524 saved_refcount
= 0; // for 'obscure cases'
2526 if (local_wrappedtext
== NULL
)
2528 local_wrappedtext
= EG (uninitialized_zval_ptr
);
2529 local_wrappedtext
->refcount
++;
2531 zval
** p_lhs
= &local_wrappedtext
;
2533 write_var (p_lhs
, rhs
);
2536 zval_ptr_dtor (&rhs
);
2537 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
2538 zval_ptr_dtor (&rhs
);
2540 phc_check_invariants (TSRMLS_C
);
2542 // if (wgTidyInternal) goto L107 else goto L108;
2545 if (local_wgTidyInternal
== NULL
)
2546 p_cond
= EG (uninitialized_zval_ptr
);
2548 p_cond
= local_wgTidyInternal
;
2550 zend_bool bcond
= zend_is_true (p_cond
);
2555 phc_check_invariants (TSRMLS_C
);
2559 // $correctedtext = mwtidy::execinternaltidy($wrappedtext);
2561 initialize_function_call (&mwtidy_execinternaltidy_fci
, &mwtidy_execinternaltidy_fcic
, "mwtidy::execinternaltidy", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 33 TSRMLS_CC
);
2562 zend_function
* signature
= mwtidy_execinternaltidy_fcic
.function_handler
;
2563 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
2567 // TODO: find names to replace index
2570 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
2574 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
2579 // Setup array of arguments
2580 // TODO: i think arrays of size 0 is an error
2583 zval
** args_ind
[1];
2586 destruct
[af_index
] = 0;
2587 if (by_ref
[af_index
])
2589 if (local_wrappedtext
== NULL
)
2591 local_wrappedtext
= EG (uninitialized_zval_ptr
);
2592 local_wrappedtext
->refcount
++;
2594 zval
** p_arg
= &local_wrappedtext
;
2596 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
2597 assert (!in_copy_on_write (*args_ind
[af_index
]));
2598 args
[af_index
] = *args_ind
[af_index
];
2603 if (local_wrappedtext
== NULL
)
2604 arg
= EG (uninitialized_zval_ptr
);
2606 arg
= local_wrappedtext
;
2608 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
2609 args_ind
[af_index
] = &args
[af_index
];
2614 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 33, NULL TSRMLS_CC
);
2616 // save existing parameters, in case of recursion
2617 int param_count_save
= mwtidy_execinternaltidy_fci
.param_count
;
2618 zval
*** params_save
= mwtidy_execinternaltidy_fci
.params
;
2619 zval
** retval_save
= mwtidy_execinternaltidy_fci
.retval_ptr_ptr
;
2624 mwtidy_execinternaltidy_fci
.params
= args_ind
;
2625 mwtidy_execinternaltidy_fci
.param_count
= 1;
2626 mwtidy_execinternaltidy_fci
.retval_ptr_ptr
= &rhs
;
2628 // call the function
2629 int success
= zend_call_function (&mwtidy_execinternaltidy_fci
, &mwtidy_execinternaltidy_fcic TSRMLS_CC
);
2630 assert(success
== SUCCESS
);
2633 mwtidy_execinternaltidy_fci
.params
= params_save
;
2634 mwtidy_execinternaltidy_fci
.param_count
= param_count_save
;
2635 mwtidy_execinternaltidy_fci
.retval_ptr_ptr
= retval_save
;
2638 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
2641 for (i
= 0; i
< 1; i
++)
2645 assert (destruct
[i
]);
2646 zval_ptr_dtor (args_ind
[i
]);
2651 // When the Zend engine returns by reference, it allocates a zval into
2652 // retval_ptr_ptr. To return by reference, the callee writes into the
2653 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
2654 // not actually return anything). So the zval returned - whether we return
2655 // it, or it is the allocated zval - has a refcount of 1.
2657 // The caller is responsible for cleaning that up (note, this is unaffected
2658 // by whether it is added to some COW set).
2660 // For reasons unknown, the Zend API resets the refcount and is_ref fields
2661 // of the return value after the function returns (unless the callee is
2662 // interpreted). If the function is supposed to return by reference, this
2663 // loses the refcount. This only happens when non-interpreted code is
2664 // called. We work around it, when compiled code is called, by saving the
2665 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
2666 // that we may create an error if our code is called by a callback, and
2667 // returns by reference, and the callback returns by reference. At least
2668 // this is an obscure case.
2669 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
2671 assert (rhs
!= EG(uninitialized_zval_ptr
));
2673 if (saved_refcount
!= 0)
2675 rhs
->refcount
= saved_refcount
;
2679 saved_refcount
= 0; // for 'obscure cases'
2681 if (local_correctedtext
== NULL
)
2683 local_correctedtext
= EG (uninitialized_zval_ptr
);
2684 local_correctedtext
->refcount
++;
2686 zval
** p_lhs
= &local_correctedtext
;
2688 write_var (p_lhs
, rhs
);
2691 zval_ptr_dtor (&rhs
);
2692 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
2693 zval_ptr_dtor (&rhs
);
2695 phc_check_invariants (TSRMLS_C
);
2700 phc_check_invariants (TSRMLS_C
);
2704 // $correctedtext = mwtidy::execexternaltidy($wrappedtext);
2706 initialize_function_call (&mwtidy_execexternaltidy_fci
, &mwtidy_execexternaltidy_fcic
, "mwtidy::execexternaltidy", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 35 TSRMLS_CC
);
2707 zend_function
* signature
= mwtidy_execexternaltidy_fcic
.function_handler
;
2708 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
2712 // TODO: find names to replace index
2715 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
2719 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
2724 // Setup array of arguments
2725 // TODO: i think arrays of size 0 is an error
2728 zval
** args_ind
[1];
2731 destruct
[af_index
] = 0;
2732 if (by_ref
[af_index
])
2734 if (local_wrappedtext
== NULL
)
2736 local_wrappedtext
= EG (uninitialized_zval_ptr
);
2737 local_wrappedtext
->refcount
++;
2739 zval
** p_arg
= &local_wrappedtext
;
2741 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
2742 assert (!in_copy_on_write (*args_ind
[af_index
]));
2743 args
[af_index
] = *args_ind
[af_index
];
2748 if (local_wrappedtext
== NULL
)
2749 arg
= EG (uninitialized_zval_ptr
);
2751 arg
= local_wrappedtext
;
2753 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
2754 args_ind
[af_index
] = &args
[af_index
];
2759 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 35, NULL TSRMLS_CC
);
2761 // save existing parameters, in case of recursion
2762 int param_count_save
= mwtidy_execexternaltidy_fci
.param_count
;
2763 zval
*** params_save
= mwtidy_execexternaltidy_fci
.params
;
2764 zval
** retval_save
= mwtidy_execexternaltidy_fci
.retval_ptr_ptr
;
2769 mwtidy_execexternaltidy_fci
.params
= args_ind
;
2770 mwtidy_execexternaltidy_fci
.param_count
= 1;
2771 mwtidy_execexternaltidy_fci
.retval_ptr_ptr
= &rhs
;
2773 // call the function
2774 int success
= zend_call_function (&mwtidy_execexternaltidy_fci
, &mwtidy_execexternaltidy_fcic TSRMLS_CC
);
2775 assert(success
== SUCCESS
);
2778 mwtidy_execexternaltidy_fci
.params
= params_save
;
2779 mwtidy_execexternaltidy_fci
.param_count
= param_count_save
;
2780 mwtidy_execexternaltidy_fci
.retval_ptr_ptr
= retval_save
;
2783 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
2786 for (i
= 0; i
< 1; i
++)
2790 assert (destruct
[i
]);
2791 zval_ptr_dtor (args_ind
[i
]);
2796 // When the Zend engine returns by reference, it allocates a zval into
2797 // retval_ptr_ptr. To return by reference, the callee writes into the
2798 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
2799 // not actually return anything). So the zval returned - whether we return
2800 // it, or it is the allocated zval - has a refcount of 1.
2802 // The caller is responsible for cleaning that up (note, this is unaffected
2803 // by whether it is added to some COW set).
2805 // For reasons unknown, the Zend API resets the refcount and is_ref fields
2806 // of the return value after the function returns (unless the callee is
2807 // interpreted). If the function is supposed to return by reference, this
2808 // loses the refcount. This only happens when non-interpreted code is
2809 // called. We work around it, when compiled code is called, by saving the
2810 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
2811 // that we may create an error if our code is called by a callback, and
2812 // returns by reference, and the callback returns by reference. At least
2813 // this is an obscure case.
2814 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
2816 assert (rhs
!= EG(uninitialized_zval_ptr
));
2818 if (saved_refcount
!= 0)
2820 rhs
->refcount
= saved_refcount
;
2824 saved_refcount
= 0; // for 'obscure cases'
2826 if (local_correctedtext
== NULL
)
2828 local_correctedtext
= EG (uninitialized_zval_ptr
);
2829 local_correctedtext
->refcount
++;
2831 zval
** p_lhs
= &local_correctedtext
;
2833 write_var (p_lhs
, rhs
);
2836 zval_ptr_dtor (&rhs
);
2837 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
2838 zval_ptr_dtor (&rhs
);
2840 phc_check_invariants (TSRMLS_C
);
2845 phc_check_invariants (TSRMLS_C
);
2849 // $TLE16 = is_null($correctedtext);
2851 initialize_function_call (&is_null_fci
, &is_null_fcic
, "is_null", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 37 TSRMLS_CC
);
2852 zend_function
* signature
= is_null_fcic
.function_handler
;
2853 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
2857 // TODO: find names to replace index
2860 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
2864 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
2869 // Setup array of arguments
2870 // TODO: i think arrays of size 0 is an error
2873 zval
** args_ind
[1];
2876 destruct
[af_index
] = 0;
2877 if (by_ref
[af_index
])
2879 if (local_correctedtext
== NULL
)
2881 local_correctedtext
= EG (uninitialized_zval_ptr
);
2882 local_correctedtext
->refcount
++;
2884 zval
** p_arg
= &local_correctedtext
;
2886 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
2887 assert (!in_copy_on_write (*args_ind
[af_index
]));
2888 args
[af_index
] = *args_ind
[af_index
];
2893 if (local_correctedtext
== NULL
)
2894 arg
= EG (uninitialized_zval_ptr
);
2896 arg
= local_correctedtext
;
2898 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
2899 args_ind
[af_index
] = &args
[af_index
];
2904 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 37, NULL TSRMLS_CC
);
2906 // save existing parameters, in case of recursion
2907 int param_count_save
= is_null_fci
.param_count
;
2908 zval
*** params_save
= is_null_fci
.params
;
2909 zval
** retval_save
= is_null_fci
.retval_ptr_ptr
;
2914 is_null_fci
.params
= args_ind
;
2915 is_null_fci
.param_count
= 1;
2916 is_null_fci
.retval_ptr_ptr
= &rhs
;
2918 // call the function
2919 int success
= zend_call_function (&is_null_fci
, &is_null_fcic TSRMLS_CC
);
2920 assert(success
== SUCCESS
);
2923 is_null_fci
.params
= params_save
;
2924 is_null_fci
.param_count
= param_count_save
;
2925 is_null_fci
.retval_ptr_ptr
= retval_save
;
2928 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
2931 for (i
= 0; i
< 1; i
++)
2935 assert (destruct
[i
]);
2936 zval_ptr_dtor (args_ind
[i
]);
2941 // When the Zend engine returns by reference, it allocates a zval into
2942 // retval_ptr_ptr. To return by reference, the callee writes into the
2943 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
2944 // not actually return anything). So the zval returned - whether we return
2945 // it, or it is the allocated zval - has a refcount of 1.
2947 // The caller is responsible for cleaning that up (note, this is unaffected
2948 // by whether it is added to some COW set).
2950 // For reasons unknown, the Zend API resets the refcount and is_ref fields
2951 // of the return value after the function returns (unless the callee is
2952 // interpreted). If the function is supposed to return by reference, this
2953 // loses the refcount. This only happens when non-interpreted code is
2954 // called. We work around it, when compiled code is called, by saving the
2955 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
2956 // that we may create an error if our code is called by a callback, and
2957 // returns by reference, and the callback returns by reference. At least
2958 // this is an obscure case.
2959 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
2961 assert (rhs
!= EG(uninitialized_zval_ptr
));
2963 if (saved_refcount
!= 0)
2965 rhs
->refcount
= saved_refcount
;
2969 saved_refcount
= 0; // for 'obscure cases'
2971 if (local_TLE16
== NULL
)
2973 local_TLE16
= EG (uninitialized_zval_ptr
);
2974 local_TLE16
->refcount
++;
2976 zval
** p_lhs
= &local_TLE16
;
2978 write_var (p_lhs
, rhs
);
2981 zval_ptr_dtor (&rhs
);
2982 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
2983 zval_ptr_dtor (&rhs
);
2985 phc_check_invariants (TSRMLS_C
);
2987 // if (TLE16) goto L110 else goto L111;
2990 if (local_TLE16
== NULL
)
2991 p_cond
= EG (uninitialized_zval_ptr
);
2993 p_cond
= local_TLE16
;
2995 zend_bool bcond
= zend_is_true (p_cond
);
3000 phc_check_invariants (TSRMLS_C
);
3004 // $TLE17 = 'Tidy error detected!
3007 if (local_TLE17
== NULL
)
3009 local_TLE17
= EG (uninitialized_zval_ptr
);
3010 local_TLE17
->refcount
++;
3012 zval
** p_lhs
= &local_TLE17
;
3015 if ((*p_lhs
)->is_ref
)
3017 // Always overwrite the current value
3023 ALLOC_INIT_ZVAL (value
);
3024 zval_ptr_dtor (p_lhs
);
3028 ZVAL_STRINGL(value
, "Tidy error detected!\012", 21, 1);
3030 phc_check_invariants (TSRMLS_C
);
3034 initialize_function_call (&wfdebug_fci
, &wfdebug_fcic
, "wfdebug", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 38 TSRMLS_CC
);
3035 zend_function
* signature
= wfdebug_fcic
.function_handler
;
3036 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
3040 // TODO: find names to replace index
3043 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
3047 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
3052 // Setup array of arguments
3053 // TODO: i think arrays of size 0 is an error
3056 zval
** args_ind
[1];
3059 destruct
[af_index
] = 0;
3060 if (by_ref
[af_index
])
3062 if (local_TLE17
== NULL
)
3064 local_TLE17
= EG (uninitialized_zval_ptr
);
3065 local_TLE17
->refcount
++;
3067 zval
** p_arg
= &local_TLE17
;
3069 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
3070 assert (!in_copy_on_write (*args_ind
[af_index
]));
3071 args
[af_index
] = *args_ind
[af_index
];
3076 if (local_TLE17
== NULL
)
3077 arg
= EG (uninitialized_zval_ptr
);
3081 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
3082 args_ind
[af_index
] = &args
[af_index
];
3087 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 38, NULL TSRMLS_CC
);
3089 // save existing parameters, in case of recursion
3090 int param_count_save
= wfdebug_fci
.param_count
;
3091 zval
*** params_save
= wfdebug_fci
.params
;
3092 zval
** retval_save
= wfdebug_fci
.retval_ptr_ptr
;
3097 wfdebug_fci
.params
= args_ind
;
3098 wfdebug_fci
.param_count
= 1;
3099 wfdebug_fci
.retval_ptr_ptr
= &rhs
;
3101 // call the function
3102 int success
= zend_call_function (&wfdebug_fci
, &wfdebug_fcic TSRMLS_CC
);
3103 assert(success
== SUCCESS
);
3106 wfdebug_fci
.params
= params_save
;
3107 wfdebug_fci
.param_count
= param_count_save
;
3108 wfdebug_fci
.retval_ptr_ptr
= retval_save
;
3111 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
3114 for (i
= 0; i
< 1; i
++)
3118 assert (destruct
[i
]);
3119 zval_ptr_dtor (args_ind
[i
]);
3124 // When the Zend engine returns by reference, it allocates a zval into
3125 // retval_ptr_ptr. To return by reference, the callee writes into the
3126 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
3127 // not actually return anything). So the zval returned - whether we return
3128 // it, or it is the allocated zval - has a refcount of 1.
3130 // The caller is responsible for cleaning that up (note, this is unaffected
3131 // by whether it is added to some COW set).
3133 // For reasons unknown, the Zend API resets the refcount and is_ref fields
3134 // of the return value after the function returns (unless the callee is
3135 // interpreted). If the function is supposed to return by reference, this
3136 // loses the refcount. This only happens when non-interpreted code is
3137 // called. We work around it, when compiled code is called, by saving the
3138 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
3139 // that we may create an error if our code is called by a callback, and
3140 // returns by reference, and the callback returns by reference. At least
3141 // this is an obscure case.
3142 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
3144 assert (rhs
!= EG(uninitialized_zval_ptr
));
3146 if (saved_refcount
!= 0)
3148 rhs
->refcount
= saved_refcount
;
3152 saved_refcount
= 0; // for 'obscure cases'
3156 zval_ptr_dtor (&rhs
);
3157 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
3158 zval_ptr_dtor (&rhs
);
3160 phc_check_invariants (TSRMLS_C
);
3163 // <!-- Tidy found serious XHTML errors -->
3166 if (local_TLE18
== NULL
)
3168 local_TLE18
= EG (uninitialized_zval_ptr
);
3169 local_TLE18
->refcount
++;
3171 zval
** p_lhs
= &local_TLE18
;
3174 if ((*p_lhs
)->is_ref
)
3176 // Always overwrite the current value
3182 ALLOC_INIT_ZVAL (value
);
3183 zval_ptr_dtor (p_lhs
);
3187 ZVAL_STRINGL(value
, "\012<!-- Tidy found serious XHTML errors -->\012", 42, 1);
3189 phc_check_invariants (TSRMLS_C
);
3191 // $TLE19 = ($text . $TLE18);
3193 if (local_TLE19
== NULL
)
3195 local_TLE19
= EG (uninitialized_zval_ptr
);
3196 local_TLE19
->refcount
++;
3198 zval
** p_lhs
= &local_TLE19
;
3201 if (local_text
== NULL
)
3202 left
= EG (uninitialized_zval_ptr
);
3207 if (local_TLE18
== NULL
)
3208 right
= EG (uninitialized_zval_ptr
);
3210 right
= local_TLE18
;
3212 if (in_copy_on_write (*p_lhs
))
3214 zval_ptr_dtor (p_lhs
);
3215 ALLOC_INIT_ZVAL (*p_lhs
);
3219 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
3220 concat_function (*p_lhs
, left
, right TSRMLS_CC
);
3222 // If the result is one of the operands, the operator function
3223 // will already have cleaned up the result
3224 if (!result_is_operand
)
3226 phc_check_invariants (TSRMLS_C
);
3231 if (local_TLE19
== NULL
)
3232 rhs
= EG (uninitialized_zval_ptr
);
3236 // Run-time return by reference has different semantics to compile-time.
3237 // If the function has CTRBR and RTRBR, the the assignment will be
3238 // reference. If one or the other is return-by-copy, the result will be
3239 // by copy. Its a question of whether its separated at return-time (which
3240 // we do here) or at the call-site.
3241 return_value
->value
= rhs
->value
;
3242 return_value
->type
= rhs
->type
;
3243 zval_copy_ctor (return_value
);
3244 goto end_of_function
;
3245 phc_check_invariants (TSRMLS_C
);
3250 phc_check_invariants (TSRMLS_C
);
3257 phc_check_invariants (TSRMLS_C
);
3263 if (local_TLE20
== NULL
)
3265 local_TLE20
= EG (uninitialized_zval_ptr
);
3266 local_TLE20
->refcount
++;
3268 zval
** p_lhs
= &local_TLE20
;
3271 if ((*p_lhs
)->is_ref
)
3273 // Always overwrite the current value
3279 ALLOC_INIT_ZVAL (value
);
3280 zval_ptr_dtor (p_lhs
);
3284 ZVAL_STRINGL(value
, "	", 4, 1);
3286 phc_check_invariants (TSRMLS_C
);
3290 if (local_TLE21
== NULL
)
3292 local_TLE21
= EG (uninitialized_zval_ptr
);
3293 local_TLE21
->refcount
++;
3295 zval
** p_lhs
= &local_TLE21
;
3298 if ((*p_lhs
)->is_ref
)
3300 // Always overwrite the current value
3306 ALLOC_INIT_ZVAL (value
);
3307 zval_ptr_dtor (p_lhs
);
3311 ZVAL_STRINGL(value
, "\011", 1, 1);
3313 phc_check_invariants (TSRMLS_C
);
3315 // $correctedtext = str_replace($TLE20, $TLE21, $correctedtext);
3317 initialize_function_call (&str_replace_fci
, &str_replace_fcic
, "str_replace", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 43 TSRMLS_CC
);
3318 zend_function
* signature
= str_replace_fcic
.function_handler
;
3319 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
3323 // TODO: find names to replace index
3326 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
3330 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
3333 // TODO: find names to replace index
3336 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
3340 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
3343 // TODO: find names to replace index
3346 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
3350 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
3355 // Setup array of arguments
3356 // TODO: i think arrays of size 0 is an error
3359 zval
** args_ind
[3];
3362 destruct
[af_index
] = 0;
3363 if (by_ref
[af_index
])
3365 if (local_TLE20
== NULL
)
3367 local_TLE20
= EG (uninitialized_zval_ptr
);
3368 local_TLE20
->refcount
++;
3370 zval
** p_arg
= &local_TLE20
;
3372 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
3373 assert (!in_copy_on_write (*args_ind
[af_index
]));
3374 args
[af_index
] = *args_ind
[af_index
];
3379 if (local_TLE20
== NULL
)
3380 arg
= EG (uninitialized_zval_ptr
);
3384 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
3385 args_ind
[af_index
] = &args
[af_index
];
3388 destruct
[af_index
] = 0;
3389 if (by_ref
[af_index
])
3391 if (local_TLE21
== NULL
)
3393 local_TLE21
= EG (uninitialized_zval_ptr
);
3394 local_TLE21
->refcount
++;
3396 zval
** p_arg
= &local_TLE21
;
3398 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
3399 assert (!in_copy_on_write (*args_ind
[af_index
]));
3400 args
[af_index
] = *args_ind
[af_index
];
3405 if (local_TLE21
== NULL
)
3406 arg
= EG (uninitialized_zval_ptr
);
3410 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
3411 args_ind
[af_index
] = &args
[af_index
];
3414 destruct
[af_index
] = 0;
3415 if (by_ref
[af_index
])
3417 if (local_correctedtext
== NULL
)
3419 local_correctedtext
= EG (uninitialized_zval_ptr
);
3420 local_correctedtext
->refcount
++;
3422 zval
** p_arg
= &local_correctedtext
;
3424 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
3425 assert (!in_copy_on_write (*args_ind
[af_index
]));
3426 args
[af_index
] = *args_ind
[af_index
];
3431 if (local_correctedtext
== NULL
)
3432 arg
= EG (uninitialized_zval_ptr
);
3434 arg
= local_correctedtext
;
3436 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
3437 args_ind
[af_index
] = &args
[af_index
];
3442 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 43, NULL TSRMLS_CC
);
3444 // save existing parameters, in case of recursion
3445 int param_count_save
= str_replace_fci
.param_count
;
3446 zval
*** params_save
= str_replace_fci
.params
;
3447 zval
** retval_save
= str_replace_fci
.retval_ptr_ptr
;
3452 str_replace_fci
.params
= args_ind
;
3453 str_replace_fci
.param_count
= 3;
3454 str_replace_fci
.retval_ptr_ptr
= &rhs
;
3456 // call the function
3457 int success
= zend_call_function (&str_replace_fci
, &str_replace_fcic TSRMLS_CC
);
3458 assert(success
== SUCCESS
);
3461 str_replace_fci
.params
= params_save
;
3462 str_replace_fci
.param_count
= param_count_save
;
3463 str_replace_fci
.retval_ptr_ptr
= retval_save
;
3466 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
3469 for (i
= 0; i
< 3; i
++)
3473 assert (destruct
[i
]);
3474 zval_ptr_dtor (args_ind
[i
]);
3479 // When the Zend engine returns by reference, it allocates a zval into
3480 // retval_ptr_ptr. To return by reference, the callee writes into the
3481 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
3482 // not actually return anything). So the zval returned - whether we return
3483 // it, or it is the allocated zval - has a refcount of 1.
3485 // The caller is responsible for cleaning that up (note, this is unaffected
3486 // by whether it is added to some COW set).
3488 // For reasons unknown, the Zend API resets the refcount and is_ref fields
3489 // of the return value after the function returns (unless the callee is
3490 // interpreted). If the function is supposed to return by reference, this
3491 // loses the refcount. This only happens when non-interpreted code is
3492 // called. We work around it, when compiled code is called, by saving the
3493 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
3494 // that we may create an error if our code is called by a callback, and
3495 // returns by reference, and the callback returns by reference. At least
3496 // this is an obscure case.
3497 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
3499 assert (rhs
!= EG(uninitialized_zval_ptr
));
3501 if (saved_refcount
!= 0)
3503 rhs
->refcount
= saved_refcount
;
3507 saved_refcount
= 0; // for 'obscure cases'
3509 if (local_correctedtext
== NULL
)
3511 local_correctedtext
= EG (uninitialized_zval_ptr
);
3512 local_correctedtext
->refcount
++;
3514 zval
** p_lhs
= &local_correctedtext
;
3516 write_var (p_lhs
, rhs
);
3519 zval_ptr_dtor (&rhs
);
3520 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
3521 zval_ptr_dtor (&rhs
);
3523 phc_check_invariants (TSRMLS_C
);
3525 // return $correctedtext;
3528 if (local_correctedtext
== NULL
)
3529 rhs
= EG (uninitialized_zval_ptr
);
3531 rhs
= local_correctedtext
;
3533 // Run-time return by reference has different semantics to compile-time.
3534 // If the function has CTRBR and RTRBR, the the assignment will be
3535 // reference. If one or the other is return-by-copy, the result will be
3536 // by copy. Its a question of whether its separated at return-time (which
3537 // we do here) or at the call-site.
3538 return_value
->value
= rhs
->value
;
3539 return_value
->type
= rhs
->type
;
3540 zval_copy_ctor (return_value
);
3541 goto end_of_function
;
3542 phc_check_invariants (TSRMLS_C
);
3545 end_of_function
:__attribute__((unused
));
3546 if (local_TLE11
!= NULL
)
3548 zval_ptr_dtor (&local_TLE11
);
3550 if (local_TLE12
!= NULL
)
3552 zval_ptr_dtor (&local_TLE12
);
3554 if (local_TLE13
!= NULL
)
3556 zval_ptr_dtor (&local_TLE13
);
3558 if (local_TLE14
!= NULL
)
3560 zval_ptr_dtor (&local_TLE14
);
3562 if (local_TLE15
!= NULL
)
3564 zval_ptr_dtor (&local_TLE15
);
3566 if (local_TLE16
!= NULL
)
3568 zval_ptr_dtor (&local_TLE16
);
3570 if (local_TLE17
!= NULL
)
3572 zval_ptr_dtor (&local_TLE17
);
3574 if (local_TLE18
!= NULL
)
3576 zval_ptr_dtor (&local_TLE18
);
3578 if (local_TLE19
!= NULL
)
3580 zval_ptr_dtor (&local_TLE19
);
3582 if (local_TLE20
!= NULL
)
3584 zval_ptr_dtor (&local_TLE20
);
3586 if (local_TLE21
!= NULL
)
3588 zval_ptr_dtor (&local_TLE21
);
3590 if (local_correctedtext
!= NULL
)
3592 zval_ptr_dtor (&local_correctedtext
);
3594 if (local_text
!= NULL
)
3596 zval_ptr_dtor (&local_text
);
3598 if (local_wgTidyInternal
!= NULL
)
3600 zval_ptr_dtor (&local_wgTidyInternal
);
3602 if (local_wrappedtext
!= NULL
)
3604 zval_ptr_dtor (&local_wrappedtext
);
3607 // public static function checkerrors($text, &$errorStr = NULL)
3609 // global $wgTidyInternal;
3611 // if (wgTidyInternal) goto L113 else goto L114;
3614 // $errorStr = mwtidy::execinternaltidy($text, $TLE22, $retval);
3618 // $errorStr = mwtidy::execexternaltidy($text, $TLE23, $retval);
3622 // $TLE0 = ($retval < $TLE24);
3623 // if (TLE0) goto L116 else goto L117;
3626 // $TEF1 = ($errorStr == $TLE25);
3632 // $TLE2 = (bool) $TEF1;
3633 // if (TLE2) goto L119 else goto L120;
3639 // $TEF3 = ($retval == $TLE26);
3642 // $TLE27 = (bool) $TEF3;
3645 PHP_METHOD(MWTidy
, checkerrors
)
3647 zval
* local_TEF1
= NULL
;
3648 zval
* local_TEF3
= NULL
;
3649 zval
* local_TLE0
= NULL
;
3650 zval
* local_TLE2
= NULL
;
3651 zval
* local_TLE22
= NULL
;
3652 zval
* local_TLE23
= NULL
;
3653 zval
* local_TLE24
= NULL
;
3654 zval
* local_TLE25
= NULL
;
3655 zval
* local_TLE26
= NULL
;
3656 zval
* local_TLE27
= NULL
;
3657 zval
* local_errorStr
= NULL
;
3658 zval
* local_retval
= NULL
;
3659 zval
* local_text
= NULL
;
3660 zval
* local_wgTidyInternal
= NULL
;
3661 // Add all parameters as local variables
3663 int num_args
= ZEND_NUM_ARGS ();
3665 zend_get_parameters_array(0, num_args
, params
);
3667 params
[0]->refcount
++;
3668 if (local_text
!= NULL
)
3670 zval_ptr_dtor (&local_text
);
3672 local_text
= params
[0];
3676 zval
* default_value
;
3678 zval
* local___static_value__
= NULL
;
3679 // $__static_value__ = NULL;
3681 if (local___static_value__
== NULL
)
3683 local___static_value__
= EG (uninitialized_zval_ptr
);
3684 local___static_value__
->refcount
++;
3686 zval
** p_lhs
= &local___static_value__
;
3689 if ((*p_lhs
)->is_ref
)
3691 // Always overwrite the current value
3697 ALLOC_INIT_ZVAL (value
);
3698 zval_ptr_dtor (p_lhs
);
3704 phc_check_invariants (TSRMLS_C
);
3706 default_value
= local___static_value__
;
3707 assert(!default_value
->is_ref
);
3708 default_value
->refcount
++;
3709 if (local___static_value__
!= NULL
)
3711 zval_ptr_dtor (&local___static_value__
);
3714 default_value
->refcount
--;
3715 params
[1] = default_value
;
3717 params
[1]->refcount
++;
3718 if (local_errorStr
!= NULL
)
3720 zval_ptr_dtor (&local_errorStr
);
3722 local_errorStr
= params
[1];
3725 // global $wgTidyInternal;
3727 if (local_wgTidyInternal
== NULL
)
3729 local_wgTidyInternal
= EG (uninitialized_zval_ptr
);
3730 local_wgTidyInternal
->refcount
++;
3732 zval
** p_local
= &local_wgTidyInternal
;
3734 zval
** p_global
= get_st_entry (&EG(symbol_table
), "wgTidyInternal", 14 + 1, 125132442u TSRMLS_CC
);
3736 sep_copy_on_write (p_global
);
3737 copy_into_ref (p_local
, p_global
);
3738 phc_check_invariants (TSRMLS_C
);
3742 if (local_retval
== NULL
)
3744 local_retval
= EG (uninitialized_zval_ptr
);
3745 local_retval
->refcount
++;
3747 zval
** p_lhs
= &local_retval
;
3750 if ((*p_lhs
)->is_ref
)
3752 // Always overwrite the current value
3758 ALLOC_INIT_ZVAL (value
);
3759 zval_ptr_dtor (p_lhs
);
3763 ZVAL_LONG (value
, 0);
3765 phc_check_invariants (TSRMLS_C
);
3767 // if (wgTidyInternal) goto L113 else goto L114;
3770 if (local_wgTidyInternal
== NULL
)
3771 p_cond
= EG (uninitialized_zval_ptr
);
3773 p_cond
= local_wgTidyInternal
;
3775 zend_bool bcond
= zend_is_true (p_cond
);
3780 phc_check_invariants (TSRMLS_C
);
3786 if (local_TLE22
== NULL
)
3788 local_TLE22
= EG (uninitialized_zval_ptr
);
3789 local_TLE22
->refcount
++;
3791 zval
** p_lhs
= &local_TLE22
;
3794 if ((*p_lhs
)->is_ref
)
3796 // Always overwrite the current value
3802 ALLOC_INIT_ZVAL (value
);
3803 zval_ptr_dtor (p_lhs
);
3807 ZVAL_BOOL (value
, 1);
3809 phc_check_invariants (TSRMLS_C
);
3811 // $errorStr = mwtidy::execinternaltidy($text, $TLE22, $retval);
3813 initialize_function_call (&mwtidy_execinternaltidy_fci
, &mwtidy_execinternaltidy_fcic
, "mwtidy::execinternaltidy", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 59 TSRMLS_CC
);
3814 zend_function
* signature
= mwtidy_execinternaltidy_fcic
.function_handler
;
3815 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
3819 // TODO: find names to replace index
3822 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
3826 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
3829 // TODO: find names to replace index
3832 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
3836 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
3839 // TODO: find names to replace index
3842 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
3846 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
3851 // Setup array of arguments
3852 // TODO: i think arrays of size 0 is an error
3855 zval
** args_ind
[3];
3858 destruct
[af_index
] = 0;
3859 if (by_ref
[af_index
])
3861 if (local_text
== NULL
)
3863 local_text
= EG (uninitialized_zval_ptr
);
3864 local_text
->refcount
++;
3866 zval
** p_arg
= &local_text
;
3868 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
3869 assert (!in_copy_on_write (*args_ind
[af_index
]));
3870 args
[af_index
] = *args_ind
[af_index
];
3875 if (local_text
== NULL
)
3876 arg
= EG (uninitialized_zval_ptr
);
3880 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
3881 args_ind
[af_index
] = &args
[af_index
];
3884 destruct
[af_index
] = 0;
3885 if (by_ref
[af_index
])
3887 if (local_TLE22
== NULL
)
3889 local_TLE22
= EG (uninitialized_zval_ptr
);
3890 local_TLE22
->refcount
++;
3892 zval
** p_arg
= &local_TLE22
;
3894 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
3895 assert (!in_copy_on_write (*args_ind
[af_index
]));
3896 args
[af_index
] = *args_ind
[af_index
];
3901 if (local_TLE22
== NULL
)
3902 arg
= EG (uninitialized_zval_ptr
);
3906 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
3907 args_ind
[af_index
] = &args
[af_index
];
3910 destruct
[af_index
] = 0;
3911 if (by_ref
[af_index
])
3913 if (local_retval
== NULL
)
3915 local_retval
= EG (uninitialized_zval_ptr
);
3916 local_retval
->refcount
++;
3918 zval
** p_arg
= &local_retval
;
3920 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
3921 assert (!in_copy_on_write (*args_ind
[af_index
]));
3922 args
[af_index
] = *args_ind
[af_index
];
3927 if (local_retval
== NULL
)
3928 arg
= EG (uninitialized_zval_ptr
);
3932 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
3933 args_ind
[af_index
] = &args
[af_index
];
3938 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 59, NULL TSRMLS_CC
);
3940 // save existing parameters, in case of recursion
3941 int param_count_save
= mwtidy_execinternaltidy_fci
.param_count
;
3942 zval
*** params_save
= mwtidy_execinternaltidy_fci
.params
;
3943 zval
** retval_save
= mwtidy_execinternaltidy_fci
.retval_ptr_ptr
;
3948 mwtidy_execinternaltidy_fci
.params
= args_ind
;
3949 mwtidy_execinternaltidy_fci
.param_count
= 3;
3950 mwtidy_execinternaltidy_fci
.retval_ptr_ptr
= &rhs
;
3952 // call the function
3953 int success
= zend_call_function (&mwtidy_execinternaltidy_fci
, &mwtidy_execinternaltidy_fcic TSRMLS_CC
);
3954 assert(success
== SUCCESS
);
3957 mwtidy_execinternaltidy_fci
.params
= params_save
;
3958 mwtidy_execinternaltidy_fci
.param_count
= param_count_save
;
3959 mwtidy_execinternaltidy_fci
.retval_ptr_ptr
= retval_save
;
3962 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
3965 for (i
= 0; i
< 3; i
++)
3969 assert (destruct
[i
]);
3970 zval_ptr_dtor (args_ind
[i
]);
3975 // When the Zend engine returns by reference, it allocates a zval into
3976 // retval_ptr_ptr. To return by reference, the callee writes into the
3977 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
3978 // not actually return anything). So the zval returned - whether we return
3979 // it, or it is the allocated zval - has a refcount of 1.
3981 // The caller is responsible for cleaning that up (note, this is unaffected
3982 // by whether it is added to some COW set).
3984 // For reasons unknown, the Zend API resets the refcount and is_ref fields
3985 // of the return value after the function returns (unless the callee is
3986 // interpreted). If the function is supposed to return by reference, this
3987 // loses the refcount. This only happens when non-interpreted code is
3988 // called. We work around it, when compiled code is called, by saving the
3989 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
3990 // that we may create an error if our code is called by a callback, and
3991 // returns by reference, and the callback returns by reference. At least
3992 // this is an obscure case.
3993 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
3995 assert (rhs
!= EG(uninitialized_zval_ptr
));
3997 if (saved_refcount
!= 0)
3999 rhs
->refcount
= saved_refcount
;
4003 saved_refcount
= 0; // for 'obscure cases'
4005 if (local_errorStr
== NULL
)
4007 local_errorStr
= EG (uninitialized_zval_ptr
);
4008 local_errorStr
->refcount
++;
4010 zval
** p_lhs
= &local_errorStr
;
4012 write_var (p_lhs
, rhs
);
4015 zval_ptr_dtor (&rhs
);
4016 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
4017 zval_ptr_dtor (&rhs
);
4019 phc_check_invariants (TSRMLS_C
);
4024 phc_check_invariants (TSRMLS_C
);
4030 if (local_TLE23
== NULL
)
4032 local_TLE23
= EG (uninitialized_zval_ptr
);
4033 local_TLE23
->refcount
++;
4035 zval
** p_lhs
= &local_TLE23
;
4038 if ((*p_lhs
)->is_ref
)
4040 // Always overwrite the current value
4046 ALLOC_INIT_ZVAL (value
);
4047 zval_ptr_dtor (p_lhs
);
4051 ZVAL_BOOL (value
, 1);
4053 phc_check_invariants (TSRMLS_C
);
4055 // $errorStr = mwtidy::execexternaltidy($text, $TLE23, $retval);
4057 initialize_function_call (&mwtidy_execexternaltidy_fci
, &mwtidy_execexternaltidy_fcic
, "mwtidy::execexternaltidy", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 61 TSRMLS_CC
);
4058 zend_function
* signature
= mwtidy_execexternaltidy_fcic
.function_handler
;
4059 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
4063 // TODO: find names to replace index
4066 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
4070 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
4073 // TODO: find names to replace index
4076 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
4080 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
4083 // TODO: find names to replace index
4086 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
4090 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
4095 // Setup array of arguments
4096 // TODO: i think arrays of size 0 is an error
4099 zval
** args_ind
[3];
4102 destruct
[af_index
] = 0;
4103 if (by_ref
[af_index
])
4105 if (local_text
== NULL
)
4107 local_text
= EG (uninitialized_zval_ptr
);
4108 local_text
->refcount
++;
4110 zval
** p_arg
= &local_text
;
4112 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
4113 assert (!in_copy_on_write (*args_ind
[af_index
]));
4114 args
[af_index
] = *args_ind
[af_index
];
4119 if (local_text
== NULL
)
4120 arg
= EG (uninitialized_zval_ptr
);
4124 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
4125 args_ind
[af_index
] = &args
[af_index
];
4128 destruct
[af_index
] = 0;
4129 if (by_ref
[af_index
])
4131 if (local_TLE23
== NULL
)
4133 local_TLE23
= EG (uninitialized_zval_ptr
);
4134 local_TLE23
->refcount
++;
4136 zval
** p_arg
= &local_TLE23
;
4138 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
4139 assert (!in_copy_on_write (*args_ind
[af_index
]));
4140 args
[af_index
] = *args_ind
[af_index
];
4145 if (local_TLE23
== NULL
)
4146 arg
= EG (uninitialized_zval_ptr
);
4150 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
4151 args_ind
[af_index
] = &args
[af_index
];
4154 destruct
[af_index
] = 0;
4155 if (by_ref
[af_index
])
4157 if (local_retval
== NULL
)
4159 local_retval
= EG (uninitialized_zval_ptr
);
4160 local_retval
->refcount
++;
4162 zval
** p_arg
= &local_retval
;
4164 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
4165 assert (!in_copy_on_write (*args_ind
[af_index
]));
4166 args
[af_index
] = *args_ind
[af_index
];
4171 if (local_retval
== NULL
)
4172 arg
= EG (uninitialized_zval_ptr
);
4176 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
4177 args_ind
[af_index
] = &args
[af_index
];
4182 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 61, NULL TSRMLS_CC
);
4184 // save existing parameters, in case of recursion
4185 int param_count_save
= mwtidy_execexternaltidy_fci
.param_count
;
4186 zval
*** params_save
= mwtidy_execexternaltidy_fci
.params
;
4187 zval
** retval_save
= mwtidy_execexternaltidy_fci
.retval_ptr_ptr
;
4192 mwtidy_execexternaltidy_fci
.params
= args_ind
;
4193 mwtidy_execexternaltidy_fci
.param_count
= 3;
4194 mwtidy_execexternaltidy_fci
.retval_ptr_ptr
= &rhs
;
4196 // call the function
4197 int success
= zend_call_function (&mwtidy_execexternaltidy_fci
, &mwtidy_execexternaltidy_fcic TSRMLS_CC
);
4198 assert(success
== SUCCESS
);
4201 mwtidy_execexternaltidy_fci
.params
= params_save
;
4202 mwtidy_execexternaltidy_fci
.param_count
= param_count_save
;
4203 mwtidy_execexternaltidy_fci
.retval_ptr_ptr
= retval_save
;
4206 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
4209 for (i
= 0; i
< 3; i
++)
4213 assert (destruct
[i
]);
4214 zval_ptr_dtor (args_ind
[i
]);
4219 // When the Zend engine returns by reference, it allocates a zval into
4220 // retval_ptr_ptr. To return by reference, the callee writes into the
4221 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
4222 // not actually return anything). So the zval returned - whether we return
4223 // it, or it is the allocated zval - has a refcount of 1.
4225 // The caller is responsible for cleaning that up (note, this is unaffected
4226 // by whether it is added to some COW set).
4228 // For reasons unknown, the Zend API resets the refcount and is_ref fields
4229 // of the return value after the function returns (unless the callee is
4230 // interpreted). If the function is supposed to return by reference, this
4231 // loses the refcount. This only happens when non-interpreted code is
4232 // called. We work around it, when compiled code is called, by saving the
4233 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
4234 // that we may create an error if our code is called by a callback, and
4235 // returns by reference, and the callback returns by reference. At least
4236 // this is an obscure case.
4237 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
4239 assert (rhs
!= EG(uninitialized_zval_ptr
));
4241 if (saved_refcount
!= 0)
4243 rhs
->refcount
= saved_refcount
;
4247 saved_refcount
= 0; // for 'obscure cases'
4249 if (local_errorStr
== NULL
)
4251 local_errorStr
= EG (uninitialized_zval_ptr
);
4252 local_errorStr
->refcount
++;
4254 zval
** p_lhs
= &local_errorStr
;
4256 write_var (p_lhs
, rhs
);
4259 zval_ptr_dtor (&rhs
);
4260 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
4261 zval_ptr_dtor (&rhs
);
4263 phc_check_invariants (TSRMLS_C
);
4268 phc_check_invariants (TSRMLS_C
);
4274 if (local_TLE24
== NULL
)
4276 local_TLE24
= EG (uninitialized_zval_ptr
);
4277 local_TLE24
->refcount
++;
4279 zval
** p_lhs
= &local_TLE24
;
4282 if ((*p_lhs
)->is_ref
)
4284 // Always overwrite the current value
4290 ALLOC_INIT_ZVAL (value
);
4291 zval_ptr_dtor (p_lhs
);
4295 ZVAL_LONG (value
, 0);
4297 phc_check_invariants (TSRMLS_C
);
4299 // $TLE0 = ($retval < $TLE24);
4301 if (local_TLE0
== NULL
)
4303 local_TLE0
= EG (uninitialized_zval_ptr
);
4304 local_TLE0
->refcount
++;
4306 zval
** p_lhs
= &local_TLE0
;
4309 if (local_retval
== NULL
)
4310 left
= EG (uninitialized_zval_ptr
);
4312 left
= local_retval
;
4315 if (local_TLE24
== NULL
)
4316 right
= EG (uninitialized_zval_ptr
);
4318 right
= local_TLE24
;
4320 if (in_copy_on_write (*p_lhs
))
4322 zval_ptr_dtor (p_lhs
);
4323 ALLOC_INIT_ZVAL (*p_lhs
);
4327 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
4328 is_smaller_function (*p_lhs
, left
, right TSRMLS_CC
);
4330 // If the result is one of the operands, the operator function
4331 // will already have cleaned up the result
4332 if (!result_is_operand
)
4334 phc_check_invariants (TSRMLS_C
);
4336 // if (TLE0) goto L116 else goto L117;
4339 if (local_TLE0
== NULL
)
4340 p_cond
= EG (uninitialized_zval_ptr
);
4342 p_cond
= local_TLE0
;
4344 zend_bool bcond
= zend_is_true (p_cond
);
4349 phc_check_invariants (TSRMLS_C
);
4355 if (local_TLE25
== NULL
)
4357 local_TLE25
= EG (uninitialized_zval_ptr
);
4358 local_TLE25
->refcount
++;
4360 zval
** p_lhs
= &local_TLE25
;
4363 if ((*p_lhs
)->is_ref
)
4365 // Always overwrite the current value
4371 ALLOC_INIT_ZVAL (value
);
4372 zval_ptr_dtor (p_lhs
);
4376 ZVAL_STRINGL(value
, "", 0, 1);
4378 phc_check_invariants (TSRMLS_C
);
4380 // $TEF1 = ($errorStr == $TLE25);
4382 if (local_TEF1
== NULL
)
4384 local_TEF1
= EG (uninitialized_zval_ptr
);
4385 local_TEF1
->refcount
++;
4387 zval
** p_lhs
= &local_TEF1
;
4390 if (local_errorStr
== NULL
)
4391 left
= EG (uninitialized_zval_ptr
);
4393 left
= local_errorStr
;
4396 if (local_TLE25
== NULL
)
4397 right
= EG (uninitialized_zval_ptr
);
4399 right
= local_TLE25
;
4401 if (in_copy_on_write (*p_lhs
))
4403 zval_ptr_dtor (p_lhs
);
4404 ALLOC_INIT_ZVAL (*p_lhs
);
4408 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
4409 is_equal_function (*p_lhs
, left
, right TSRMLS_CC
);
4411 // If the result is one of the operands, the operator function
4412 // will already have cleaned up the result
4413 if (!result_is_operand
)
4415 phc_check_invariants (TSRMLS_C
);
4420 phc_check_invariants (TSRMLS_C
);
4426 if (local_TEF1
== NULL
)
4428 local_TEF1
= EG (uninitialized_zval_ptr
);
4429 local_TEF1
->refcount
++;
4431 zval
** p_lhs
= &local_TEF1
;
4434 if (local_TLE0
== NULL
)
4435 rhs
= EG (uninitialized_zval_ptr
);
4441 if ((*p_lhs
)->is_ref
)
4442 overwrite_lhs (*p_lhs
, rhs
);
4445 zval_ptr_dtor (p_lhs
);
4448 // Take a copy of RHS for LHS
4449 *p_lhs
= zvp_clone_ex (rhs
);
4461 phc_check_invariants (TSRMLS_C
);
4466 phc_check_invariants (TSRMLS_C
);
4470 // $TLE2 = (bool) $TEF1;
4472 if (local_TLE2
== NULL
)
4474 local_TLE2
= EG (uninitialized_zval_ptr
);
4475 local_TLE2
->refcount
++;
4477 zval
** p_lhs
= &local_TLE2
;
4480 if (local_TEF1
== NULL
)
4481 rhs
= EG (uninitialized_zval_ptr
);
4487 if ((*p_lhs
)->is_ref
)
4488 overwrite_lhs (*p_lhs
, rhs
);
4491 zval_ptr_dtor (p_lhs
);
4494 // Take a copy of RHS for LHS
4495 *p_lhs
= zvp_clone_ex (rhs
);
4508 assert (IS_BOOL
>= 0 && IS_BOOL
<= 6);
4509 if ((*p_lhs
)->type
!= IS_BOOL
)
4511 sep_copy_on_write (p_lhs
);
4512 convert_to_boolean (*p_lhs
);
4515 phc_check_invariants (TSRMLS_C
);
4517 // if (TLE2) goto L119 else goto L120;
4520 if (local_TLE2
== NULL
)
4521 p_cond
= EG (uninitialized_zval_ptr
);
4523 p_cond
= local_TLE2
;
4525 zend_bool bcond
= zend_is_true (p_cond
);
4530 phc_check_invariants (TSRMLS_C
);
4536 if (local_TEF3
== NULL
)
4538 local_TEF3
= EG (uninitialized_zval_ptr
);
4539 local_TEF3
->refcount
++;
4541 zval
** p_lhs
= &local_TEF3
;
4544 if (local_TLE2
== NULL
)
4545 rhs
= EG (uninitialized_zval_ptr
);
4551 if ((*p_lhs
)->is_ref
)
4552 overwrite_lhs (*p_lhs
, rhs
);
4555 zval_ptr_dtor (p_lhs
);
4558 // Take a copy of RHS for LHS
4559 *p_lhs
= zvp_clone_ex (rhs
);
4571 phc_check_invariants (TSRMLS_C
);
4576 phc_check_invariants (TSRMLS_C
);
4582 if (local_TLE26
== NULL
)
4584 local_TLE26
= EG (uninitialized_zval_ptr
);
4585 local_TLE26
->refcount
++;
4587 zval
** p_lhs
= &local_TLE26
;
4590 if ((*p_lhs
)->is_ref
)
4592 // Always overwrite the current value
4598 ALLOC_INIT_ZVAL (value
);
4599 zval_ptr_dtor (p_lhs
);
4603 ZVAL_LONG (value
, 0);
4605 phc_check_invariants (TSRMLS_C
);
4607 // $TEF3 = ($retval == $TLE26);
4609 if (local_TEF3
== NULL
)
4611 local_TEF3
= EG (uninitialized_zval_ptr
);
4612 local_TEF3
->refcount
++;
4614 zval
** p_lhs
= &local_TEF3
;
4617 if (local_retval
== NULL
)
4618 left
= EG (uninitialized_zval_ptr
);
4620 left
= local_retval
;
4623 if (local_TLE26
== NULL
)
4624 right
= EG (uninitialized_zval_ptr
);
4626 right
= local_TLE26
;
4628 if (in_copy_on_write (*p_lhs
))
4630 zval_ptr_dtor (p_lhs
);
4631 ALLOC_INIT_ZVAL (*p_lhs
);
4635 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
4636 is_equal_function (*p_lhs
, left
, right TSRMLS_CC
);
4638 // If the result is one of the operands, the operator function
4639 // will already have cleaned up the result
4640 if (!result_is_operand
)
4642 phc_check_invariants (TSRMLS_C
);
4647 phc_check_invariants (TSRMLS_C
);
4651 // $TLE27 = (bool) $TEF3;
4653 if (local_TLE27
== NULL
)
4655 local_TLE27
= EG (uninitialized_zval_ptr
);
4656 local_TLE27
->refcount
++;
4658 zval
** p_lhs
= &local_TLE27
;
4661 if (local_TEF3
== NULL
)
4662 rhs
= EG (uninitialized_zval_ptr
);
4668 if ((*p_lhs
)->is_ref
)
4669 overwrite_lhs (*p_lhs
, rhs
);
4672 zval_ptr_dtor (p_lhs
);
4675 // Take a copy of RHS for LHS
4676 *p_lhs
= zvp_clone_ex (rhs
);
4689 assert (IS_BOOL
>= 0 && IS_BOOL
<= 6);
4690 if ((*p_lhs
)->type
!= IS_BOOL
)
4692 sep_copy_on_write (p_lhs
);
4693 convert_to_boolean (*p_lhs
);
4696 phc_check_invariants (TSRMLS_C
);
4701 if (local_TLE27
== NULL
)
4702 rhs
= EG (uninitialized_zval_ptr
);
4706 // Run-time return by reference has different semantics to compile-time.
4707 // If the function has CTRBR and RTRBR, the the assignment will be
4708 // reference. If one or the other is return-by-copy, the result will be
4709 // by copy. Its a question of whether its separated at return-time (which
4710 // we do here) or at the call-site.
4711 return_value
->value
= rhs
->value
;
4712 return_value
->type
= rhs
->type
;
4713 zval_copy_ctor (return_value
);
4714 goto end_of_function
;
4715 phc_check_invariants (TSRMLS_C
);
4718 end_of_function
:__attribute__((unused
));
4719 if (local_TEF1
!= NULL
)
4721 zval_ptr_dtor (&local_TEF1
);
4723 if (local_TEF3
!= NULL
)
4725 zval_ptr_dtor (&local_TEF3
);
4727 if (local_TLE0
!= NULL
)
4729 zval_ptr_dtor (&local_TLE0
);
4731 if (local_TLE2
!= NULL
)
4733 zval_ptr_dtor (&local_TLE2
);
4735 if (local_TLE22
!= NULL
)
4737 zval_ptr_dtor (&local_TLE22
);
4739 if (local_TLE23
!= NULL
)
4741 zval_ptr_dtor (&local_TLE23
);
4743 if (local_TLE24
!= NULL
)
4745 zval_ptr_dtor (&local_TLE24
);
4747 if (local_TLE25
!= NULL
)
4749 zval_ptr_dtor (&local_TLE25
);
4751 if (local_TLE26
!= NULL
)
4753 zval_ptr_dtor (&local_TLE26
);
4755 if (local_TLE27
!= NULL
)
4757 zval_ptr_dtor (&local_TLE27
);
4759 if (local_errorStr
!= NULL
)
4761 zval_ptr_dtor (&local_errorStr
);
4763 if (local_retval
!= NULL
)
4765 zval_ptr_dtor (&local_retval
);
4767 if (local_text
!= NULL
)
4769 zval_ptr_dtor (&local_text
);
4771 if (local_wgTidyInternal
!= NULL
)
4773 zval_ptr_dtor (&local_wgTidyInternal
);
4776 // private static function execexternaltidy($text, $stderr = False, &$retval = NULL)
4778 // global $wgTidyConf;
4779 // global $wgTidyBin;
4780 // global $wgTidyOpts;
4781 // $TLE28 = 'MWTidy::execExternalTidy';
4782 // wfprofilein($TLE28);
4783 // $cleansource = '';
4784 // $opts = ' -utf8';
4785 // if (stderr) goto L122 else goto L123;
4791 // $TSa32 = (array) $TSa32;
4792 // $TSa32[] = $TLE30;
4793 // $TSa32[] = $TLE31;
4796 // $TLE35 = wfgetnull();
4799 // $TSa37 = (array) $TSa37;
4800 // $TSa37[] = $TLE34;
4801 // $TSa37[] = $TLE35;
4802 // $TSa37[] = $TLE36;
4807 // $TSa41 = (array) $TSa41;
4808 // $TSa41[] = $TLE39;
4809 // $TSa41[] = $TLE40;
4811 // $TSa42 = (array) $TSa42;
4812 // $TSa42[$TLE29] = $TSa32;
4813 // $TSa42[$TLE33] = $TSa37;
4814 // $TSa42[$TLE38] = $TSa41;
4815 // $descriptorspec = $TSa42;
4822 // $TSa46 = (array) $TSa46;
4823 // $TSa46[] = $TLE44;
4824 // $TSa46[] = $TLE45;
4829 // $TSa50 = (array) $TSa50;
4830 // $TSa50[] = $TLE48;
4831 // $TSa50[] = $TLE49;
4834 // $TLE53 = wfgetnull();
4837 // $TSa55 = (array) $TSa55;
4838 // $TSa55[] = $TLE52;
4839 // $TSa55[] = $TLE53;
4840 // $TSa55[] = $TLE54;
4842 // $TSa56 = (array) $TSa56;
4843 // $TSa56[$TLE43] = $TSa46;
4844 // $TSa56[$TLE47] = $TSa50;
4845 // $TSa56[$TLE51] = $TSa55;
4846 // $descriptorspec = $TSa56;
4849 // if (stderr) goto L125 else goto L126;
4857 // $readpipe = $TEF4;
4859 // $TSa57 = (array) $TSa57;
4861 // $TLE58 = 'proc_open';
4862 // $TLE59 = function_exists($TLE58);
4863 // if (TLE59) goto L151 else goto L152;
4865 // $TLE60 = ' -config ';
4866 // $TLE61 = ($wgTidyBin . $TLE60);
4867 // $TLE62 = ($TLE61 . $wgTidyConf);
4869 // $TLE64 = ($TLE62 . $TLE63);
4870 // $TLE65 = ($TLE64 . $wgTidyOpts);
4871 // $TLE66 = ($TLE65 . $opts);
4872 // $process = proc_open($TLE66, $descriptorspec, $pipes);
4873 // $TLE67 = is_resource($process);
4874 // if (TLE67) goto L148 else goto L149;
4877 // $TLE96 = param_is_ref (NULL, "fwrite", 0);
4879 // if (TLE96) goto L128 else goto L129;
4881 // $TMIi95 =& $pipes[$TLE68];
4884 // $TMIi95 = $pipes[$TLE68];
4887 // fwrite($TMIi95, $text);
4889 // $TLE98 = param_is_ref (NULL, "fclose", 0);
4891 // if (TLE98) goto L131 else goto L132;
4893 // $TMIi97 =& $pipes[$TLE69];
4896 // $TMIi97 = $pipes[$TLE69];
4901 // $TLE100 = param_is_ref (NULL, "feof", 0);
4903 // if (TLE100) goto L134 else goto L135;
4905 // $TMIi99 =& $pipes[$readpipe];
4908 // $TMIi99 = $pipes[$readpipe];
4911 // $TLE70 = feof($TMIi99);
4912 // $TLE71 = !$TLE70;
4913 // $TLE72 = !$TLE71;
4914 // if (TLE72) goto L138 else goto L139;
4922 // $TLE102 = param_is_ref (NULL, "fgets", 0);
4924 // if (TLE102) goto L141 else goto L142;
4926 // $TMIi101 =& $pipes[$readpipe];
4929 // $TMIi101 = $pipes[$readpipe];
4932 // $TLE74 = fgets($TMIi101, $TLE73);
4933 // $cleansource = ($cleansource . $TLE74);
4936 // $TLE104 = param_is_ref (NULL, "fclose", 0);
4938 // if (TLE104) goto L145 else goto L146;
4940 // $TMIi103 =& $pipes[$readpipe];
4943 // $TMIi103 = $pipes[$readpipe];
4946 // fclose($TMIi103);
4947 // $retval = proc_close($process);
4958 // $TLE75 = 'MWTidy::execExternalTidy';
4959 // wfprofileout($TLE75);
4960 // $TLE5 = !$stderr;
4961 // if (TLE5) goto L154 else goto L155;
4964 // $TEF6 = ($cleansource == $TLE76);
4970 // $TLE7 = (bool) $TEF6;
4971 // if (TLE7) goto L157 else goto L158;
4974 // $TEF8 = ($text != $TLE77);
4980 // $TLE78 = (bool) $TEF8;
4981 // if (TLE78) goto L160 else goto L161;
4987 // return $cleansource;
4991 PHP_METHOD(MWTidy
, execexternaltidy
)
4993 zval
* local_TEF4
= NULL
;
4994 zval
* local_TEF6
= NULL
;
4995 zval
* local_TEF8
= NULL
;
4996 zval
* local_TLE100
= NULL
;
4997 zval
* local_TLE102
= NULL
;
4998 zval
* local_TLE104
= NULL
;
4999 zval
* local_TLE28
= NULL
;
5000 zval
* local_TLE29
= NULL
;
5001 zval
* local_TLE30
= NULL
;
5002 zval
* local_TLE31
= NULL
;
5003 zval
* local_TLE33
= NULL
;
5004 zval
* local_TLE34
= NULL
;
5005 zval
* local_TLE35
= NULL
;
5006 zval
* local_TLE36
= NULL
;
5007 zval
* local_TLE38
= NULL
;
5008 zval
* local_TLE39
= NULL
;
5009 zval
* local_TLE40
= NULL
;
5010 zval
* local_TLE43
= NULL
;
5011 zval
* local_TLE44
= NULL
;
5012 zval
* local_TLE45
= NULL
;
5013 zval
* local_TLE47
= NULL
;
5014 zval
* local_TLE48
= NULL
;
5015 zval
* local_TLE49
= NULL
;
5016 zval
* local_TLE5
= NULL
;
5017 zval
* local_TLE51
= NULL
;
5018 zval
* local_TLE52
= NULL
;
5019 zval
* local_TLE53
= NULL
;
5020 zval
* local_TLE54
= NULL
;
5021 zval
* local_TLE58
= NULL
;
5022 zval
* local_TLE59
= NULL
;
5023 zval
* local_TLE60
= NULL
;
5024 zval
* local_TLE61
= NULL
;
5025 zval
* local_TLE62
= NULL
;
5026 zval
* local_TLE63
= NULL
;
5027 zval
* local_TLE64
= NULL
;
5028 zval
* local_TLE65
= NULL
;
5029 zval
* local_TLE66
= NULL
;
5030 zval
* local_TLE67
= NULL
;
5031 zval
* local_TLE68
= NULL
;
5032 zval
* local_TLE69
= NULL
;
5033 zval
* local_TLE7
= NULL
;
5034 zval
* local_TLE70
= NULL
;
5035 zval
* local_TLE71
= NULL
;
5036 zval
* local_TLE72
= NULL
;
5037 zval
* local_TLE73
= NULL
;
5038 zval
* local_TLE74
= NULL
;
5039 zval
* local_TLE75
= NULL
;
5040 zval
* local_TLE76
= NULL
;
5041 zval
* local_TLE77
= NULL
;
5042 zval
* local_TLE78
= NULL
;
5043 zval
* local_TLE79
= NULL
;
5044 zval
* local_TLE96
= NULL
;
5045 zval
* local_TLE98
= NULL
;
5046 zval
* local_TMIi101
= NULL
;
5047 zval
* local_TMIi103
= NULL
;
5048 zval
* local_TMIi95
= NULL
;
5049 zval
* local_TMIi97
= NULL
;
5050 zval
* local_TMIi99
= NULL
;
5051 zval
* local_TSa32
= NULL
;
5052 zval
* local_TSa37
= NULL
;
5053 zval
* local_TSa41
= NULL
;
5054 zval
* local_TSa42
= NULL
;
5055 zval
* local_TSa46
= NULL
;
5056 zval
* local_TSa50
= NULL
;
5057 zval
* local_TSa55
= NULL
;
5058 zval
* local_TSa56
= NULL
;
5059 zval
* local_TSa57
= NULL
;
5060 zval
* local_cleansource
= NULL
;
5061 zval
* local_descriptorspec
= NULL
;
5062 zval
* local_opts
= NULL
;
5063 zval
* local_pipes
= NULL
;
5064 zval
* local_process
= NULL
;
5065 zval
* local_readpipe
= NULL
;
5066 zval
* local_retval
= NULL
;
5067 zval
* local_stderr
= NULL
;
5068 zval
* local_text
= NULL
;
5069 zval
* local_wgTidyBin
= NULL
;
5070 zval
* local_wgTidyConf
= NULL
;
5071 zval
* local_wgTidyOpts
= NULL
;
5072 // Add all parameters as local variables
5074 int num_args
= ZEND_NUM_ARGS ();
5076 zend_get_parameters_array(0, num_args
, params
);
5078 params
[0]->refcount
++;
5079 if (local_text
!= NULL
)
5081 zval_ptr_dtor (&local_text
);
5083 local_text
= params
[0];
5087 zval
* default_value
;
5089 zval
* local___static_value__
= NULL
;
5090 // $__static_value__ = False;
5092 if (local___static_value__
== NULL
)
5094 local___static_value__
= EG (uninitialized_zval_ptr
);
5095 local___static_value__
->refcount
++;
5097 zval
** p_lhs
= &local___static_value__
;
5100 if ((*p_lhs
)->is_ref
)
5102 // Always overwrite the current value
5108 ALLOC_INIT_ZVAL (value
);
5109 zval_ptr_dtor (p_lhs
);
5113 ZVAL_BOOL (value
, 0);
5115 phc_check_invariants (TSRMLS_C
);
5117 default_value
= local___static_value__
;
5118 assert(!default_value
->is_ref
);
5119 default_value
->refcount
++;
5120 if (local___static_value__
!= NULL
)
5122 zval_ptr_dtor (&local___static_value__
);
5125 default_value
->refcount
--;
5126 params
[1] = default_value
;
5128 params
[1]->refcount
++;
5129 if (local_stderr
!= NULL
)
5131 zval_ptr_dtor (&local_stderr
);
5133 local_stderr
= params
[1];
5137 zval
* default_value
;
5139 zval
* local___static_value__
= NULL
;
5140 // $__static_value__ = NULL;
5142 if (local___static_value__
== NULL
)
5144 local___static_value__
= EG (uninitialized_zval_ptr
);
5145 local___static_value__
->refcount
++;
5147 zval
** p_lhs
= &local___static_value__
;
5150 if ((*p_lhs
)->is_ref
)
5152 // Always overwrite the current value
5158 ALLOC_INIT_ZVAL (value
);
5159 zval_ptr_dtor (p_lhs
);
5165 phc_check_invariants (TSRMLS_C
);
5167 default_value
= local___static_value__
;
5168 assert(!default_value
->is_ref
);
5169 default_value
->refcount
++;
5170 if (local___static_value__
!= NULL
)
5172 zval_ptr_dtor (&local___static_value__
);
5175 default_value
->refcount
--;
5176 params
[2] = default_value
;
5178 params
[2]->refcount
++;
5179 if (local_retval
!= NULL
)
5181 zval_ptr_dtor (&local_retval
);
5183 local_retval
= params
[2];
5186 // global $wgTidyConf;
5188 if (local_wgTidyConf
== NULL
)
5190 local_wgTidyConf
= EG (uninitialized_zval_ptr
);
5191 local_wgTidyConf
->refcount
++;
5193 zval
** p_local
= &local_wgTidyConf
;
5195 zval
** p_global
= get_st_entry (&EG(symbol_table
), "wgTidyConf", 10 + 1, 3667061347u TSRMLS_CC
);
5197 sep_copy_on_write (p_global
);
5198 copy_into_ref (p_local
, p_global
);
5199 phc_check_invariants (TSRMLS_C
);
5201 // global $wgTidyBin;
5203 if (local_wgTidyBin
== NULL
)
5205 local_wgTidyBin
= EG (uninitialized_zval_ptr
);
5206 local_wgTidyBin
->refcount
++;
5208 zval
** p_local
= &local_wgTidyBin
;
5210 zval
** p_global
= get_st_entry (&EG(symbol_table
), "wgTidyBin", 9 + 1, 4275897270u TSRMLS_CC
);
5212 sep_copy_on_write (p_global
);
5213 copy_into_ref (p_local
, p_global
);
5214 phc_check_invariants (TSRMLS_C
);
5216 // global $wgTidyOpts;
5218 if (local_wgTidyOpts
== NULL
)
5220 local_wgTidyOpts
= EG (uninitialized_zval_ptr
);
5221 local_wgTidyOpts
->refcount
++;
5223 zval
** p_local
= &local_wgTidyOpts
;
5225 zval
** p_global
= get_st_entry (&EG(symbol_table
), "wgTidyOpts", 10 + 1, 3681335299u TSRMLS_CC
);
5227 sep_copy_on_write (p_global
);
5228 copy_into_ref (p_local
, p_global
);
5229 phc_check_invariants (TSRMLS_C
);
5231 // $TLE28 = 'MWTidy::execExternalTidy';
5233 if (local_TLE28
== NULL
)
5235 local_TLE28
= EG (uninitialized_zval_ptr
);
5236 local_TLE28
->refcount
++;
5238 zval
** p_lhs
= &local_TLE28
;
5241 if ((*p_lhs
)->is_ref
)
5243 // Always overwrite the current value
5249 ALLOC_INIT_ZVAL (value
);
5250 zval_ptr_dtor (p_lhs
);
5254 ZVAL_STRINGL(value
, "MWTidy::execExternalTidy", 24, 1);
5256 phc_check_invariants (TSRMLS_C
);
5258 // wfprofilein($TLE28);
5260 initialize_function_call (&wfprofilein_fci
, &wfprofilein_fcic
, "wfprofilein", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 77 TSRMLS_CC
);
5261 zend_function
* signature
= wfprofilein_fcic
.function_handler
;
5262 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
5266 // TODO: find names to replace index
5269 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
5273 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
5278 // Setup array of arguments
5279 // TODO: i think arrays of size 0 is an error
5282 zval
** args_ind
[1];
5285 destruct
[af_index
] = 0;
5286 if (by_ref
[af_index
])
5288 if (local_TLE28
== NULL
)
5290 local_TLE28
= EG (uninitialized_zval_ptr
);
5291 local_TLE28
->refcount
++;
5293 zval
** p_arg
= &local_TLE28
;
5295 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
5296 assert (!in_copy_on_write (*args_ind
[af_index
]));
5297 args
[af_index
] = *args_ind
[af_index
];
5302 if (local_TLE28
== NULL
)
5303 arg
= EG (uninitialized_zval_ptr
);
5307 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
5308 args_ind
[af_index
] = &args
[af_index
];
5313 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 77, NULL TSRMLS_CC
);
5315 // save existing parameters, in case of recursion
5316 int param_count_save
= wfprofilein_fci
.param_count
;
5317 zval
*** params_save
= wfprofilein_fci
.params
;
5318 zval
** retval_save
= wfprofilein_fci
.retval_ptr_ptr
;
5323 wfprofilein_fci
.params
= args_ind
;
5324 wfprofilein_fci
.param_count
= 1;
5325 wfprofilein_fci
.retval_ptr_ptr
= &rhs
;
5327 // call the function
5328 int success
= zend_call_function (&wfprofilein_fci
, &wfprofilein_fcic TSRMLS_CC
);
5329 assert(success
== SUCCESS
);
5332 wfprofilein_fci
.params
= params_save
;
5333 wfprofilein_fci
.param_count
= param_count_save
;
5334 wfprofilein_fci
.retval_ptr_ptr
= retval_save
;
5337 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
5340 for (i
= 0; i
< 1; i
++)
5344 assert (destruct
[i
]);
5345 zval_ptr_dtor (args_ind
[i
]);
5350 // When the Zend engine returns by reference, it allocates a zval into
5351 // retval_ptr_ptr. To return by reference, the callee writes into the
5352 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
5353 // not actually return anything). So the zval returned - whether we return
5354 // it, or it is the allocated zval - has a refcount of 1.
5356 // The caller is responsible for cleaning that up (note, this is unaffected
5357 // by whether it is added to some COW set).
5359 // For reasons unknown, the Zend API resets the refcount and is_ref fields
5360 // of the return value after the function returns (unless the callee is
5361 // interpreted). If the function is supposed to return by reference, this
5362 // loses the refcount. This only happens when non-interpreted code is
5363 // called. We work around it, when compiled code is called, by saving the
5364 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
5365 // that we may create an error if our code is called by a callback, and
5366 // returns by reference, and the callback returns by reference. At least
5367 // this is an obscure case.
5368 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
5370 assert (rhs
!= EG(uninitialized_zval_ptr
));
5372 if (saved_refcount
!= 0)
5374 rhs
->refcount
= saved_refcount
;
5378 saved_refcount
= 0; // for 'obscure cases'
5382 zval_ptr_dtor (&rhs
);
5383 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
5384 zval_ptr_dtor (&rhs
);
5386 phc_check_invariants (TSRMLS_C
);
5388 // $cleansource = '';
5390 if (local_cleansource
== NULL
)
5392 local_cleansource
= EG (uninitialized_zval_ptr
);
5393 local_cleansource
->refcount
++;
5395 zval
** p_lhs
= &local_cleansource
;
5398 if ((*p_lhs
)->is_ref
)
5400 // Always overwrite the current value
5406 ALLOC_INIT_ZVAL (value
);
5407 zval_ptr_dtor (p_lhs
);
5411 ZVAL_STRINGL(value
, "", 0, 1);
5413 phc_check_invariants (TSRMLS_C
);
5415 // $opts = ' -utf8';
5417 if (local_opts
== NULL
)
5419 local_opts
= EG (uninitialized_zval_ptr
);
5420 local_opts
->refcount
++;
5422 zval
** p_lhs
= &local_opts
;
5425 if ((*p_lhs
)->is_ref
)
5427 // Always overwrite the current value
5433 ALLOC_INIT_ZVAL (value
);
5434 zval_ptr_dtor (p_lhs
);
5438 ZVAL_STRINGL(value
, " -utf8", 6, 1);
5440 phc_check_invariants (TSRMLS_C
);
5442 // if (stderr) goto L122 else goto L123;
5445 if (local_stderr
== NULL
)
5446 p_cond
= EG (uninitialized_zval_ptr
);
5448 p_cond
= local_stderr
;
5450 zend_bool bcond
= zend_is_true (p_cond
);
5455 phc_check_invariants (TSRMLS_C
);
5461 if (local_TLE29
== NULL
)
5463 local_TLE29
= EG (uninitialized_zval_ptr
);
5464 local_TLE29
->refcount
++;
5466 zval
** p_lhs
= &local_TLE29
;
5469 if ((*p_lhs
)->is_ref
)
5471 // Always overwrite the current value
5477 ALLOC_INIT_ZVAL (value
);
5478 zval_ptr_dtor (p_lhs
);
5482 ZVAL_LONG (value
, 0);
5484 phc_check_invariants (TSRMLS_C
);
5488 if (local_TLE30
== NULL
)
5490 local_TLE30
= EG (uninitialized_zval_ptr
);
5491 local_TLE30
->refcount
++;
5493 zval
** p_lhs
= &local_TLE30
;
5496 if ((*p_lhs
)->is_ref
)
5498 // Always overwrite the current value
5504 ALLOC_INIT_ZVAL (value
);
5505 zval_ptr_dtor (p_lhs
);
5509 ZVAL_STRINGL(value
, "pipe", 4, 1);
5511 phc_check_invariants (TSRMLS_C
);
5515 if (local_TLE31
== NULL
)
5517 local_TLE31
= EG (uninitialized_zval_ptr
);
5518 local_TLE31
->refcount
++;
5520 zval
** p_lhs
= &local_TLE31
;
5523 if ((*p_lhs
)->is_ref
)
5525 // Always overwrite the current value
5531 ALLOC_INIT_ZVAL (value
);
5532 zval_ptr_dtor (p_lhs
);
5536 ZVAL_STRINGL(value
, "r", 1, 1);
5538 phc_check_invariants (TSRMLS_C
);
5542 if (local_TSa32
!= NULL
)
5544 zval_ptr_dtor (&local_TSa32
);
5547 phc_check_invariants (TSRMLS_C
);
5549 // $TSa32 = (array) $TSa32;
5551 if (local_TSa32
== NULL
)
5553 local_TSa32
= EG (uninitialized_zval_ptr
);
5554 local_TSa32
->refcount
++;
5556 zval
** p_lhs
= &local_TSa32
;
5559 if (local_TSa32
== NULL
)
5560 rhs
= EG (uninitialized_zval_ptr
);
5566 if ((*p_lhs
)->is_ref
)
5567 overwrite_lhs (*p_lhs
, rhs
);
5570 zval_ptr_dtor (p_lhs
);
5573 // Take a copy of RHS for LHS
5574 *p_lhs
= zvp_clone_ex (rhs
);
5587 assert (IS_ARRAY
>= 0 && IS_ARRAY
<= 6);
5588 if ((*p_lhs
)->type
!= IS_ARRAY
)
5590 sep_copy_on_write (p_lhs
);
5591 convert_to_array (*p_lhs
);
5594 phc_check_invariants (TSRMLS_C
);
5596 // $TSa32[] = $TLE30;
5598 if (local_TSa32
== NULL
)
5600 local_TSa32
= EG (uninitialized_zval_ptr
);
5601 local_TSa32
->refcount
++;
5603 zval
** p_array
= &local_TSa32
;
5605 // Push EG(uninit) and get a pointer to the symtable entry
5606 zval
** p_lhs
= push_and_index_ht (p_array TSRMLS_CC
);
5610 if (local_TLE30
== NULL
)
5611 rhs
= EG (uninitialized_zval_ptr
);
5616 write_var (p_lhs
, rhs
);
5618 // I think if this is NULL, then the LHS is a bool or similar, and you cant
5620 phc_check_invariants (TSRMLS_C
);
5622 // $TSa32[] = $TLE31;
5624 if (local_TSa32
== NULL
)
5626 local_TSa32
= EG (uninitialized_zval_ptr
);
5627 local_TSa32
->refcount
++;
5629 zval
** p_array
= &local_TSa32
;
5631 // Push EG(uninit) and get a pointer to the symtable entry
5632 zval
** p_lhs
= push_and_index_ht (p_array TSRMLS_CC
);
5636 if (local_TLE31
== NULL
)
5637 rhs
= EG (uninitialized_zval_ptr
);
5642 write_var (p_lhs
, rhs
);
5644 // I think if this is NULL, then the LHS is a bool or similar, and you cant
5646 phc_check_invariants (TSRMLS_C
);
5650 if (local_TLE33
== NULL
)
5652 local_TLE33
= EG (uninitialized_zval_ptr
);
5653 local_TLE33
->refcount
++;
5655 zval
** p_lhs
= &local_TLE33
;
5658 if ((*p_lhs
)->is_ref
)
5660 // Always overwrite the current value
5666 ALLOC_INIT_ZVAL (value
);
5667 zval_ptr_dtor (p_lhs
);
5671 ZVAL_LONG (value
, 1);
5673 phc_check_invariants (TSRMLS_C
);
5677 if (local_TLE34
== NULL
)
5679 local_TLE34
= EG (uninitialized_zval_ptr
);
5680 local_TLE34
->refcount
++;
5682 zval
** p_lhs
= &local_TLE34
;
5685 if ((*p_lhs
)->is_ref
)
5687 // Always overwrite the current value
5693 ALLOC_INIT_ZVAL (value
);
5694 zval_ptr_dtor (p_lhs
);
5698 ZVAL_STRINGL(value
, "file", 4, 1);
5700 phc_check_invariants (TSRMLS_C
);
5702 // $TLE35 = wfgetnull();
5704 initialize_function_call (&wfgetnull_fci
, &wfgetnull_fcic
, "wfgetnull", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 85 TSRMLS_CC
);
5705 zend_function
* signature
= wfgetnull_fcic
.function_handler
;
5706 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
5712 // Setup array of arguments
5713 // TODO: i think arrays of size 0 is an error
5716 zval
** args_ind
[0];
5721 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 85, NULL TSRMLS_CC
);
5723 // save existing parameters, in case of recursion
5724 int param_count_save
= wfgetnull_fci
.param_count
;
5725 zval
*** params_save
= wfgetnull_fci
.params
;
5726 zval
** retval_save
= wfgetnull_fci
.retval_ptr_ptr
;
5731 wfgetnull_fci
.params
= args_ind
;
5732 wfgetnull_fci
.param_count
= 0;
5733 wfgetnull_fci
.retval_ptr_ptr
= &rhs
;
5735 // call the function
5736 int success
= zend_call_function (&wfgetnull_fci
, &wfgetnull_fcic TSRMLS_CC
);
5737 assert(success
== SUCCESS
);
5740 wfgetnull_fci
.params
= params_save
;
5741 wfgetnull_fci
.param_count
= param_count_save
;
5742 wfgetnull_fci
.retval_ptr_ptr
= retval_save
;
5745 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
5748 for (i
= 0; i
< 0; i
++)
5752 assert (destruct
[i
]);
5753 zval_ptr_dtor (args_ind
[i
]);
5758 // When the Zend engine returns by reference, it allocates a zval into
5759 // retval_ptr_ptr. To return by reference, the callee writes into the
5760 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
5761 // not actually return anything). So the zval returned - whether we return
5762 // it, or it is the allocated zval - has a refcount of 1.
5764 // The caller is responsible for cleaning that up (note, this is unaffected
5765 // by whether it is added to some COW set).
5767 // For reasons unknown, the Zend API resets the refcount and is_ref fields
5768 // of the return value after the function returns (unless the callee is
5769 // interpreted). If the function is supposed to return by reference, this
5770 // loses the refcount. This only happens when non-interpreted code is
5771 // called. We work around it, when compiled code is called, by saving the
5772 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
5773 // that we may create an error if our code is called by a callback, and
5774 // returns by reference, and the callback returns by reference. At least
5775 // this is an obscure case.
5776 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
5778 assert (rhs
!= EG(uninitialized_zval_ptr
));
5780 if (saved_refcount
!= 0)
5782 rhs
->refcount
= saved_refcount
;
5786 saved_refcount
= 0; // for 'obscure cases'
5788 if (local_TLE35
== NULL
)
5790 local_TLE35
= EG (uninitialized_zval_ptr
);
5791 local_TLE35
->refcount
++;
5793 zval
** p_lhs
= &local_TLE35
;
5795 write_var (p_lhs
, rhs
);
5798 zval_ptr_dtor (&rhs
);
5799 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
5800 zval_ptr_dtor (&rhs
);
5802 phc_check_invariants (TSRMLS_C
);
5806 if (local_TLE36
== NULL
)
5808 local_TLE36
= EG (uninitialized_zval_ptr
);
5809 local_TLE36
->refcount
++;
5811 zval
** p_lhs
= &local_TLE36
;
5814 if ((*p_lhs
)->is_ref
)
5816 // Always overwrite the current value
5822 ALLOC_INIT_ZVAL (value
);
5823 zval_ptr_dtor (p_lhs
);
5827 ZVAL_STRINGL(value
, "a", 1, 1);
5829 phc_check_invariants (TSRMLS_C
);
5833 if (local_TSa37
!= NULL
)
5835 zval_ptr_dtor (&local_TSa37
);
5838 phc_check_invariants (TSRMLS_C
);
5840 // $TSa37 = (array) $TSa37;
5842 if (local_TSa37
== NULL
)
5844 local_TSa37
= EG (uninitialized_zval_ptr
);
5845 local_TSa37
->refcount
++;
5847 zval
** p_lhs
= &local_TSa37
;
5850 if (local_TSa37
== NULL
)
5851 rhs
= EG (uninitialized_zval_ptr
);
5857 if ((*p_lhs
)->is_ref
)
5858 overwrite_lhs (*p_lhs
, rhs
);
5861 zval_ptr_dtor (p_lhs
);
5864 // Take a copy of RHS for LHS
5865 *p_lhs
= zvp_clone_ex (rhs
);
5878 assert (IS_ARRAY
>= 0 && IS_ARRAY
<= 6);
5879 if ((*p_lhs
)->type
!= IS_ARRAY
)
5881 sep_copy_on_write (p_lhs
);
5882 convert_to_array (*p_lhs
);
5885 phc_check_invariants (TSRMLS_C
);
5887 // $TSa37[] = $TLE34;
5889 if (local_TSa37
== NULL
)
5891 local_TSa37
= EG (uninitialized_zval_ptr
);
5892 local_TSa37
->refcount
++;
5894 zval
** p_array
= &local_TSa37
;
5896 // Push EG(uninit) and get a pointer to the symtable entry
5897 zval
** p_lhs
= push_and_index_ht (p_array TSRMLS_CC
);
5901 if (local_TLE34
== NULL
)
5902 rhs
= EG (uninitialized_zval_ptr
);
5907 write_var (p_lhs
, rhs
);
5909 // I think if this is NULL, then the LHS is a bool or similar, and you cant
5911 phc_check_invariants (TSRMLS_C
);
5913 // $TSa37[] = $TLE35;
5915 if (local_TSa37
== NULL
)
5917 local_TSa37
= EG (uninitialized_zval_ptr
);
5918 local_TSa37
->refcount
++;
5920 zval
** p_array
= &local_TSa37
;
5922 // Push EG(uninit) and get a pointer to the symtable entry
5923 zval
** p_lhs
= push_and_index_ht (p_array TSRMLS_CC
);
5927 if (local_TLE35
== NULL
)
5928 rhs
= EG (uninitialized_zval_ptr
);
5933 write_var (p_lhs
, rhs
);
5935 // I think if this is NULL, then the LHS is a bool or similar, and you cant
5937 phc_check_invariants (TSRMLS_C
);
5939 // $TSa37[] = $TLE36;
5941 if (local_TSa37
== NULL
)
5943 local_TSa37
= EG (uninitialized_zval_ptr
);
5944 local_TSa37
->refcount
++;
5946 zval
** p_array
= &local_TSa37
;
5948 // Push EG(uninit) and get a pointer to the symtable entry
5949 zval
** p_lhs
= push_and_index_ht (p_array TSRMLS_CC
);
5953 if (local_TLE36
== NULL
)
5954 rhs
= EG (uninitialized_zval_ptr
);
5959 write_var (p_lhs
, rhs
);
5961 // I think if this is NULL, then the LHS is a bool or similar, and you cant
5963 phc_check_invariants (TSRMLS_C
);
5967 if (local_TLE38
== NULL
)
5969 local_TLE38
= EG (uninitialized_zval_ptr
);
5970 local_TLE38
->refcount
++;
5972 zval
** p_lhs
= &local_TLE38
;
5975 if ((*p_lhs
)->is_ref
)
5977 // Always overwrite the current value
5983 ALLOC_INIT_ZVAL (value
);
5984 zval_ptr_dtor (p_lhs
);
5988 ZVAL_LONG (value
, 2);
5990 phc_check_invariants (TSRMLS_C
);
5994 if (local_TLE39
== NULL
)
5996 local_TLE39
= EG (uninitialized_zval_ptr
);
5997 local_TLE39
->refcount
++;
5999 zval
** p_lhs
= &local_TLE39
;
6002 if ((*p_lhs
)->is_ref
)
6004 // Always overwrite the current value
6010 ALLOC_INIT_ZVAL (value
);
6011 zval_ptr_dtor (p_lhs
);
6015 ZVAL_STRINGL(value
, "pipe", 4, 1);
6017 phc_check_invariants (TSRMLS_C
);
6021 if (local_TLE40
== NULL
)
6023 local_TLE40
= EG (uninitialized_zval_ptr
);
6024 local_TLE40
->refcount
++;
6026 zval
** p_lhs
= &local_TLE40
;
6029 if ((*p_lhs
)->is_ref
)
6031 // Always overwrite the current value
6037 ALLOC_INIT_ZVAL (value
);
6038 zval_ptr_dtor (p_lhs
);
6042 ZVAL_STRINGL(value
, "w", 1, 1);
6044 phc_check_invariants (TSRMLS_C
);
6048 if (local_TSa41
!= NULL
)
6050 zval_ptr_dtor (&local_TSa41
);
6053 phc_check_invariants (TSRMLS_C
);
6055 // $TSa41 = (array) $TSa41;
6057 if (local_TSa41
== NULL
)
6059 local_TSa41
= EG (uninitialized_zval_ptr
);
6060 local_TSa41
->refcount
++;
6062 zval
** p_lhs
= &local_TSa41
;
6065 if (local_TSa41
== NULL
)
6066 rhs
= EG (uninitialized_zval_ptr
);
6072 if ((*p_lhs
)->is_ref
)
6073 overwrite_lhs (*p_lhs
, rhs
);
6076 zval_ptr_dtor (p_lhs
);
6079 // Take a copy of RHS for LHS
6080 *p_lhs
= zvp_clone_ex (rhs
);
6093 assert (IS_ARRAY
>= 0 && IS_ARRAY
<= 6);
6094 if ((*p_lhs
)->type
!= IS_ARRAY
)
6096 sep_copy_on_write (p_lhs
);
6097 convert_to_array (*p_lhs
);
6100 phc_check_invariants (TSRMLS_C
);
6102 // $TSa41[] = $TLE39;
6104 if (local_TSa41
== NULL
)
6106 local_TSa41
= EG (uninitialized_zval_ptr
);
6107 local_TSa41
->refcount
++;
6109 zval
** p_array
= &local_TSa41
;
6111 // Push EG(uninit) and get a pointer to the symtable entry
6112 zval
** p_lhs
= push_and_index_ht (p_array TSRMLS_CC
);
6116 if (local_TLE39
== NULL
)
6117 rhs
= EG (uninitialized_zval_ptr
);
6122 write_var (p_lhs
, rhs
);
6124 // I think if this is NULL, then the LHS is a bool or similar, and you cant
6126 phc_check_invariants (TSRMLS_C
);
6128 // $TSa41[] = $TLE40;
6130 if (local_TSa41
== NULL
)
6132 local_TSa41
= EG (uninitialized_zval_ptr
);
6133 local_TSa41
->refcount
++;
6135 zval
** p_array
= &local_TSa41
;
6137 // Push EG(uninit) and get a pointer to the symtable entry
6138 zval
** p_lhs
= push_and_index_ht (p_array TSRMLS_CC
);
6142 if (local_TLE40
== NULL
)
6143 rhs
= EG (uninitialized_zval_ptr
);
6148 write_var (p_lhs
, rhs
);
6150 // I think if this is NULL, then the LHS is a bool or similar, and you cant
6152 phc_check_invariants (TSRMLS_C
);
6156 if (local_TSa42
!= NULL
)
6158 zval_ptr_dtor (&local_TSa42
);
6161 phc_check_invariants (TSRMLS_C
);
6163 // $TSa42 = (array) $TSa42;
6165 if (local_TSa42
== NULL
)
6167 local_TSa42
= EG (uninitialized_zval_ptr
);
6168 local_TSa42
->refcount
++;
6170 zval
** p_lhs
= &local_TSa42
;
6173 if (local_TSa42
== NULL
)
6174 rhs
= EG (uninitialized_zval_ptr
);
6180 if ((*p_lhs
)->is_ref
)
6181 overwrite_lhs (*p_lhs
, rhs
);
6184 zval_ptr_dtor (p_lhs
);
6187 // Take a copy of RHS for LHS
6188 *p_lhs
= zvp_clone_ex (rhs
);
6201 assert (IS_ARRAY
>= 0 && IS_ARRAY
<= 6);
6202 if ((*p_lhs
)->type
!= IS_ARRAY
)
6204 sep_copy_on_write (p_lhs
);
6205 convert_to_array (*p_lhs
);
6208 phc_check_invariants (TSRMLS_C
);
6210 // $TSa42[$TLE29] = $TSa32;
6212 if (local_TSa42
== NULL
)
6214 local_TSa42
= EG (uninitialized_zval_ptr
);
6215 local_TSa42
->refcount
++;
6217 zval
** p_array
= &local_TSa42
;
6219 check_array_type (p_array TSRMLS_CC
);
6222 if (local_TLE29
== NULL
)
6223 index
= EG (uninitialized_zval_ptr
);
6225 index
= local_TLE29
;
6229 if (Z_TYPE_PP (p_array
) == IS_STRING
&& Z_STRLEN_PP (p_array
) > 0)
6232 if (local_TSa32
== NULL
)
6233 rhs
= EG (uninitialized_zval_ptr
);
6237 write_string_index (p_array
, index
, rhs TSRMLS_CC
);
6239 else if (Z_TYPE_PP (p_array
) == IS_ARRAY
)
6241 zval
** p_lhs
= get_ht_entry (p_array
, index TSRMLS_CC
);
6243 if (local_TSa32
== NULL
)
6244 rhs
= EG (uninitialized_zval_ptr
);
6250 write_var (p_lhs
, rhs
);
6253 phc_check_invariants (TSRMLS_C
);
6255 // $TSa42[$TLE33] = $TSa37;
6257 if (local_TSa42
== NULL
)
6259 local_TSa42
= EG (uninitialized_zval_ptr
);
6260 local_TSa42
->refcount
++;
6262 zval
** p_array
= &local_TSa42
;
6264 check_array_type (p_array TSRMLS_CC
);
6267 if (local_TLE33
== NULL
)
6268 index
= EG (uninitialized_zval_ptr
);
6270 index
= local_TLE33
;
6274 if (Z_TYPE_PP (p_array
) == IS_STRING
&& Z_STRLEN_PP (p_array
) > 0)
6277 if (local_TSa37
== NULL
)
6278 rhs
= EG (uninitialized_zval_ptr
);
6282 write_string_index (p_array
, index
, rhs TSRMLS_CC
);
6284 else if (Z_TYPE_PP (p_array
) == IS_ARRAY
)
6286 zval
** p_lhs
= get_ht_entry (p_array
, index TSRMLS_CC
);
6288 if (local_TSa37
== NULL
)
6289 rhs
= EG (uninitialized_zval_ptr
);
6295 write_var (p_lhs
, rhs
);
6298 phc_check_invariants (TSRMLS_C
);
6300 // $TSa42[$TLE38] = $TSa41;
6302 if (local_TSa42
== NULL
)
6304 local_TSa42
= EG (uninitialized_zval_ptr
);
6305 local_TSa42
->refcount
++;
6307 zval
** p_array
= &local_TSa42
;
6309 check_array_type (p_array TSRMLS_CC
);
6312 if (local_TLE38
== NULL
)
6313 index
= EG (uninitialized_zval_ptr
);
6315 index
= local_TLE38
;
6319 if (Z_TYPE_PP (p_array
) == IS_STRING
&& Z_STRLEN_PP (p_array
) > 0)
6322 if (local_TSa41
== NULL
)
6323 rhs
= EG (uninitialized_zval_ptr
);
6327 write_string_index (p_array
, index
, rhs TSRMLS_CC
);
6329 else if (Z_TYPE_PP (p_array
) == IS_ARRAY
)
6331 zval
** p_lhs
= get_ht_entry (p_array
, index TSRMLS_CC
);
6333 if (local_TSa41
== NULL
)
6334 rhs
= EG (uninitialized_zval_ptr
);
6340 write_var (p_lhs
, rhs
);
6343 phc_check_invariants (TSRMLS_C
);
6345 // $descriptorspec = $TSa42;
6347 if (local_descriptorspec
== NULL
)
6349 local_descriptorspec
= EG (uninitialized_zval_ptr
);
6350 local_descriptorspec
->refcount
++;
6352 zval
** p_lhs
= &local_descriptorspec
;
6355 if (local_TSa42
== NULL
)
6356 rhs
= EG (uninitialized_zval_ptr
);
6362 if ((*p_lhs
)->is_ref
)
6363 overwrite_lhs (*p_lhs
, rhs
);
6366 zval_ptr_dtor (p_lhs
);
6369 // Take a copy of RHS for LHS
6370 *p_lhs
= zvp_clone_ex (rhs
);
6382 phc_check_invariants (TSRMLS_C
);
6387 phc_check_invariants (TSRMLS_C
);
6393 if (local_TLE43
== NULL
)
6395 local_TLE43
= EG (uninitialized_zval_ptr
);
6396 local_TLE43
->refcount
++;
6398 zval
** p_lhs
= &local_TLE43
;
6401 if ((*p_lhs
)->is_ref
)
6403 // Always overwrite the current value
6409 ALLOC_INIT_ZVAL (value
);
6410 zval_ptr_dtor (p_lhs
);
6414 ZVAL_LONG (value
, 0);
6416 phc_check_invariants (TSRMLS_C
);
6420 if (local_TLE44
== NULL
)
6422 local_TLE44
= EG (uninitialized_zval_ptr
);
6423 local_TLE44
->refcount
++;
6425 zval
** p_lhs
= &local_TLE44
;
6428 if ((*p_lhs
)->is_ref
)
6430 // Always overwrite the current value
6436 ALLOC_INIT_ZVAL (value
);
6437 zval_ptr_dtor (p_lhs
);
6441 ZVAL_STRINGL(value
, "pipe", 4, 1);
6443 phc_check_invariants (TSRMLS_C
);
6447 if (local_TLE45
== NULL
)
6449 local_TLE45
= EG (uninitialized_zval_ptr
);
6450 local_TLE45
->refcount
++;
6452 zval
** p_lhs
= &local_TLE45
;
6455 if ((*p_lhs
)->is_ref
)
6457 // Always overwrite the current value
6463 ALLOC_INIT_ZVAL (value
);
6464 zval_ptr_dtor (p_lhs
);
6468 ZVAL_STRINGL(value
, "r", 1, 1);
6470 phc_check_invariants (TSRMLS_C
);
6474 if (local_TSa46
!= NULL
)
6476 zval_ptr_dtor (&local_TSa46
);
6479 phc_check_invariants (TSRMLS_C
);
6481 // $TSa46 = (array) $TSa46;
6483 if (local_TSa46
== NULL
)
6485 local_TSa46
= EG (uninitialized_zval_ptr
);
6486 local_TSa46
->refcount
++;
6488 zval
** p_lhs
= &local_TSa46
;
6491 if (local_TSa46
== NULL
)
6492 rhs
= EG (uninitialized_zval_ptr
);
6498 if ((*p_lhs
)->is_ref
)
6499 overwrite_lhs (*p_lhs
, rhs
);
6502 zval_ptr_dtor (p_lhs
);
6505 // Take a copy of RHS for LHS
6506 *p_lhs
= zvp_clone_ex (rhs
);
6519 assert (IS_ARRAY
>= 0 && IS_ARRAY
<= 6);
6520 if ((*p_lhs
)->type
!= IS_ARRAY
)
6522 sep_copy_on_write (p_lhs
);
6523 convert_to_array (*p_lhs
);
6526 phc_check_invariants (TSRMLS_C
);
6528 // $TSa46[] = $TLE44;
6530 if (local_TSa46
== NULL
)
6532 local_TSa46
= EG (uninitialized_zval_ptr
);
6533 local_TSa46
->refcount
++;
6535 zval
** p_array
= &local_TSa46
;
6537 // Push EG(uninit) and get a pointer to the symtable entry
6538 zval
** p_lhs
= push_and_index_ht (p_array TSRMLS_CC
);
6542 if (local_TLE44
== NULL
)
6543 rhs
= EG (uninitialized_zval_ptr
);
6548 write_var (p_lhs
, rhs
);
6550 // I think if this is NULL, then the LHS is a bool or similar, and you cant
6552 phc_check_invariants (TSRMLS_C
);
6554 // $TSa46[] = $TLE45;
6556 if (local_TSa46
== NULL
)
6558 local_TSa46
= EG (uninitialized_zval_ptr
);
6559 local_TSa46
->refcount
++;
6561 zval
** p_array
= &local_TSa46
;
6563 // Push EG(uninit) and get a pointer to the symtable entry
6564 zval
** p_lhs
= push_and_index_ht (p_array TSRMLS_CC
);
6568 if (local_TLE45
== NULL
)
6569 rhs
= EG (uninitialized_zval_ptr
);
6574 write_var (p_lhs
, rhs
);
6576 // I think if this is NULL, then the LHS is a bool or similar, and you cant
6578 phc_check_invariants (TSRMLS_C
);
6582 if (local_TLE47
== NULL
)
6584 local_TLE47
= EG (uninitialized_zval_ptr
);
6585 local_TLE47
->refcount
++;
6587 zval
** p_lhs
= &local_TLE47
;
6590 if ((*p_lhs
)->is_ref
)
6592 // Always overwrite the current value
6598 ALLOC_INIT_ZVAL (value
);
6599 zval_ptr_dtor (p_lhs
);
6603 ZVAL_LONG (value
, 1);
6605 phc_check_invariants (TSRMLS_C
);
6609 if (local_TLE48
== NULL
)
6611 local_TLE48
= EG (uninitialized_zval_ptr
);
6612 local_TLE48
->refcount
++;
6614 zval
** p_lhs
= &local_TLE48
;
6617 if ((*p_lhs
)->is_ref
)
6619 // Always overwrite the current value
6625 ALLOC_INIT_ZVAL (value
);
6626 zval_ptr_dtor (p_lhs
);
6630 ZVAL_STRINGL(value
, "pipe", 4, 1);
6632 phc_check_invariants (TSRMLS_C
);
6636 if (local_TLE49
== NULL
)
6638 local_TLE49
= EG (uninitialized_zval_ptr
);
6639 local_TLE49
->refcount
++;
6641 zval
** p_lhs
= &local_TLE49
;
6644 if ((*p_lhs
)->is_ref
)
6646 // Always overwrite the current value
6652 ALLOC_INIT_ZVAL (value
);
6653 zval_ptr_dtor (p_lhs
);
6657 ZVAL_STRINGL(value
, "w", 1, 1);
6659 phc_check_invariants (TSRMLS_C
);
6663 if (local_TSa50
!= NULL
)
6665 zval_ptr_dtor (&local_TSa50
);
6668 phc_check_invariants (TSRMLS_C
);
6670 // $TSa50 = (array) $TSa50;
6672 if (local_TSa50
== NULL
)
6674 local_TSa50
= EG (uninitialized_zval_ptr
);
6675 local_TSa50
->refcount
++;
6677 zval
** p_lhs
= &local_TSa50
;
6680 if (local_TSa50
== NULL
)
6681 rhs
= EG (uninitialized_zval_ptr
);
6687 if ((*p_lhs
)->is_ref
)
6688 overwrite_lhs (*p_lhs
, rhs
);
6691 zval_ptr_dtor (p_lhs
);
6694 // Take a copy of RHS for LHS
6695 *p_lhs
= zvp_clone_ex (rhs
);
6708 assert (IS_ARRAY
>= 0 && IS_ARRAY
<= 6);
6709 if ((*p_lhs
)->type
!= IS_ARRAY
)
6711 sep_copy_on_write (p_lhs
);
6712 convert_to_array (*p_lhs
);
6715 phc_check_invariants (TSRMLS_C
);
6717 // $TSa50[] = $TLE48;
6719 if (local_TSa50
== NULL
)
6721 local_TSa50
= EG (uninitialized_zval_ptr
);
6722 local_TSa50
->refcount
++;
6724 zval
** p_array
= &local_TSa50
;
6726 // Push EG(uninit) and get a pointer to the symtable entry
6727 zval
** p_lhs
= push_and_index_ht (p_array TSRMLS_CC
);
6731 if (local_TLE48
== NULL
)
6732 rhs
= EG (uninitialized_zval_ptr
);
6737 write_var (p_lhs
, rhs
);
6739 // I think if this is NULL, then the LHS is a bool or similar, and you cant
6741 phc_check_invariants (TSRMLS_C
);
6743 // $TSa50[] = $TLE49;
6745 if (local_TSa50
== NULL
)
6747 local_TSa50
= EG (uninitialized_zval_ptr
);
6748 local_TSa50
->refcount
++;
6750 zval
** p_array
= &local_TSa50
;
6752 // Push EG(uninit) and get a pointer to the symtable entry
6753 zval
** p_lhs
= push_and_index_ht (p_array TSRMLS_CC
);
6757 if (local_TLE49
== NULL
)
6758 rhs
= EG (uninitialized_zval_ptr
);
6763 write_var (p_lhs
, rhs
);
6765 // I think if this is NULL, then the LHS is a bool or similar, and you cant
6767 phc_check_invariants (TSRMLS_C
);
6771 if (local_TLE51
== NULL
)
6773 local_TLE51
= EG (uninitialized_zval_ptr
);
6774 local_TLE51
->refcount
++;
6776 zval
** p_lhs
= &local_TLE51
;
6779 if ((*p_lhs
)->is_ref
)
6781 // Always overwrite the current value
6787 ALLOC_INIT_ZVAL (value
);
6788 zval_ptr_dtor (p_lhs
);
6792 ZVAL_LONG (value
, 2);
6794 phc_check_invariants (TSRMLS_C
);
6798 if (local_TLE52
== NULL
)
6800 local_TLE52
= EG (uninitialized_zval_ptr
);
6801 local_TLE52
->refcount
++;
6803 zval
** p_lhs
= &local_TLE52
;
6806 if ((*p_lhs
)->is_ref
)
6808 // Always overwrite the current value
6814 ALLOC_INIT_ZVAL (value
);
6815 zval_ptr_dtor (p_lhs
);
6819 ZVAL_STRINGL(value
, "file", 4, 1);
6821 phc_check_invariants (TSRMLS_C
);
6823 // $TLE53 = wfgetnull();
6825 initialize_function_call (&wfgetnull_fci
, &wfgetnull_fcic
, "wfgetnull", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 92 TSRMLS_CC
);
6826 zend_function
* signature
= wfgetnull_fcic
.function_handler
;
6827 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
6833 // Setup array of arguments
6834 // TODO: i think arrays of size 0 is an error
6837 zval
** args_ind
[0];
6842 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 92, NULL TSRMLS_CC
);
6844 // save existing parameters, in case of recursion
6845 int param_count_save
= wfgetnull_fci
.param_count
;
6846 zval
*** params_save
= wfgetnull_fci
.params
;
6847 zval
** retval_save
= wfgetnull_fci
.retval_ptr_ptr
;
6852 wfgetnull_fci
.params
= args_ind
;
6853 wfgetnull_fci
.param_count
= 0;
6854 wfgetnull_fci
.retval_ptr_ptr
= &rhs
;
6856 // call the function
6857 int success
= zend_call_function (&wfgetnull_fci
, &wfgetnull_fcic TSRMLS_CC
);
6858 assert(success
== SUCCESS
);
6861 wfgetnull_fci
.params
= params_save
;
6862 wfgetnull_fci
.param_count
= param_count_save
;
6863 wfgetnull_fci
.retval_ptr_ptr
= retval_save
;
6866 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
6869 for (i
= 0; i
< 0; i
++)
6873 assert (destruct
[i
]);
6874 zval_ptr_dtor (args_ind
[i
]);
6879 // When the Zend engine returns by reference, it allocates a zval into
6880 // retval_ptr_ptr. To return by reference, the callee writes into the
6881 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
6882 // not actually return anything). So the zval returned - whether we return
6883 // it, or it is the allocated zval - has a refcount of 1.
6885 // The caller is responsible for cleaning that up (note, this is unaffected
6886 // by whether it is added to some COW set).
6888 // For reasons unknown, the Zend API resets the refcount and is_ref fields
6889 // of the return value after the function returns (unless the callee is
6890 // interpreted). If the function is supposed to return by reference, this
6891 // loses the refcount. This only happens when non-interpreted code is
6892 // called. We work around it, when compiled code is called, by saving the
6893 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
6894 // that we may create an error if our code is called by a callback, and
6895 // returns by reference, and the callback returns by reference. At least
6896 // this is an obscure case.
6897 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
6899 assert (rhs
!= EG(uninitialized_zval_ptr
));
6901 if (saved_refcount
!= 0)
6903 rhs
->refcount
= saved_refcount
;
6907 saved_refcount
= 0; // for 'obscure cases'
6909 if (local_TLE53
== NULL
)
6911 local_TLE53
= EG (uninitialized_zval_ptr
);
6912 local_TLE53
->refcount
++;
6914 zval
** p_lhs
= &local_TLE53
;
6916 write_var (p_lhs
, rhs
);
6919 zval_ptr_dtor (&rhs
);
6920 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
6921 zval_ptr_dtor (&rhs
);
6923 phc_check_invariants (TSRMLS_C
);
6927 if (local_TLE54
== NULL
)
6929 local_TLE54
= EG (uninitialized_zval_ptr
);
6930 local_TLE54
->refcount
++;
6932 zval
** p_lhs
= &local_TLE54
;
6935 if ((*p_lhs
)->is_ref
)
6937 // Always overwrite the current value
6943 ALLOC_INIT_ZVAL (value
);
6944 zval_ptr_dtor (p_lhs
);
6948 ZVAL_STRINGL(value
, "a", 1, 1);
6950 phc_check_invariants (TSRMLS_C
);
6954 if (local_TSa55
!= NULL
)
6956 zval_ptr_dtor (&local_TSa55
);
6959 phc_check_invariants (TSRMLS_C
);
6961 // $TSa55 = (array) $TSa55;
6963 if (local_TSa55
== NULL
)
6965 local_TSa55
= EG (uninitialized_zval_ptr
);
6966 local_TSa55
->refcount
++;
6968 zval
** p_lhs
= &local_TSa55
;
6971 if (local_TSa55
== NULL
)
6972 rhs
= EG (uninitialized_zval_ptr
);
6978 if ((*p_lhs
)->is_ref
)
6979 overwrite_lhs (*p_lhs
, rhs
);
6982 zval_ptr_dtor (p_lhs
);
6985 // Take a copy of RHS for LHS
6986 *p_lhs
= zvp_clone_ex (rhs
);
6999 assert (IS_ARRAY
>= 0 && IS_ARRAY
<= 6);
7000 if ((*p_lhs
)->type
!= IS_ARRAY
)
7002 sep_copy_on_write (p_lhs
);
7003 convert_to_array (*p_lhs
);
7006 phc_check_invariants (TSRMLS_C
);
7008 // $TSa55[] = $TLE52;
7010 if (local_TSa55
== NULL
)
7012 local_TSa55
= EG (uninitialized_zval_ptr
);
7013 local_TSa55
->refcount
++;
7015 zval
** p_array
= &local_TSa55
;
7017 // Push EG(uninit) and get a pointer to the symtable entry
7018 zval
** p_lhs
= push_and_index_ht (p_array TSRMLS_CC
);
7022 if (local_TLE52
== NULL
)
7023 rhs
= EG (uninitialized_zval_ptr
);
7028 write_var (p_lhs
, rhs
);
7030 // I think if this is NULL, then the LHS is a bool or similar, and you cant
7032 phc_check_invariants (TSRMLS_C
);
7034 // $TSa55[] = $TLE53;
7036 if (local_TSa55
== NULL
)
7038 local_TSa55
= EG (uninitialized_zval_ptr
);
7039 local_TSa55
->refcount
++;
7041 zval
** p_array
= &local_TSa55
;
7043 // Push EG(uninit) and get a pointer to the symtable entry
7044 zval
** p_lhs
= push_and_index_ht (p_array TSRMLS_CC
);
7048 if (local_TLE53
== NULL
)
7049 rhs
= EG (uninitialized_zval_ptr
);
7054 write_var (p_lhs
, rhs
);
7056 // I think if this is NULL, then the LHS is a bool or similar, and you cant
7058 phc_check_invariants (TSRMLS_C
);
7060 // $TSa55[] = $TLE54;
7062 if (local_TSa55
== NULL
)
7064 local_TSa55
= EG (uninitialized_zval_ptr
);
7065 local_TSa55
->refcount
++;
7067 zval
** p_array
= &local_TSa55
;
7069 // Push EG(uninit) and get a pointer to the symtable entry
7070 zval
** p_lhs
= push_and_index_ht (p_array TSRMLS_CC
);
7074 if (local_TLE54
== NULL
)
7075 rhs
= EG (uninitialized_zval_ptr
);
7080 write_var (p_lhs
, rhs
);
7082 // I think if this is NULL, then the LHS is a bool or similar, and you cant
7084 phc_check_invariants (TSRMLS_C
);
7088 if (local_TSa56
!= NULL
)
7090 zval_ptr_dtor (&local_TSa56
);
7093 phc_check_invariants (TSRMLS_C
);
7095 // $TSa56 = (array) $TSa56;
7097 if (local_TSa56
== NULL
)
7099 local_TSa56
= EG (uninitialized_zval_ptr
);
7100 local_TSa56
->refcount
++;
7102 zval
** p_lhs
= &local_TSa56
;
7105 if (local_TSa56
== NULL
)
7106 rhs
= EG (uninitialized_zval_ptr
);
7112 if ((*p_lhs
)->is_ref
)
7113 overwrite_lhs (*p_lhs
, rhs
);
7116 zval_ptr_dtor (p_lhs
);
7119 // Take a copy of RHS for LHS
7120 *p_lhs
= zvp_clone_ex (rhs
);
7133 assert (IS_ARRAY
>= 0 && IS_ARRAY
<= 6);
7134 if ((*p_lhs
)->type
!= IS_ARRAY
)
7136 sep_copy_on_write (p_lhs
);
7137 convert_to_array (*p_lhs
);
7140 phc_check_invariants (TSRMLS_C
);
7142 // $TSa56[$TLE43] = $TSa46;
7144 if (local_TSa56
== NULL
)
7146 local_TSa56
= EG (uninitialized_zval_ptr
);
7147 local_TSa56
->refcount
++;
7149 zval
** p_array
= &local_TSa56
;
7151 check_array_type (p_array TSRMLS_CC
);
7154 if (local_TLE43
== NULL
)
7155 index
= EG (uninitialized_zval_ptr
);
7157 index
= local_TLE43
;
7161 if (Z_TYPE_PP (p_array
) == IS_STRING
&& Z_STRLEN_PP (p_array
) > 0)
7164 if (local_TSa46
== NULL
)
7165 rhs
= EG (uninitialized_zval_ptr
);
7169 write_string_index (p_array
, index
, rhs TSRMLS_CC
);
7171 else if (Z_TYPE_PP (p_array
) == IS_ARRAY
)
7173 zval
** p_lhs
= get_ht_entry (p_array
, index TSRMLS_CC
);
7175 if (local_TSa46
== NULL
)
7176 rhs
= EG (uninitialized_zval_ptr
);
7182 write_var (p_lhs
, rhs
);
7185 phc_check_invariants (TSRMLS_C
);
7187 // $TSa56[$TLE47] = $TSa50;
7189 if (local_TSa56
== NULL
)
7191 local_TSa56
= EG (uninitialized_zval_ptr
);
7192 local_TSa56
->refcount
++;
7194 zval
** p_array
= &local_TSa56
;
7196 check_array_type (p_array TSRMLS_CC
);
7199 if (local_TLE47
== NULL
)
7200 index
= EG (uninitialized_zval_ptr
);
7202 index
= local_TLE47
;
7206 if (Z_TYPE_PP (p_array
) == IS_STRING
&& Z_STRLEN_PP (p_array
) > 0)
7209 if (local_TSa50
== NULL
)
7210 rhs
= EG (uninitialized_zval_ptr
);
7214 write_string_index (p_array
, index
, rhs TSRMLS_CC
);
7216 else if (Z_TYPE_PP (p_array
) == IS_ARRAY
)
7218 zval
** p_lhs
= get_ht_entry (p_array
, index TSRMLS_CC
);
7220 if (local_TSa50
== NULL
)
7221 rhs
= EG (uninitialized_zval_ptr
);
7227 write_var (p_lhs
, rhs
);
7230 phc_check_invariants (TSRMLS_C
);
7232 // $TSa56[$TLE51] = $TSa55;
7234 if (local_TSa56
== NULL
)
7236 local_TSa56
= EG (uninitialized_zval_ptr
);
7237 local_TSa56
->refcount
++;
7239 zval
** p_array
= &local_TSa56
;
7241 check_array_type (p_array TSRMLS_CC
);
7244 if (local_TLE51
== NULL
)
7245 index
= EG (uninitialized_zval_ptr
);
7247 index
= local_TLE51
;
7251 if (Z_TYPE_PP (p_array
) == IS_STRING
&& Z_STRLEN_PP (p_array
) > 0)
7254 if (local_TSa55
== NULL
)
7255 rhs
= EG (uninitialized_zval_ptr
);
7259 write_string_index (p_array
, index
, rhs TSRMLS_CC
);
7261 else if (Z_TYPE_PP (p_array
) == IS_ARRAY
)
7263 zval
** p_lhs
= get_ht_entry (p_array
, index TSRMLS_CC
);
7265 if (local_TSa55
== NULL
)
7266 rhs
= EG (uninitialized_zval_ptr
);
7272 write_var (p_lhs
, rhs
);
7275 phc_check_invariants (TSRMLS_C
);
7277 // $descriptorspec = $TSa56;
7279 if (local_descriptorspec
== NULL
)
7281 local_descriptorspec
= EG (uninitialized_zval_ptr
);
7282 local_descriptorspec
->refcount
++;
7284 zval
** p_lhs
= &local_descriptorspec
;
7287 if (local_TSa56
== NULL
)
7288 rhs
= EG (uninitialized_zval_ptr
);
7294 if ((*p_lhs
)->is_ref
)
7295 overwrite_lhs (*p_lhs
, rhs
);
7298 zval_ptr_dtor (p_lhs
);
7301 // Take a copy of RHS for LHS
7302 *p_lhs
= zvp_clone_ex (rhs
);
7314 phc_check_invariants (TSRMLS_C
);
7319 phc_check_invariants (TSRMLS_C
);
7323 // if (stderr) goto L125 else goto L126;
7326 if (local_stderr
== NULL
)
7327 p_cond
= EG (uninitialized_zval_ptr
);
7329 p_cond
= local_stderr
;
7331 zend_bool bcond
= zend_is_true (p_cond
);
7336 phc_check_invariants (TSRMLS_C
);
7342 if (local_TEF4
== NULL
)
7344 local_TEF4
= EG (uninitialized_zval_ptr
);
7345 local_TEF4
->refcount
++;
7347 zval
** p_lhs
= &local_TEF4
;
7350 if ((*p_lhs
)->is_ref
)
7352 // Always overwrite the current value
7358 ALLOC_INIT_ZVAL (value
);
7359 zval_ptr_dtor (p_lhs
);
7363 ZVAL_LONG (value
, 2);
7365 phc_check_invariants (TSRMLS_C
);
7370 phc_check_invariants (TSRMLS_C
);
7376 if (local_TEF4
== NULL
)
7378 local_TEF4
= EG (uninitialized_zval_ptr
);
7379 local_TEF4
->refcount
++;
7381 zval
** p_lhs
= &local_TEF4
;
7384 if ((*p_lhs
)->is_ref
)
7386 // Always overwrite the current value
7392 ALLOC_INIT_ZVAL (value
);
7393 zval_ptr_dtor (p_lhs
);
7397 ZVAL_LONG (value
, 1);
7399 phc_check_invariants (TSRMLS_C
);
7404 phc_check_invariants (TSRMLS_C
);
7408 // $readpipe = $TEF4;
7410 if (local_readpipe
== NULL
)
7412 local_readpipe
= EG (uninitialized_zval_ptr
);
7413 local_readpipe
->refcount
++;
7415 zval
** p_lhs
= &local_readpipe
;
7418 if (local_TEF4
== NULL
)
7419 rhs
= EG (uninitialized_zval_ptr
);
7425 if ((*p_lhs
)->is_ref
)
7426 overwrite_lhs (*p_lhs
, rhs
);
7429 zval_ptr_dtor (p_lhs
);
7432 // Take a copy of RHS for LHS
7433 *p_lhs
= zvp_clone_ex (rhs
);
7445 phc_check_invariants (TSRMLS_C
);
7449 if (local_TSa57
!= NULL
)
7451 zval_ptr_dtor (&local_TSa57
);
7454 phc_check_invariants (TSRMLS_C
);
7456 // $TSa57 = (array) $TSa57;
7458 if (local_TSa57
== NULL
)
7460 local_TSa57
= EG (uninitialized_zval_ptr
);
7461 local_TSa57
->refcount
++;
7463 zval
** p_lhs
= &local_TSa57
;
7466 if (local_TSa57
== NULL
)
7467 rhs
= EG (uninitialized_zval_ptr
);
7473 if ((*p_lhs
)->is_ref
)
7474 overwrite_lhs (*p_lhs
, rhs
);
7477 zval_ptr_dtor (p_lhs
);
7480 // Take a copy of RHS for LHS
7481 *p_lhs
= zvp_clone_ex (rhs
);
7494 assert (IS_ARRAY
>= 0 && IS_ARRAY
<= 6);
7495 if ((*p_lhs
)->type
!= IS_ARRAY
)
7497 sep_copy_on_write (p_lhs
);
7498 convert_to_array (*p_lhs
);
7501 phc_check_invariants (TSRMLS_C
);
7505 if (local_pipes
== NULL
)
7507 local_pipes
= EG (uninitialized_zval_ptr
);
7508 local_pipes
->refcount
++;
7510 zval
** p_lhs
= &local_pipes
;
7513 if (local_TSa57
== NULL
)
7514 rhs
= EG (uninitialized_zval_ptr
);
7520 if ((*p_lhs
)->is_ref
)
7521 overwrite_lhs (*p_lhs
, rhs
);
7524 zval_ptr_dtor (p_lhs
);
7527 // Take a copy of RHS for LHS
7528 *p_lhs
= zvp_clone_ex (rhs
);
7540 phc_check_invariants (TSRMLS_C
);
7542 // $TLE58 = 'proc_open';
7544 if (local_TLE58
== NULL
)
7546 local_TLE58
= EG (uninitialized_zval_ptr
);
7547 local_TLE58
->refcount
++;
7549 zval
** p_lhs
= &local_TLE58
;
7552 if ((*p_lhs
)->is_ref
)
7554 // Always overwrite the current value
7560 ALLOC_INIT_ZVAL (value
);
7561 zval_ptr_dtor (p_lhs
);
7565 ZVAL_STRINGL(value
, "proc_open", 9, 1);
7567 phc_check_invariants (TSRMLS_C
);
7569 // $TLE59 = function_exists($TLE58);
7571 initialize_function_call (&function_exists_fci
, &function_exists_fcic
, "function_exists", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 98 TSRMLS_CC
);
7572 zend_function
* signature
= function_exists_fcic
.function_handler
;
7573 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
7577 // TODO: find names to replace index
7580 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
7584 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
7589 // Setup array of arguments
7590 // TODO: i think arrays of size 0 is an error
7593 zval
** args_ind
[1];
7596 destruct
[af_index
] = 0;
7597 if (by_ref
[af_index
])
7599 if (local_TLE58
== NULL
)
7601 local_TLE58
= EG (uninitialized_zval_ptr
);
7602 local_TLE58
->refcount
++;
7604 zval
** p_arg
= &local_TLE58
;
7606 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
7607 assert (!in_copy_on_write (*args_ind
[af_index
]));
7608 args
[af_index
] = *args_ind
[af_index
];
7613 if (local_TLE58
== NULL
)
7614 arg
= EG (uninitialized_zval_ptr
);
7618 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
7619 args_ind
[af_index
] = &args
[af_index
];
7624 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 98, NULL TSRMLS_CC
);
7626 // save existing parameters, in case of recursion
7627 int param_count_save
= function_exists_fci
.param_count
;
7628 zval
*** params_save
= function_exists_fci
.params
;
7629 zval
** retval_save
= function_exists_fci
.retval_ptr_ptr
;
7634 function_exists_fci
.params
= args_ind
;
7635 function_exists_fci
.param_count
= 1;
7636 function_exists_fci
.retval_ptr_ptr
= &rhs
;
7638 // call the function
7639 int success
= zend_call_function (&function_exists_fci
, &function_exists_fcic TSRMLS_CC
);
7640 assert(success
== SUCCESS
);
7643 function_exists_fci
.params
= params_save
;
7644 function_exists_fci
.param_count
= param_count_save
;
7645 function_exists_fci
.retval_ptr_ptr
= retval_save
;
7648 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
7651 for (i
= 0; i
< 1; i
++)
7655 assert (destruct
[i
]);
7656 zval_ptr_dtor (args_ind
[i
]);
7661 // When the Zend engine returns by reference, it allocates a zval into
7662 // retval_ptr_ptr. To return by reference, the callee writes into the
7663 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
7664 // not actually return anything). So the zval returned - whether we return
7665 // it, or it is the allocated zval - has a refcount of 1.
7667 // The caller is responsible for cleaning that up (note, this is unaffected
7668 // by whether it is added to some COW set).
7670 // For reasons unknown, the Zend API resets the refcount and is_ref fields
7671 // of the return value after the function returns (unless the callee is
7672 // interpreted). If the function is supposed to return by reference, this
7673 // loses the refcount. This only happens when non-interpreted code is
7674 // called. We work around it, when compiled code is called, by saving the
7675 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
7676 // that we may create an error if our code is called by a callback, and
7677 // returns by reference, and the callback returns by reference. At least
7678 // this is an obscure case.
7679 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
7681 assert (rhs
!= EG(uninitialized_zval_ptr
));
7683 if (saved_refcount
!= 0)
7685 rhs
->refcount
= saved_refcount
;
7689 saved_refcount
= 0; // for 'obscure cases'
7691 if (local_TLE59
== NULL
)
7693 local_TLE59
= EG (uninitialized_zval_ptr
);
7694 local_TLE59
->refcount
++;
7696 zval
** p_lhs
= &local_TLE59
;
7698 write_var (p_lhs
, rhs
);
7701 zval_ptr_dtor (&rhs
);
7702 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
7703 zval_ptr_dtor (&rhs
);
7705 phc_check_invariants (TSRMLS_C
);
7707 // if (TLE59) goto L151 else goto L152;
7710 if (local_TLE59
== NULL
)
7711 p_cond
= EG (uninitialized_zval_ptr
);
7713 p_cond
= local_TLE59
;
7715 zend_bool bcond
= zend_is_true (p_cond
);
7720 phc_check_invariants (TSRMLS_C
);
7724 // $TLE60 = ' -config ';
7726 if (local_TLE60
== NULL
)
7728 local_TLE60
= EG (uninitialized_zval_ptr
);
7729 local_TLE60
->refcount
++;
7731 zval
** p_lhs
= &local_TLE60
;
7734 if ((*p_lhs
)->is_ref
)
7736 // Always overwrite the current value
7742 ALLOC_INIT_ZVAL (value
);
7743 zval_ptr_dtor (p_lhs
);
7747 ZVAL_STRINGL(value
, " -config ", 9, 1);
7749 phc_check_invariants (TSRMLS_C
);
7751 // $TLE61 = ($wgTidyBin . $TLE60);
7753 if (local_TLE61
== NULL
)
7755 local_TLE61
= EG (uninitialized_zval_ptr
);
7756 local_TLE61
->refcount
++;
7758 zval
** p_lhs
= &local_TLE61
;
7761 if (local_wgTidyBin
== NULL
)
7762 left
= EG (uninitialized_zval_ptr
);
7764 left
= local_wgTidyBin
;
7767 if (local_TLE60
== NULL
)
7768 right
= EG (uninitialized_zval_ptr
);
7770 right
= local_TLE60
;
7772 if (in_copy_on_write (*p_lhs
))
7774 zval_ptr_dtor (p_lhs
);
7775 ALLOC_INIT_ZVAL (*p_lhs
);
7779 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
7780 concat_function (*p_lhs
, left
, right TSRMLS_CC
);
7782 // If the result is one of the operands, the operator function
7783 // will already have cleaned up the result
7784 if (!result_is_operand
)
7786 phc_check_invariants (TSRMLS_C
);
7788 // $TLE62 = ($TLE61 . $wgTidyConf);
7790 if (local_TLE62
== NULL
)
7792 local_TLE62
= EG (uninitialized_zval_ptr
);
7793 local_TLE62
->refcount
++;
7795 zval
** p_lhs
= &local_TLE62
;
7798 if (local_TLE61
== NULL
)
7799 left
= EG (uninitialized_zval_ptr
);
7804 if (local_wgTidyConf
== NULL
)
7805 right
= EG (uninitialized_zval_ptr
);
7807 right
= local_wgTidyConf
;
7809 if (in_copy_on_write (*p_lhs
))
7811 zval_ptr_dtor (p_lhs
);
7812 ALLOC_INIT_ZVAL (*p_lhs
);
7816 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
7817 concat_function (*p_lhs
, left
, right TSRMLS_CC
);
7819 // If the result is one of the operands, the operator function
7820 // will already have cleaned up the result
7821 if (!result_is_operand
)
7823 phc_check_invariants (TSRMLS_C
);
7827 if (local_TLE63
== NULL
)
7829 local_TLE63
= EG (uninitialized_zval_ptr
);
7830 local_TLE63
->refcount
++;
7832 zval
** p_lhs
= &local_TLE63
;
7835 if ((*p_lhs
)->is_ref
)
7837 // Always overwrite the current value
7843 ALLOC_INIT_ZVAL (value
);
7844 zval_ptr_dtor (p_lhs
);
7848 ZVAL_STRINGL(value
, " ", 1, 1);
7850 phc_check_invariants (TSRMLS_C
);
7852 // $TLE64 = ($TLE62 . $TLE63);
7854 if (local_TLE64
== NULL
)
7856 local_TLE64
= EG (uninitialized_zval_ptr
);
7857 local_TLE64
->refcount
++;
7859 zval
** p_lhs
= &local_TLE64
;
7862 if (local_TLE62
== NULL
)
7863 left
= EG (uninitialized_zval_ptr
);
7868 if (local_TLE63
== NULL
)
7869 right
= EG (uninitialized_zval_ptr
);
7871 right
= local_TLE63
;
7873 if (in_copy_on_write (*p_lhs
))
7875 zval_ptr_dtor (p_lhs
);
7876 ALLOC_INIT_ZVAL (*p_lhs
);
7880 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
7881 concat_function (*p_lhs
, left
, right TSRMLS_CC
);
7883 // If the result is one of the operands, the operator function
7884 // will already have cleaned up the result
7885 if (!result_is_operand
)
7887 phc_check_invariants (TSRMLS_C
);
7889 // $TLE65 = ($TLE64 . $wgTidyOpts);
7891 if (local_TLE65
== NULL
)
7893 local_TLE65
= EG (uninitialized_zval_ptr
);
7894 local_TLE65
->refcount
++;
7896 zval
** p_lhs
= &local_TLE65
;
7899 if (local_TLE64
== NULL
)
7900 left
= EG (uninitialized_zval_ptr
);
7905 if (local_wgTidyOpts
== NULL
)
7906 right
= EG (uninitialized_zval_ptr
);
7908 right
= local_wgTidyOpts
;
7910 if (in_copy_on_write (*p_lhs
))
7912 zval_ptr_dtor (p_lhs
);
7913 ALLOC_INIT_ZVAL (*p_lhs
);
7917 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
7918 concat_function (*p_lhs
, left
, right TSRMLS_CC
);
7920 // If the result is one of the operands, the operator function
7921 // will already have cleaned up the result
7922 if (!result_is_operand
)
7924 phc_check_invariants (TSRMLS_C
);
7926 // $TLE66 = ($TLE65 . $opts);
7928 if (local_TLE66
== NULL
)
7930 local_TLE66
= EG (uninitialized_zval_ptr
);
7931 local_TLE66
->refcount
++;
7933 zval
** p_lhs
= &local_TLE66
;
7936 if (local_TLE65
== NULL
)
7937 left
= EG (uninitialized_zval_ptr
);
7942 if (local_opts
== NULL
)
7943 right
= EG (uninitialized_zval_ptr
);
7947 if (in_copy_on_write (*p_lhs
))
7949 zval_ptr_dtor (p_lhs
);
7950 ALLOC_INIT_ZVAL (*p_lhs
);
7954 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
7955 concat_function (*p_lhs
, left
, right TSRMLS_CC
);
7957 // If the result is one of the operands, the operator function
7958 // will already have cleaned up the result
7959 if (!result_is_operand
)
7961 phc_check_invariants (TSRMLS_C
);
7963 // $process = proc_open($TLE66, $descriptorspec, $pipes);
7965 initialize_function_call (&proc_open_fci
, &proc_open_fcic
, "proc_open", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 99 TSRMLS_CC
);
7966 zend_function
* signature
= proc_open_fcic
.function_handler
;
7967 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
7971 // TODO: find names to replace index
7974 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
7978 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
7981 // TODO: find names to replace index
7984 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
7988 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
7991 // TODO: find names to replace index
7994 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
7998 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
8003 // Setup array of arguments
8004 // TODO: i think arrays of size 0 is an error
8007 zval
** args_ind
[3];
8010 destruct
[af_index
] = 0;
8011 if (by_ref
[af_index
])
8013 if (local_TLE66
== NULL
)
8015 local_TLE66
= EG (uninitialized_zval_ptr
);
8016 local_TLE66
->refcount
++;
8018 zval
** p_arg
= &local_TLE66
;
8020 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
8021 assert (!in_copy_on_write (*args_ind
[af_index
]));
8022 args
[af_index
] = *args_ind
[af_index
];
8027 if (local_TLE66
== NULL
)
8028 arg
= EG (uninitialized_zval_ptr
);
8032 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
8033 args_ind
[af_index
] = &args
[af_index
];
8036 destruct
[af_index
] = 0;
8037 if (by_ref
[af_index
])
8039 if (local_descriptorspec
== NULL
)
8041 local_descriptorspec
= EG (uninitialized_zval_ptr
);
8042 local_descriptorspec
->refcount
++;
8044 zval
** p_arg
= &local_descriptorspec
;
8046 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
8047 assert (!in_copy_on_write (*args_ind
[af_index
]));
8048 args
[af_index
] = *args_ind
[af_index
];
8053 if (local_descriptorspec
== NULL
)
8054 arg
= EG (uninitialized_zval_ptr
);
8056 arg
= local_descriptorspec
;
8058 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
8059 args_ind
[af_index
] = &args
[af_index
];
8062 destruct
[af_index
] = 0;
8063 if (by_ref
[af_index
])
8065 if (local_pipes
== NULL
)
8067 local_pipes
= EG (uninitialized_zval_ptr
);
8068 local_pipes
->refcount
++;
8070 zval
** p_arg
= &local_pipes
;
8072 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
8073 assert (!in_copy_on_write (*args_ind
[af_index
]));
8074 args
[af_index
] = *args_ind
[af_index
];
8079 if (local_pipes
== NULL
)
8080 arg
= EG (uninitialized_zval_ptr
);
8084 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
8085 args_ind
[af_index
] = &args
[af_index
];
8090 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 99, NULL TSRMLS_CC
);
8092 // save existing parameters, in case of recursion
8093 int param_count_save
= proc_open_fci
.param_count
;
8094 zval
*** params_save
= proc_open_fci
.params
;
8095 zval
** retval_save
= proc_open_fci
.retval_ptr_ptr
;
8100 proc_open_fci
.params
= args_ind
;
8101 proc_open_fci
.param_count
= 3;
8102 proc_open_fci
.retval_ptr_ptr
= &rhs
;
8104 // call the function
8105 int success
= zend_call_function (&proc_open_fci
, &proc_open_fcic TSRMLS_CC
);
8106 assert(success
== SUCCESS
);
8109 proc_open_fci
.params
= params_save
;
8110 proc_open_fci
.param_count
= param_count_save
;
8111 proc_open_fci
.retval_ptr_ptr
= retval_save
;
8114 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
8117 for (i
= 0; i
< 3; i
++)
8121 assert (destruct
[i
]);
8122 zval_ptr_dtor (args_ind
[i
]);
8127 // When the Zend engine returns by reference, it allocates a zval into
8128 // retval_ptr_ptr. To return by reference, the callee writes into the
8129 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
8130 // not actually return anything). So the zval returned - whether we return
8131 // it, or it is the allocated zval - has a refcount of 1.
8133 // The caller is responsible for cleaning that up (note, this is unaffected
8134 // by whether it is added to some COW set).
8136 // For reasons unknown, the Zend API resets the refcount and is_ref fields
8137 // of the return value after the function returns (unless the callee is
8138 // interpreted). If the function is supposed to return by reference, this
8139 // loses the refcount. This only happens when non-interpreted code is
8140 // called. We work around it, when compiled code is called, by saving the
8141 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
8142 // that we may create an error if our code is called by a callback, and
8143 // returns by reference, and the callback returns by reference. At least
8144 // this is an obscure case.
8145 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
8147 assert (rhs
!= EG(uninitialized_zval_ptr
));
8149 if (saved_refcount
!= 0)
8151 rhs
->refcount
= saved_refcount
;
8155 saved_refcount
= 0; // for 'obscure cases'
8157 if (local_process
== NULL
)
8159 local_process
= EG (uninitialized_zval_ptr
);
8160 local_process
->refcount
++;
8162 zval
** p_lhs
= &local_process
;
8164 write_var (p_lhs
, rhs
);
8167 zval_ptr_dtor (&rhs
);
8168 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
8169 zval_ptr_dtor (&rhs
);
8171 phc_check_invariants (TSRMLS_C
);
8173 // $TLE67 = is_resource($process);
8175 initialize_function_call (&is_resource_fci
, &is_resource_fcic
, "is_resource", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 100 TSRMLS_CC
);
8176 zend_function
* signature
= is_resource_fcic
.function_handler
;
8177 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
8181 // TODO: find names to replace index
8184 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
8188 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
8193 // Setup array of arguments
8194 // TODO: i think arrays of size 0 is an error
8197 zval
** args_ind
[1];
8200 destruct
[af_index
] = 0;
8201 if (by_ref
[af_index
])
8203 if (local_process
== NULL
)
8205 local_process
= EG (uninitialized_zval_ptr
);
8206 local_process
->refcount
++;
8208 zval
** p_arg
= &local_process
;
8210 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
8211 assert (!in_copy_on_write (*args_ind
[af_index
]));
8212 args
[af_index
] = *args_ind
[af_index
];
8217 if (local_process
== NULL
)
8218 arg
= EG (uninitialized_zval_ptr
);
8220 arg
= local_process
;
8222 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
8223 args_ind
[af_index
] = &args
[af_index
];
8228 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 100, NULL TSRMLS_CC
);
8230 // save existing parameters, in case of recursion
8231 int param_count_save
= is_resource_fci
.param_count
;
8232 zval
*** params_save
= is_resource_fci
.params
;
8233 zval
** retval_save
= is_resource_fci
.retval_ptr_ptr
;
8238 is_resource_fci
.params
= args_ind
;
8239 is_resource_fci
.param_count
= 1;
8240 is_resource_fci
.retval_ptr_ptr
= &rhs
;
8242 // call the function
8243 int success
= zend_call_function (&is_resource_fci
, &is_resource_fcic TSRMLS_CC
);
8244 assert(success
== SUCCESS
);
8247 is_resource_fci
.params
= params_save
;
8248 is_resource_fci
.param_count
= param_count_save
;
8249 is_resource_fci
.retval_ptr_ptr
= retval_save
;
8252 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
8255 for (i
= 0; i
< 1; i
++)
8259 assert (destruct
[i
]);
8260 zval_ptr_dtor (args_ind
[i
]);
8265 // When the Zend engine returns by reference, it allocates a zval into
8266 // retval_ptr_ptr. To return by reference, the callee writes into the
8267 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
8268 // not actually return anything). So the zval returned - whether we return
8269 // it, or it is the allocated zval - has a refcount of 1.
8271 // The caller is responsible for cleaning that up (note, this is unaffected
8272 // by whether it is added to some COW set).
8274 // For reasons unknown, the Zend API resets the refcount and is_ref fields
8275 // of the return value after the function returns (unless the callee is
8276 // interpreted). If the function is supposed to return by reference, this
8277 // loses the refcount. This only happens when non-interpreted code is
8278 // called. We work around it, when compiled code is called, by saving the
8279 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
8280 // that we may create an error if our code is called by a callback, and
8281 // returns by reference, and the callback returns by reference. At least
8282 // this is an obscure case.
8283 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
8285 assert (rhs
!= EG(uninitialized_zval_ptr
));
8287 if (saved_refcount
!= 0)
8289 rhs
->refcount
= saved_refcount
;
8293 saved_refcount
= 0; // for 'obscure cases'
8295 if (local_TLE67
== NULL
)
8297 local_TLE67
= EG (uninitialized_zval_ptr
);
8298 local_TLE67
->refcount
++;
8300 zval
** p_lhs
= &local_TLE67
;
8302 write_var (p_lhs
, rhs
);
8305 zval_ptr_dtor (&rhs
);
8306 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
8307 zval_ptr_dtor (&rhs
);
8309 phc_check_invariants (TSRMLS_C
);
8311 // if (TLE67) goto L148 else goto L149;
8314 if (local_TLE67
== NULL
)
8315 p_cond
= EG (uninitialized_zval_ptr
);
8317 p_cond
= local_TLE67
;
8319 zend_bool bcond
= zend_is_true (p_cond
);
8324 phc_check_invariants (TSRMLS_C
);
8330 if (local_TLE68
== NULL
)
8332 local_TLE68
= EG (uninitialized_zval_ptr
);
8333 local_TLE68
->refcount
++;
8335 zval
** p_lhs
= &local_TLE68
;
8338 if ((*p_lhs
)->is_ref
)
8340 // Always overwrite the current value
8346 ALLOC_INIT_ZVAL (value
);
8347 zval_ptr_dtor (p_lhs
);
8351 ZVAL_LONG (value
, 0);
8353 phc_check_invariants (TSRMLS_C
);
8355 // $TLE96 = param_is_ref (NULL, "fwrite", 0);
8358 initialize_function_call (&fwrite_fci
, &fwrite_fcic
, "fwrite", "<unknown>", 0 TSRMLS_CC
);
8359 zend_function
* signature
= fwrite_fcic
.function_handler
;
8360 zend_arg_info
* arg_info
= signature
->common
.arg_info
;
8362 while (arg_info
&& count
< 0)
8368 if (local_TLE96
== NULL
)
8370 local_TLE96
= EG (uninitialized_zval_ptr
);
8371 local_TLE96
->refcount
++;
8373 zval
** p_lhs
= &local_TLE96
;
8376 ALLOC_INIT_ZVAL (rhs
);
8377 if (arg_info
&& count
== 0)
8379 ZVAL_BOOL (rhs
, arg_info
->pass_by_reference
);
8383 ZVAL_BOOL (rhs
, signature
->common
.pass_rest_by_reference
);
8385 write_var (p_lhs
, rhs
);
8386 zval_ptr_dtor (&rhs
);
8387 phc_check_invariants (TSRMLS_C
);
8389 // if (TLE96) goto L128 else goto L129;
8392 if (local_TLE96
== NULL
)
8393 p_cond
= EG (uninitialized_zval_ptr
);
8395 p_cond
= local_TLE96
;
8397 zend_bool bcond
= zend_is_true (p_cond
);
8402 phc_check_invariants (TSRMLS_C
);
8406 // $TMIi95 =& $pipes[$TLE68];
8408 if (local_TMIi95
== NULL
)
8410 local_TMIi95
= EG (uninitialized_zval_ptr
);
8411 local_TMIi95
->refcount
++;
8413 zval
** p_lhs
= &local_TMIi95
;
8415 if (local_pipes
== NULL
)
8417 local_pipes
= EG (uninitialized_zval_ptr
);
8418 local_pipes
->refcount
++;
8420 zval
** p_r_array
= &local_pipes
;
8423 if (local_TLE68
== NULL
)
8424 r_index
= EG (uninitialized_zval_ptr
);
8426 r_index
= local_TLE68
;
8428 check_array_type (p_r_array TSRMLS_CC
);
8429 zval
** p_rhs
= get_ht_entry (p_r_array
, r_index TSRMLS_CC
);
8430 sep_copy_on_write (p_rhs
);
8431 copy_into_ref (p_lhs
, p_rhs
);
8432 phc_check_invariants (TSRMLS_C
);
8437 phc_check_invariants (TSRMLS_C
);
8441 // $TMIi95 = $pipes[$TLE68];
8443 if (local_TMIi95
== NULL
)
8445 local_TMIi95
= EG (uninitialized_zval_ptr
);
8446 local_TMIi95
->refcount
++;
8448 zval
** p_lhs
= &local_TMIi95
;
8451 if (local_pipes
== NULL
)
8452 r_array
= EG (uninitialized_zval_ptr
);
8454 r_array
= local_pipes
;
8457 if (local_TLE68
== NULL
)
8458 r_index
= EG (uninitialized_zval_ptr
);
8460 r_index
= local_TLE68
;
8465 if (Z_TYPE_P (r_array
) != IS_ARRAY
)
8467 if (Z_TYPE_P (r_array
) == IS_STRING
)
8470 rhs
= read_string_index (r_array
, r_index TSRMLS_CC
);
8473 // TODO: warning here?
8474 rhs
= EG (uninitialized_zval_ptr
);
8478 if (check_array_index_type (r_index TSRMLS_CC
))
8480 // Read array variable
8481 read_array (&rhs
, r_array
, r_index TSRMLS_CC
);
8484 rhs
= *p_lhs
; // HACK to fail *p_lhs != rhs
8488 write_var (p_lhs
, rhs
);
8490 if (is_rhs_new
) zval_ptr_dtor (&rhs
);
8491 phc_check_invariants (TSRMLS_C
);
8496 phc_check_invariants (TSRMLS_C
);
8500 // fwrite($TMIi95, $text);
8502 initialize_function_call (&fwrite_fci
, &fwrite_fcic
, "fwrite", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 106 TSRMLS_CC
);
8503 zend_function
* signature
= fwrite_fcic
.function_handler
;
8504 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
8508 // TODO: find names to replace index
8511 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
8515 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
8518 // TODO: find names to replace index
8521 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
8525 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
8530 // Setup array of arguments
8531 // TODO: i think arrays of size 0 is an error
8534 zval
** args_ind
[2];
8537 destruct
[af_index
] = 0;
8538 if (by_ref
[af_index
])
8540 if (local_TMIi95
== NULL
)
8542 local_TMIi95
= EG (uninitialized_zval_ptr
);
8543 local_TMIi95
->refcount
++;
8545 zval
** p_arg
= &local_TMIi95
;
8547 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
8548 assert (!in_copy_on_write (*args_ind
[af_index
]));
8549 args
[af_index
] = *args_ind
[af_index
];
8554 if (local_TMIi95
== NULL
)
8555 arg
= EG (uninitialized_zval_ptr
);
8559 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
8560 args_ind
[af_index
] = &args
[af_index
];
8563 destruct
[af_index
] = 0;
8564 if (by_ref
[af_index
])
8566 if (local_text
== NULL
)
8568 local_text
= EG (uninitialized_zval_ptr
);
8569 local_text
->refcount
++;
8571 zval
** p_arg
= &local_text
;
8573 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
8574 assert (!in_copy_on_write (*args_ind
[af_index
]));
8575 args
[af_index
] = *args_ind
[af_index
];
8580 if (local_text
== NULL
)
8581 arg
= EG (uninitialized_zval_ptr
);
8585 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
8586 args_ind
[af_index
] = &args
[af_index
];
8591 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 106, NULL TSRMLS_CC
);
8593 // save existing parameters, in case of recursion
8594 int param_count_save
= fwrite_fci
.param_count
;
8595 zval
*** params_save
= fwrite_fci
.params
;
8596 zval
** retval_save
= fwrite_fci
.retval_ptr_ptr
;
8601 fwrite_fci
.params
= args_ind
;
8602 fwrite_fci
.param_count
= 2;
8603 fwrite_fci
.retval_ptr_ptr
= &rhs
;
8605 // call the function
8606 int success
= zend_call_function (&fwrite_fci
, &fwrite_fcic TSRMLS_CC
);
8607 assert(success
== SUCCESS
);
8610 fwrite_fci
.params
= params_save
;
8611 fwrite_fci
.param_count
= param_count_save
;
8612 fwrite_fci
.retval_ptr_ptr
= retval_save
;
8615 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
8618 for (i
= 0; i
< 2; i
++)
8622 assert (destruct
[i
]);
8623 zval_ptr_dtor (args_ind
[i
]);
8628 // When the Zend engine returns by reference, it allocates a zval into
8629 // retval_ptr_ptr. To return by reference, the callee writes into the
8630 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
8631 // not actually return anything). So the zval returned - whether we return
8632 // it, or it is the allocated zval - has a refcount of 1.
8634 // The caller is responsible for cleaning that up (note, this is unaffected
8635 // by whether it is added to some COW set).
8637 // For reasons unknown, the Zend API resets the refcount and is_ref fields
8638 // of the return value after the function returns (unless the callee is
8639 // interpreted). If the function is supposed to return by reference, this
8640 // loses the refcount. This only happens when non-interpreted code is
8641 // called. We work around it, when compiled code is called, by saving the
8642 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
8643 // that we may create an error if our code is called by a callback, and
8644 // returns by reference, and the callback returns by reference. At least
8645 // this is an obscure case.
8646 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
8648 assert (rhs
!= EG(uninitialized_zval_ptr
));
8650 if (saved_refcount
!= 0)
8652 rhs
->refcount
= saved_refcount
;
8656 saved_refcount
= 0; // for 'obscure cases'
8660 zval_ptr_dtor (&rhs
);
8661 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
8662 zval_ptr_dtor (&rhs
);
8664 phc_check_invariants (TSRMLS_C
);
8668 if (local_TLE69
== NULL
)
8670 local_TLE69
= EG (uninitialized_zval_ptr
);
8671 local_TLE69
->refcount
++;
8673 zval
** p_lhs
= &local_TLE69
;
8676 if ((*p_lhs
)->is_ref
)
8678 // Always overwrite the current value
8684 ALLOC_INIT_ZVAL (value
);
8685 zval_ptr_dtor (p_lhs
);
8689 ZVAL_LONG (value
, 0);
8691 phc_check_invariants (TSRMLS_C
);
8693 // $TLE98 = param_is_ref (NULL, "fclose", 0);
8696 initialize_function_call (&fclose_fci
, &fclose_fcic
, "fclose", "<unknown>", 0 TSRMLS_CC
);
8697 zend_function
* signature
= fclose_fcic
.function_handler
;
8698 zend_arg_info
* arg_info
= signature
->common
.arg_info
;
8700 while (arg_info
&& count
< 0)
8706 if (local_TLE98
== NULL
)
8708 local_TLE98
= EG (uninitialized_zval_ptr
);
8709 local_TLE98
->refcount
++;
8711 zval
** p_lhs
= &local_TLE98
;
8714 ALLOC_INIT_ZVAL (rhs
);
8715 if (arg_info
&& count
== 0)
8717 ZVAL_BOOL (rhs
, arg_info
->pass_by_reference
);
8721 ZVAL_BOOL (rhs
, signature
->common
.pass_rest_by_reference
);
8723 write_var (p_lhs
, rhs
);
8724 zval_ptr_dtor (&rhs
);
8725 phc_check_invariants (TSRMLS_C
);
8727 // if (TLE98) goto L131 else goto L132;
8730 if (local_TLE98
== NULL
)
8731 p_cond
= EG (uninitialized_zval_ptr
);
8733 p_cond
= local_TLE98
;
8735 zend_bool bcond
= zend_is_true (p_cond
);
8740 phc_check_invariants (TSRMLS_C
);
8744 // $TMIi97 =& $pipes[$TLE69];
8746 if (local_TMIi97
== NULL
)
8748 local_TMIi97
= EG (uninitialized_zval_ptr
);
8749 local_TMIi97
->refcount
++;
8751 zval
** p_lhs
= &local_TMIi97
;
8753 if (local_pipes
== NULL
)
8755 local_pipes
= EG (uninitialized_zval_ptr
);
8756 local_pipes
->refcount
++;
8758 zval
** p_r_array
= &local_pipes
;
8761 if (local_TLE69
== NULL
)
8762 r_index
= EG (uninitialized_zval_ptr
);
8764 r_index
= local_TLE69
;
8766 check_array_type (p_r_array TSRMLS_CC
);
8767 zval
** p_rhs
= get_ht_entry (p_r_array
, r_index TSRMLS_CC
);
8768 sep_copy_on_write (p_rhs
);
8769 copy_into_ref (p_lhs
, p_rhs
);
8770 phc_check_invariants (TSRMLS_C
);
8775 phc_check_invariants (TSRMLS_C
);
8779 // $TMIi97 = $pipes[$TLE69];
8781 if (local_TMIi97
== NULL
)
8783 local_TMIi97
= EG (uninitialized_zval_ptr
);
8784 local_TMIi97
->refcount
++;
8786 zval
** p_lhs
= &local_TMIi97
;
8789 if (local_pipes
== NULL
)
8790 r_array
= EG (uninitialized_zval_ptr
);
8792 r_array
= local_pipes
;
8795 if (local_TLE69
== NULL
)
8796 r_index
= EG (uninitialized_zval_ptr
);
8798 r_index
= local_TLE69
;
8803 if (Z_TYPE_P (r_array
) != IS_ARRAY
)
8805 if (Z_TYPE_P (r_array
) == IS_STRING
)
8808 rhs
= read_string_index (r_array
, r_index TSRMLS_CC
);
8811 // TODO: warning here?
8812 rhs
= EG (uninitialized_zval_ptr
);
8816 if (check_array_index_type (r_index TSRMLS_CC
))
8818 // Read array variable
8819 read_array (&rhs
, r_array
, r_index TSRMLS_CC
);
8822 rhs
= *p_lhs
; // HACK to fail *p_lhs != rhs
8826 write_var (p_lhs
, rhs
);
8828 if (is_rhs_new
) zval_ptr_dtor (&rhs
);
8829 phc_check_invariants (TSRMLS_C
);
8834 phc_check_invariants (TSRMLS_C
);
8840 initialize_function_call (&fclose_fci
, &fclose_fcic
, "fclose", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 107 TSRMLS_CC
);
8841 zend_function
* signature
= fclose_fcic
.function_handler
;
8842 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
8846 // TODO: find names to replace index
8849 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
8853 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
8858 // Setup array of arguments
8859 // TODO: i think arrays of size 0 is an error
8862 zval
** args_ind
[1];
8865 destruct
[af_index
] = 0;
8866 if (by_ref
[af_index
])
8868 if (local_TMIi97
== NULL
)
8870 local_TMIi97
= EG (uninitialized_zval_ptr
);
8871 local_TMIi97
->refcount
++;
8873 zval
** p_arg
= &local_TMIi97
;
8875 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
8876 assert (!in_copy_on_write (*args_ind
[af_index
]));
8877 args
[af_index
] = *args_ind
[af_index
];
8882 if (local_TMIi97
== NULL
)
8883 arg
= EG (uninitialized_zval_ptr
);
8887 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
8888 args_ind
[af_index
] = &args
[af_index
];
8893 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 107, NULL TSRMLS_CC
);
8895 // save existing parameters, in case of recursion
8896 int param_count_save
= fclose_fci
.param_count
;
8897 zval
*** params_save
= fclose_fci
.params
;
8898 zval
** retval_save
= fclose_fci
.retval_ptr_ptr
;
8903 fclose_fci
.params
= args_ind
;
8904 fclose_fci
.param_count
= 1;
8905 fclose_fci
.retval_ptr_ptr
= &rhs
;
8907 // call the function
8908 int success
= zend_call_function (&fclose_fci
, &fclose_fcic TSRMLS_CC
);
8909 assert(success
== SUCCESS
);
8912 fclose_fci
.params
= params_save
;
8913 fclose_fci
.param_count
= param_count_save
;
8914 fclose_fci
.retval_ptr_ptr
= retval_save
;
8917 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
8920 for (i
= 0; i
< 1; i
++)
8924 assert (destruct
[i
]);
8925 zval_ptr_dtor (args_ind
[i
]);
8930 // When the Zend engine returns by reference, it allocates a zval into
8931 // retval_ptr_ptr. To return by reference, the callee writes into the
8932 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
8933 // not actually return anything). So the zval returned - whether we return
8934 // it, or it is the allocated zval - has a refcount of 1.
8936 // The caller is responsible for cleaning that up (note, this is unaffected
8937 // by whether it is added to some COW set).
8939 // For reasons unknown, the Zend API resets the refcount and is_ref fields
8940 // of the return value after the function returns (unless the callee is
8941 // interpreted). If the function is supposed to return by reference, this
8942 // loses the refcount. This only happens when non-interpreted code is
8943 // called. We work around it, when compiled code is called, by saving the
8944 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
8945 // that we may create an error if our code is called by a callback, and
8946 // returns by reference, and the callback returns by reference. At least
8947 // this is an obscure case.
8948 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
8950 assert (rhs
!= EG(uninitialized_zval_ptr
));
8952 if (saved_refcount
!= 0)
8954 rhs
->refcount
= saved_refcount
;
8958 saved_refcount
= 0; // for 'obscure cases'
8962 zval_ptr_dtor (&rhs
);
8963 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
8964 zval_ptr_dtor (&rhs
);
8966 phc_check_invariants (TSRMLS_C
);
8970 // $TLE100 = param_is_ref (NULL, "feof", 0);
8973 initialize_function_call (&feof_fci
, &feof_fcic
, "feof", "<unknown>", 0 TSRMLS_CC
);
8974 zend_function
* signature
= feof_fcic
.function_handler
;
8975 zend_arg_info
* arg_info
= signature
->common
.arg_info
;
8977 while (arg_info
&& count
< 0)
8983 if (local_TLE100
== NULL
)
8985 local_TLE100
= EG (uninitialized_zval_ptr
);
8986 local_TLE100
->refcount
++;
8988 zval
** p_lhs
= &local_TLE100
;
8991 ALLOC_INIT_ZVAL (rhs
);
8992 if (arg_info
&& count
== 0)
8994 ZVAL_BOOL (rhs
, arg_info
->pass_by_reference
);
8998 ZVAL_BOOL (rhs
, signature
->common
.pass_rest_by_reference
);
9000 write_var (p_lhs
, rhs
);
9001 zval_ptr_dtor (&rhs
);
9002 phc_check_invariants (TSRMLS_C
);
9004 // if (TLE100) goto L134 else goto L135;
9007 if (local_TLE100
== NULL
)
9008 p_cond
= EG (uninitialized_zval_ptr
);
9010 p_cond
= local_TLE100
;
9012 zend_bool bcond
= zend_is_true (p_cond
);
9017 phc_check_invariants (TSRMLS_C
);
9021 // $TMIi99 =& $pipes[$readpipe];
9023 if (local_TMIi99
== NULL
)
9025 local_TMIi99
= EG (uninitialized_zval_ptr
);
9026 local_TMIi99
->refcount
++;
9028 zval
** p_lhs
= &local_TMIi99
;
9030 if (local_pipes
== NULL
)
9032 local_pipes
= EG (uninitialized_zval_ptr
);
9033 local_pipes
->refcount
++;
9035 zval
** p_r_array
= &local_pipes
;
9038 if (local_readpipe
== NULL
)
9039 r_index
= EG (uninitialized_zval_ptr
);
9041 r_index
= local_readpipe
;
9043 check_array_type (p_r_array TSRMLS_CC
);
9044 zval
** p_rhs
= get_ht_entry (p_r_array
, r_index TSRMLS_CC
);
9045 sep_copy_on_write (p_rhs
);
9046 copy_into_ref (p_lhs
, p_rhs
);
9047 phc_check_invariants (TSRMLS_C
);
9052 phc_check_invariants (TSRMLS_C
);
9056 // $TMIi99 = $pipes[$readpipe];
9058 if (local_TMIi99
== NULL
)
9060 local_TMIi99
= EG (uninitialized_zval_ptr
);
9061 local_TMIi99
->refcount
++;
9063 zval
** p_lhs
= &local_TMIi99
;
9066 if (local_pipes
== NULL
)
9067 r_array
= EG (uninitialized_zval_ptr
);
9069 r_array
= local_pipes
;
9072 if (local_readpipe
== NULL
)
9073 r_index
= EG (uninitialized_zval_ptr
);
9075 r_index
= local_readpipe
;
9080 if (Z_TYPE_P (r_array
) != IS_ARRAY
)
9082 if (Z_TYPE_P (r_array
) == IS_STRING
)
9085 rhs
= read_string_index (r_array
, r_index TSRMLS_CC
);
9088 // TODO: warning here?
9089 rhs
= EG (uninitialized_zval_ptr
);
9093 if (check_array_index_type (r_index TSRMLS_CC
))
9095 // Read array variable
9096 read_array (&rhs
, r_array
, r_index TSRMLS_CC
);
9099 rhs
= *p_lhs
; // HACK to fail *p_lhs != rhs
9103 write_var (p_lhs
, rhs
);
9105 if (is_rhs_new
) zval_ptr_dtor (&rhs
);
9106 phc_check_invariants (TSRMLS_C
);
9111 phc_check_invariants (TSRMLS_C
);
9115 // $TLE70 = feof($TMIi99);
9117 initialize_function_call (&feof_fci
, &feof_fcic
, "feof", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 108 TSRMLS_CC
);
9118 zend_function
* signature
= feof_fcic
.function_handler
;
9119 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
9123 // TODO: find names to replace index
9126 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
9130 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
9135 // Setup array of arguments
9136 // TODO: i think arrays of size 0 is an error
9139 zval
** args_ind
[1];
9142 destruct
[af_index
] = 0;
9143 if (by_ref
[af_index
])
9145 if (local_TMIi99
== NULL
)
9147 local_TMIi99
= EG (uninitialized_zval_ptr
);
9148 local_TMIi99
->refcount
++;
9150 zval
** p_arg
= &local_TMIi99
;
9152 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
9153 assert (!in_copy_on_write (*args_ind
[af_index
]));
9154 args
[af_index
] = *args_ind
[af_index
];
9159 if (local_TMIi99
== NULL
)
9160 arg
= EG (uninitialized_zval_ptr
);
9164 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
9165 args_ind
[af_index
] = &args
[af_index
];
9170 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 108, NULL TSRMLS_CC
);
9172 // save existing parameters, in case of recursion
9173 int param_count_save
= feof_fci
.param_count
;
9174 zval
*** params_save
= feof_fci
.params
;
9175 zval
** retval_save
= feof_fci
.retval_ptr_ptr
;
9180 feof_fci
.params
= args_ind
;
9181 feof_fci
.param_count
= 1;
9182 feof_fci
.retval_ptr_ptr
= &rhs
;
9184 // call the function
9185 int success
= zend_call_function (&feof_fci
, &feof_fcic TSRMLS_CC
);
9186 assert(success
== SUCCESS
);
9189 feof_fci
.params
= params_save
;
9190 feof_fci
.param_count
= param_count_save
;
9191 feof_fci
.retval_ptr_ptr
= retval_save
;
9194 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
9197 for (i
= 0; i
< 1; i
++)
9201 assert (destruct
[i
]);
9202 zval_ptr_dtor (args_ind
[i
]);
9207 // When the Zend engine returns by reference, it allocates a zval into
9208 // retval_ptr_ptr. To return by reference, the callee writes into the
9209 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
9210 // not actually return anything). So the zval returned - whether we return
9211 // it, or it is the allocated zval - has a refcount of 1.
9213 // The caller is responsible for cleaning that up (note, this is unaffected
9214 // by whether it is added to some COW set).
9216 // For reasons unknown, the Zend API resets the refcount and is_ref fields
9217 // of the return value after the function returns (unless the callee is
9218 // interpreted). If the function is supposed to return by reference, this
9219 // loses the refcount. This only happens when non-interpreted code is
9220 // called. We work around it, when compiled code is called, by saving the
9221 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
9222 // that we may create an error if our code is called by a callback, and
9223 // returns by reference, and the callback returns by reference. At least
9224 // this is an obscure case.
9225 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
9227 assert (rhs
!= EG(uninitialized_zval_ptr
));
9229 if (saved_refcount
!= 0)
9231 rhs
->refcount
= saved_refcount
;
9235 saved_refcount
= 0; // for 'obscure cases'
9237 if (local_TLE70
== NULL
)
9239 local_TLE70
= EG (uninitialized_zval_ptr
);
9240 local_TLE70
->refcount
++;
9242 zval
** p_lhs
= &local_TLE70
;
9244 write_var (p_lhs
, rhs
);
9247 zval_ptr_dtor (&rhs
);
9248 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
9249 zval_ptr_dtor (&rhs
);
9251 phc_check_invariants (TSRMLS_C
);
9253 // $TLE71 = !$TLE70;
9255 if (local_TLE71
== NULL
)
9257 local_TLE71
= EG (uninitialized_zval_ptr
);
9258 local_TLE71
->refcount
++;
9260 zval
** p_lhs
= &local_TLE71
;
9263 if (local_TLE70
== NULL
)
9264 rhs
= EG (uninitialized_zval_ptr
);
9268 if (in_copy_on_write (*p_lhs
))
9270 zval_ptr_dtor (p_lhs
);
9271 ALLOC_INIT_ZVAL (*p_lhs
);
9275 int result_is_operand
= (*p_lhs
== rhs
);
9276 boolean_not_function (*p_lhs
, rhs TSRMLS_CC
);
9277 if (!result_is_operand
)
9279 phc_check_invariants (TSRMLS_C
);
9281 // $TLE72 = !$TLE71;
9283 if (local_TLE72
== NULL
)
9285 local_TLE72
= EG (uninitialized_zval_ptr
);
9286 local_TLE72
->refcount
++;
9288 zval
** p_lhs
= &local_TLE72
;
9291 if (local_TLE71
== NULL
)
9292 rhs
= EG (uninitialized_zval_ptr
);
9296 if (in_copy_on_write (*p_lhs
))
9298 zval_ptr_dtor (p_lhs
);
9299 ALLOC_INIT_ZVAL (*p_lhs
);
9303 int result_is_operand
= (*p_lhs
== rhs
);
9304 boolean_not_function (*p_lhs
, rhs TSRMLS_CC
);
9305 if (!result_is_operand
)
9307 phc_check_invariants (TSRMLS_C
);
9309 // if (TLE72) goto L138 else goto L139;
9312 if (local_TLE72
== NULL
)
9313 p_cond
= EG (uninitialized_zval_ptr
);
9315 p_cond
= local_TLE72
;
9317 zend_bool bcond
= zend_is_true (p_cond
);
9322 phc_check_invariants (TSRMLS_C
);
9329 phc_check_invariants (TSRMLS_C
);
9334 phc_check_invariants (TSRMLS_C
);
9341 phc_check_invariants (TSRMLS_C
);
9347 if (local_TLE73
== NULL
)
9349 local_TLE73
= EG (uninitialized_zval_ptr
);
9350 local_TLE73
->refcount
++;
9352 zval
** p_lhs
= &local_TLE73
;
9355 if ((*p_lhs
)->is_ref
)
9357 // Always overwrite the current value
9363 ALLOC_INIT_ZVAL (value
);
9364 zval_ptr_dtor (p_lhs
);
9368 ZVAL_LONG (value
, 1024);
9370 phc_check_invariants (TSRMLS_C
);
9372 // $TLE102 = param_is_ref (NULL, "fgets", 0);
9375 initialize_function_call (&fgets_fci
, &fgets_fcic
, "fgets", "<unknown>", 0 TSRMLS_CC
);
9376 zend_function
* signature
= fgets_fcic
.function_handler
;
9377 zend_arg_info
* arg_info
= signature
->common
.arg_info
;
9379 while (arg_info
&& count
< 0)
9385 if (local_TLE102
== NULL
)
9387 local_TLE102
= EG (uninitialized_zval_ptr
);
9388 local_TLE102
->refcount
++;
9390 zval
** p_lhs
= &local_TLE102
;
9393 ALLOC_INIT_ZVAL (rhs
);
9394 if (arg_info
&& count
== 0)
9396 ZVAL_BOOL (rhs
, arg_info
->pass_by_reference
);
9400 ZVAL_BOOL (rhs
, signature
->common
.pass_rest_by_reference
);
9402 write_var (p_lhs
, rhs
);
9403 zval_ptr_dtor (&rhs
);
9404 phc_check_invariants (TSRMLS_C
);
9406 // if (TLE102) goto L141 else goto L142;
9409 if (local_TLE102
== NULL
)
9410 p_cond
= EG (uninitialized_zval_ptr
);
9412 p_cond
= local_TLE102
;
9414 zend_bool bcond
= zend_is_true (p_cond
);
9419 phc_check_invariants (TSRMLS_C
);
9423 // $TMIi101 =& $pipes[$readpipe];
9425 if (local_TMIi101
== NULL
)
9427 local_TMIi101
= EG (uninitialized_zval_ptr
);
9428 local_TMIi101
->refcount
++;
9430 zval
** p_lhs
= &local_TMIi101
;
9432 if (local_pipes
== NULL
)
9434 local_pipes
= EG (uninitialized_zval_ptr
);
9435 local_pipes
->refcount
++;
9437 zval
** p_r_array
= &local_pipes
;
9440 if (local_readpipe
== NULL
)
9441 r_index
= EG (uninitialized_zval_ptr
);
9443 r_index
= local_readpipe
;
9445 check_array_type (p_r_array TSRMLS_CC
);
9446 zval
** p_rhs
= get_ht_entry (p_r_array
, r_index TSRMLS_CC
);
9447 sep_copy_on_write (p_rhs
);
9448 copy_into_ref (p_lhs
, p_rhs
);
9449 phc_check_invariants (TSRMLS_C
);
9454 phc_check_invariants (TSRMLS_C
);
9458 // $TMIi101 = $pipes[$readpipe];
9460 if (local_TMIi101
== NULL
)
9462 local_TMIi101
= EG (uninitialized_zval_ptr
);
9463 local_TMIi101
->refcount
++;
9465 zval
** p_lhs
= &local_TMIi101
;
9468 if (local_pipes
== NULL
)
9469 r_array
= EG (uninitialized_zval_ptr
);
9471 r_array
= local_pipes
;
9474 if (local_readpipe
== NULL
)
9475 r_index
= EG (uninitialized_zval_ptr
);
9477 r_index
= local_readpipe
;
9482 if (Z_TYPE_P (r_array
) != IS_ARRAY
)
9484 if (Z_TYPE_P (r_array
) == IS_STRING
)
9487 rhs
= read_string_index (r_array
, r_index TSRMLS_CC
);
9490 // TODO: warning here?
9491 rhs
= EG (uninitialized_zval_ptr
);
9495 if (check_array_index_type (r_index TSRMLS_CC
))
9497 // Read array variable
9498 read_array (&rhs
, r_array
, r_index TSRMLS_CC
);
9501 rhs
= *p_lhs
; // HACK to fail *p_lhs != rhs
9505 write_var (p_lhs
, rhs
);
9507 if (is_rhs_new
) zval_ptr_dtor (&rhs
);
9508 phc_check_invariants (TSRMLS_C
);
9513 phc_check_invariants (TSRMLS_C
);
9517 // $TLE74 = fgets($TMIi101, $TLE73);
9519 initialize_function_call (&fgets_fci
, &fgets_fcic
, "fgets", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 109 TSRMLS_CC
);
9520 zend_function
* signature
= fgets_fcic
.function_handler
;
9521 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
9525 // TODO: find names to replace index
9528 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
9532 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
9535 // TODO: find names to replace index
9538 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
9542 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
9547 // Setup array of arguments
9548 // TODO: i think arrays of size 0 is an error
9551 zval
** args_ind
[2];
9554 destruct
[af_index
] = 0;
9555 if (by_ref
[af_index
])
9557 if (local_TMIi101
== NULL
)
9559 local_TMIi101
= EG (uninitialized_zval_ptr
);
9560 local_TMIi101
->refcount
++;
9562 zval
** p_arg
= &local_TMIi101
;
9564 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
9565 assert (!in_copy_on_write (*args_ind
[af_index
]));
9566 args
[af_index
] = *args_ind
[af_index
];
9571 if (local_TMIi101
== NULL
)
9572 arg
= EG (uninitialized_zval_ptr
);
9574 arg
= local_TMIi101
;
9576 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
9577 args_ind
[af_index
] = &args
[af_index
];
9580 destruct
[af_index
] = 0;
9581 if (by_ref
[af_index
])
9583 if (local_TLE73
== NULL
)
9585 local_TLE73
= EG (uninitialized_zval_ptr
);
9586 local_TLE73
->refcount
++;
9588 zval
** p_arg
= &local_TLE73
;
9590 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
9591 assert (!in_copy_on_write (*args_ind
[af_index
]));
9592 args
[af_index
] = *args_ind
[af_index
];
9597 if (local_TLE73
== NULL
)
9598 arg
= EG (uninitialized_zval_ptr
);
9602 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
9603 args_ind
[af_index
] = &args
[af_index
];
9608 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 109, NULL TSRMLS_CC
);
9610 // save existing parameters, in case of recursion
9611 int param_count_save
= fgets_fci
.param_count
;
9612 zval
*** params_save
= fgets_fci
.params
;
9613 zval
** retval_save
= fgets_fci
.retval_ptr_ptr
;
9618 fgets_fci
.params
= args_ind
;
9619 fgets_fci
.param_count
= 2;
9620 fgets_fci
.retval_ptr_ptr
= &rhs
;
9622 // call the function
9623 int success
= zend_call_function (&fgets_fci
, &fgets_fcic TSRMLS_CC
);
9624 assert(success
== SUCCESS
);
9627 fgets_fci
.params
= params_save
;
9628 fgets_fci
.param_count
= param_count_save
;
9629 fgets_fci
.retval_ptr_ptr
= retval_save
;
9632 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
9635 for (i
= 0; i
< 2; i
++)
9639 assert (destruct
[i
]);
9640 zval_ptr_dtor (args_ind
[i
]);
9645 // When the Zend engine returns by reference, it allocates a zval into
9646 // retval_ptr_ptr. To return by reference, the callee writes into the
9647 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
9648 // not actually return anything). So the zval returned - whether we return
9649 // it, or it is the allocated zval - has a refcount of 1.
9651 // The caller is responsible for cleaning that up (note, this is unaffected
9652 // by whether it is added to some COW set).
9654 // For reasons unknown, the Zend API resets the refcount and is_ref fields
9655 // of the return value after the function returns (unless the callee is
9656 // interpreted). If the function is supposed to return by reference, this
9657 // loses the refcount. This only happens when non-interpreted code is
9658 // called. We work around it, when compiled code is called, by saving the
9659 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
9660 // that we may create an error if our code is called by a callback, and
9661 // returns by reference, and the callback returns by reference. At least
9662 // this is an obscure case.
9663 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
9665 assert (rhs
!= EG(uninitialized_zval_ptr
));
9667 if (saved_refcount
!= 0)
9669 rhs
->refcount
= saved_refcount
;
9673 saved_refcount
= 0; // for 'obscure cases'
9675 if (local_TLE74
== NULL
)
9677 local_TLE74
= EG (uninitialized_zval_ptr
);
9678 local_TLE74
->refcount
++;
9680 zval
** p_lhs
= &local_TLE74
;
9682 write_var (p_lhs
, rhs
);
9685 zval_ptr_dtor (&rhs
);
9686 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
9687 zval_ptr_dtor (&rhs
);
9689 phc_check_invariants (TSRMLS_C
);
9691 // $cleansource = ($cleansource . $TLE74);
9693 if (local_cleansource
== NULL
)
9695 local_cleansource
= EG (uninitialized_zval_ptr
);
9696 local_cleansource
->refcount
++;
9698 zval
** p_lhs
= &local_cleansource
;
9701 if (local_cleansource
== NULL
)
9702 left
= EG (uninitialized_zval_ptr
);
9704 left
= local_cleansource
;
9707 if (local_TLE74
== NULL
)
9708 right
= EG (uninitialized_zval_ptr
);
9710 right
= local_TLE74
;
9712 if (in_copy_on_write (*p_lhs
))
9714 zval_ptr_dtor (p_lhs
);
9715 ALLOC_INIT_ZVAL (*p_lhs
);
9719 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
9720 concat_function (*p_lhs
, left
, right TSRMLS_CC
);
9722 // If the result is one of the operands, the operator function
9723 // will already have cleaned up the result
9724 if (!result_is_operand
)
9726 phc_check_invariants (TSRMLS_C
);
9731 phc_check_invariants (TSRMLS_C
);
9735 // $TLE104 = param_is_ref (NULL, "fclose", 0);
9738 initialize_function_call (&fclose_fci
, &fclose_fcic
, "fclose", "<unknown>", 0 TSRMLS_CC
);
9739 zend_function
* signature
= fclose_fcic
.function_handler
;
9740 zend_arg_info
* arg_info
= signature
->common
.arg_info
;
9742 while (arg_info
&& count
< 0)
9748 if (local_TLE104
== NULL
)
9750 local_TLE104
= EG (uninitialized_zval_ptr
);
9751 local_TLE104
->refcount
++;
9753 zval
** p_lhs
= &local_TLE104
;
9756 ALLOC_INIT_ZVAL (rhs
);
9757 if (arg_info
&& count
== 0)
9759 ZVAL_BOOL (rhs
, arg_info
->pass_by_reference
);
9763 ZVAL_BOOL (rhs
, signature
->common
.pass_rest_by_reference
);
9765 write_var (p_lhs
, rhs
);
9766 zval_ptr_dtor (&rhs
);
9767 phc_check_invariants (TSRMLS_C
);
9769 // if (TLE104) goto L145 else goto L146;
9772 if (local_TLE104
== NULL
)
9773 p_cond
= EG (uninitialized_zval_ptr
);
9775 p_cond
= local_TLE104
;
9777 zend_bool bcond
= zend_is_true (p_cond
);
9782 phc_check_invariants (TSRMLS_C
);
9786 // $TMIi103 =& $pipes[$readpipe];
9788 if (local_TMIi103
== NULL
)
9790 local_TMIi103
= EG (uninitialized_zval_ptr
);
9791 local_TMIi103
->refcount
++;
9793 zval
** p_lhs
= &local_TMIi103
;
9795 if (local_pipes
== NULL
)
9797 local_pipes
= EG (uninitialized_zval_ptr
);
9798 local_pipes
->refcount
++;
9800 zval
** p_r_array
= &local_pipes
;
9803 if (local_readpipe
== NULL
)
9804 r_index
= EG (uninitialized_zval_ptr
);
9806 r_index
= local_readpipe
;
9808 check_array_type (p_r_array TSRMLS_CC
);
9809 zval
** p_rhs
= get_ht_entry (p_r_array
, r_index TSRMLS_CC
);
9810 sep_copy_on_write (p_rhs
);
9811 copy_into_ref (p_lhs
, p_rhs
);
9812 phc_check_invariants (TSRMLS_C
);
9817 phc_check_invariants (TSRMLS_C
);
9821 // $TMIi103 = $pipes[$readpipe];
9823 if (local_TMIi103
== NULL
)
9825 local_TMIi103
= EG (uninitialized_zval_ptr
);
9826 local_TMIi103
->refcount
++;
9828 zval
** p_lhs
= &local_TMIi103
;
9831 if (local_pipes
== NULL
)
9832 r_array
= EG (uninitialized_zval_ptr
);
9834 r_array
= local_pipes
;
9837 if (local_readpipe
== NULL
)
9838 r_index
= EG (uninitialized_zval_ptr
);
9840 r_index
= local_readpipe
;
9845 if (Z_TYPE_P (r_array
) != IS_ARRAY
)
9847 if (Z_TYPE_P (r_array
) == IS_STRING
)
9850 rhs
= read_string_index (r_array
, r_index TSRMLS_CC
);
9853 // TODO: warning here?
9854 rhs
= EG (uninitialized_zval_ptr
);
9858 if (check_array_index_type (r_index TSRMLS_CC
))
9860 // Read array variable
9861 read_array (&rhs
, r_array
, r_index TSRMLS_CC
);
9864 rhs
= *p_lhs
; // HACK to fail *p_lhs != rhs
9868 write_var (p_lhs
, rhs
);
9870 if (is_rhs_new
) zval_ptr_dtor (&rhs
);
9871 phc_check_invariants (TSRMLS_C
);
9876 phc_check_invariants (TSRMLS_C
);
9880 // fclose($TMIi103);
9882 initialize_function_call (&fclose_fci
, &fclose_fcic
, "fclose", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 111 TSRMLS_CC
);
9883 zend_function
* signature
= fclose_fcic
.function_handler
;
9884 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
9888 // TODO: find names to replace index
9891 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
9895 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
9900 // Setup array of arguments
9901 // TODO: i think arrays of size 0 is an error
9904 zval
** args_ind
[1];
9907 destruct
[af_index
] = 0;
9908 if (by_ref
[af_index
])
9910 if (local_TMIi103
== NULL
)
9912 local_TMIi103
= EG (uninitialized_zval_ptr
);
9913 local_TMIi103
->refcount
++;
9915 zval
** p_arg
= &local_TMIi103
;
9917 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
9918 assert (!in_copy_on_write (*args_ind
[af_index
]));
9919 args
[af_index
] = *args_ind
[af_index
];
9924 if (local_TMIi103
== NULL
)
9925 arg
= EG (uninitialized_zval_ptr
);
9927 arg
= local_TMIi103
;
9929 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
9930 args_ind
[af_index
] = &args
[af_index
];
9935 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 111, NULL TSRMLS_CC
);
9937 // save existing parameters, in case of recursion
9938 int param_count_save
= fclose_fci
.param_count
;
9939 zval
*** params_save
= fclose_fci
.params
;
9940 zval
** retval_save
= fclose_fci
.retval_ptr_ptr
;
9945 fclose_fci
.params
= args_ind
;
9946 fclose_fci
.param_count
= 1;
9947 fclose_fci
.retval_ptr_ptr
= &rhs
;
9949 // call the function
9950 int success
= zend_call_function (&fclose_fci
, &fclose_fcic TSRMLS_CC
);
9951 assert(success
== SUCCESS
);
9954 fclose_fci
.params
= params_save
;
9955 fclose_fci
.param_count
= param_count_save
;
9956 fclose_fci
.retval_ptr_ptr
= retval_save
;
9959 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
9962 for (i
= 0; i
< 1; i
++)
9966 assert (destruct
[i
]);
9967 zval_ptr_dtor (args_ind
[i
]);
9972 // When the Zend engine returns by reference, it allocates a zval into
9973 // retval_ptr_ptr. To return by reference, the callee writes into the
9974 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
9975 // not actually return anything). So the zval returned - whether we return
9976 // it, or it is the allocated zval - has a refcount of 1.
9978 // The caller is responsible for cleaning that up (note, this is unaffected
9979 // by whether it is added to some COW set).
9981 // For reasons unknown, the Zend API resets the refcount and is_ref fields
9982 // of the return value after the function returns (unless the callee is
9983 // interpreted). If the function is supposed to return by reference, this
9984 // loses the refcount. This only happens when non-interpreted code is
9985 // called. We work around it, when compiled code is called, by saving the
9986 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
9987 // that we may create an error if our code is called by a callback, and
9988 // returns by reference, and the callback returns by reference. At least
9989 // this is an obscure case.
9990 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
9992 assert (rhs
!= EG(uninitialized_zval_ptr
));
9994 if (saved_refcount
!= 0)
9996 rhs
->refcount
= saved_refcount
;
10000 saved_refcount
= 0; // for 'obscure cases'
10004 zval_ptr_dtor (&rhs
);
10005 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
10006 zval_ptr_dtor (&rhs
);
10008 phc_check_invariants (TSRMLS_C
);
10010 // $retval = proc_close($process);
10012 initialize_function_call (&proc_close_fci
, &proc_close_fcic
, "proc_close", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 112 TSRMLS_CC
);
10013 zend_function
* signature
= proc_close_fcic
.function_handler
;
10014 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
10018 // TODO: find names to replace index
10021 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
10025 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
10030 // Setup array of arguments
10031 // TODO: i think arrays of size 0 is an error
10034 zval
** args_ind
[1];
10037 destruct
[af_index
] = 0;
10038 if (by_ref
[af_index
])
10040 if (local_process
== NULL
)
10042 local_process
= EG (uninitialized_zval_ptr
);
10043 local_process
->refcount
++;
10045 zval
** p_arg
= &local_process
;
10047 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
10048 assert (!in_copy_on_write (*args_ind
[af_index
]));
10049 args
[af_index
] = *args_ind
[af_index
];
10054 if (local_process
== NULL
)
10055 arg
= EG (uninitialized_zval_ptr
);
10057 arg
= local_process
;
10059 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
10060 args_ind
[af_index
] = &args
[af_index
];
10065 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 112, NULL TSRMLS_CC
);
10067 // save existing parameters, in case of recursion
10068 int param_count_save
= proc_close_fci
.param_count
;
10069 zval
*** params_save
= proc_close_fci
.params
;
10070 zval
** retval_save
= proc_close_fci
.retval_ptr_ptr
;
10075 proc_close_fci
.params
= args_ind
;
10076 proc_close_fci
.param_count
= 1;
10077 proc_close_fci
.retval_ptr_ptr
= &rhs
;
10079 // call the function
10080 int success
= zend_call_function (&proc_close_fci
, &proc_close_fcic TSRMLS_CC
);
10081 assert(success
== SUCCESS
);
10084 proc_close_fci
.params
= params_save
;
10085 proc_close_fci
.param_count
= param_count_save
;
10086 proc_close_fci
.retval_ptr_ptr
= retval_save
;
10088 // unset the errors
10089 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
10092 for (i
= 0; i
< 1; i
++)
10096 assert (destruct
[i
]);
10097 zval_ptr_dtor (args_ind
[i
]);
10102 // When the Zend engine returns by reference, it allocates a zval into
10103 // retval_ptr_ptr. To return by reference, the callee writes into the
10104 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
10105 // not actually return anything). So the zval returned - whether we return
10106 // it, or it is the allocated zval - has a refcount of 1.
10108 // The caller is responsible for cleaning that up (note, this is unaffected
10109 // by whether it is added to some COW set).
10111 // For reasons unknown, the Zend API resets the refcount and is_ref fields
10112 // of the return value after the function returns (unless the callee is
10113 // interpreted). If the function is supposed to return by reference, this
10114 // loses the refcount. This only happens when non-interpreted code is
10115 // called. We work around it, when compiled code is called, by saving the
10116 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
10117 // that we may create an error if our code is called by a callback, and
10118 // returns by reference, and the callback returns by reference. At least
10119 // this is an obscure case.
10120 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
10122 assert (rhs
!= EG(uninitialized_zval_ptr
));
10124 if (saved_refcount
!= 0)
10126 rhs
->refcount
= saved_refcount
;
10130 saved_refcount
= 0; // for 'obscure cases'
10132 if (local_retval
== NULL
)
10134 local_retval
= EG (uninitialized_zval_ptr
);
10135 local_retval
->refcount
++;
10137 zval
** p_lhs
= &local_retval
;
10139 write_var (p_lhs
, rhs
);
10142 zval_ptr_dtor (&rhs
);
10143 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
10144 zval_ptr_dtor (&rhs
);
10146 phc_check_invariants (TSRMLS_C
);
10151 phc_check_invariants (TSRMLS_C
);
10157 if (local_retval
== NULL
)
10159 local_retval
= EG (uninitialized_zval_ptr
);
10160 local_retval
->refcount
++;
10162 zval
** p_lhs
= &local_retval
;
10165 if ((*p_lhs
)->is_ref
)
10167 // Always overwrite the current value
10173 ALLOC_INIT_ZVAL (value
);
10174 zval_ptr_dtor (p_lhs
);
10178 ZVAL_LONG (value
, -1);
10180 phc_check_invariants (TSRMLS_C
);
10185 phc_check_invariants (TSRMLS_C
);
10192 phc_check_invariants (TSRMLS_C
);
10198 if (local_retval
== NULL
)
10200 local_retval
= EG (uninitialized_zval_ptr
);
10201 local_retval
->refcount
++;
10203 zval
** p_lhs
= &local_retval
;
10206 if ((*p_lhs
)->is_ref
)
10208 // Always overwrite the current value
10214 ALLOC_INIT_ZVAL (value
);
10215 zval_ptr_dtor (p_lhs
);
10219 ZVAL_LONG (value
, -1);
10221 phc_check_invariants (TSRMLS_C
);
10226 phc_check_invariants (TSRMLS_C
);
10230 // $TLE75 = 'MWTidy::execExternalTidy';
10232 if (local_TLE75
== NULL
)
10234 local_TLE75
= EG (uninitialized_zval_ptr
);
10235 local_TLE75
->refcount
++;
10237 zval
** p_lhs
= &local_TLE75
;
10240 if ((*p_lhs
)->is_ref
)
10242 // Always overwrite the current value
10248 ALLOC_INIT_ZVAL (value
);
10249 zval_ptr_dtor (p_lhs
);
10253 ZVAL_STRINGL(value
, "MWTidy::execExternalTidy", 24, 1);
10255 phc_check_invariants (TSRMLS_C
);
10257 // wfprofileout($TLE75);
10259 initialize_function_call (&wfprofileout_fci
, &wfprofileout_fcic
, "wfprofileout", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 120 TSRMLS_CC
);
10260 zend_function
* signature
= wfprofileout_fcic
.function_handler
;
10261 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
10265 // TODO: find names to replace index
10268 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
10272 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
10277 // Setup array of arguments
10278 // TODO: i think arrays of size 0 is an error
10281 zval
** args_ind
[1];
10284 destruct
[af_index
] = 0;
10285 if (by_ref
[af_index
])
10287 if (local_TLE75
== NULL
)
10289 local_TLE75
= EG (uninitialized_zval_ptr
);
10290 local_TLE75
->refcount
++;
10292 zval
** p_arg
= &local_TLE75
;
10294 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
10295 assert (!in_copy_on_write (*args_ind
[af_index
]));
10296 args
[af_index
] = *args_ind
[af_index
];
10301 if (local_TLE75
== NULL
)
10302 arg
= EG (uninitialized_zval_ptr
);
10306 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
10307 args_ind
[af_index
] = &args
[af_index
];
10312 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 120, NULL TSRMLS_CC
);
10314 // save existing parameters, in case of recursion
10315 int param_count_save
= wfprofileout_fci
.param_count
;
10316 zval
*** params_save
= wfprofileout_fci
.params
;
10317 zval
** retval_save
= wfprofileout_fci
.retval_ptr_ptr
;
10322 wfprofileout_fci
.params
= args_ind
;
10323 wfprofileout_fci
.param_count
= 1;
10324 wfprofileout_fci
.retval_ptr_ptr
= &rhs
;
10326 // call the function
10327 int success
= zend_call_function (&wfprofileout_fci
, &wfprofileout_fcic TSRMLS_CC
);
10328 assert(success
== SUCCESS
);
10331 wfprofileout_fci
.params
= params_save
;
10332 wfprofileout_fci
.param_count
= param_count_save
;
10333 wfprofileout_fci
.retval_ptr_ptr
= retval_save
;
10335 // unset the errors
10336 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
10339 for (i
= 0; i
< 1; i
++)
10343 assert (destruct
[i
]);
10344 zval_ptr_dtor (args_ind
[i
]);
10349 // When the Zend engine returns by reference, it allocates a zval into
10350 // retval_ptr_ptr. To return by reference, the callee writes into the
10351 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
10352 // not actually return anything). So the zval returned - whether we return
10353 // it, or it is the allocated zval - has a refcount of 1.
10355 // The caller is responsible for cleaning that up (note, this is unaffected
10356 // by whether it is added to some COW set).
10358 // For reasons unknown, the Zend API resets the refcount and is_ref fields
10359 // of the return value after the function returns (unless the callee is
10360 // interpreted). If the function is supposed to return by reference, this
10361 // loses the refcount. This only happens when non-interpreted code is
10362 // called. We work around it, when compiled code is called, by saving the
10363 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
10364 // that we may create an error if our code is called by a callback, and
10365 // returns by reference, and the callback returns by reference. At least
10366 // this is an obscure case.
10367 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
10369 assert (rhs
!= EG(uninitialized_zval_ptr
));
10371 if (saved_refcount
!= 0)
10373 rhs
->refcount
= saved_refcount
;
10377 saved_refcount
= 0; // for 'obscure cases'
10381 zval_ptr_dtor (&rhs
);
10382 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
10383 zval_ptr_dtor (&rhs
);
10385 phc_check_invariants (TSRMLS_C
);
10387 // $TLE5 = !$stderr;
10389 if (local_TLE5
== NULL
)
10391 local_TLE5
= EG (uninitialized_zval_ptr
);
10392 local_TLE5
->refcount
++;
10394 zval
** p_lhs
= &local_TLE5
;
10397 if (local_stderr
== NULL
)
10398 rhs
= EG (uninitialized_zval_ptr
);
10400 rhs
= local_stderr
;
10402 if (in_copy_on_write (*p_lhs
))
10404 zval_ptr_dtor (p_lhs
);
10405 ALLOC_INIT_ZVAL (*p_lhs
);
10408 zval old
= **p_lhs
;
10409 int result_is_operand
= (*p_lhs
== rhs
);
10410 boolean_not_function (*p_lhs
, rhs TSRMLS_CC
);
10411 if (!result_is_operand
)
10413 phc_check_invariants (TSRMLS_C
);
10415 // if (TLE5) goto L154 else goto L155;
10418 if (local_TLE5
== NULL
)
10419 p_cond
= EG (uninitialized_zval_ptr
);
10421 p_cond
= local_TLE5
;
10423 zend_bool bcond
= zend_is_true (p_cond
);
10428 phc_check_invariants (TSRMLS_C
);
10434 if (local_TLE76
== NULL
)
10436 local_TLE76
= EG (uninitialized_zval_ptr
);
10437 local_TLE76
->refcount
++;
10439 zval
** p_lhs
= &local_TLE76
;
10442 if ((*p_lhs
)->is_ref
)
10444 // Always overwrite the current value
10450 ALLOC_INIT_ZVAL (value
);
10451 zval_ptr_dtor (p_lhs
);
10455 ZVAL_STRINGL(value
, "", 0, 1);
10457 phc_check_invariants (TSRMLS_C
);
10459 // $TEF6 = ($cleansource == $TLE76);
10461 if (local_TEF6
== NULL
)
10463 local_TEF6
= EG (uninitialized_zval_ptr
);
10464 local_TEF6
->refcount
++;
10466 zval
** p_lhs
= &local_TEF6
;
10469 if (local_cleansource
== NULL
)
10470 left
= EG (uninitialized_zval_ptr
);
10472 left
= local_cleansource
;
10475 if (local_TLE76
== NULL
)
10476 right
= EG (uninitialized_zval_ptr
);
10478 right
= local_TLE76
;
10480 if (in_copy_on_write (*p_lhs
))
10482 zval_ptr_dtor (p_lhs
);
10483 ALLOC_INIT_ZVAL (*p_lhs
);
10486 zval old
= **p_lhs
;
10487 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
10488 is_equal_function (*p_lhs
, left
, right TSRMLS_CC
);
10490 // If the result is one of the operands, the operator function
10491 // will already have cleaned up the result
10492 if (!result_is_operand
)
10494 phc_check_invariants (TSRMLS_C
);
10499 phc_check_invariants (TSRMLS_C
);
10505 if (local_TEF6
== NULL
)
10507 local_TEF6
= EG (uninitialized_zval_ptr
);
10508 local_TEF6
->refcount
++;
10510 zval
** p_lhs
= &local_TEF6
;
10513 if (local_TLE5
== NULL
)
10514 rhs
= EG (uninitialized_zval_ptr
);
10520 if ((*p_lhs
)->is_ref
)
10521 overwrite_lhs (*p_lhs
, rhs
);
10524 zval_ptr_dtor (p_lhs
);
10527 // Take a copy of RHS for LHS
10528 *p_lhs
= zvp_clone_ex (rhs
);
10540 phc_check_invariants (TSRMLS_C
);
10545 phc_check_invariants (TSRMLS_C
);
10549 // $TLE7 = (bool) $TEF6;
10551 if (local_TLE7
== NULL
)
10553 local_TLE7
= EG (uninitialized_zval_ptr
);
10554 local_TLE7
->refcount
++;
10556 zval
** p_lhs
= &local_TLE7
;
10559 if (local_TEF6
== NULL
)
10560 rhs
= EG (uninitialized_zval_ptr
);
10566 if ((*p_lhs
)->is_ref
)
10567 overwrite_lhs (*p_lhs
, rhs
);
10570 zval_ptr_dtor (p_lhs
);
10573 // Take a copy of RHS for LHS
10574 *p_lhs
= zvp_clone_ex (rhs
);
10587 assert (IS_BOOL
>= 0 && IS_BOOL
<= 6);
10588 if ((*p_lhs
)->type
!= IS_BOOL
)
10590 sep_copy_on_write (p_lhs
);
10591 convert_to_boolean (*p_lhs
);
10594 phc_check_invariants (TSRMLS_C
);
10596 // if (TLE7) goto L157 else goto L158;
10599 if (local_TLE7
== NULL
)
10600 p_cond
= EG (uninitialized_zval_ptr
);
10602 p_cond
= local_TLE7
;
10604 zend_bool bcond
= zend_is_true (p_cond
);
10609 phc_check_invariants (TSRMLS_C
);
10615 if (local_TLE77
== NULL
)
10617 local_TLE77
= EG (uninitialized_zval_ptr
);
10618 local_TLE77
->refcount
++;
10620 zval
** p_lhs
= &local_TLE77
;
10623 if ((*p_lhs
)->is_ref
)
10625 // Always overwrite the current value
10631 ALLOC_INIT_ZVAL (value
);
10632 zval_ptr_dtor (p_lhs
);
10636 ZVAL_STRINGL(value
, "", 0, 1);
10638 phc_check_invariants (TSRMLS_C
);
10640 // $TEF8 = ($text != $TLE77);
10642 if (local_TEF8
== NULL
)
10644 local_TEF8
= EG (uninitialized_zval_ptr
);
10645 local_TEF8
->refcount
++;
10647 zval
** p_lhs
= &local_TEF8
;
10650 if (local_text
== NULL
)
10651 left
= EG (uninitialized_zval_ptr
);
10656 if (local_TLE77
== NULL
)
10657 right
= EG (uninitialized_zval_ptr
);
10659 right
= local_TLE77
;
10661 if (in_copy_on_write (*p_lhs
))
10663 zval_ptr_dtor (p_lhs
);
10664 ALLOC_INIT_ZVAL (*p_lhs
);
10667 zval old
= **p_lhs
;
10668 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
10669 is_not_equal_function (*p_lhs
, left
, right TSRMLS_CC
);
10671 // If the result is one of the operands, the operator function
10672 // will already have cleaned up the result
10673 if (!result_is_operand
)
10675 phc_check_invariants (TSRMLS_C
);
10680 phc_check_invariants (TSRMLS_C
);
10686 if (local_TEF8
== NULL
)
10688 local_TEF8
= EG (uninitialized_zval_ptr
);
10689 local_TEF8
->refcount
++;
10691 zval
** p_lhs
= &local_TEF8
;
10694 if (local_TLE7
== NULL
)
10695 rhs
= EG (uninitialized_zval_ptr
);
10701 if ((*p_lhs
)->is_ref
)
10702 overwrite_lhs (*p_lhs
, rhs
);
10705 zval_ptr_dtor (p_lhs
);
10708 // Take a copy of RHS for LHS
10709 *p_lhs
= zvp_clone_ex (rhs
);
10721 phc_check_invariants (TSRMLS_C
);
10726 phc_check_invariants (TSRMLS_C
);
10730 // $TLE78 = (bool) $TEF8;
10732 if (local_TLE78
== NULL
)
10734 local_TLE78
= EG (uninitialized_zval_ptr
);
10735 local_TLE78
->refcount
++;
10737 zval
** p_lhs
= &local_TLE78
;
10740 if (local_TEF8
== NULL
)
10741 rhs
= EG (uninitialized_zval_ptr
);
10747 if ((*p_lhs
)->is_ref
)
10748 overwrite_lhs (*p_lhs
, rhs
);
10751 zval_ptr_dtor (p_lhs
);
10754 // Take a copy of RHS for LHS
10755 *p_lhs
= zvp_clone_ex (rhs
);
10768 assert (IS_BOOL
>= 0 && IS_BOOL
<= 6);
10769 if ((*p_lhs
)->type
!= IS_BOOL
)
10771 sep_copy_on_write (p_lhs
);
10772 convert_to_boolean (*p_lhs
);
10775 phc_check_invariants (TSRMLS_C
);
10777 // if (TLE78) goto L160 else goto L161;
10780 if (local_TLE78
== NULL
)
10781 p_cond
= EG (uninitialized_zval_ptr
);
10783 p_cond
= local_TLE78
;
10785 zend_bool bcond
= zend_is_true (p_cond
);
10790 phc_check_invariants (TSRMLS_C
);
10796 if (local_TLE79
== NULL
)
10798 local_TLE79
= EG (uninitialized_zval_ptr
);
10799 local_TLE79
->refcount
++;
10801 zval
** p_lhs
= &local_TLE79
;
10804 if ((*p_lhs
)->is_ref
)
10806 // Always overwrite the current value
10812 ALLOC_INIT_ZVAL (value
);
10813 zval_ptr_dtor (p_lhs
);
10819 phc_check_invariants (TSRMLS_C
);
10824 if (local_TLE79
== NULL
)
10825 rhs
= EG (uninitialized_zval_ptr
);
10829 // Run-time return by reference has different semantics to compile-time.
10830 // If the function has CTRBR and RTRBR, the the assignment will be
10831 // reference. If one or the other is return-by-copy, the result will be
10832 // by copy. Its a question of whether its separated at return-time (which
10833 // we do here) or at the call-site.
10834 return_value
->value
= rhs
->value
;
10835 return_value
->type
= rhs
->type
;
10836 zval_copy_ctor (return_value
);
10837 goto end_of_function
;
10838 phc_check_invariants (TSRMLS_C
);
10843 phc_check_invariants (TSRMLS_C
);
10847 // return $cleansource;
10850 if (local_cleansource
== NULL
)
10851 rhs
= EG (uninitialized_zval_ptr
);
10853 rhs
= local_cleansource
;
10855 // Run-time return by reference has different semantics to compile-time.
10856 // If the function has CTRBR and RTRBR, the the assignment will be
10857 // reference. If one or the other is return-by-copy, the result will be
10858 // by copy. Its a question of whether its separated at return-time (which
10859 // we do here) or at the call-site.
10860 return_value
->value
= rhs
->value
;
10861 return_value
->type
= rhs
->type
;
10862 zval_copy_ctor (return_value
);
10863 goto end_of_function
;
10864 phc_check_invariants (TSRMLS_C
);
10869 phc_check_invariants (TSRMLS_C
);
10874 end_of_function
:__attribute__((unused
));
10875 if (local_TEF4
!= NULL
)
10877 zval_ptr_dtor (&local_TEF4
);
10879 if (local_TEF6
!= NULL
)
10881 zval_ptr_dtor (&local_TEF6
);
10883 if (local_TEF8
!= NULL
)
10885 zval_ptr_dtor (&local_TEF8
);
10887 if (local_TLE100
!= NULL
)
10889 zval_ptr_dtor (&local_TLE100
);
10891 if (local_TLE102
!= NULL
)
10893 zval_ptr_dtor (&local_TLE102
);
10895 if (local_TLE104
!= NULL
)
10897 zval_ptr_dtor (&local_TLE104
);
10899 if (local_TLE28
!= NULL
)
10901 zval_ptr_dtor (&local_TLE28
);
10903 if (local_TLE29
!= NULL
)
10905 zval_ptr_dtor (&local_TLE29
);
10907 if (local_TLE30
!= NULL
)
10909 zval_ptr_dtor (&local_TLE30
);
10911 if (local_TLE31
!= NULL
)
10913 zval_ptr_dtor (&local_TLE31
);
10915 if (local_TLE33
!= NULL
)
10917 zval_ptr_dtor (&local_TLE33
);
10919 if (local_TLE34
!= NULL
)
10921 zval_ptr_dtor (&local_TLE34
);
10923 if (local_TLE35
!= NULL
)
10925 zval_ptr_dtor (&local_TLE35
);
10927 if (local_TLE36
!= NULL
)
10929 zval_ptr_dtor (&local_TLE36
);
10931 if (local_TLE38
!= NULL
)
10933 zval_ptr_dtor (&local_TLE38
);
10935 if (local_TLE39
!= NULL
)
10937 zval_ptr_dtor (&local_TLE39
);
10939 if (local_TLE40
!= NULL
)
10941 zval_ptr_dtor (&local_TLE40
);
10943 if (local_TLE43
!= NULL
)
10945 zval_ptr_dtor (&local_TLE43
);
10947 if (local_TLE44
!= NULL
)
10949 zval_ptr_dtor (&local_TLE44
);
10951 if (local_TLE45
!= NULL
)
10953 zval_ptr_dtor (&local_TLE45
);
10955 if (local_TLE47
!= NULL
)
10957 zval_ptr_dtor (&local_TLE47
);
10959 if (local_TLE48
!= NULL
)
10961 zval_ptr_dtor (&local_TLE48
);
10963 if (local_TLE49
!= NULL
)
10965 zval_ptr_dtor (&local_TLE49
);
10967 if (local_TLE5
!= NULL
)
10969 zval_ptr_dtor (&local_TLE5
);
10971 if (local_TLE51
!= NULL
)
10973 zval_ptr_dtor (&local_TLE51
);
10975 if (local_TLE52
!= NULL
)
10977 zval_ptr_dtor (&local_TLE52
);
10979 if (local_TLE53
!= NULL
)
10981 zval_ptr_dtor (&local_TLE53
);
10983 if (local_TLE54
!= NULL
)
10985 zval_ptr_dtor (&local_TLE54
);
10987 if (local_TLE58
!= NULL
)
10989 zval_ptr_dtor (&local_TLE58
);
10991 if (local_TLE59
!= NULL
)
10993 zval_ptr_dtor (&local_TLE59
);
10995 if (local_TLE60
!= NULL
)
10997 zval_ptr_dtor (&local_TLE60
);
10999 if (local_TLE61
!= NULL
)
11001 zval_ptr_dtor (&local_TLE61
);
11003 if (local_TLE62
!= NULL
)
11005 zval_ptr_dtor (&local_TLE62
);
11007 if (local_TLE63
!= NULL
)
11009 zval_ptr_dtor (&local_TLE63
);
11011 if (local_TLE64
!= NULL
)
11013 zval_ptr_dtor (&local_TLE64
);
11015 if (local_TLE65
!= NULL
)
11017 zval_ptr_dtor (&local_TLE65
);
11019 if (local_TLE66
!= NULL
)
11021 zval_ptr_dtor (&local_TLE66
);
11023 if (local_TLE67
!= NULL
)
11025 zval_ptr_dtor (&local_TLE67
);
11027 if (local_TLE68
!= NULL
)
11029 zval_ptr_dtor (&local_TLE68
);
11031 if (local_TLE69
!= NULL
)
11033 zval_ptr_dtor (&local_TLE69
);
11035 if (local_TLE7
!= NULL
)
11037 zval_ptr_dtor (&local_TLE7
);
11039 if (local_TLE70
!= NULL
)
11041 zval_ptr_dtor (&local_TLE70
);
11043 if (local_TLE71
!= NULL
)
11045 zval_ptr_dtor (&local_TLE71
);
11047 if (local_TLE72
!= NULL
)
11049 zval_ptr_dtor (&local_TLE72
);
11051 if (local_TLE73
!= NULL
)
11053 zval_ptr_dtor (&local_TLE73
);
11055 if (local_TLE74
!= NULL
)
11057 zval_ptr_dtor (&local_TLE74
);
11059 if (local_TLE75
!= NULL
)
11061 zval_ptr_dtor (&local_TLE75
);
11063 if (local_TLE76
!= NULL
)
11065 zval_ptr_dtor (&local_TLE76
);
11067 if (local_TLE77
!= NULL
)
11069 zval_ptr_dtor (&local_TLE77
);
11071 if (local_TLE78
!= NULL
)
11073 zval_ptr_dtor (&local_TLE78
);
11075 if (local_TLE79
!= NULL
)
11077 zval_ptr_dtor (&local_TLE79
);
11079 if (local_TLE96
!= NULL
)
11081 zval_ptr_dtor (&local_TLE96
);
11083 if (local_TLE98
!= NULL
)
11085 zval_ptr_dtor (&local_TLE98
);
11087 if (local_TMIi101
!= NULL
)
11089 zval_ptr_dtor (&local_TMIi101
);
11091 if (local_TMIi103
!= NULL
)
11093 zval_ptr_dtor (&local_TMIi103
);
11095 if (local_TMIi95
!= NULL
)
11097 zval_ptr_dtor (&local_TMIi95
);
11099 if (local_TMIi97
!= NULL
)
11101 zval_ptr_dtor (&local_TMIi97
);
11103 if (local_TMIi99
!= NULL
)
11105 zval_ptr_dtor (&local_TMIi99
);
11107 if (local_TSa32
!= NULL
)
11109 zval_ptr_dtor (&local_TSa32
);
11111 if (local_TSa37
!= NULL
)
11113 zval_ptr_dtor (&local_TSa37
);
11115 if (local_TSa41
!= NULL
)
11117 zval_ptr_dtor (&local_TSa41
);
11119 if (local_TSa42
!= NULL
)
11121 zval_ptr_dtor (&local_TSa42
);
11123 if (local_TSa46
!= NULL
)
11125 zval_ptr_dtor (&local_TSa46
);
11127 if (local_TSa50
!= NULL
)
11129 zval_ptr_dtor (&local_TSa50
);
11131 if (local_TSa55
!= NULL
)
11133 zval_ptr_dtor (&local_TSa55
);
11135 if (local_TSa56
!= NULL
)
11137 zval_ptr_dtor (&local_TSa56
);
11139 if (local_TSa57
!= NULL
)
11141 zval_ptr_dtor (&local_TSa57
);
11143 if (local_cleansource
!= NULL
)
11145 zval_ptr_dtor (&local_cleansource
);
11147 if (local_descriptorspec
!= NULL
)
11149 zval_ptr_dtor (&local_descriptorspec
);
11151 if (local_opts
!= NULL
)
11153 zval_ptr_dtor (&local_opts
);
11155 if (local_pipes
!= NULL
)
11157 zval_ptr_dtor (&local_pipes
);
11159 if (local_process
!= NULL
)
11161 zval_ptr_dtor (&local_process
);
11163 if (local_readpipe
!= NULL
)
11165 zval_ptr_dtor (&local_readpipe
);
11167 if (local_retval
!= NULL
)
11169 zval_ptr_dtor (&local_retval
);
11171 if (local_stderr
!= NULL
)
11173 zval_ptr_dtor (&local_stderr
);
11175 if (local_text
!= NULL
)
11177 zval_ptr_dtor (&local_text
);
11179 if (local_wgTidyBin
!= NULL
)
11181 zval_ptr_dtor (&local_wgTidyBin
);
11183 if (local_wgTidyConf
!= NULL
)
11185 zval_ptr_dtor (&local_wgTidyConf
);
11187 if (local_wgTidyOpts
!= NULL
)
11189 zval_ptr_dtor (&local_wgTidyOpts
);
11192 // private static function execinternaltidy($text, $stderr = False, &$retval = NULL)
11194 // global $wgTidyConf;
11196 // global $wgDebugTidy;
11197 // $TLE80 = 'MWTidy::execInternalTidy';
11198 // wfprofilein($TLE80);
11199 // $tidy = new tidy();
11200 // $TLE81 = 'utf8';
11201 // $tidy->parsestring($text, $wgTidyConf, $TLE81);
11202 // if (stderr) goto L175 else goto L176;
11204 // $retval = $tidy->getstatus();
11205 // $TSt82 = $tidy->errorBuffer;
11209 // $tidy->cleanrepair();
11210 // $retval = $tidy->getstatus();
11212 // $TLE84 = ($retval == $TLE83);
11213 // if (TLE84) goto L163 else goto L164;
11215 // $cleansource = NULL;
11218 // $cleansource = tidy_get_output($tidy);
11221 // $TLE9 = $wgDebugTidy;
11222 // if (TLE9) goto L166 else goto L167;
11225 // $TEF10 = ($TLE85 < $retval);
11231 // $TLE86 = (bool) $TEF10;
11232 // if (TLE86) goto L172 else goto L173;
11238 // $TLE89 = '-->';
11239 // $TLE106 = param_is_ref (NULL, "str_replace", 0);
11241 // if (TLE106) goto L169 else goto L170;
11243 // $TMIt105 =& $tidy->errorBuffer;
11246 // $TMIt105 = $tidy->errorBuffer;
11249 // $TLE90 = str_replace($TLE88, $TLE89, $TMIt105);
11250 // $TLE91 = ($TLE87 . $TLE90);
11253 // $TLE93 = ($TLE91 . $TLE92);
11254 // $cleansource = ($cleansource . $TLE93);
11259 // $TLE94 = 'MWTidy::execInternalTidy';
11260 // wfprofileout($TLE94);
11261 // return $cleansource;
11265 PHP_METHOD(MWTidy
, execinternaltidy
)
11267 zval
* local_IP
= NULL
;
11268 zval
* local_TEF10
= NULL
;
11269 zval
* local_TLE106
= NULL
;
11270 zval
* local_TLE80
= NULL
;
11271 zval
* local_TLE81
= NULL
;
11272 zval
* local_TLE83
= NULL
;
11273 zval
* local_TLE84
= NULL
;
11274 zval
* local_TLE85
= NULL
;
11275 zval
* local_TLE86
= NULL
;
11276 zval
* local_TLE87
= NULL
;
11277 zval
* local_TLE88
= NULL
;
11278 zval
* local_TLE89
= NULL
;
11279 zval
* local_TLE9
= NULL
;
11280 zval
* local_TLE90
= NULL
;
11281 zval
* local_TLE91
= NULL
;
11282 zval
* local_TLE92
= NULL
;
11283 zval
* local_TLE93
= NULL
;
11284 zval
* local_TLE94
= NULL
;
11285 zval
* local_TMIt105
= NULL
;
11286 zval
* local_TSt82
= NULL
;
11287 zval
* local_cleansource
= NULL
;
11288 zval
* local_retval
= NULL
;
11289 zval
* local_stderr
= NULL
;
11290 zval
* local_text
= NULL
;
11291 zval
* local_tidy
= NULL
;
11292 zval
* local_wgDebugTidy
= NULL
;
11293 zval
* local_wgTidyConf
= NULL
;
11294 // Add all parameters as local variables
11296 int num_args
= ZEND_NUM_ARGS ();
11298 zend_get_parameters_array(0, num_args
, params
);
11300 params
[0]->refcount
++;
11301 if (local_text
!= NULL
)
11303 zval_ptr_dtor (&local_text
);
11305 local_text
= params
[0];
11309 zval
* default_value
;
11311 zval
* local___static_value__
= NULL
;
11312 // $__static_value__ = False;
11314 if (local___static_value__
== NULL
)
11316 local___static_value__
= EG (uninitialized_zval_ptr
);
11317 local___static_value__
->refcount
++;
11319 zval
** p_lhs
= &local___static_value__
;
11322 if ((*p_lhs
)->is_ref
)
11324 // Always overwrite the current value
11330 ALLOC_INIT_ZVAL (value
);
11331 zval_ptr_dtor (p_lhs
);
11335 ZVAL_BOOL (value
, 0);
11337 phc_check_invariants (TSRMLS_C
);
11339 default_value
= local___static_value__
;
11340 assert(!default_value
->is_ref
);
11341 default_value
->refcount
++;
11342 if (local___static_value__
!= NULL
)
11344 zval_ptr_dtor (&local___static_value__
);
11347 default_value
->refcount
--;
11348 params
[1] = default_value
;
11350 params
[1]->refcount
++;
11351 if (local_stderr
!= NULL
)
11353 zval_ptr_dtor (&local_stderr
);
11355 local_stderr
= params
[1];
11359 zval
* default_value
;
11361 zval
* local___static_value__
= NULL
;
11362 // $__static_value__ = NULL;
11364 if (local___static_value__
== NULL
)
11366 local___static_value__
= EG (uninitialized_zval_ptr
);
11367 local___static_value__
->refcount
++;
11369 zval
** p_lhs
= &local___static_value__
;
11372 if ((*p_lhs
)->is_ref
)
11374 // Always overwrite the current value
11380 ALLOC_INIT_ZVAL (value
);
11381 zval_ptr_dtor (p_lhs
);
11387 phc_check_invariants (TSRMLS_C
);
11389 default_value
= local___static_value__
;
11390 assert(!default_value
->is_ref
);
11391 default_value
->refcount
++;
11392 if (local___static_value__
!= NULL
)
11394 zval_ptr_dtor (&local___static_value__
);
11397 default_value
->refcount
--;
11398 params
[2] = default_value
;
11400 params
[2]->refcount
++;
11401 if (local_retval
!= NULL
)
11403 zval_ptr_dtor (&local_retval
);
11405 local_retval
= params
[2];
11408 // global $wgTidyConf;
11410 if (local_wgTidyConf
== NULL
)
11412 local_wgTidyConf
= EG (uninitialized_zval_ptr
);
11413 local_wgTidyConf
->refcount
++;
11415 zval
** p_local
= &local_wgTidyConf
;
11417 zval
** p_global
= get_st_entry (&EG(symbol_table
), "wgTidyConf", 10 + 1, 3667061347u TSRMLS_CC
);
11419 sep_copy_on_write (p_global
);
11420 copy_into_ref (p_local
, p_global
);
11421 phc_check_invariants (TSRMLS_C
);
11425 if (local_IP
== NULL
)
11427 local_IP
= EG (uninitialized_zval_ptr
);
11428 local_IP
->refcount
++;
11430 zval
** p_local
= &local_IP
;
11432 zval
** p_global
= get_st_entry (&EG(symbol_table
), "IP", 2 + 1, 193459134u TSRMLS_CC
);
11434 sep_copy_on_write (p_global
);
11435 copy_into_ref (p_local
, p_global
);
11436 phc_check_invariants (TSRMLS_C
);
11438 // global $wgDebugTidy;
11440 if (local_wgDebugTidy
== NULL
)
11442 local_wgDebugTidy
= EG (uninitialized_zval_ptr
);
11443 local_wgDebugTidy
->refcount
++;
11445 zval
** p_local
= &local_wgDebugTidy
;
11447 zval
** p_global
= get_st_entry (&EG(symbol_table
), "wgDebugTidy", 11 + 1, 1610034724u TSRMLS_CC
);
11449 sep_copy_on_write (p_global
);
11450 copy_into_ref (p_local
, p_global
);
11451 phc_check_invariants (TSRMLS_C
);
11453 // $TLE80 = 'MWTidy::execInternalTidy';
11455 if (local_TLE80
== NULL
)
11457 local_TLE80
= EG (uninitialized_zval_ptr
);
11458 local_TLE80
->refcount
++;
11460 zval
** p_lhs
= &local_TLE80
;
11463 if ((*p_lhs
)->is_ref
)
11465 // Always overwrite the current value
11471 ALLOC_INIT_ZVAL (value
);
11472 zval_ptr_dtor (p_lhs
);
11476 ZVAL_STRINGL(value
, "MWTidy::execInternalTidy", 24, 1);
11478 phc_check_invariants (TSRMLS_C
);
11480 // wfprofilein($TLE80);
11482 initialize_function_call (&wfprofilein_fci
, &wfprofilein_fcic
, "wfprofilein", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 139 TSRMLS_CC
);
11483 zend_function
* signature
= wfprofilein_fcic
.function_handler
;
11484 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
11488 // TODO: find names to replace index
11491 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
11495 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
11500 // Setup array of arguments
11501 // TODO: i think arrays of size 0 is an error
11504 zval
** args_ind
[1];
11507 destruct
[af_index
] = 0;
11508 if (by_ref
[af_index
])
11510 if (local_TLE80
== NULL
)
11512 local_TLE80
= EG (uninitialized_zval_ptr
);
11513 local_TLE80
->refcount
++;
11515 zval
** p_arg
= &local_TLE80
;
11517 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
11518 assert (!in_copy_on_write (*args_ind
[af_index
]));
11519 args
[af_index
] = *args_ind
[af_index
];
11524 if (local_TLE80
== NULL
)
11525 arg
= EG (uninitialized_zval_ptr
);
11529 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
11530 args_ind
[af_index
] = &args
[af_index
];
11535 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 139, NULL TSRMLS_CC
);
11537 // save existing parameters, in case of recursion
11538 int param_count_save
= wfprofilein_fci
.param_count
;
11539 zval
*** params_save
= wfprofilein_fci
.params
;
11540 zval
** retval_save
= wfprofilein_fci
.retval_ptr_ptr
;
11545 wfprofilein_fci
.params
= args_ind
;
11546 wfprofilein_fci
.param_count
= 1;
11547 wfprofilein_fci
.retval_ptr_ptr
= &rhs
;
11549 // call the function
11550 int success
= zend_call_function (&wfprofilein_fci
, &wfprofilein_fcic TSRMLS_CC
);
11551 assert(success
== SUCCESS
);
11554 wfprofilein_fci
.params
= params_save
;
11555 wfprofilein_fci
.param_count
= param_count_save
;
11556 wfprofilein_fci
.retval_ptr_ptr
= retval_save
;
11558 // unset the errors
11559 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
11562 for (i
= 0; i
< 1; i
++)
11566 assert (destruct
[i
]);
11567 zval_ptr_dtor (args_ind
[i
]);
11572 // When the Zend engine returns by reference, it allocates a zval into
11573 // retval_ptr_ptr. To return by reference, the callee writes into the
11574 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
11575 // not actually return anything). So the zval returned - whether we return
11576 // it, or it is the allocated zval - has a refcount of 1.
11578 // The caller is responsible for cleaning that up (note, this is unaffected
11579 // by whether it is added to some COW set).
11581 // For reasons unknown, the Zend API resets the refcount and is_ref fields
11582 // of the return value after the function returns (unless the callee is
11583 // interpreted). If the function is supposed to return by reference, this
11584 // loses the refcount. This only happens when non-interpreted code is
11585 // called. We work around it, when compiled code is called, by saving the
11586 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
11587 // that we may create an error if our code is called by a callback, and
11588 // returns by reference, and the callback returns by reference. At least
11589 // this is an obscure case.
11590 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
11592 assert (rhs
!= EG(uninitialized_zval_ptr
));
11594 if (saved_refcount
!= 0)
11596 rhs
->refcount
= saved_refcount
;
11600 saved_refcount
= 0; // for 'obscure cases'
11604 zval_ptr_dtor (&rhs
);
11605 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
11606 zval_ptr_dtor (&rhs
);
11608 phc_check_invariants (TSRMLS_C
);
11610 // $tidy = new tidy();
11612 if (local_tidy
== NULL
)
11614 local_tidy
= EG (uninitialized_zval_ptr
);
11615 local_tidy
->refcount
++;
11617 zval
** p_lhs
= &local_tidy
;
11620 if ((*p_lhs
)->is_ref
)
11622 // Always overwrite the current value
11628 ALLOC_INIT_ZVAL (lhs
);
11629 zval_ptr_dtor (p_lhs
);
11633 zend_class_entry
* ce
;
11634 ce
= zend_fetch_class ("tidy", strlen("tidy"), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC
);
11635 object_init_ex(lhs
, ce
);
11636 if (local_tidy
== NULL
)
11638 local_tidy
= EG (uninitialized_zval_ptr
);
11639 local_tidy
->refcount
++;
11641 zval
** p_obj
= &local_tidy
;
11643 zend_fcall_info fci_object
;
11644 zend_fcall_info_cache fcic_object
= {0, NULL
, NULL
, NULL
};
11645 int has_constructor
= initialize_constructor_call (&fci_object
, &fcic_object
, p_obj
, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 141 TSRMLS_CC
);
11646 // TODO: We pass in __construct to call_function, but in general it may be a
11647 // a different name (the name of the class, for example).
11648 // However, \call_function does not actually use this name at all atm.
11649 if(has_constructor
)
11651 zend_function
* signature
= fcic_object
.function_handler
;
11652 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
11658 // Setup array of arguments
11659 // TODO: i think arrays of size 0 is an error
11662 zval
** args_ind
[0];
11667 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 141, NULL TSRMLS_CC
);
11669 // save existing parameters, in case of recursion
11670 int param_count_save
= fci_object
.param_count
;
11671 zval
*** params_save
= fci_object
.params
;
11672 zval
** retval_save
= fci_object
.retval_ptr_ptr
;
11677 fci_object
.params
= args_ind
;
11678 fci_object
.param_count
= 0;
11679 fci_object
.retval_ptr_ptr
= &rhs
;
11681 // call the function
11682 int success
= zend_call_function (&fci_object
, &fcic_object TSRMLS_CC
);
11683 assert(success
== SUCCESS
);
11686 fci_object
.params
= params_save
;
11687 fci_object
.param_count
= param_count_save
;
11688 fci_object
.retval_ptr_ptr
= retval_save
;
11690 // unset the errors
11691 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
11694 for (i
= 0; i
< 0; i
++)
11698 assert (destruct
[i
]);
11699 zval_ptr_dtor (args_ind
[i
]);
11704 // When the Zend engine returns by reference, it allocates a zval into
11705 // retval_ptr_ptr. To return by reference, the callee writes into the
11706 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
11707 // not actually return anything). So the zval returned - whether we return
11708 // it, or it is the allocated zval - has a refcount of 1.
11710 // The caller is responsible for cleaning that up (note, this is unaffected
11711 // by whether it is added to some COW set).
11713 // For reasons unknown, the Zend API resets the refcount and is_ref fields
11714 // of the return value after the function returns (unless the callee is
11715 // interpreted). If the function is supposed to return by reference, this
11716 // loses the refcount. This only happens when non-interpreted code is
11717 // called. We work around it, when compiled code is called, by saving the
11718 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
11719 // that we may create an error if our code is called by a callback, and
11720 // returns by reference, and the callback returns by reference. At least
11721 // this is an obscure case.
11722 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
11724 assert (rhs
!= EG(uninitialized_zval_ptr
));
11726 if (saved_refcount
!= 0)
11728 rhs
->refcount
= saved_refcount
;
11732 saved_refcount
= 0; // for 'obscure cases'
11736 zval_ptr_dtor (&rhs
);
11737 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
11738 zval_ptr_dtor (&rhs
);
11741 phc_check_invariants (TSRMLS_C
);
11743 // $TLE81 = 'utf8';
11745 if (local_TLE81
== NULL
)
11747 local_TLE81
= EG (uninitialized_zval_ptr
);
11748 local_TLE81
->refcount
++;
11750 zval
** p_lhs
= &local_TLE81
;
11753 if ((*p_lhs
)->is_ref
)
11755 // Always overwrite the current value
11761 ALLOC_INIT_ZVAL (value
);
11762 zval_ptr_dtor (p_lhs
);
11766 ZVAL_STRINGL(value
, "utf8", 4, 1);
11768 phc_check_invariants (TSRMLS_C
);
11770 // $tidy->parsestring($text, $wgTidyConf, $TLE81);
11772 if (local_tidy
== NULL
)
11774 local_tidy
= EG (uninitialized_zval_ptr
);
11775 local_tidy
->refcount
++;
11777 zval
** p_obj
= &local_tidy
;
11779 zend_fcall_info fci_object
;
11780 zend_fcall_info_cache fcic_object
= {0, NULL
, NULL
, NULL
};
11781 initialize_method_call (&fci_object
, &fcic_object
, p_obj
, "parsestring", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 142 TSRMLS_CC
);
11782 zend_function
* signature
= fcic_object
.function_handler
;
11783 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
11787 // TODO: find names to replace index
11790 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
11794 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
11797 // TODO: find names to replace index
11800 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
11804 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
11807 // TODO: find names to replace index
11810 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
11814 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
11819 // Setup array of arguments
11820 // TODO: i think arrays of size 0 is an error
11823 zval
** args_ind
[3];
11826 destruct
[af_index
] = 0;
11827 if (by_ref
[af_index
])
11829 if (local_text
== NULL
)
11831 local_text
= EG (uninitialized_zval_ptr
);
11832 local_text
->refcount
++;
11834 zval
** p_arg
= &local_text
;
11836 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
11837 assert (!in_copy_on_write (*args_ind
[af_index
]));
11838 args
[af_index
] = *args_ind
[af_index
];
11843 if (local_text
== NULL
)
11844 arg
= EG (uninitialized_zval_ptr
);
11848 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
11849 args_ind
[af_index
] = &args
[af_index
];
11852 destruct
[af_index
] = 0;
11853 if (by_ref
[af_index
])
11855 if (local_wgTidyConf
== NULL
)
11857 local_wgTidyConf
= EG (uninitialized_zval_ptr
);
11858 local_wgTidyConf
->refcount
++;
11860 zval
** p_arg
= &local_wgTidyConf
;
11862 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
11863 assert (!in_copy_on_write (*args_ind
[af_index
]));
11864 args
[af_index
] = *args_ind
[af_index
];
11869 if (local_wgTidyConf
== NULL
)
11870 arg
= EG (uninitialized_zval_ptr
);
11872 arg
= local_wgTidyConf
;
11874 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
11875 args_ind
[af_index
] = &args
[af_index
];
11878 destruct
[af_index
] = 0;
11879 if (by_ref
[af_index
])
11881 if (local_TLE81
== NULL
)
11883 local_TLE81
= EG (uninitialized_zval_ptr
);
11884 local_TLE81
->refcount
++;
11886 zval
** p_arg
= &local_TLE81
;
11888 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
11889 assert (!in_copy_on_write (*args_ind
[af_index
]));
11890 args
[af_index
] = *args_ind
[af_index
];
11895 if (local_TLE81
== NULL
)
11896 arg
= EG (uninitialized_zval_ptr
);
11900 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
11901 args_ind
[af_index
] = &args
[af_index
];
11906 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 142, NULL TSRMLS_CC
);
11908 // save existing parameters, in case of recursion
11909 int param_count_save
= fci_object
.param_count
;
11910 zval
*** params_save
= fci_object
.params
;
11911 zval
** retval_save
= fci_object
.retval_ptr_ptr
;
11916 fci_object
.params
= args_ind
;
11917 fci_object
.param_count
= 3;
11918 fci_object
.retval_ptr_ptr
= &rhs
;
11920 // call the function
11921 int success
= zend_call_function (&fci_object
, &fcic_object TSRMLS_CC
);
11922 assert(success
== SUCCESS
);
11925 fci_object
.params
= params_save
;
11926 fci_object
.param_count
= param_count_save
;
11927 fci_object
.retval_ptr_ptr
= retval_save
;
11929 // unset the errors
11930 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
11933 for (i
= 0; i
< 3; i
++)
11937 assert (destruct
[i
]);
11938 zval_ptr_dtor (args_ind
[i
]);
11943 // When the Zend engine returns by reference, it allocates a zval into
11944 // retval_ptr_ptr. To return by reference, the callee writes into the
11945 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
11946 // not actually return anything). So the zval returned - whether we return
11947 // it, or it is the allocated zval - has a refcount of 1.
11949 // The caller is responsible for cleaning that up (note, this is unaffected
11950 // by whether it is added to some COW set).
11952 // For reasons unknown, the Zend API resets the refcount and is_ref fields
11953 // of the return value after the function returns (unless the callee is
11954 // interpreted). If the function is supposed to return by reference, this
11955 // loses the refcount. This only happens when non-interpreted code is
11956 // called. We work around it, when compiled code is called, by saving the
11957 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
11958 // that we may create an error if our code is called by a callback, and
11959 // returns by reference, and the callback returns by reference. At least
11960 // this is an obscure case.
11961 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
11963 assert (rhs
!= EG(uninitialized_zval_ptr
));
11965 if (saved_refcount
!= 0)
11967 rhs
->refcount
= saved_refcount
;
11971 saved_refcount
= 0; // for 'obscure cases'
11975 zval_ptr_dtor (&rhs
);
11976 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
11977 zval_ptr_dtor (&rhs
);
11979 phc_check_invariants (TSRMLS_C
);
11981 // if (stderr) goto L175 else goto L176;
11984 if (local_stderr
== NULL
)
11985 p_cond
= EG (uninitialized_zval_ptr
);
11987 p_cond
= local_stderr
;
11989 zend_bool bcond
= zend_is_true (p_cond
);
11994 phc_check_invariants (TSRMLS_C
);
11998 // $retval = $tidy->getstatus();
12000 if (local_tidy
== NULL
)
12002 local_tidy
= EG (uninitialized_zval_ptr
);
12003 local_tidy
->refcount
++;
12005 zval
** p_obj
= &local_tidy
;
12007 zend_fcall_info fci_object
;
12008 zend_fcall_info_cache fcic_object
= {0, NULL
, NULL
, NULL
};
12009 initialize_method_call (&fci_object
, &fcic_object
, p_obj
, "getstatus", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 145 TSRMLS_CC
);
12010 zend_function
* signature
= fcic_object
.function_handler
;
12011 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
12017 // Setup array of arguments
12018 // TODO: i think arrays of size 0 is an error
12021 zval
** args_ind
[0];
12026 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 145, NULL TSRMLS_CC
);
12028 // save existing parameters, in case of recursion
12029 int param_count_save
= fci_object
.param_count
;
12030 zval
*** params_save
= fci_object
.params
;
12031 zval
** retval_save
= fci_object
.retval_ptr_ptr
;
12036 fci_object
.params
= args_ind
;
12037 fci_object
.param_count
= 0;
12038 fci_object
.retval_ptr_ptr
= &rhs
;
12040 // call the function
12041 int success
= zend_call_function (&fci_object
, &fcic_object TSRMLS_CC
);
12042 assert(success
== SUCCESS
);
12045 fci_object
.params
= params_save
;
12046 fci_object
.param_count
= param_count_save
;
12047 fci_object
.retval_ptr_ptr
= retval_save
;
12049 // unset the errors
12050 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
12053 for (i
= 0; i
< 0; i
++)
12057 assert (destruct
[i
]);
12058 zval_ptr_dtor (args_ind
[i
]);
12063 // When the Zend engine returns by reference, it allocates a zval into
12064 // retval_ptr_ptr. To return by reference, the callee writes into the
12065 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
12066 // not actually return anything). So the zval returned - whether we return
12067 // it, or it is the allocated zval - has a refcount of 1.
12069 // The caller is responsible for cleaning that up (note, this is unaffected
12070 // by whether it is added to some COW set).
12072 // For reasons unknown, the Zend API resets the refcount and is_ref fields
12073 // of the return value after the function returns (unless the callee is
12074 // interpreted). If the function is supposed to return by reference, this
12075 // loses the refcount. This only happens when non-interpreted code is
12076 // called. We work around it, when compiled code is called, by saving the
12077 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
12078 // that we may create an error if our code is called by a callback, and
12079 // returns by reference, and the callback returns by reference. At least
12080 // this is an obscure case.
12081 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
12083 assert (rhs
!= EG(uninitialized_zval_ptr
));
12085 if (saved_refcount
!= 0)
12087 rhs
->refcount
= saved_refcount
;
12091 saved_refcount
= 0; // for 'obscure cases'
12093 if (local_retval
== NULL
)
12095 local_retval
= EG (uninitialized_zval_ptr
);
12096 local_retval
->refcount
++;
12098 zval
** p_lhs
= &local_retval
;
12100 write_var (p_lhs
, rhs
);
12103 zval_ptr_dtor (&rhs
);
12104 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
12105 zval_ptr_dtor (&rhs
);
12107 phc_check_invariants (TSRMLS_C
);
12109 // $TSt82 = $tidy->errorBuffer;
12111 if (local_tidy
== NULL
)
12113 local_tidy
= EG (uninitialized_zval_ptr
);
12114 local_tidy
->refcount
++;
12116 zval
** p_obj
= &local_tidy
;
12119 INIT_ZVAL (field_name
);
12120 ZVAL_STRING (&field_name
, "errorBuffer", 0);
12122 // I *think* this is correct, but documentation of the Zend API is scarce :)
12123 zval
* field
= Z_OBJ_HT_PP(p_obj
)->read_property(*p_obj
, &field_name
, BP_VAR_R TSRMLS_CC
);
12124 if (local_TSt82
== NULL
)
12126 local_TSt82
= EG (uninitialized_zval_ptr
);
12127 local_TSt82
->refcount
++;
12129 zval
** p_lhs
= &local_TSt82
;
12131 write_var (p_lhs
, field
);
12132 phc_check_invariants (TSRMLS_C
);
12137 if (local_TSt82
== NULL
)
12138 rhs
= EG (uninitialized_zval_ptr
);
12142 // Run-time return by reference has different semantics to compile-time.
12143 // If the function has CTRBR and RTRBR, the the assignment will be
12144 // reference. If one or the other is return-by-copy, the result will be
12145 // by copy. Its a question of whether its separated at return-time (which
12146 // we do here) or at the call-site.
12147 return_value
->value
= rhs
->value
;
12148 return_value
->type
= rhs
->type
;
12149 zval_copy_ctor (return_value
);
12150 goto end_of_function
;
12151 phc_check_invariants (TSRMLS_C
);
12156 phc_check_invariants (TSRMLS_C
);
12160 // $tidy->cleanrepair();
12162 if (local_tidy
== NULL
)
12164 local_tidy
= EG (uninitialized_zval_ptr
);
12165 local_tidy
->refcount
++;
12167 zval
** p_obj
= &local_tidy
;
12169 zend_fcall_info fci_object
;
12170 zend_fcall_info_cache fcic_object
= {0, NULL
, NULL
, NULL
};
12171 initialize_method_call (&fci_object
, &fcic_object
, p_obj
, "cleanrepair", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 148 TSRMLS_CC
);
12172 zend_function
* signature
= fcic_object
.function_handler
;
12173 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
12179 // Setup array of arguments
12180 // TODO: i think arrays of size 0 is an error
12183 zval
** args_ind
[0];
12188 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 148, NULL TSRMLS_CC
);
12190 // save existing parameters, in case of recursion
12191 int param_count_save
= fci_object
.param_count
;
12192 zval
*** params_save
= fci_object
.params
;
12193 zval
** retval_save
= fci_object
.retval_ptr_ptr
;
12198 fci_object
.params
= args_ind
;
12199 fci_object
.param_count
= 0;
12200 fci_object
.retval_ptr_ptr
= &rhs
;
12202 // call the function
12203 int success
= zend_call_function (&fci_object
, &fcic_object TSRMLS_CC
);
12204 assert(success
== SUCCESS
);
12207 fci_object
.params
= params_save
;
12208 fci_object
.param_count
= param_count_save
;
12209 fci_object
.retval_ptr_ptr
= retval_save
;
12211 // unset the errors
12212 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
12215 for (i
= 0; i
< 0; i
++)
12219 assert (destruct
[i
]);
12220 zval_ptr_dtor (args_ind
[i
]);
12225 // When the Zend engine returns by reference, it allocates a zval into
12226 // retval_ptr_ptr. To return by reference, the callee writes into the
12227 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
12228 // not actually return anything). So the zval returned - whether we return
12229 // it, or it is the allocated zval - has a refcount of 1.
12231 // The caller is responsible for cleaning that up (note, this is unaffected
12232 // by whether it is added to some COW set).
12234 // For reasons unknown, the Zend API resets the refcount and is_ref fields
12235 // of the return value after the function returns (unless the callee is
12236 // interpreted). If the function is supposed to return by reference, this
12237 // loses the refcount. This only happens when non-interpreted code is
12238 // called. We work around it, when compiled code is called, by saving the
12239 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
12240 // that we may create an error if our code is called by a callback, and
12241 // returns by reference, and the callback returns by reference. At least
12242 // this is an obscure case.
12243 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
12245 assert (rhs
!= EG(uninitialized_zval_ptr
));
12247 if (saved_refcount
!= 0)
12249 rhs
->refcount
= saved_refcount
;
12253 saved_refcount
= 0; // for 'obscure cases'
12257 zval_ptr_dtor (&rhs
);
12258 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
12259 zval_ptr_dtor (&rhs
);
12261 phc_check_invariants (TSRMLS_C
);
12263 // $retval = $tidy->getstatus();
12265 if (local_tidy
== NULL
)
12267 local_tidy
= EG (uninitialized_zval_ptr
);
12268 local_tidy
->refcount
++;
12270 zval
** p_obj
= &local_tidy
;
12272 zend_fcall_info fci_object
;
12273 zend_fcall_info_cache fcic_object
= {0, NULL
, NULL
, NULL
};
12274 initialize_method_call (&fci_object
, &fcic_object
, p_obj
, "getstatus", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 149 TSRMLS_CC
);
12275 zend_function
* signature
= fcic_object
.function_handler
;
12276 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
12282 // Setup array of arguments
12283 // TODO: i think arrays of size 0 is an error
12286 zval
** args_ind
[0];
12291 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 149, NULL TSRMLS_CC
);
12293 // save existing parameters, in case of recursion
12294 int param_count_save
= fci_object
.param_count
;
12295 zval
*** params_save
= fci_object
.params
;
12296 zval
** retval_save
= fci_object
.retval_ptr_ptr
;
12301 fci_object
.params
= args_ind
;
12302 fci_object
.param_count
= 0;
12303 fci_object
.retval_ptr_ptr
= &rhs
;
12305 // call the function
12306 int success
= zend_call_function (&fci_object
, &fcic_object TSRMLS_CC
);
12307 assert(success
== SUCCESS
);
12310 fci_object
.params
= params_save
;
12311 fci_object
.param_count
= param_count_save
;
12312 fci_object
.retval_ptr_ptr
= retval_save
;
12314 // unset the errors
12315 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
12318 for (i
= 0; i
< 0; i
++)
12322 assert (destruct
[i
]);
12323 zval_ptr_dtor (args_ind
[i
]);
12328 // When the Zend engine returns by reference, it allocates a zval into
12329 // retval_ptr_ptr. To return by reference, the callee writes into the
12330 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
12331 // not actually return anything). So the zval returned - whether we return
12332 // it, or it is the allocated zval - has a refcount of 1.
12334 // The caller is responsible for cleaning that up (note, this is unaffected
12335 // by whether it is added to some COW set).
12337 // For reasons unknown, the Zend API resets the refcount and is_ref fields
12338 // of the return value after the function returns (unless the callee is
12339 // interpreted). If the function is supposed to return by reference, this
12340 // loses the refcount. This only happens when non-interpreted code is
12341 // called. We work around it, when compiled code is called, by saving the
12342 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
12343 // that we may create an error if our code is called by a callback, and
12344 // returns by reference, and the callback returns by reference. At least
12345 // this is an obscure case.
12346 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
12348 assert (rhs
!= EG(uninitialized_zval_ptr
));
12350 if (saved_refcount
!= 0)
12352 rhs
->refcount
= saved_refcount
;
12356 saved_refcount
= 0; // for 'obscure cases'
12358 if (local_retval
== NULL
)
12360 local_retval
= EG (uninitialized_zval_ptr
);
12361 local_retval
->refcount
++;
12363 zval
** p_lhs
= &local_retval
;
12365 write_var (p_lhs
, rhs
);
12368 zval_ptr_dtor (&rhs
);
12369 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
12370 zval_ptr_dtor (&rhs
);
12372 phc_check_invariants (TSRMLS_C
);
12376 if (local_TLE83
== NULL
)
12378 local_TLE83
= EG (uninitialized_zval_ptr
);
12379 local_TLE83
->refcount
++;
12381 zval
** p_lhs
= &local_TLE83
;
12384 if ((*p_lhs
)->is_ref
)
12386 // Always overwrite the current value
12392 ALLOC_INIT_ZVAL (value
);
12393 zval_ptr_dtor (p_lhs
);
12397 ZVAL_LONG (value
, 2);
12399 phc_check_invariants (TSRMLS_C
);
12401 // $TLE84 = ($retval == $TLE83);
12403 if (local_TLE84
== NULL
)
12405 local_TLE84
= EG (uninitialized_zval_ptr
);
12406 local_TLE84
->refcount
++;
12408 zval
** p_lhs
= &local_TLE84
;
12411 if (local_retval
== NULL
)
12412 left
= EG (uninitialized_zval_ptr
);
12414 left
= local_retval
;
12417 if (local_TLE83
== NULL
)
12418 right
= EG (uninitialized_zval_ptr
);
12420 right
= local_TLE83
;
12422 if (in_copy_on_write (*p_lhs
))
12424 zval_ptr_dtor (p_lhs
);
12425 ALLOC_INIT_ZVAL (*p_lhs
);
12428 zval old
= **p_lhs
;
12429 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
12430 is_equal_function (*p_lhs
, left
, right TSRMLS_CC
);
12432 // If the result is one of the operands, the operator function
12433 // will already have cleaned up the result
12434 if (!result_is_operand
)
12436 phc_check_invariants (TSRMLS_C
);
12438 // if (TLE84) goto L163 else goto L164;
12441 if (local_TLE84
== NULL
)
12442 p_cond
= EG (uninitialized_zval_ptr
);
12444 p_cond
= local_TLE84
;
12446 zend_bool bcond
= zend_is_true (p_cond
);
12451 phc_check_invariants (TSRMLS_C
);
12455 // $cleansource = NULL;
12457 if (local_cleansource
== NULL
)
12459 local_cleansource
= EG (uninitialized_zval_ptr
);
12460 local_cleansource
->refcount
++;
12462 zval
** p_lhs
= &local_cleansource
;
12465 if ((*p_lhs
)->is_ref
)
12467 // Always overwrite the current value
12473 ALLOC_INIT_ZVAL (value
);
12474 zval_ptr_dtor (p_lhs
);
12480 phc_check_invariants (TSRMLS_C
);
12485 phc_check_invariants (TSRMLS_C
);
12489 // $cleansource = tidy_get_output($tidy);
12491 initialize_function_call (&tidy_get_output_fci
, &tidy_get_output_fcic
, "tidy_get_output", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 155 TSRMLS_CC
);
12492 zend_function
* signature
= tidy_get_output_fcic
.function_handler
;
12493 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
12497 // TODO: find names to replace index
12500 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
12504 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
12509 // Setup array of arguments
12510 // TODO: i think arrays of size 0 is an error
12513 zval
** args_ind
[1];
12516 destruct
[af_index
] = 0;
12517 if (by_ref
[af_index
])
12519 if (local_tidy
== NULL
)
12521 local_tidy
= EG (uninitialized_zval_ptr
);
12522 local_tidy
->refcount
++;
12524 zval
** p_arg
= &local_tidy
;
12526 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
12527 assert (!in_copy_on_write (*args_ind
[af_index
]));
12528 args
[af_index
] = *args_ind
[af_index
];
12533 if (local_tidy
== NULL
)
12534 arg
= EG (uninitialized_zval_ptr
);
12538 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
12539 args_ind
[af_index
] = &args
[af_index
];
12544 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 155, NULL TSRMLS_CC
);
12546 // save existing parameters, in case of recursion
12547 int param_count_save
= tidy_get_output_fci
.param_count
;
12548 zval
*** params_save
= tidy_get_output_fci
.params
;
12549 zval
** retval_save
= tidy_get_output_fci
.retval_ptr_ptr
;
12554 tidy_get_output_fci
.params
= args_ind
;
12555 tidy_get_output_fci
.param_count
= 1;
12556 tidy_get_output_fci
.retval_ptr_ptr
= &rhs
;
12558 // call the function
12559 int success
= zend_call_function (&tidy_get_output_fci
, &tidy_get_output_fcic TSRMLS_CC
);
12560 assert(success
== SUCCESS
);
12563 tidy_get_output_fci
.params
= params_save
;
12564 tidy_get_output_fci
.param_count
= param_count_save
;
12565 tidy_get_output_fci
.retval_ptr_ptr
= retval_save
;
12567 // unset the errors
12568 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
12571 for (i
= 0; i
< 1; i
++)
12575 assert (destruct
[i
]);
12576 zval_ptr_dtor (args_ind
[i
]);
12581 // When the Zend engine returns by reference, it allocates a zval into
12582 // retval_ptr_ptr. To return by reference, the callee writes into the
12583 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
12584 // not actually return anything). So the zval returned - whether we return
12585 // it, or it is the allocated zval - has a refcount of 1.
12587 // The caller is responsible for cleaning that up (note, this is unaffected
12588 // by whether it is added to some COW set).
12590 // For reasons unknown, the Zend API resets the refcount and is_ref fields
12591 // of the return value after the function returns (unless the callee is
12592 // interpreted). If the function is supposed to return by reference, this
12593 // loses the refcount. This only happens when non-interpreted code is
12594 // called. We work around it, when compiled code is called, by saving the
12595 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
12596 // that we may create an error if our code is called by a callback, and
12597 // returns by reference, and the callback returns by reference. At least
12598 // this is an obscure case.
12599 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
12601 assert (rhs
!= EG(uninitialized_zval_ptr
));
12603 if (saved_refcount
!= 0)
12605 rhs
->refcount
= saved_refcount
;
12609 saved_refcount
= 0; // for 'obscure cases'
12611 if (local_cleansource
== NULL
)
12613 local_cleansource
= EG (uninitialized_zval_ptr
);
12614 local_cleansource
->refcount
++;
12616 zval
** p_lhs
= &local_cleansource
;
12618 write_var (p_lhs
, rhs
);
12621 zval_ptr_dtor (&rhs
);
12622 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
12623 zval_ptr_dtor (&rhs
);
12625 phc_check_invariants (TSRMLS_C
);
12630 phc_check_invariants (TSRMLS_C
);
12634 // $TLE9 = $wgDebugTidy;
12636 if (local_TLE9
== NULL
)
12638 local_TLE9
= EG (uninitialized_zval_ptr
);
12639 local_TLE9
->refcount
++;
12641 zval
** p_lhs
= &local_TLE9
;
12644 if (local_wgDebugTidy
== NULL
)
12645 rhs
= EG (uninitialized_zval_ptr
);
12647 rhs
= local_wgDebugTidy
;
12651 if ((*p_lhs
)->is_ref
)
12652 overwrite_lhs (*p_lhs
, rhs
);
12655 zval_ptr_dtor (p_lhs
);
12658 // Take a copy of RHS for LHS
12659 *p_lhs
= zvp_clone_ex (rhs
);
12671 phc_check_invariants (TSRMLS_C
);
12673 // if (TLE9) goto L166 else goto L167;
12676 if (local_TLE9
== NULL
)
12677 p_cond
= EG (uninitialized_zval_ptr
);
12679 p_cond
= local_TLE9
;
12681 zend_bool bcond
= zend_is_true (p_cond
);
12686 phc_check_invariants (TSRMLS_C
);
12692 if (local_TLE85
== NULL
)
12694 local_TLE85
= EG (uninitialized_zval_ptr
);
12695 local_TLE85
->refcount
++;
12697 zval
** p_lhs
= &local_TLE85
;
12700 if ((*p_lhs
)->is_ref
)
12702 // Always overwrite the current value
12708 ALLOC_INIT_ZVAL (value
);
12709 zval_ptr_dtor (p_lhs
);
12713 ZVAL_LONG (value
, 0);
12715 phc_check_invariants (TSRMLS_C
);
12717 // $TEF10 = ($TLE85 < $retval);
12719 if (local_TEF10
== NULL
)
12721 local_TEF10
= EG (uninitialized_zval_ptr
);
12722 local_TEF10
->refcount
++;
12724 zval
** p_lhs
= &local_TEF10
;
12727 if (local_TLE85
== NULL
)
12728 left
= EG (uninitialized_zval_ptr
);
12730 left
= local_TLE85
;
12733 if (local_retval
== NULL
)
12734 right
= EG (uninitialized_zval_ptr
);
12736 right
= local_retval
;
12738 if (in_copy_on_write (*p_lhs
))
12740 zval_ptr_dtor (p_lhs
);
12741 ALLOC_INIT_ZVAL (*p_lhs
);
12744 zval old
= **p_lhs
;
12745 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
12746 is_smaller_function (*p_lhs
, left
, right TSRMLS_CC
);
12748 // If the result is one of the operands, the operator function
12749 // will already have cleaned up the result
12750 if (!result_is_operand
)
12752 phc_check_invariants (TSRMLS_C
);
12757 phc_check_invariants (TSRMLS_C
);
12763 if (local_TEF10
== NULL
)
12765 local_TEF10
= EG (uninitialized_zval_ptr
);
12766 local_TEF10
->refcount
++;
12768 zval
** p_lhs
= &local_TEF10
;
12771 if (local_TLE9
== NULL
)
12772 rhs
= EG (uninitialized_zval_ptr
);
12778 if ((*p_lhs
)->is_ref
)
12779 overwrite_lhs (*p_lhs
, rhs
);
12782 zval_ptr_dtor (p_lhs
);
12785 // Take a copy of RHS for LHS
12786 *p_lhs
= zvp_clone_ex (rhs
);
12798 phc_check_invariants (TSRMLS_C
);
12803 phc_check_invariants (TSRMLS_C
);
12807 // $TLE86 = (bool) $TEF10;
12809 if (local_TLE86
== NULL
)
12811 local_TLE86
= EG (uninitialized_zval_ptr
);
12812 local_TLE86
->refcount
++;
12814 zval
** p_lhs
= &local_TLE86
;
12817 if (local_TEF10
== NULL
)
12818 rhs
= EG (uninitialized_zval_ptr
);
12824 if ((*p_lhs
)->is_ref
)
12825 overwrite_lhs (*p_lhs
, rhs
);
12828 zval_ptr_dtor (p_lhs
);
12831 // Take a copy of RHS for LHS
12832 *p_lhs
= zvp_clone_ex (rhs
);
12845 assert (IS_BOOL
>= 0 && IS_BOOL
<= 6);
12846 if ((*p_lhs
)->type
!= IS_BOOL
)
12848 sep_copy_on_write (p_lhs
);
12849 convert_to_boolean (*p_lhs
);
12852 phc_check_invariants (TSRMLS_C
);
12854 // if (TLE86) goto L172 else goto L173;
12857 if (local_TLE86
== NULL
)
12858 p_cond
= EG (uninitialized_zval_ptr
);
12860 p_cond
= local_TLE86
;
12862 zend_bool bcond
= zend_is_true (p_cond
);
12867 phc_check_invariants (TSRMLS_C
);
12875 if (local_TLE87
== NULL
)
12877 local_TLE87
= EG (uninitialized_zval_ptr
);
12878 local_TLE87
->refcount
++;
12880 zval
** p_lhs
= &local_TLE87
;
12883 if ((*p_lhs
)->is_ref
)
12885 // Always overwrite the current value
12891 ALLOC_INIT_ZVAL (value
);
12892 zval_ptr_dtor (p_lhs
);
12896 ZVAL_STRINGL(value
, "<!--\012Tidy reports:\012", 19, 1);
12898 phc_check_invariants (TSRMLS_C
);
12902 if (local_TLE88
== NULL
)
12904 local_TLE88
= EG (uninitialized_zval_ptr
);
12905 local_TLE88
->refcount
++;
12907 zval
** p_lhs
= &local_TLE88
;
12910 if ((*p_lhs
)->is_ref
)
12912 // Always overwrite the current value
12918 ALLOC_INIT_ZVAL (value
);
12919 zval_ptr_dtor (p_lhs
);
12923 ZVAL_STRINGL(value
, "-->", 3, 1);
12925 phc_check_invariants (TSRMLS_C
);
12927 // $TLE89 = '-->';
12929 if (local_TLE89
== NULL
)
12931 local_TLE89
= EG (uninitialized_zval_ptr
);
12932 local_TLE89
->refcount
++;
12934 zval
** p_lhs
= &local_TLE89
;
12937 if ((*p_lhs
)->is_ref
)
12939 // Always overwrite the current value
12945 ALLOC_INIT_ZVAL (value
);
12946 zval_ptr_dtor (p_lhs
);
12950 ZVAL_STRINGL(value
, "-->", 6, 1);
12952 phc_check_invariants (TSRMLS_C
);
12954 // $TLE106 = param_is_ref (NULL, "str_replace", 0);
12957 initialize_function_call (&str_replace_fci
, &str_replace_fcic
, "str_replace", "<unknown>", 0 TSRMLS_CC
);
12958 zend_function
* signature
= str_replace_fcic
.function_handler
;
12959 zend_arg_info
* arg_info
= signature
->common
.arg_info
;
12961 while (arg_info
&& count
< 0)
12967 if (local_TLE106
== NULL
)
12969 local_TLE106
= EG (uninitialized_zval_ptr
);
12970 local_TLE106
->refcount
++;
12972 zval
** p_lhs
= &local_TLE106
;
12975 ALLOC_INIT_ZVAL (rhs
);
12976 if (arg_info
&& count
== 0)
12978 ZVAL_BOOL (rhs
, arg_info
->pass_by_reference
);
12982 ZVAL_BOOL (rhs
, signature
->common
.pass_rest_by_reference
);
12984 write_var (p_lhs
, rhs
);
12985 zval_ptr_dtor (&rhs
);
12986 phc_check_invariants (TSRMLS_C
);
12988 // if (TLE106) goto L169 else goto L170;
12991 if (local_TLE106
== NULL
)
12992 p_cond
= EG (uninitialized_zval_ptr
);
12994 p_cond
= local_TLE106
;
12996 zend_bool bcond
= zend_is_true (p_cond
);
13001 phc_check_invariants (TSRMLS_C
);
13005 // $TMIt105 =& $tidy->errorBuffer;
13007 if (local_tidy
== NULL
)
13009 local_tidy
= EG (uninitialized_zval_ptr
);
13010 local_tidy
->refcount
++;
13012 zval
** p_obj
= &local_tidy
;
13015 INIT_ZVAL (field_name
);
13016 ZVAL_STRING (&field_name
, "errorBuffer", 0);
13018 zval
** field
= Z_OBJ_HT_PP(p_obj
)->get_property_ptr_ptr(*p_obj
, &field_name TSRMLS_CC
);
13019 sep_copy_on_write (field
);
13020 if (local_TMIt105
== NULL
)
13022 local_TMIt105
= EG (uninitialized_zval_ptr
);
13023 local_TMIt105
->refcount
++;
13025 zval
** p_lhs
= &local_TMIt105
;
13027 copy_into_ref (p_lhs
, field
);
13028 phc_check_invariants (TSRMLS_C
);
13033 phc_check_invariants (TSRMLS_C
);
13037 // $TMIt105 = $tidy->errorBuffer;
13039 if (local_tidy
== NULL
)
13041 local_tidy
= EG (uninitialized_zval_ptr
);
13042 local_tidy
->refcount
++;
13044 zval
** p_obj
= &local_tidy
;
13047 INIT_ZVAL (field_name
);
13048 ZVAL_STRING (&field_name
, "errorBuffer", 0);
13050 // I *think* this is correct, but documentation of the Zend API is scarce :)
13051 zval
* field
= Z_OBJ_HT_PP(p_obj
)->read_property(*p_obj
, &field_name
, BP_VAR_R TSRMLS_CC
);
13052 if (local_TMIt105
== NULL
)
13054 local_TMIt105
= EG (uninitialized_zval_ptr
);
13055 local_TMIt105
->refcount
++;
13057 zval
** p_lhs
= &local_TMIt105
;
13059 write_var (p_lhs
, field
);
13060 phc_check_invariants (TSRMLS_C
);
13065 phc_check_invariants (TSRMLS_C
);
13069 // $TLE90 = str_replace($TLE88, $TLE89, $TMIt105);
13071 initialize_function_call (&str_replace_fci
, &str_replace_fcic
, "str_replace", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 159 TSRMLS_CC
);
13072 zend_function
* signature
= str_replace_fcic
.function_handler
;
13073 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
13077 // TODO: find names to replace index
13080 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
13084 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
13087 // TODO: find names to replace index
13090 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
13094 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
13097 // TODO: find names to replace index
13100 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
13104 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
13109 // Setup array of arguments
13110 // TODO: i think arrays of size 0 is an error
13113 zval
** args_ind
[3];
13116 destruct
[af_index
] = 0;
13117 if (by_ref
[af_index
])
13119 if (local_TLE88
== NULL
)
13121 local_TLE88
= EG (uninitialized_zval_ptr
);
13122 local_TLE88
->refcount
++;
13124 zval
** p_arg
= &local_TLE88
;
13126 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
13127 assert (!in_copy_on_write (*args_ind
[af_index
]));
13128 args
[af_index
] = *args_ind
[af_index
];
13133 if (local_TLE88
== NULL
)
13134 arg
= EG (uninitialized_zval_ptr
);
13138 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
13139 args_ind
[af_index
] = &args
[af_index
];
13142 destruct
[af_index
] = 0;
13143 if (by_ref
[af_index
])
13145 if (local_TLE89
== NULL
)
13147 local_TLE89
= EG (uninitialized_zval_ptr
);
13148 local_TLE89
->refcount
++;
13150 zval
** p_arg
= &local_TLE89
;
13152 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
13153 assert (!in_copy_on_write (*args_ind
[af_index
]));
13154 args
[af_index
] = *args_ind
[af_index
];
13159 if (local_TLE89
== NULL
)
13160 arg
= EG (uninitialized_zval_ptr
);
13164 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
13165 args_ind
[af_index
] = &args
[af_index
];
13168 destruct
[af_index
] = 0;
13169 if (by_ref
[af_index
])
13171 if (local_TMIt105
== NULL
)
13173 local_TMIt105
= EG (uninitialized_zval_ptr
);
13174 local_TMIt105
->refcount
++;
13176 zval
** p_arg
= &local_TMIt105
;
13178 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
13179 assert (!in_copy_on_write (*args_ind
[af_index
]));
13180 args
[af_index
] = *args_ind
[af_index
];
13185 if (local_TMIt105
== NULL
)
13186 arg
= EG (uninitialized_zval_ptr
);
13188 arg
= local_TMIt105
;
13190 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
13191 args_ind
[af_index
] = &args
[af_index
];
13196 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 159, NULL TSRMLS_CC
);
13198 // save existing parameters, in case of recursion
13199 int param_count_save
= str_replace_fci
.param_count
;
13200 zval
*** params_save
= str_replace_fci
.params
;
13201 zval
** retval_save
= str_replace_fci
.retval_ptr_ptr
;
13206 str_replace_fci
.params
= args_ind
;
13207 str_replace_fci
.param_count
= 3;
13208 str_replace_fci
.retval_ptr_ptr
= &rhs
;
13210 // call the function
13211 int success
= zend_call_function (&str_replace_fci
, &str_replace_fcic TSRMLS_CC
);
13212 assert(success
== SUCCESS
);
13215 str_replace_fci
.params
= params_save
;
13216 str_replace_fci
.param_count
= param_count_save
;
13217 str_replace_fci
.retval_ptr_ptr
= retval_save
;
13219 // unset the errors
13220 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
13223 for (i
= 0; i
< 3; i
++)
13227 assert (destruct
[i
]);
13228 zval_ptr_dtor (args_ind
[i
]);
13233 // When the Zend engine returns by reference, it allocates a zval into
13234 // retval_ptr_ptr. To return by reference, the callee writes into the
13235 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
13236 // not actually return anything). So the zval returned - whether we return
13237 // it, or it is the allocated zval - has a refcount of 1.
13239 // The caller is responsible for cleaning that up (note, this is unaffected
13240 // by whether it is added to some COW set).
13242 // For reasons unknown, the Zend API resets the refcount and is_ref fields
13243 // of the return value after the function returns (unless the callee is
13244 // interpreted). If the function is supposed to return by reference, this
13245 // loses the refcount. This only happens when non-interpreted code is
13246 // called. We work around it, when compiled code is called, by saving the
13247 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
13248 // that we may create an error if our code is called by a callback, and
13249 // returns by reference, and the callback returns by reference. At least
13250 // this is an obscure case.
13251 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
13253 assert (rhs
!= EG(uninitialized_zval_ptr
));
13255 if (saved_refcount
!= 0)
13257 rhs
->refcount
= saved_refcount
;
13261 saved_refcount
= 0; // for 'obscure cases'
13263 if (local_TLE90
== NULL
)
13265 local_TLE90
= EG (uninitialized_zval_ptr
);
13266 local_TLE90
->refcount
++;
13268 zval
** p_lhs
= &local_TLE90
;
13270 write_var (p_lhs
, rhs
);
13273 zval_ptr_dtor (&rhs
);
13274 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
13275 zval_ptr_dtor (&rhs
);
13277 phc_check_invariants (TSRMLS_C
);
13279 // $TLE91 = ($TLE87 . $TLE90);
13281 if (local_TLE91
== NULL
)
13283 local_TLE91
= EG (uninitialized_zval_ptr
);
13284 local_TLE91
->refcount
++;
13286 zval
** p_lhs
= &local_TLE91
;
13289 if (local_TLE87
== NULL
)
13290 left
= EG (uninitialized_zval_ptr
);
13292 left
= local_TLE87
;
13295 if (local_TLE90
== NULL
)
13296 right
= EG (uninitialized_zval_ptr
);
13298 right
= local_TLE90
;
13300 if (in_copy_on_write (*p_lhs
))
13302 zval_ptr_dtor (p_lhs
);
13303 ALLOC_INIT_ZVAL (*p_lhs
);
13306 zval old
= **p_lhs
;
13307 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
13308 concat_function (*p_lhs
, left
, right TSRMLS_CC
);
13310 // If the result is one of the operands, the operator function
13311 // will already have cleaned up the result
13312 if (!result_is_operand
)
13314 phc_check_invariants (TSRMLS_C
);
13319 if (local_TLE92
== NULL
)
13321 local_TLE92
= EG (uninitialized_zval_ptr
);
13322 local_TLE92
->refcount
++;
13324 zval
** p_lhs
= &local_TLE92
;
13327 if ((*p_lhs
)->is_ref
)
13329 // Always overwrite the current value
13335 ALLOC_INIT_ZVAL (value
);
13336 zval_ptr_dtor (p_lhs
);
13340 ZVAL_STRINGL(value
, "\012-->", 4, 1);
13342 phc_check_invariants (TSRMLS_C
);
13344 // $TLE93 = ($TLE91 . $TLE92);
13346 if (local_TLE93
== NULL
)
13348 local_TLE93
= EG (uninitialized_zval_ptr
);
13349 local_TLE93
->refcount
++;
13351 zval
** p_lhs
= &local_TLE93
;
13354 if (local_TLE91
== NULL
)
13355 left
= EG (uninitialized_zval_ptr
);
13357 left
= local_TLE91
;
13360 if (local_TLE92
== NULL
)
13361 right
= EG (uninitialized_zval_ptr
);
13363 right
= local_TLE92
;
13365 if (in_copy_on_write (*p_lhs
))
13367 zval_ptr_dtor (p_lhs
);
13368 ALLOC_INIT_ZVAL (*p_lhs
);
13371 zval old
= **p_lhs
;
13372 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
13373 concat_function (*p_lhs
, left
, right TSRMLS_CC
);
13375 // If the result is one of the operands, the operator function
13376 // will already have cleaned up the result
13377 if (!result_is_operand
)
13379 phc_check_invariants (TSRMLS_C
);
13381 // $cleansource = ($cleansource . $TLE93);
13383 if (local_cleansource
== NULL
)
13385 local_cleansource
= EG (uninitialized_zval_ptr
);
13386 local_cleansource
->refcount
++;
13388 zval
** p_lhs
= &local_cleansource
;
13391 if (local_cleansource
== NULL
)
13392 left
= EG (uninitialized_zval_ptr
);
13394 left
= local_cleansource
;
13397 if (local_TLE93
== NULL
)
13398 right
= EG (uninitialized_zval_ptr
);
13400 right
= local_TLE93
;
13402 if (in_copy_on_write (*p_lhs
))
13404 zval_ptr_dtor (p_lhs
);
13405 ALLOC_INIT_ZVAL (*p_lhs
);
13408 zval old
= **p_lhs
;
13409 int result_is_operand
= (*p_lhs
== left
|| *p_lhs
== right
);
13410 concat_function (*p_lhs
, left
, right TSRMLS_CC
);
13412 // If the result is one of the operands, the operator function
13413 // will already have cleaned up the result
13414 if (!result_is_operand
)
13416 phc_check_invariants (TSRMLS_C
);
13421 phc_check_invariants (TSRMLS_C
);
13428 phc_check_invariants (TSRMLS_C
);
13432 // $TLE94 = 'MWTidy::execInternalTidy';
13434 if (local_TLE94
== NULL
)
13436 local_TLE94
= EG (uninitialized_zval_ptr
);
13437 local_TLE94
->refcount
++;
13439 zval
** p_lhs
= &local_TLE94
;
13442 if ((*p_lhs
)->is_ref
)
13444 // Always overwrite the current value
13450 ALLOC_INIT_ZVAL (value
);
13451 zval_ptr_dtor (p_lhs
);
13455 ZVAL_STRINGL(value
, "MWTidy::execInternalTidy", 24, 1);
13457 phc_check_invariants (TSRMLS_C
);
13459 // wfprofileout($TLE94);
13461 initialize_function_call (&wfprofileout_fci
, &wfprofileout_fcic
, "wfprofileout", "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 162 TSRMLS_CC
);
13462 zend_function
* signature
= wfprofileout_fcic
.function_handler
;
13463 zend_arg_info
* arg_info
= signature
->common
.arg_info
; // optional
13467 // TODO: find names to replace index
13470 by_ref
[abr_index
] = arg_info
->pass_by_reference
;
13474 by_ref
[abr_index
] = signature
->common
.pass_rest_by_reference
;
13479 // Setup array of arguments
13480 // TODO: i think arrays of size 0 is an error
13483 zval
** args_ind
[1];
13486 destruct
[af_index
] = 0;
13487 if (by_ref
[af_index
])
13489 if (local_TLE94
== NULL
)
13491 local_TLE94
= EG (uninitialized_zval_ptr
);
13492 local_TLE94
->refcount
++;
13494 zval
** p_arg
= &local_TLE94
;
13496 args_ind
[af_index
] = fetch_var_arg_by_ref (p_arg
);
13497 assert (!in_copy_on_write (*args_ind
[af_index
]));
13498 args
[af_index
] = *args_ind
[af_index
];
13503 if (local_TLE94
== NULL
)
13504 arg
= EG (uninitialized_zval_ptr
);
13508 args
[af_index
] = fetch_var_arg (arg
, &destruct
[af_index
]);
13509 args_ind
[af_index
] = &args
[af_index
];
13514 phc_setup_error (1, "/home/mdupont/2009/02/introspector/rdfintrospector/mediawiki/trunk/phase3/includes/parser/Tidy.php", 162, NULL TSRMLS_CC
);
13516 // save existing parameters, in case of recursion
13517 int param_count_save
= wfprofileout_fci
.param_count
;
13518 zval
*** params_save
= wfprofileout_fci
.params
;
13519 zval
** retval_save
= wfprofileout_fci
.retval_ptr_ptr
;
13524 wfprofileout_fci
.params
= args_ind
;
13525 wfprofileout_fci
.param_count
= 1;
13526 wfprofileout_fci
.retval_ptr_ptr
= &rhs
;
13528 // call the function
13529 int success
= zend_call_function (&wfprofileout_fci
, &wfprofileout_fcic TSRMLS_CC
);
13530 assert(success
== SUCCESS
);
13533 wfprofileout_fci
.params
= params_save
;
13534 wfprofileout_fci
.param_count
= param_count_save
;
13535 wfprofileout_fci
.retval_ptr_ptr
= retval_save
;
13537 // unset the errors
13538 phc_setup_error (0, NULL
, 0, NULL TSRMLS_CC
);
13541 for (i
= 0; i
< 1; i
++)
13545 assert (destruct
[i
]);
13546 zval_ptr_dtor (args_ind
[i
]);
13551 // When the Zend engine returns by reference, it allocates a zval into
13552 // retval_ptr_ptr. To return by reference, the callee writes into the
13553 // retval_ptr_ptr, freeing the allocated value as it does. (Note, it may
13554 // not actually return anything). So the zval returned - whether we return
13555 // it, or it is the allocated zval - has a refcount of 1.
13557 // The caller is responsible for cleaning that up (note, this is unaffected
13558 // by whether it is added to some COW set).
13560 // For reasons unknown, the Zend API resets the refcount and is_ref fields
13561 // of the return value after the function returns (unless the callee is
13562 // interpreted). If the function is supposed to return by reference, this
13563 // loses the refcount. This only happens when non-interpreted code is
13564 // called. We work around it, when compiled code is called, by saving the
13565 // refcount into SAVED_REFCOUNT, in the return statement. The downside is
13566 // that we may create an error if our code is called by a callback, and
13567 // returns by reference, and the callback returns by reference. At least
13568 // this is an obscure case.
13569 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
13571 assert (rhs
!= EG(uninitialized_zval_ptr
));
13573 if (saved_refcount
!= 0)
13575 rhs
->refcount
= saved_refcount
;
13579 saved_refcount
= 0; // for 'obscure cases'
13583 zval_ptr_dtor (&rhs
);
13584 if(signature
->common
.return_reference
&& signature
->type
!= ZEND_USER_FUNCTION
)
13585 zval_ptr_dtor (&rhs
);
13587 phc_check_invariants (TSRMLS_C
);
13589 // return $cleansource;
13592 if (local_cleansource
== NULL
)
13593 rhs
= EG (uninitialized_zval_ptr
);
13595 rhs
= local_cleansource
;
13597 // Run-time return by reference has different semantics to compile-time.
13598 // If the function has CTRBR and RTRBR, the the assignment will be
13599 // reference. If one or the other is return-by-copy, the result will be
13600 // by copy. Its a question of whether its separated at return-time (which
13601 // we do here) or at the call-site.
13602 return_value
->value
= rhs
->value
;
13603 return_value
->type
= rhs
->type
;
13604 zval_copy_ctor (return_value
);
13605 goto end_of_function
;
13606 phc_check_invariants (TSRMLS_C
);
13611 phc_check_invariants (TSRMLS_C
);
13616 end_of_function
:__attribute__((unused
));
13617 if (local_IP
!= NULL
)
13619 zval_ptr_dtor (&local_IP
);
13621 if (local_TEF10
!= NULL
)
13623 zval_ptr_dtor (&local_TEF10
);
13625 if (local_TLE106
!= NULL
)
13627 zval_ptr_dtor (&local_TLE106
);
13629 if (local_TLE80
!= NULL
)
13631 zval_ptr_dtor (&local_TLE80
);
13633 if (local_TLE81
!= NULL
)
13635 zval_ptr_dtor (&local_TLE81
);
13637 if (local_TLE83
!= NULL
)
13639 zval_ptr_dtor (&local_TLE83
);
13641 if (local_TLE84
!= NULL
)
13643 zval_ptr_dtor (&local_TLE84
);
13645 if (local_TLE85
!= NULL
)
13647 zval_ptr_dtor (&local_TLE85
);
13649 if (local_TLE86
!= NULL
)
13651 zval_ptr_dtor (&local_TLE86
);
13653 if (local_TLE87
!= NULL
)
13655 zval_ptr_dtor (&local_TLE87
);
13657 if (local_TLE88
!= NULL
)
13659 zval_ptr_dtor (&local_TLE88
);
13661 if (local_TLE89
!= NULL
)
13663 zval_ptr_dtor (&local_TLE89
);
13665 if (local_TLE9
!= NULL
)
13667 zval_ptr_dtor (&local_TLE9
);
13669 if (local_TLE90
!= NULL
)
13671 zval_ptr_dtor (&local_TLE90
);
13673 if (local_TLE91
!= NULL
)
13675 zval_ptr_dtor (&local_TLE91
);
13677 if (local_TLE92
!= NULL
)
13679 zval_ptr_dtor (&local_TLE92
);
13681 if (local_TLE93
!= NULL
)
13683 zval_ptr_dtor (&local_TLE93
);
13685 if (local_TLE94
!= NULL
)
13687 zval_ptr_dtor (&local_TLE94
);
13689 if (local_TMIt105
!= NULL
)
13691 zval_ptr_dtor (&local_TMIt105
);
13693 if (local_TSt82
!= NULL
)
13695 zval_ptr_dtor (&local_TSt82
);
13697 if (local_cleansource
!= NULL
)
13699 zval_ptr_dtor (&local_cleansource
);
13701 if (local_retval
!= NULL
)
13703 zval_ptr_dtor (&local_retval
);
13705 if (local_stderr
!= NULL
)
13707 zval_ptr_dtor (&local_stderr
);
13709 if (local_text
!= NULL
)
13711 zval_ptr_dtor (&local_text
);
13713 if (local_tidy
!= NULL
)
13715 zval_ptr_dtor (&local_tidy
);
13717 if (local_wgDebugTidy
!= NULL
)
13719 zval_ptr_dtor (&local_wgDebugTidy
);
13721 if (local_wgTidyConf
!= NULL
)
13723 zval_ptr_dtor (&local_wgTidyConf
);
13726 // ArgInfo structures (necessary to support compile time pass-by-reference)
13727 ZEND_BEGIN_ARG_INFO_EX(MWTidy_tidy_arg_info
, 0, 0, 0)
13728 ZEND_ARG_INFO(0, "text")
13729 ZEND_END_ARG_INFO()
13731 ZEND_BEGIN_ARG_INFO_EX(MWTidy_checkerrors_arg_info
, 0, 0, 0)
13732 ZEND_ARG_INFO(0, "text")
13733 ZEND_ARG_INFO(1, "errorStr")
13734 ZEND_END_ARG_INFO()
13736 ZEND_BEGIN_ARG_INFO_EX(MWTidy_execexternaltidy_arg_info
, 0, 0, 0)
13737 ZEND_ARG_INFO(0, "text")
13738 ZEND_ARG_INFO(0, "stderr")
13739 ZEND_ARG_INFO(1, "retval")
13740 ZEND_END_ARG_INFO()
13742 ZEND_BEGIN_ARG_INFO_EX(MWTidy_execinternaltidy_arg_info
, 0, 0, 0)
13743 ZEND_ARG_INFO(0, "text")
13744 ZEND_ARG_INFO(0, "stderr")
13745 ZEND_ARG_INFO(1, "retval")
13746 ZEND_END_ARG_INFO()
13748 static function_entry MWTidy_functions
[] = {
13749 PHP_ME(MWTidy
, tidy
, MWTidy_tidy_arg_info
, ZEND_ACC_PUBLIC
| ZEND_ACC_STATIC
)
13750 PHP_ME(MWTidy
, checkerrors
, MWTidy_checkerrors_arg_info
, ZEND_ACC_PUBLIC
| ZEND_ACC_STATIC
)
13751 PHP_ME(MWTidy
, execexternaltidy
, MWTidy_execexternaltidy_arg_info
, ZEND_ACC_PRIVATE
| ZEND_ACC_STATIC
)
13752 PHP_ME(MWTidy
, execinternaltidy
, MWTidy_execinternaltidy_arg_info
, ZEND_ACC_PRIVATE
| ZEND_ACC_STATIC
)
13753 { NULL
, NULL
, NULL
}
13755 // function __MAIN__()
13758 PHP_FUNCTION(__MAIN__
)
13762 end_of_function
:__attribute__((unused
));
13764 // Module initialization
13765 PHP_MINIT_FUNCTION(app
)
13768 zend_class_entry ce
; // temp
13769 zend_class_entry
* ce_reg
; // once registered, ce_ptr should be used
13770 INIT_CLASS_ENTRY(ce
, "MWTidy", MWTidy_functions
);
13771 ce_reg
= zend_register_internal_class(&ce TSRMLS_CC
);
13772 ce_reg
->type
&= ~ZEND_INTERNAL_CLASS
;
13773 }return SUCCESS
;}// ArgInfo structures (necessary to support compile time pass-by-reference)
13774 ZEND_BEGIN_ARG_INFO_EX(app___MAIN___arg_info
, 0, 0, 0)
13775 ZEND_END_ARG_INFO()
13777 static function_entry app_functions
[] = {
13778 PHP_FE(__MAIN__
, app___MAIN___arg_info
)
13779 { NULL
, NULL
, NULL
}
13781 // Register the module itself with PHP
13782 zend_module_entry app_module_entry
= {
13783 STANDARD_MODULE_HEADER
,
13786 PHP_MINIT(app
), /* MINIT */
13787 NULL
, /* MSHUTDOWN */
13789 NULL
, /* RSHUTDOWN */
13792 STANDARD_MODULE_PROPERTIES
13794 #include <sapi/embed/php_embed.h>
13795 #include <signal.h>
13797 void sighandler(int signum
)
13802 printf("SIGABRT received!\n");
13805 printf("SIGSEGV received!\n");
13808 printf("Unknown signal received!\n");
13812 printf("This could be a bug in phc. If you suspect it is, please email\n");
13813 printf("a bug report to phc-general@phpcompiler.org.\n");
13818 main (int argc
, char* argv
[])
13820 int phc_exit_status
;
13821 signal(SIGABRT
, sighandler
);
13822 signal(SIGSEGV
, sighandler
);
13825 int dealloc_pools
= 1;
13826 php_embed_init (argc
, argv PTSRMLS_CC
);
13830 // initialize the phc runtime
13833 // load the compiled extension
13834 zend_startup_module (&app_module_entry
);
13837 ZVAL_STRING (&main_name
, "__MAIN__", NULL
);
13841 // Use standard errors, on stdout
13842 zend_alter_ini_entry ("report_zend_debug", sizeof("report_zend_debug"), "0", sizeof("0") - 1, PHP_INI_ALL
, PHP_INI_STAGE_RUNTIME
);
13843 zend_alter_ini_entry ("display_startup_errors", sizeof("display_startup_errors"), "1", sizeof("1") - 1, PHP_INI_ALL
, PHP_INI_STAGE_RUNTIME
);
13845 // initialize all the constants
13846 saved_refcount
= 0;
13849 int success
= call_user_function(
13850 EG (function_table
),
13858 assert (success
== SUCCESS
);
13860 // finalize the runtime
13861 finalize_runtime();
13872 phc_exit_status
= EG(exit_status
);
13873 php_embed_shutdown (TSRMLS_C
);
13875 return phc_exit_status
;