update porting to new machine
[wikipedia-parser-hphp.git] / parser / Tidy.php.c
blob3d20623da64a5ed877b44f62ec8bd7134888dfe9
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.
8 */
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
20 #include "php.h"
23 * The runtime needs its own initialization and finalization. phc is
24 * responsible for generating calls to these functions.
27 void
28 init_runtime ()
32 void
33 finalize_runtime ()
37 static void
38 ht_debug (HashTable * ht)
40 printf ("\nHASH\n");
41 if (ht == NULL)
43 printf ("NULL\n");
44 return;
46 for (zend_hash_internal_pointer_reset (ht);
47 zend_hash_has_more_elements (ht) == SUCCESS;
48 zend_hash_move_forward (ht))
50 char *key;
51 unsigned keylen;
52 unsigned long idx;
53 int type;
54 zval **ppzval;
55 zval *zvp;
57 type = zend_hash_get_current_key_ex (ht, &key, &keylen, &idx, 0, NULL);
58 zend_hash_get_current_data (ht, (void **) &ppzval);
60 zvp = *ppzval;
62 if (type == HASH_KEY_IS_STRING)
64 printf ("%s", key);
66 else
68 printf ("%ld", idx);
71 printf (": addr = %08lX, refcount = %d, is_ref = %d ",
72 (long unsigned int) (*ppzval), (*ppzval)->refcount,
73 (*ppzval)->is_ref);
74 switch (Z_TYPE_P (zvp))
76 case IS_NULL:
77 printf ("(NULL)");
78 break;
79 case IS_LONG:
80 printf ("(%ldL)", Z_LVAL_P (zvp));
81 break;
82 case IS_DOUBLE:
83 printf ("(%lff)", Z_DVAL_P (zvp));
84 break;
85 case IS_BOOL:
86 printf (Z_BVAL_P (zvp) ? "(true)" : "(false)");
87 break;
88 case IS_ARRAY:
89 printf ("(array(%d))", Z_ARRVAL_P (zvp)->nNumOfElements);
90 break;
91 case IS_OBJECT:
92 printf ("(Object)");
93 break;
94 case IS_STRING:
95 printf ("(\"%s\")", Z_STRVAL_P (zvp));
96 break;
97 case IS_RESOURCE:
98 printf ("(Resource)");
99 break;
100 default:
101 printf ("(Invalid: %d)", Z_TYPE_P (zvp));
104 printf ("\n");
107 printf ("END HASH\n");
110 // Call ht_debug on the named var in the given symbol table
111 static void
112 ht_var_debug (HashTable * st, char *name)
114 zval **p_zvp;
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);
119 return;
122 if (Z_TYPE_P (*p_zvp) != IS_ARRAY)
124 printf ("NOT HASH\n");
125 return;
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))
147 char *key;
148 zval **p_zvp;
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)
161 zval** p_zvp;
162 int success = zend_hash_quick_find (Z_ARRVAL_P (counters),
163 name,
164 length,
165 hashval,
166 (void **) &p_zvp);
168 if (success == SUCCESS)
170 Z_LVAL_PP (p_zvp)++;
172 else
175 zval* new_val;
176 ALLOC_INIT_ZVAL (new_val);
177 ZVAL_LONG (new_val, 1);
179 zend_hash_quick_add (Z_ARRVAL_P (counters),
180 name,
181 length,
182 hashval,
183 &new_val,
184 sizeof (zval *),
185 NULL);
191 /* Make a copy of *P_ZVP, storing it in *P_ZVP. */
192 static zval *
193 zvp_clone_ex (zval * zvp)
195 // TODO: use INIT_PZVAL_COPY
196 zval *clone;
197 MAKE_STD_ZVAL (clone);
198 clone->value = zvp->value;
199 clone->type = zvp->type;
200 zval_copy_ctor (clone);
201 return clone;
205 static inline int
206 in_copy_on_write (zval * zvp)
208 return (zvp->refcount > 1 && !zvp->is_ref);
211 static inline int
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
219 * original. */
220 static void
221 sep_copy_on_write (zval ** p_zvp)
223 if (!in_copy_on_write (*p_zvp))
224 return;
226 zval *old = *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
235 * original. */
236 static void
237 sep_change_on_write (zval ** p_zvp)
239 assert (in_change_on_write (*p_zvp));
241 zval *old = *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
249 * zval* as RHS. */
250 static void
251 copy_into_ref (zval ** lhs, zval ** rhs)
253 (*rhs)->is_ref = 1;
254 (*rhs)->refcount++;
255 zval_ptr_dtor (lhs);
256 *lhs = *rhs;
260 // Overwrite one zval with another
261 static void
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
266 zval_dtor (lhs);
267 // Overwrite LHS
268 lhs->value = rhs->value;
269 lhs->type = rhs->type;
270 zval_copy_ctor (lhs);
273 // Overwrite one zval with another
274 static void
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
279 zval_dtor (lhs);
280 // Overwrite LHS
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.
289 static void
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.
296 if (rhs->is_ref)
298 *p_lhs = zvp_clone_ex (rhs);
300 else // share a copy
302 rhs->refcount++;
303 *p_lhs = rhs;
306 else
308 overwrite_lhs (*p_lhs, rhs);
312 // TODO: this functino does too much, and much might be redundant
313 static zval **
314 get_st_entry (HashTable * st, char *name, int length, ulong hashval TSRMLS_DC)
316 zval **p_zvp;
317 if (zend_hash_quick_find
318 (st, name, length, hashval, (void **) &p_zvp) == SUCCESS)
320 assert (p_zvp != NULL);
321 return p_zvp;
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);
333 return p_zvp;
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
338 * *IS_NEW is set. */
339 static zval *
340 read_var (HashTable * st, char *name, int length, ulong hashval TSRMLS_DC)
342 zval **p_zvp;
343 if (zend_hash_quick_find
344 (st, name, length, hashval, (void **) &p_zvp) == SUCCESS)
345 return *p_zvp;
347 return EG (uninitialized_zval_ptr);
350 static long
351 get_integer_index (zval * ind TSRMLS_DC)
353 long index;
354 switch (Z_TYPE_P (ind))
356 case IS_DOUBLE:
357 return (long) Z_DVAL_P (ind);
359 case IS_LONG:
360 case IS_BOOL:
361 return Z_LVAL_P (ind);
363 case IS_NULL:
364 return 0;
366 default:
367 php_error_docref (NULL TSRMLS_CC, E_WARNING, "Illegal offset type");
371 static zval *
372 read_string_index (zval * var, zval * ind TSRMLS_DC)
374 // This must always allocate memory, since we cant return the
375 // passed string.
376 assert (Z_TYPE_P (var) == IS_STRING);
377 long index = get_integer_index (ind TSRMLS_CC);
379 zval *result;
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);
387 else
389 char *string = Z_STRVAL_P (var);
390 ZVAL_STRINGL (result, &string[index], 1, 1);
393 return result;
396 /* Given a string (p_lhs), write into it for $x[i] = $y; */
397 void
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
405 char new_char;
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 (&copy);
414 else
416 new_char = Z_STRVAL_P (rhs)[0];
419 // Bounds check
420 if (index < 0)
422 php_error_docref (NULL TSRMLS_CC, E_WARNING,
423 "Illegal string offset: %ld", index);
424 return;
427 // We overwrite if it's change-on-write
428 sep_copy_on_write (p_lhs);
430 if (index > Z_STRLEN_PP (p_lhs))
432 // Extend to fix new
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);
437 // pad with ' '
438 memset (&Z_STRVAL_PP (p_lhs)[len], ' ', index - len);
440 // change the strlen
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
455 static HashTable *
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)
462 array_init (arr);
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");
468 array_init (arr);
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. */
475 static 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. */
486 static int
487 ht_find (HashTable * ht, zval * ind, zval *** data)
489 int result;
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),
497 (void **) data);
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);
508 else
510 // TODO: I believe this might need a warning.
512 // TODO avoid alloc
513 // use a string index for other types
514 zval *string_index;
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,
523 (void **) data);
524 zval_ptr_dtor (&string_index);
526 return result;
530 static int
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");
536 return 0;
539 return 1;
542 // Update a hashtable using a zval* index
543 static void
544 ht_update (HashTable * ht, zval * ind, zval * val, zval *** dest)
546 int result;
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);
568 else
570 // TODO avoid alloc
571 zval *string_index;
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
587 static void
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);
607 else
609 // TODO avoid alloc
610 zval *string_index;
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
624 static int
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);
643 else
645 // TODO avoid alloc
646 int result;
647 zval *string_index;
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);
656 return result;
658 assert (0);
661 static zval **
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);
677 array_init (*p_var);
680 HashTable *ht = extract_ht (p_var TSRMLS_CC);
682 zval **data;
683 if (ht_find (ht, ind, &data) == SUCCESS)
685 assert (data != NULL);
686 return data;
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);
696 return data;
700 // Like extract_ht_ex, but for objects
701 static HashTable *
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)
708 assert (0);
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
717 assert (0);
719 return Z_OBJPROP_P (obj);
722 // Like extract_ht, but for objects
723 static HashTable *
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
732 static zval **
733 get_field (zval ** p_var, char *ind TSRMLS_DC)
735 if (Z_TYPE_P (*p_var) != IS_OBJECT)
737 // TODO: implement initialization
738 assert (0);
741 HashTable *ht = extract_field (p_var TSRMLS_CC);
743 zval **data;
744 if (zend_symtable_find (ht, ind, strlen (ind) + 1, (void **) &data) ==
745 SUCCESS)
747 assert (data != NULL);
748 return data;
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 *),
756 (void **) &data);
758 assert (data != NULL);
760 return data;
763 void
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))
769 *result = array;
770 return;
773 // Since we know its an array, and we dont write to it, we dont need
774 // to separate it.
775 HashTable *ht = Z_ARRVAL_P (array);
777 // find the result
778 zval **p_result;
779 if (ht_find (ht, ind, &p_result) == SUCCESS)
781 *result = *p_result;
782 return;
785 *result = EG (uninitialized_zval_ptr);
788 /* If its not an array, convert it into an array. */
789 static void
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);
802 else
803 // Refs are just replaced
804 zval_dtor (*p_var);
806 array_init (*p_var);
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. */
817 static void
818 check_object_type (zval ** p_var TSRMLS_DC)
820 // TODO: implement
823 /* Push EG (uninitialized_zval_ptr) and return a pointer into the ht
824 * for it */
826 * Converted to array automatically:
827 * ""
828 * NULL
829 * false
831 * Warning, no conversion:
832 * ints
833 * floats
834 * true
836 * Error, no conversion:
837 * strings other than ""
839 // TODO: objects, resources, etc
840 static zval **
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");
857 return NULL;
860 if (Z_TYPE_P (*p_var) != IS_ARRAY)
862 zval_ptr_dtor (p_var);
863 ALLOC_INIT_ZVAL (*p_var);
864 array_init (*p_var);
867 // if its not an array, make it an array
868 HashTable *ht = extract_ht (p_var TSRMLS_CC);
869 zval **data;
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);
876 assert (data);
878 return data;
883 * isset
885 static int
886 isset_var (HashTable * st, char *name, int length)
888 return zend_hash_exists (st, name, length);
891 static int
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);
902 return result;
905 // NO error required; return false
906 if (Z_TYPE_P (*p_var) != IS_ARRAY)
907 return 0;
909 // if its not an array, make it an array
910 HashTable *ht = Z_ARRVAL_P (*p_var);
912 zval **data;
913 if (ht_find (ht, ind, &data) == SUCCESS)
915 return !ZVAL_IS_NULL (*data);
917 else
918 return 0;
922 static zval **
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
937 // seperated above).
938 (*p_arg)->is_ref = 1;
940 return p_arg;
943 /* Dont pass-by-ref */
944 static zval *
945 fetch_var_arg (zval * arg, int *is_arg_new)
947 if (arg->is_ref)
949 // We dont separate since we don't own one of ARG's references.
950 arg = zvp_clone_ex (arg);
951 *is_arg_new = 1;
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
956 // this.
958 arg->refcount--;
960 return arg;
963 // TODO dont overwrite line numbers if we're compiling an extension
964 static void
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;
973 if (init)
975 if (filename == NULL)
976 filename = "[phc_compiled_file]";
977 // Save old values
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;
983 // Put in our values
984 CG (in_compilation) = 1;
985 EG (in_execution) = 1;
986 CG (compiled_filename) = filename;
987 CG (zend_lineno) = line_number;
988 if (function)
989 EG (function_state_ptr)->function = function;
991 else
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;
1001 static void
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)
1007 return;
1009 zval fn;
1010 INIT_PZVAL (&fn);
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.
1030 static void
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)
1036 return;
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,
1061 function_name,
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.
1078 static int
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)
1084 return;
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);
1112 // vi:set ts=8:
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.
1120 zval *
1121 persistent_clone (zval * in, int destroy_in TSRMLS_DC)
1123 zval *out = pemalloc (sizeof (zval), 1);
1124 *out = *in;
1126 switch (Z_TYPE_P (in))
1128 case IS_NULL:
1129 case IS_LONG:
1130 case IS_DOUBLE:
1131 case IS_BOOL:
1132 /* nothing more to be done */
1133 break;
1134 case IS_STRING:
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);
1137 break;
1138 case IS_ARRAY:
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))
1149 char *key;
1150 uint keylen;
1151 ulong idx;
1152 int type;
1153 zval **old_elem, *new_elem;
1155 type =
1156 zend_hash_get_current_key_ex (old_arr, &key, &keylen, &idx, 0,
1157 NULL);
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 *),
1165 NULL);
1166 else
1167 zend_hash_index_update (new_arr, idx, &new_elem,
1168 sizeof (zval *), NULL);
1172 Z_ARRVAL_P (out) = new_arr;
1174 break;
1175 default:
1176 /* other types are not supported */
1177 assert (0);
1180 zval_ptr_dtor (&in);
1181 return out;
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
1197 static int
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;
1213 return SUCCESS;
1216 // vi:set ts=8:
1219 static void
1220 cast_var (zval ** p_zvp, int type)
1222 assert (type >= 0 && type <= 6);
1223 if ((*p_zvp)->type == type)
1224 return;
1226 sep_copy_on_write (p_zvp);
1227 zval *zvp = *p_zvp;
1229 switch (type)
1231 case IS_NULL:
1232 convert_to_null (zvp);
1233 break;
1234 case IS_BOOL:
1235 convert_to_boolean (zvp);
1236 break;
1237 case IS_LONG:
1238 convert_to_long (zvp);
1239 break;
1240 case IS_DOUBLE:
1241 convert_to_double (zvp);
1242 break;
1243 case IS_STRING:
1244 convert_to_string (zvp);
1245 break;
1246 case IS_ARRAY:
1247 convert_to_array (zvp);
1248 break;
1249 case IS_OBJECT:
1250 convert_to_object (zvp);
1251 break;
1252 default:
1253 assert (0); // TODO unimplemented
1254 break;
1258 /* Copies a constant into ZVP. Note that LENGTH does not include the NULL-terminating byte. */
1259 static void
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);
1265 if (result == 0)
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.
1276 static void
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);
1287 static int
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");
1294 return 0;
1297 return 1;
1303 * unset
1306 static void
1307 unset_var (HashTable * st, char *name, int length)
1309 zend_hash_del (st, name, length);
1312 static void
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");
1329 return;
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
1352 * value.
1354 zval*
1355 get_string_val (zval* zvp)
1357 if (Z_TYPE_P (zvp) == IS_STRING)
1359 zvp->refcount++;
1360 return zvp;
1362 else
1364 zval* clone = zvp_clone_ex (zvp);
1365 convert_to_string (clone);
1366 return clone;
1370 zval **
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);
1380 return result;
1384 * Read the variable described by var_var from symbol table st
1385 * See comments for get_var_var
1387 zval *
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);
1397 return result;
1400 static void
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);
1421 else
1423 zend_eval_string (Z_STRVAL_P (copy), NULL, "eval'd code" TSRMLS_CC);
1426 // cleanup
1427 assert (copy->refcount == 1);
1428 zval_ptr_dtor (&copy);
1431 static void
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);
1436 else
1437 zend_print_variable (arg);
1439 zend_bailout ();
1442 static void
1443 phc_builtin_die (zval * arg, zval ** p_result, char *filename TSRMLS_DC)
1445 phc_builtin_exit (arg, p_result, filename TSRMLS_CC);
1448 static void
1449 phc_builtin_echo (zval * arg, zval ** p_result TSRMLS_DC)
1451 assert (*p_result == NULL);
1452 zend_print_variable (arg);
1455 static void
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);
1461 if (*p_result)
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
1467 static void
1468 phc_builtin_empty (zval * arg, zval ** p_result, char *filename TSRMLS_DC)
1470 assert (*p_result);
1471 ZVAL_BOOL (*p_result, !zend_is_true (arg));
1474 // For require, include, require_once and include_once.
1476 // Include:
1477 // return 1 for success
1478 // Warning, and return false for failure
1479 // Require:
1480 // return 1 for success
1481 // Fail for failure
1482 // Include_once
1483 // Return true if already included
1484 // Return 1 for success
1485 // Warning and return false for failure
1486 // Require_once:
1487 // Return true if already included
1488 // return 1 for success
1489 // Fail for failure
1491 static void
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;
1517 zend_function zf;
1519 // Check the _ONCE varieties (based on zend_vm_def.h)
1520 if (is_once)
1522 if (IS_ABSOLUTE_PATH (Z_STRVAL_P (arg_file), Z_STRLEN_P (arg_file)))
1524 // Get the proper path name for require
1525 cwd_state state;
1527 state.cwd_length = 0;
1528 state.cwd = malloc(1);
1529 state.cwd[0] = 0;
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);
1534 free (state.cwd);
1536 if (!success)
1537 goto cleanup;
1542 // Compile the file
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);
1548 // Stop pretending
1549 EG (in_execution) = 0;
1550 EG (active_op_array) = NULL;
1552 if (success != SUCCESS)
1553 goto fail;
1556 if (is_once)
1558 // Check it hadnt been included already
1559 int once_success = zend_hash_add_empty_element(&EG(included_files),
1560 handle.opened_path,
1561 strlen (handle.opened_path)+1);
1562 // Return true
1563 if (once_success != SUCCESS)
1565 ZVAL_BOOL (*p_result, 1);
1566 goto cleanup;
1570 if (!handle.opened_path)
1571 handle.opened_path = estrndup (Z_STRVAL_P(arg_file), Z_STRLEN_P (arg_file));
1573 // run it
1574 success = zend_execute_scripts (type TSRMLS_CC, p_result, 1, &handle);
1575 assert (success == SUCCESS);
1576 zend_stream_close (&handle);
1578 // Success
1579 if (*p_result)
1580 ZVAL_LONG (*p_result, 1);
1583 goto cleanup;
1586 fail:
1588 php_error_docref (error_function
1589 TSRMLS_CC,
1590 (type == ZEND_INCLUDE) ? E_WARNING : E_ERROR,
1591 error,
1592 php_strip_url_passwd (Z_STRVAL_P (arg_file)),
1593 STR_PRINT (PG (include_path)));
1596 // Failure
1597 if (*p_result)
1598 ZVAL_BOOL (*p_result, 0);
1600 cleanup:
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);
1611 static void
1612 phc_builtin_include (zval * arg, zval ** p_result, char *filename TSRMLS_DC)
1614 include_backend ( arg,
1615 p_result,
1616 filename,
1617 ZEND_INCLUDE,
1619 "Failed opening '%s' for inclusion (include_path='%s')",
1620 "function.include"
1621 TSRMLS_CC);
1624 static void
1625 phc_builtin_require (zval * arg, zval ** p_result, char *filename TSRMLS_DC)
1627 include_backend ( arg,
1628 p_result,
1629 filename,
1630 ZEND_REQUIRE,
1632 "Failed opening required '%s' (include_path='%s')",
1633 "function.require"
1634 TSRMLS_CC);
1637 static void
1638 phc_builtin_include_once (zval * arg, zval ** p_result, char *filename TSRMLS_DC)
1640 include_backend ( arg,
1641 p_result,
1642 filename,
1643 ZEND_INCLUDE,
1645 "Failed opening '%s' for inclusion (include_path='%s')",
1646 "function.include_once"
1647 TSRMLS_CC);
1650 static void
1651 phc_builtin_require_once (zval * arg, zval ** p_result, char *filename TSRMLS_DC)
1653 include_backend ( arg,
1654 p_result,
1655 filename,
1656 ZEND_REQUIRE,
1658 "Failed opening required '%s' (include_path='%s')",
1659 "function.require_once"
1660 TSRMLS_CC);
1663 // END INCLUDED FILES
1664 int saved_refcount;
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};
1699 // class MWTidy
1700 // {
1701 // public static function tidy($text)
1702 // {
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);
1708 // $TLE14 = ' ';
1709 // $TLE15 = '&#9;';
1710 // $wrappedtext = str_replace($TLE14, $TLE15, $wrappedtext);
1711 // if (wgTidyInternal) goto L107 else goto L108;
1712 // L107:
1713 // $correctedtext = mwtidy::execinternaltidy($wrappedtext);
1714 // goto L109;
1715 // L108:
1716 // $correctedtext = mwtidy::execexternaltidy($wrappedtext);
1717 // goto L109;
1718 // L109:
1719 // $TLE16 = is_null($correctedtext);
1720 // if (TLE16) goto L110 else goto L111;
1721 // L110:
1722 // $TLE17 = 'Tidy error detected!
1723 // ';
1724 // wfdebug($TLE17);
1725 // $TLE18 = '
1726 // <!-- Tidy found serious XHTML errors -->
1727 // ';
1728 // $TLE19 = ($text . $TLE18);
1729 // return $TLE19;
1730 // goto L112;
1731 // L111:
1732 // goto L112;
1733 // L112:
1734 // $TLE20 = '&#9;';
1735 // $TLE21 = ' ';
1736 // $correctedtext = str_replace($TLE20, $TLE21, $correctedtext);
1737 // return $correctedtext;
1738 // }
1739 // public static function checkerrors($text, &$errorStr = NULL)
1740 // {
1741 // global $wgTidyInternal;
1742 // $retval = 0;
1743 // if (wgTidyInternal) goto L113 else goto L114;
1744 // L113:
1745 // $TLE22 = True;
1746 // $errorStr = mwtidy::execinternaltidy($text, $TLE22, $retval);
1747 // goto L115;
1748 // L114:
1749 // $TLE23 = True;
1750 // $errorStr = mwtidy::execexternaltidy($text, $TLE23, $retval);
1751 // goto L115;
1752 // L115:
1753 // $TLE24 = 0;
1754 // $TLE0 = ($retval < $TLE24);
1755 // if (TLE0) goto L116 else goto L117;
1756 // L116:
1757 // $TLE25 = '';
1758 // $TEF1 = ($errorStr == $TLE25);
1759 // goto L118;
1760 // L117:
1761 // $TEF1 = $TLE0;
1762 // goto L118;
1763 // L118:
1764 // $TLE2 = (bool) $TEF1;
1765 // if (TLE2) goto L119 else goto L120;
1766 // L119:
1767 // $TEF3 = $TLE2;
1768 // goto L121;
1769 // L120:
1770 // $TLE26 = 0;
1771 // $TEF3 = ($retval == $TLE26);
1772 // goto L121;
1773 // L121:
1774 // $TLE27 = (bool) $TEF3;
1775 // return $TLE27;
1776 // }
1777 // private static function execexternaltidy($text, $stderr = False, &$retval = NULL)
1778 // {
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;
1787 // L122:
1788 // $TLE29 = 0;
1789 // $TLE30 = 'pipe';
1790 // $TLE31 = 'r';
1791 // unset($TSa32);
1792 // $TSa32 = (array) $TSa32;
1793 // $TSa32[] = $TLE30;
1794 // $TSa32[] = $TLE31;
1795 // $TLE33 = 1;
1796 // $TLE34 = 'file';
1797 // $TLE35 = wfgetnull();
1798 // $TLE36 = 'a';
1799 // unset($TSa37);
1800 // $TSa37 = (array) $TSa37;
1801 // $TSa37[] = $TLE34;
1802 // $TSa37[] = $TLE35;
1803 // $TSa37[] = $TLE36;
1804 // $TLE38 = 2;
1805 // $TLE39 = 'pipe';
1806 // $TLE40 = 'w';
1807 // unset($TSa41);
1808 // $TSa41 = (array) $TSa41;
1809 // $TSa41[] = $TLE39;
1810 // $TSa41[] = $TLE40;
1811 // unset($TSa42);
1812 // $TSa42 = (array) $TSa42;
1813 // $TSa42[$TLE29] = $TSa32;
1814 // $TSa42[$TLE33] = $TSa37;
1815 // $TSa42[$TLE38] = $TSa41;
1816 // $descriptorspec = $TSa42;
1817 // goto L124;
1818 // L123:
1819 // $TLE43 = 0;
1820 // $TLE44 = 'pipe';
1821 // $TLE45 = 'r';
1822 // unset($TSa46);
1823 // $TSa46 = (array) $TSa46;
1824 // $TSa46[] = $TLE44;
1825 // $TSa46[] = $TLE45;
1826 // $TLE47 = 1;
1827 // $TLE48 = 'pipe';
1828 // $TLE49 = 'w';
1829 // unset($TSa50);
1830 // $TSa50 = (array) $TSa50;
1831 // $TSa50[] = $TLE48;
1832 // $TSa50[] = $TLE49;
1833 // $TLE51 = 2;
1834 // $TLE52 = 'file';
1835 // $TLE53 = wfgetnull();
1836 // $TLE54 = 'a';
1837 // unset($TSa55);
1838 // $TSa55 = (array) $TSa55;
1839 // $TSa55[] = $TLE52;
1840 // $TSa55[] = $TLE53;
1841 // $TSa55[] = $TLE54;
1842 // unset($TSa56);
1843 // $TSa56 = (array) $TSa56;
1844 // $TSa56[$TLE43] = $TSa46;
1845 // $TSa56[$TLE47] = $TSa50;
1846 // $TSa56[$TLE51] = $TSa55;
1847 // $descriptorspec = $TSa56;
1848 // goto L124;
1849 // L124:
1850 // if (stderr) goto L125 else goto L126;
1851 // L125:
1852 // $TEF4 = 2;
1853 // goto L127;
1854 // L126:
1855 // $TEF4 = 1;
1856 // goto L127;
1857 // L127:
1858 // $readpipe = $TEF4;
1859 // unset($TSa57);
1860 // $TSa57 = (array) $TSa57;
1861 // $pipes = $TSa57;
1862 // $TLE58 = 'proc_open';
1863 // $TLE59 = function_exists($TLE58);
1864 // if (TLE59) goto L151 else goto L152;
1865 // L151:
1866 // $TLE60 = ' -config ';
1867 // $TLE61 = ($wgTidyBin . $TLE60);
1868 // $TLE62 = ($TLE61 . $wgTidyConf);
1869 // $TLE63 = ' ';
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;
1876 // L148:
1877 // $TLE68 = 0;
1878 // $TLE96 = param_is_ref (NULL, "fwrite", 0);
1879 // ;
1880 // if (TLE96) goto L128 else goto L129;
1881 // L128:
1882 // $TMIi95 =& $pipes[$TLE68];
1883 // goto L130;
1884 // L129:
1885 // $TMIi95 = $pipes[$TLE68];
1886 // goto L130;
1887 // L130:
1888 // fwrite($TMIi95, $text);
1889 // $TLE69 = 0;
1890 // $TLE98 = param_is_ref (NULL, "fclose", 0);
1891 // ;
1892 // if (TLE98) goto L131 else goto L132;
1893 // L131:
1894 // $TMIi97 =& $pipes[$TLE69];
1895 // goto L133;
1896 // L132:
1897 // $TMIi97 = $pipes[$TLE69];
1898 // goto L133;
1899 // L133:
1900 // fclose($TMIi97);
1901 // L144:
1902 // $TLE100 = param_is_ref (NULL, "feof", 0);
1903 // ;
1904 // if (TLE100) goto L134 else goto L135;
1905 // L134:
1906 // $TMIi99 =& $pipes[$readpipe];
1907 // goto L136;
1908 // L135:
1909 // $TMIi99 = $pipes[$readpipe];
1910 // goto L136;
1911 // L136:
1912 // $TLE70 = feof($TMIi99);
1913 // $TLE71 = !$TLE70;
1914 // $TLE72 = !$TLE71;
1915 // if (TLE72) goto L138 else goto L139;
1916 // L138:
1917 // goto L137;
1918 // goto L140;
1919 // L139:
1920 // goto L140;
1921 // L140:
1922 // $TLE73 = 1024;
1923 // $TLE102 = param_is_ref (NULL, "fgets", 0);
1924 // ;
1925 // if (TLE102) goto L141 else goto L142;
1926 // L141:
1927 // $TMIi101 =& $pipes[$readpipe];
1928 // goto L143;
1929 // L142:
1930 // $TMIi101 = $pipes[$readpipe];
1931 // goto L143;
1932 // L143:
1933 // $TLE74 = fgets($TMIi101, $TLE73);
1934 // $cleansource = ($cleansource . $TLE74);
1935 // goto L144;
1936 // L137:
1937 // $TLE104 = param_is_ref (NULL, "fclose", 0);
1938 // ;
1939 // if (TLE104) goto L145 else goto L146;
1940 // L145:
1941 // $TMIi103 =& $pipes[$readpipe];
1942 // goto L147;
1943 // L146:
1944 // $TMIi103 = $pipes[$readpipe];
1945 // goto L147;
1946 // L147:
1947 // fclose($TMIi103);
1948 // $retval = proc_close($process);
1949 // goto L150;
1950 // L149:
1951 // $retval = -1;
1952 // goto L150;
1953 // L150:
1954 // goto L153;
1955 // L152:
1956 // $retval = -1;
1957 // goto L153;
1958 // L153:
1959 // $TLE75 = 'MWTidy::execExternalTidy';
1960 // wfprofileout($TLE75);
1961 // $TLE5 = !$stderr;
1962 // if (TLE5) goto L154 else goto L155;
1963 // L154:
1964 // $TLE76 = '';
1965 // $TEF6 = ($cleansource == $TLE76);
1966 // goto L156;
1967 // L155:
1968 // $TEF6 = $TLE5;
1969 // goto L156;
1970 // L156:
1971 // $TLE7 = (bool) $TEF6;
1972 // if (TLE7) goto L157 else goto L158;
1973 // L157:
1974 // $TLE77 = '';
1975 // $TEF8 = ($text != $TLE77);
1976 // goto L159;
1977 // L158:
1978 // $TEF8 = $TLE7;
1979 // goto L159;
1980 // L159:
1981 // $TLE78 = (bool) $TEF8;
1982 // if (TLE78) goto L160 else goto L161;
1983 // L160:
1984 // $TLE79 = NULL;
1985 // return $TLE79;
1986 // goto L162;
1987 // L161:
1988 // return $cleansource;
1989 // goto L162;
1990 // L162:
1991 // }
1992 // private static function execinternaltidy($text, $stderr = False, &$retval = NULL)
1993 // {
1994 // global $wgTidyConf;
1995 // global $IP;
1996 // global $wgDebugTidy;
1997 // $TLE80 = 'MWTidy::execInternalTidy';
1998 // wfprofilein($TLE80);
1999 // $tidy = new tidy();
2000 // $TLE81 = 'utf8';
2001 // $tidy->parsestring($text, $wgTidyConf, $TLE81);
2002 // if (stderr) goto L175 else goto L176;
2003 // L175:
2004 // $retval = $tidy->getstatus();
2005 // $TSt82 = $tidy->errorBuffer;
2006 // return $TSt82;
2007 // goto L177;
2008 // L176:
2009 // $tidy->cleanrepair();
2010 // $retval = $tidy->getstatus();
2011 // $TLE83 = 2;
2012 // $TLE84 = ($retval == $TLE83);
2013 // if (TLE84) goto L163 else goto L164;
2014 // L163:
2015 // $cleansource = NULL;
2016 // goto L165;
2017 // L164:
2018 // $cleansource = tidy_get_output($tidy);
2019 // goto L165;
2020 // L165:
2021 // $TLE9 = $wgDebugTidy;
2022 // if (TLE9) goto L166 else goto L167;
2023 // L166:
2024 // $TLE85 = 0;
2025 // $TEF10 = ($TLE85 < $retval);
2026 // goto L168;
2027 // L167:
2028 // $TEF10 = $TLE9;
2029 // goto L168;
2030 // L168:
2031 // $TLE86 = (bool) $TEF10;
2032 // if (TLE86) goto L172 else goto L173;
2033 // L172:
2034 // $TLE87 = '<!--
2035 // Tidy reports:
2036 // ';
2037 // $TLE88 = '-->';
2038 // $TLE89 = '--&gt;';
2039 // $TLE106 = param_is_ref (NULL, "str_replace", 0);
2040 // ;
2041 // if (TLE106) goto L169 else goto L170;
2042 // L169:
2043 // $TMIt105 =& $tidy->errorBuffer;
2044 // goto L171;
2045 // L170:
2046 // $TMIt105 = $tidy->errorBuffer;
2047 // goto L171;
2048 // L171:
2049 // $TLE90 = str_replace($TLE88, $TLE89, $TMIt105);
2050 // $TLE91 = ($TLE87 . $TLE90);
2051 // $TLE92 = '
2052 // -->';
2053 // $TLE93 = ($TLE91 . $TLE92);
2054 // $cleansource = ($cleansource . $TLE93);
2055 // goto L174;
2056 // L173:
2057 // goto L174;
2058 // L174:
2059 // $TLE94 = 'MWTidy::execInternalTidy';
2060 // wfprofileout($TLE94);
2061 // return $cleansource;
2062 // goto L177;
2063 // L177:
2064 // }
2065 // }
2066 // public static function tidy($text)
2067 // {
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);
2073 // $TLE14 = ' ';
2074 // $TLE15 = '&#9;';
2075 // $wrappedtext = str_replace($TLE14, $TLE15, $wrappedtext);
2076 // if (wgTidyInternal) goto L107 else goto L108;
2077 // L107:
2078 // $correctedtext = mwtidy::execinternaltidy($wrappedtext);
2079 // goto L109;
2080 // L108:
2081 // $correctedtext = mwtidy::execexternaltidy($wrappedtext);
2082 // goto L109;
2083 // L109:
2084 // $TLE16 = is_null($correctedtext);
2085 // if (TLE16) goto L110 else goto L111;
2086 // L110:
2087 // $TLE17 = 'Tidy error detected!
2088 // ';
2089 // wfdebug($TLE17);
2090 // $TLE18 = '
2091 // <!-- Tidy found serious XHTML errors -->
2092 // ';
2093 // $TLE19 = ($text . $TLE18);
2094 // return $TLE19;
2095 // goto L112;
2096 // L111:
2097 // goto L112;
2098 // L112:
2099 // $TLE20 = '&#9;';
2100 // $TLE21 = ' ';
2101 // $correctedtext = str_replace($TLE20, $TLE21, $correctedtext);
2102 // return $correctedtext;
2103 // }
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 ();
2124 zval* params[1];
2125 zend_get_parameters_array(0, num_args, params);
2126 // param 0
2127 params[0]->refcount++;
2128 if (local_text != NULL)
2130 zval_ptr_dtor (&local_text);
2132 local_text = params[0];
2134 // Function body
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;
2159 zval* value;
2160 if ((*p_lhs)->is_ref)
2162 // Always overwrite the current value
2163 value = *p_lhs;
2164 zval_dtor (value);
2166 else
2168 ALLOC_INIT_ZVAL (value);
2169 zval_ptr_dtor (p_lhs);
2170 *p_lhs = value;
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;
2186 zval* left;
2187 if (local_TLE11 == NULL)
2188 left = EG (uninitialized_zval_ptr);
2189 else
2190 left = local_TLE11;
2192 zval* right;
2193 if (local_text == NULL)
2194 right = EG (uninitialized_zval_ptr);
2195 else
2196 right = local_text;
2198 if (in_copy_on_write (*p_lhs))
2200 zval_ptr_dtor (p_lhs);
2201 ALLOC_INIT_ZVAL (*p_lhs);
2204 zval old = **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)
2211 zval_dtor (&old);
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;
2223 zval* value;
2224 if ((*p_lhs)->is_ref)
2226 // Always overwrite the current value
2227 value = *p_lhs;
2228 zval_dtor (value);
2230 else
2232 ALLOC_INIT_ZVAL (value);
2233 zval_ptr_dtor (p_lhs);
2234 *p_lhs = value;
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;
2250 zval* left;
2251 if (local_TLE12 == NULL)
2252 left = EG (uninitialized_zval_ptr);
2253 else
2254 left = local_TLE12;
2256 zval* right;
2257 if (local_TLE13 == NULL)
2258 right = EG (uninitialized_zval_ptr);
2259 else
2260 right = local_TLE13;
2262 if (in_copy_on_write (*p_lhs))
2264 zval_ptr_dtor (p_lhs);
2265 ALLOC_INIT_ZVAL (*p_lhs);
2268 zval old = **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)
2275 zval_dtor (&old);
2276 phc_check_invariants (TSRMLS_C);
2278 // $TLE14 = ' ';
2280 if (local_TLE14 == NULL)
2282 local_TLE14 = EG (uninitialized_zval_ptr);
2283 local_TLE14->refcount++;
2285 zval** p_lhs = &local_TLE14;
2287 zval* value;
2288 if ((*p_lhs)->is_ref)
2290 // Always overwrite the current value
2291 value = *p_lhs;
2292 zval_dtor (value);
2294 else
2296 ALLOC_INIT_ZVAL (value);
2297 zval_ptr_dtor (p_lhs);
2298 *p_lhs = value;
2301 ZVAL_STRINGL(value, "\011", 1, 1);
2303 phc_check_invariants (TSRMLS_C);
2305 // $TLE15 = '&#9;';
2307 if (local_TLE15 == NULL)
2309 local_TLE15 = EG (uninitialized_zval_ptr);
2310 local_TLE15->refcount++;
2312 zval** p_lhs = &local_TLE15;
2314 zval* value;
2315 if ((*p_lhs)->is_ref)
2317 // Always overwrite the current value
2318 value = *p_lhs;
2319 zval_dtor (value);
2321 else
2323 ALLOC_INIT_ZVAL (value);
2324 zval_ptr_dtor (p_lhs);
2325 *p_lhs = value;
2328 ZVAL_STRINGL(value, "&#9;", 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
2338 int by_ref[3];
2339 int abr_index = 0;
2340 // TODO: find names to replace index
2341 if (arg_info)
2343 by_ref[abr_index] = arg_info->pass_by_reference;
2344 arg_info++;
2346 else
2347 by_ref[abr_index] = signature->common.pass_rest_by_reference;
2349 abr_index++;
2350 // TODO: find names to replace index
2351 if (arg_info)
2353 by_ref[abr_index] = arg_info->pass_by_reference;
2354 arg_info++;
2356 else
2357 by_ref[abr_index] = signature->common.pass_rest_by_reference;
2359 abr_index++;
2360 // TODO: find names to replace index
2361 if (arg_info)
2363 by_ref[abr_index] = arg_info->pass_by_reference;
2364 arg_info++;
2366 else
2367 by_ref[abr_index] = signature->common.pass_rest_by_reference;
2369 abr_index++;
2372 // Setup array of arguments
2373 // TODO: i think arrays of size 0 is an error
2374 int destruct [3];
2375 zval* args [3];
2376 zval** args_ind [3];
2378 int af_index = 0;
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];
2393 else
2395 zval* arg;
2396 if (local_TLE14 == NULL)
2397 arg = EG (uninitialized_zval_ptr);
2398 else
2399 arg = local_TLE14;
2401 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
2402 args_ind[af_index] = &args[af_index];
2404 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];
2419 else
2421 zval* arg;
2422 if (local_TLE15 == NULL)
2423 arg = EG (uninitialized_zval_ptr);
2424 else
2425 arg = local_TLE15;
2427 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
2428 args_ind[af_index] = &args[af_index];
2430 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];
2445 else
2447 zval* arg;
2448 if (local_wrappedtext == NULL)
2449 arg = EG (uninitialized_zval_ptr);
2450 else
2451 arg = local_wrappedtext;
2453 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
2454 args_ind[af_index] = &args[af_index];
2456 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;
2466 zval* rhs = NULL;
2468 // set up params
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);
2477 // restore params
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;
2482 // unset the errors
2483 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
2485 int i;
2486 for (i = 0; i < 3; i++)
2488 if (destruct[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));
2517 rhs->is_ref = 1;
2518 if (saved_refcount != 0)
2520 rhs->refcount = saved_refcount;
2522 rhs->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;
2544 zval* p_cond;
2545 if (local_wgTidyInternal == NULL)
2546 p_cond = EG (uninitialized_zval_ptr);
2547 else
2548 p_cond = local_wgTidyInternal;
2550 zend_bool bcond = zend_is_true (p_cond);
2551 if (bcond)
2552 goto L107;
2553 else
2554 goto L108;
2555 phc_check_invariants (TSRMLS_C);
2557 // L107:
2558 L107:;
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
2565 int by_ref[1];
2566 int abr_index = 0;
2567 // TODO: find names to replace index
2568 if (arg_info)
2570 by_ref[abr_index] = arg_info->pass_by_reference;
2571 arg_info++;
2573 else
2574 by_ref[abr_index] = signature->common.pass_rest_by_reference;
2576 abr_index++;
2579 // Setup array of arguments
2580 // TODO: i think arrays of size 0 is an error
2581 int destruct [1];
2582 zval* args [1];
2583 zval** args_ind [1];
2585 int af_index = 0;
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];
2600 else
2602 zval* arg;
2603 if (local_wrappedtext == NULL)
2604 arg = EG (uninitialized_zval_ptr);
2605 else
2606 arg = local_wrappedtext;
2608 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
2609 args_ind[af_index] = &args[af_index];
2611 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;
2621 zval* rhs = NULL;
2623 // set up params
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);
2632 // restore params
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;
2637 // unset the errors
2638 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
2640 int i;
2641 for (i = 0; i < 1; i++)
2643 if (destruct[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));
2672 rhs->is_ref = 1;
2673 if (saved_refcount != 0)
2675 rhs->refcount = saved_refcount;
2677 rhs->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);
2697 // goto L109;
2699 goto L109;
2700 phc_check_invariants (TSRMLS_C);
2702 // L108:
2703 L108:;
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
2710 int by_ref[1];
2711 int abr_index = 0;
2712 // TODO: find names to replace index
2713 if (arg_info)
2715 by_ref[abr_index] = arg_info->pass_by_reference;
2716 arg_info++;
2718 else
2719 by_ref[abr_index] = signature->common.pass_rest_by_reference;
2721 abr_index++;
2724 // Setup array of arguments
2725 // TODO: i think arrays of size 0 is an error
2726 int destruct [1];
2727 zval* args [1];
2728 zval** args_ind [1];
2730 int af_index = 0;
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];
2745 else
2747 zval* arg;
2748 if (local_wrappedtext == NULL)
2749 arg = EG (uninitialized_zval_ptr);
2750 else
2751 arg = local_wrappedtext;
2753 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
2754 args_ind[af_index] = &args[af_index];
2756 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;
2766 zval* rhs = NULL;
2768 // set up params
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);
2777 // restore params
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;
2782 // unset the errors
2783 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
2785 int i;
2786 for (i = 0; i < 1; i++)
2788 if (destruct[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));
2817 rhs->is_ref = 1;
2818 if (saved_refcount != 0)
2820 rhs->refcount = saved_refcount;
2822 rhs->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);
2842 // goto L109;
2844 goto L109;
2845 phc_check_invariants (TSRMLS_C);
2847 // L109:
2848 L109:;
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
2855 int by_ref[1];
2856 int abr_index = 0;
2857 // TODO: find names to replace index
2858 if (arg_info)
2860 by_ref[abr_index] = arg_info->pass_by_reference;
2861 arg_info++;
2863 else
2864 by_ref[abr_index] = signature->common.pass_rest_by_reference;
2866 abr_index++;
2869 // Setup array of arguments
2870 // TODO: i think arrays of size 0 is an error
2871 int destruct [1];
2872 zval* args [1];
2873 zval** args_ind [1];
2875 int af_index = 0;
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];
2890 else
2892 zval* arg;
2893 if (local_correctedtext == NULL)
2894 arg = EG (uninitialized_zval_ptr);
2895 else
2896 arg = local_correctedtext;
2898 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
2899 args_ind[af_index] = &args[af_index];
2901 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;
2911 zval* rhs = NULL;
2913 // set up params
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);
2922 // restore params
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;
2927 // unset the errors
2928 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
2930 int i;
2931 for (i = 0; i < 1; i++)
2933 if (destruct[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));
2962 rhs->is_ref = 1;
2963 if (saved_refcount != 0)
2965 rhs->refcount = saved_refcount;
2967 rhs->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;
2989 zval* p_cond;
2990 if (local_TLE16 == NULL)
2991 p_cond = EG (uninitialized_zval_ptr);
2992 else
2993 p_cond = local_TLE16;
2995 zend_bool bcond = zend_is_true (p_cond);
2996 if (bcond)
2997 goto L110;
2998 else
2999 goto L111;
3000 phc_check_invariants (TSRMLS_C);
3002 // L110:
3003 L110:;
3004 // $TLE17 = 'Tidy error detected!
3005 // ';
3007 if (local_TLE17 == NULL)
3009 local_TLE17 = EG (uninitialized_zval_ptr);
3010 local_TLE17->refcount++;
3012 zval** p_lhs = &local_TLE17;
3014 zval* value;
3015 if ((*p_lhs)->is_ref)
3017 // Always overwrite the current value
3018 value = *p_lhs;
3019 zval_dtor (value);
3021 else
3023 ALLOC_INIT_ZVAL (value);
3024 zval_ptr_dtor (p_lhs);
3025 *p_lhs = value;
3028 ZVAL_STRINGL(value, "Tidy error detected!\012", 21, 1);
3030 phc_check_invariants (TSRMLS_C);
3032 // wfdebug($TLE17);
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
3038 int by_ref[1];
3039 int abr_index = 0;
3040 // TODO: find names to replace index
3041 if (arg_info)
3043 by_ref[abr_index] = arg_info->pass_by_reference;
3044 arg_info++;
3046 else
3047 by_ref[abr_index] = signature->common.pass_rest_by_reference;
3049 abr_index++;
3052 // Setup array of arguments
3053 // TODO: i think arrays of size 0 is an error
3054 int destruct [1];
3055 zval* args [1];
3056 zval** args_ind [1];
3058 int af_index = 0;
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];
3073 else
3075 zval* arg;
3076 if (local_TLE17 == NULL)
3077 arg = EG (uninitialized_zval_ptr);
3078 else
3079 arg = local_TLE17;
3081 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
3082 args_ind[af_index] = &args[af_index];
3084 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;
3094 zval* rhs = NULL;
3096 // set up params
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);
3105 // restore params
3106 wfdebug_fci.params = params_save;
3107 wfdebug_fci.param_count = param_count_save;
3108 wfdebug_fci.retval_ptr_ptr = retval_save;
3110 // unset the errors
3111 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
3113 int i;
3114 for (i = 0; i < 1; i++)
3116 if (destruct[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));
3145 rhs->is_ref = 1;
3146 if (saved_refcount != 0)
3148 rhs->refcount = saved_refcount;
3150 rhs->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);
3162 // $TLE18 = '
3163 // <!-- Tidy found serious XHTML errors -->
3164 // ';
3166 if (local_TLE18 == NULL)
3168 local_TLE18 = EG (uninitialized_zval_ptr);
3169 local_TLE18->refcount++;
3171 zval** p_lhs = &local_TLE18;
3173 zval* value;
3174 if ((*p_lhs)->is_ref)
3176 // Always overwrite the current value
3177 value = *p_lhs;
3178 zval_dtor (value);
3180 else
3182 ALLOC_INIT_ZVAL (value);
3183 zval_ptr_dtor (p_lhs);
3184 *p_lhs = value;
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;
3200 zval* left;
3201 if (local_text == NULL)
3202 left = EG (uninitialized_zval_ptr);
3203 else
3204 left = local_text;
3206 zval* right;
3207 if (local_TLE18 == NULL)
3208 right = EG (uninitialized_zval_ptr);
3209 else
3210 right = local_TLE18;
3212 if (in_copy_on_write (*p_lhs))
3214 zval_ptr_dtor (p_lhs);
3215 ALLOC_INIT_ZVAL (*p_lhs);
3218 zval old = **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)
3225 zval_dtor (&old);
3226 phc_check_invariants (TSRMLS_C);
3228 // return $TLE19;
3230 zval* rhs;
3231 if (local_TLE19 == NULL)
3232 rhs = EG (uninitialized_zval_ptr);
3233 else
3234 rhs = local_TLE19;
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);
3247 // goto L112;
3249 goto L112;
3250 phc_check_invariants (TSRMLS_C);
3252 // L111:
3253 L111:;
3254 // goto L112;
3256 goto L112;
3257 phc_check_invariants (TSRMLS_C);
3259 // L112:
3260 L112:;
3261 // $TLE20 = '&#9;';
3263 if (local_TLE20 == NULL)
3265 local_TLE20 = EG (uninitialized_zval_ptr);
3266 local_TLE20->refcount++;
3268 zval** p_lhs = &local_TLE20;
3270 zval* value;
3271 if ((*p_lhs)->is_ref)
3273 // Always overwrite the current value
3274 value = *p_lhs;
3275 zval_dtor (value);
3277 else
3279 ALLOC_INIT_ZVAL (value);
3280 zval_ptr_dtor (p_lhs);
3281 *p_lhs = value;
3284 ZVAL_STRINGL(value, "&#9;", 4, 1);
3286 phc_check_invariants (TSRMLS_C);
3288 // $TLE21 = ' ';
3290 if (local_TLE21 == NULL)
3292 local_TLE21 = EG (uninitialized_zval_ptr);
3293 local_TLE21->refcount++;
3295 zval** p_lhs = &local_TLE21;
3297 zval* value;
3298 if ((*p_lhs)->is_ref)
3300 // Always overwrite the current value
3301 value = *p_lhs;
3302 zval_dtor (value);
3304 else
3306 ALLOC_INIT_ZVAL (value);
3307 zval_ptr_dtor (p_lhs);
3308 *p_lhs = value;
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
3321 int by_ref[3];
3322 int abr_index = 0;
3323 // TODO: find names to replace index
3324 if (arg_info)
3326 by_ref[abr_index] = arg_info->pass_by_reference;
3327 arg_info++;
3329 else
3330 by_ref[abr_index] = signature->common.pass_rest_by_reference;
3332 abr_index++;
3333 // TODO: find names to replace index
3334 if (arg_info)
3336 by_ref[abr_index] = arg_info->pass_by_reference;
3337 arg_info++;
3339 else
3340 by_ref[abr_index] = signature->common.pass_rest_by_reference;
3342 abr_index++;
3343 // TODO: find names to replace index
3344 if (arg_info)
3346 by_ref[abr_index] = arg_info->pass_by_reference;
3347 arg_info++;
3349 else
3350 by_ref[abr_index] = signature->common.pass_rest_by_reference;
3352 abr_index++;
3355 // Setup array of arguments
3356 // TODO: i think arrays of size 0 is an error
3357 int destruct [3];
3358 zval* args [3];
3359 zval** args_ind [3];
3361 int af_index = 0;
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];
3376 else
3378 zval* arg;
3379 if (local_TLE20 == NULL)
3380 arg = EG (uninitialized_zval_ptr);
3381 else
3382 arg = local_TLE20;
3384 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
3385 args_ind[af_index] = &args[af_index];
3387 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];
3402 else
3404 zval* arg;
3405 if (local_TLE21 == NULL)
3406 arg = EG (uninitialized_zval_ptr);
3407 else
3408 arg = local_TLE21;
3410 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
3411 args_ind[af_index] = &args[af_index];
3413 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];
3428 else
3430 zval* arg;
3431 if (local_correctedtext == NULL)
3432 arg = EG (uninitialized_zval_ptr);
3433 else
3434 arg = local_correctedtext;
3436 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
3437 args_ind[af_index] = &args[af_index];
3439 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;
3449 zval* rhs = NULL;
3451 // set up params
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);
3460 // restore params
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;
3465 // unset the errors
3466 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
3468 int i;
3469 for (i = 0; i < 3; i++)
3471 if (destruct[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));
3500 rhs->is_ref = 1;
3501 if (saved_refcount != 0)
3503 rhs->refcount = saved_refcount;
3505 rhs->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;
3527 zval* rhs;
3528 if (local_correctedtext == NULL)
3529 rhs = EG (uninitialized_zval_ptr);
3530 else
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);
3544 // Method exit
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)
3608 // {
3609 // global $wgTidyInternal;
3610 // $retval = 0;
3611 // if (wgTidyInternal) goto L113 else goto L114;
3612 // L113:
3613 // $TLE22 = True;
3614 // $errorStr = mwtidy::execinternaltidy($text, $TLE22, $retval);
3615 // goto L115;
3616 // L114:
3617 // $TLE23 = True;
3618 // $errorStr = mwtidy::execexternaltidy($text, $TLE23, $retval);
3619 // goto L115;
3620 // L115:
3621 // $TLE24 = 0;
3622 // $TLE0 = ($retval < $TLE24);
3623 // if (TLE0) goto L116 else goto L117;
3624 // L116:
3625 // $TLE25 = '';
3626 // $TEF1 = ($errorStr == $TLE25);
3627 // goto L118;
3628 // L117:
3629 // $TEF1 = $TLE0;
3630 // goto L118;
3631 // L118:
3632 // $TLE2 = (bool) $TEF1;
3633 // if (TLE2) goto L119 else goto L120;
3634 // L119:
3635 // $TEF3 = $TLE2;
3636 // goto L121;
3637 // L120:
3638 // $TLE26 = 0;
3639 // $TEF3 = ($retval == $TLE26);
3640 // goto L121;
3641 // L121:
3642 // $TLE27 = (bool) $TEF3;
3643 // return $TLE27;
3644 // }
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 ();
3664 zval* params[2];
3665 zend_get_parameters_array(0, num_args, params);
3666 // param 0
3667 params[0]->refcount++;
3668 if (local_text != NULL)
3670 zval_ptr_dtor (&local_text);
3672 local_text = params[0];
3673 // param 1
3674 if (num_args <= 1)
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__;
3688 zval* value;
3689 if ((*p_lhs)->is_ref)
3691 // Always overwrite the current value
3692 value = *p_lhs;
3693 zval_dtor (value);
3695 else
3697 ALLOC_INIT_ZVAL (value);
3698 zval_ptr_dtor (p_lhs);
3699 *p_lhs = value;
3702 ZVAL_NULL (value);
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];
3724 // Function body
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);
3740 // $retval = 0;
3742 if (local_retval == NULL)
3744 local_retval = EG (uninitialized_zval_ptr);
3745 local_retval->refcount++;
3747 zval** p_lhs = &local_retval;
3749 zval* value;
3750 if ((*p_lhs)->is_ref)
3752 // Always overwrite the current value
3753 value = *p_lhs;
3754 zval_dtor (value);
3756 else
3758 ALLOC_INIT_ZVAL (value);
3759 zval_ptr_dtor (p_lhs);
3760 *p_lhs = value;
3763 ZVAL_LONG (value, 0);
3765 phc_check_invariants (TSRMLS_C);
3767 // if (wgTidyInternal) goto L113 else goto L114;
3769 zval* p_cond;
3770 if (local_wgTidyInternal == NULL)
3771 p_cond = EG (uninitialized_zval_ptr);
3772 else
3773 p_cond = local_wgTidyInternal;
3775 zend_bool bcond = zend_is_true (p_cond);
3776 if (bcond)
3777 goto L113;
3778 else
3779 goto L114;
3780 phc_check_invariants (TSRMLS_C);
3782 // L113:
3783 L113:;
3784 // $TLE22 = True;
3786 if (local_TLE22 == NULL)
3788 local_TLE22 = EG (uninitialized_zval_ptr);
3789 local_TLE22->refcount++;
3791 zval** p_lhs = &local_TLE22;
3793 zval* value;
3794 if ((*p_lhs)->is_ref)
3796 // Always overwrite the current value
3797 value = *p_lhs;
3798 zval_dtor (value);
3800 else
3802 ALLOC_INIT_ZVAL (value);
3803 zval_ptr_dtor (p_lhs);
3804 *p_lhs = value;
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
3817 int by_ref[3];
3818 int abr_index = 0;
3819 // TODO: find names to replace index
3820 if (arg_info)
3822 by_ref[abr_index] = arg_info->pass_by_reference;
3823 arg_info++;
3825 else
3826 by_ref[abr_index] = signature->common.pass_rest_by_reference;
3828 abr_index++;
3829 // TODO: find names to replace index
3830 if (arg_info)
3832 by_ref[abr_index] = arg_info->pass_by_reference;
3833 arg_info++;
3835 else
3836 by_ref[abr_index] = signature->common.pass_rest_by_reference;
3838 abr_index++;
3839 // TODO: find names to replace index
3840 if (arg_info)
3842 by_ref[abr_index] = arg_info->pass_by_reference;
3843 arg_info++;
3845 else
3846 by_ref[abr_index] = signature->common.pass_rest_by_reference;
3848 abr_index++;
3851 // Setup array of arguments
3852 // TODO: i think arrays of size 0 is an error
3853 int destruct [3];
3854 zval* args [3];
3855 zval** args_ind [3];
3857 int af_index = 0;
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];
3872 else
3874 zval* arg;
3875 if (local_text == NULL)
3876 arg = EG (uninitialized_zval_ptr);
3877 else
3878 arg = local_text;
3880 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
3881 args_ind[af_index] = &args[af_index];
3883 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];
3898 else
3900 zval* arg;
3901 if (local_TLE22 == NULL)
3902 arg = EG (uninitialized_zval_ptr);
3903 else
3904 arg = local_TLE22;
3906 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
3907 args_ind[af_index] = &args[af_index];
3909 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];
3924 else
3926 zval* arg;
3927 if (local_retval == NULL)
3928 arg = EG (uninitialized_zval_ptr);
3929 else
3930 arg = local_retval;
3932 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
3933 args_ind[af_index] = &args[af_index];
3935 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;
3945 zval* rhs = NULL;
3947 // set up params
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);
3956 // restore params
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;
3961 // unset the errors
3962 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
3964 int i;
3965 for (i = 0; i < 3; i++)
3967 if (destruct[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));
3996 rhs->is_ref = 1;
3997 if (saved_refcount != 0)
3999 rhs->refcount = saved_refcount;
4001 rhs->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);
4021 // goto L115;
4023 goto L115;
4024 phc_check_invariants (TSRMLS_C);
4026 // L114:
4027 L114:;
4028 // $TLE23 = True;
4030 if (local_TLE23 == NULL)
4032 local_TLE23 = EG (uninitialized_zval_ptr);
4033 local_TLE23->refcount++;
4035 zval** p_lhs = &local_TLE23;
4037 zval* value;
4038 if ((*p_lhs)->is_ref)
4040 // Always overwrite the current value
4041 value = *p_lhs;
4042 zval_dtor (value);
4044 else
4046 ALLOC_INIT_ZVAL (value);
4047 zval_ptr_dtor (p_lhs);
4048 *p_lhs = value;
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
4061 int by_ref[3];
4062 int abr_index = 0;
4063 // TODO: find names to replace index
4064 if (arg_info)
4066 by_ref[abr_index] = arg_info->pass_by_reference;
4067 arg_info++;
4069 else
4070 by_ref[abr_index] = signature->common.pass_rest_by_reference;
4072 abr_index++;
4073 // TODO: find names to replace index
4074 if (arg_info)
4076 by_ref[abr_index] = arg_info->pass_by_reference;
4077 arg_info++;
4079 else
4080 by_ref[abr_index] = signature->common.pass_rest_by_reference;
4082 abr_index++;
4083 // TODO: find names to replace index
4084 if (arg_info)
4086 by_ref[abr_index] = arg_info->pass_by_reference;
4087 arg_info++;
4089 else
4090 by_ref[abr_index] = signature->common.pass_rest_by_reference;
4092 abr_index++;
4095 // Setup array of arguments
4096 // TODO: i think arrays of size 0 is an error
4097 int destruct [3];
4098 zval* args [3];
4099 zval** args_ind [3];
4101 int af_index = 0;
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];
4116 else
4118 zval* arg;
4119 if (local_text == NULL)
4120 arg = EG (uninitialized_zval_ptr);
4121 else
4122 arg = local_text;
4124 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
4125 args_ind[af_index] = &args[af_index];
4127 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];
4142 else
4144 zval* arg;
4145 if (local_TLE23 == NULL)
4146 arg = EG (uninitialized_zval_ptr);
4147 else
4148 arg = local_TLE23;
4150 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
4151 args_ind[af_index] = &args[af_index];
4153 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];
4168 else
4170 zval* arg;
4171 if (local_retval == NULL)
4172 arg = EG (uninitialized_zval_ptr);
4173 else
4174 arg = local_retval;
4176 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
4177 args_ind[af_index] = &args[af_index];
4179 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;
4189 zval* rhs = NULL;
4191 // set up params
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);
4200 // restore params
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;
4205 // unset the errors
4206 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
4208 int i;
4209 for (i = 0; i < 3; i++)
4211 if (destruct[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));
4240 rhs->is_ref = 1;
4241 if (saved_refcount != 0)
4243 rhs->refcount = saved_refcount;
4245 rhs->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);
4265 // goto L115;
4267 goto L115;
4268 phc_check_invariants (TSRMLS_C);
4270 // L115:
4271 L115:;
4272 // $TLE24 = 0;
4274 if (local_TLE24 == NULL)
4276 local_TLE24 = EG (uninitialized_zval_ptr);
4277 local_TLE24->refcount++;
4279 zval** p_lhs = &local_TLE24;
4281 zval* value;
4282 if ((*p_lhs)->is_ref)
4284 // Always overwrite the current value
4285 value = *p_lhs;
4286 zval_dtor (value);
4288 else
4290 ALLOC_INIT_ZVAL (value);
4291 zval_ptr_dtor (p_lhs);
4292 *p_lhs = value;
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;
4308 zval* left;
4309 if (local_retval == NULL)
4310 left = EG (uninitialized_zval_ptr);
4311 else
4312 left = local_retval;
4314 zval* right;
4315 if (local_TLE24 == NULL)
4316 right = EG (uninitialized_zval_ptr);
4317 else
4318 right = local_TLE24;
4320 if (in_copy_on_write (*p_lhs))
4322 zval_ptr_dtor (p_lhs);
4323 ALLOC_INIT_ZVAL (*p_lhs);
4326 zval old = **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)
4333 zval_dtor (&old);
4334 phc_check_invariants (TSRMLS_C);
4336 // if (TLE0) goto L116 else goto L117;
4338 zval* p_cond;
4339 if (local_TLE0 == NULL)
4340 p_cond = EG (uninitialized_zval_ptr);
4341 else
4342 p_cond = local_TLE0;
4344 zend_bool bcond = zend_is_true (p_cond);
4345 if (bcond)
4346 goto L116;
4347 else
4348 goto L117;
4349 phc_check_invariants (TSRMLS_C);
4351 // L116:
4352 L116:;
4353 // $TLE25 = '';
4355 if (local_TLE25 == NULL)
4357 local_TLE25 = EG (uninitialized_zval_ptr);
4358 local_TLE25->refcount++;
4360 zval** p_lhs = &local_TLE25;
4362 zval* value;
4363 if ((*p_lhs)->is_ref)
4365 // Always overwrite the current value
4366 value = *p_lhs;
4367 zval_dtor (value);
4369 else
4371 ALLOC_INIT_ZVAL (value);
4372 zval_ptr_dtor (p_lhs);
4373 *p_lhs = value;
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;
4389 zval* left;
4390 if (local_errorStr == NULL)
4391 left = EG (uninitialized_zval_ptr);
4392 else
4393 left = local_errorStr;
4395 zval* right;
4396 if (local_TLE25 == NULL)
4397 right = EG (uninitialized_zval_ptr);
4398 else
4399 right = local_TLE25;
4401 if (in_copy_on_write (*p_lhs))
4403 zval_ptr_dtor (p_lhs);
4404 ALLOC_INIT_ZVAL (*p_lhs);
4407 zval old = **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)
4414 zval_dtor (&old);
4415 phc_check_invariants (TSRMLS_C);
4417 // goto L118;
4419 goto L118;
4420 phc_check_invariants (TSRMLS_C);
4422 // L117:
4423 L117:;
4424 // $TEF1 = $TLE0;
4426 if (local_TEF1 == NULL)
4428 local_TEF1 = EG (uninitialized_zval_ptr);
4429 local_TEF1->refcount++;
4431 zval** p_lhs = &local_TEF1;
4433 zval* rhs;
4434 if (local_TLE0 == NULL)
4435 rhs = EG (uninitialized_zval_ptr);
4436 else
4437 rhs = local_TLE0;
4439 if (*p_lhs != rhs)
4441 if ((*p_lhs)->is_ref)
4442 overwrite_lhs (*p_lhs, rhs);
4443 else
4445 zval_ptr_dtor (p_lhs);
4446 if (rhs->is_ref)
4448 // Take a copy of RHS for LHS
4449 *p_lhs = zvp_clone_ex (rhs);
4451 else
4453 // Share a copy
4454 rhs->refcount++;
4455 *p_lhs = rhs;
4461 phc_check_invariants (TSRMLS_C);
4463 // goto L118;
4465 goto L118;
4466 phc_check_invariants (TSRMLS_C);
4468 // L118:
4469 L118:;
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;
4479 zval* rhs;
4480 if (local_TEF1 == NULL)
4481 rhs = EG (uninitialized_zval_ptr);
4482 else
4483 rhs = local_TEF1;
4485 if (*p_lhs != rhs)
4487 if ((*p_lhs)->is_ref)
4488 overwrite_lhs (*p_lhs, rhs);
4489 else
4491 zval_ptr_dtor (p_lhs);
4492 if (rhs->is_ref)
4494 // Take a copy of RHS for LHS
4495 *p_lhs = zvp_clone_ex (rhs);
4497 else
4499 // Share a copy
4500 rhs->refcount++;
4501 *p_lhs = 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;
4519 zval* p_cond;
4520 if (local_TLE2 == NULL)
4521 p_cond = EG (uninitialized_zval_ptr);
4522 else
4523 p_cond = local_TLE2;
4525 zend_bool bcond = zend_is_true (p_cond);
4526 if (bcond)
4527 goto L119;
4528 else
4529 goto L120;
4530 phc_check_invariants (TSRMLS_C);
4532 // L119:
4533 L119:;
4534 // $TEF3 = $TLE2;
4536 if (local_TEF3 == NULL)
4538 local_TEF3 = EG (uninitialized_zval_ptr);
4539 local_TEF3->refcount++;
4541 zval** p_lhs = &local_TEF3;
4543 zval* rhs;
4544 if (local_TLE2 == NULL)
4545 rhs = EG (uninitialized_zval_ptr);
4546 else
4547 rhs = local_TLE2;
4549 if (*p_lhs != rhs)
4551 if ((*p_lhs)->is_ref)
4552 overwrite_lhs (*p_lhs, rhs);
4553 else
4555 zval_ptr_dtor (p_lhs);
4556 if (rhs->is_ref)
4558 // Take a copy of RHS for LHS
4559 *p_lhs = zvp_clone_ex (rhs);
4561 else
4563 // Share a copy
4564 rhs->refcount++;
4565 *p_lhs = rhs;
4571 phc_check_invariants (TSRMLS_C);
4573 // goto L121;
4575 goto L121;
4576 phc_check_invariants (TSRMLS_C);
4578 // L120:
4579 L120:;
4580 // $TLE26 = 0;
4582 if (local_TLE26 == NULL)
4584 local_TLE26 = EG (uninitialized_zval_ptr);
4585 local_TLE26->refcount++;
4587 zval** p_lhs = &local_TLE26;
4589 zval* value;
4590 if ((*p_lhs)->is_ref)
4592 // Always overwrite the current value
4593 value = *p_lhs;
4594 zval_dtor (value);
4596 else
4598 ALLOC_INIT_ZVAL (value);
4599 zval_ptr_dtor (p_lhs);
4600 *p_lhs = value;
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;
4616 zval* left;
4617 if (local_retval == NULL)
4618 left = EG (uninitialized_zval_ptr);
4619 else
4620 left = local_retval;
4622 zval* right;
4623 if (local_TLE26 == NULL)
4624 right = EG (uninitialized_zval_ptr);
4625 else
4626 right = local_TLE26;
4628 if (in_copy_on_write (*p_lhs))
4630 zval_ptr_dtor (p_lhs);
4631 ALLOC_INIT_ZVAL (*p_lhs);
4634 zval old = **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)
4641 zval_dtor (&old);
4642 phc_check_invariants (TSRMLS_C);
4644 // goto L121;
4646 goto L121;
4647 phc_check_invariants (TSRMLS_C);
4649 // L121:
4650 L121:;
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;
4660 zval* rhs;
4661 if (local_TEF3 == NULL)
4662 rhs = EG (uninitialized_zval_ptr);
4663 else
4664 rhs = local_TEF3;
4666 if (*p_lhs != rhs)
4668 if ((*p_lhs)->is_ref)
4669 overwrite_lhs (*p_lhs, rhs);
4670 else
4672 zval_ptr_dtor (p_lhs);
4673 if (rhs->is_ref)
4675 // Take a copy of RHS for LHS
4676 *p_lhs = zvp_clone_ex (rhs);
4678 else
4680 // Share a copy
4681 rhs->refcount++;
4682 *p_lhs = 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);
4698 // return $TLE27;
4700 zval* rhs;
4701 if (local_TLE27 == NULL)
4702 rhs = EG (uninitialized_zval_ptr);
4703 else
4704 rhs = local_TLE27;
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);
4717 // Method exit
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)
4777 // {
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;
4786 // L122:
4787 // $TLE29 = 0;
4788 // $TLE30 = 'pipe';
4789 // $TLE31 = 'r';
4790 // unset($TSa32);
4791 // $TSa32 = (array) $TSa32;
4792 // $TSa32[] = $TLE30;
4793 // $TSa32[] = $TLE31;
4794 // $TLE33 = 1;
4795 // $TLE34 = 'file';
4796 // $TLE35 = wfgetnull();
4797 // $TLE36 = 'a';
4798 // unset($TSa37);
4799 // $TSa37 = (array) $TSa37;
4800 // $TSa37[] = $TLE34;
4801 // $TSa37[] = $TLE35;
4802 // $TSa37[] = $TLE36;
4803 // $TLE38 = 2;
4804 // $TLE39 = 'pipe';
4805 // $TLE40 = 'w';
4806 // unset($TSa41);
4807 // $TSa41 = (array) $TSa41;
4808 // $TSa41[] = $TLE39;
4809 // $TSa41[] = $TLE40;
4810 // unset($TSa42);
4811 // $TSa42 = (array) $TSa42;
4812 // $TSa42[$TLE29] = $TSa32;
4813 // $TSa42[$TLE33] = $TSa37;
4814 // $TSa42[$TLE38] = $TSa41;
4815 // $descriptorspec = $TSa42;
4816 // goto L124;
4817 // L123:
4818 // $TLE43 = 0;
4819 // $TLE44 = 'pipe';
4820 // $TLE45 = 'r';
4821 // unset($TSa46);
4822 // $TSa46 = (array) $TSa46;
4823 // $TSa46[] = $TLE44;
4824 // $TSa46[] = $TLE45;
4825 // $TLE47 = 1;
4826 // $TLE48 = 'pipe';
4827 // $TLE49 = 'w';
4828 // unset($TSa50);
4829 // $TSa50 = (array) $TSa50;
4830 // $TSa50[] = $TLE48;
4831 // $TSa50[] = $TLE49;
4832 // $TLE51 = 2;
4833 // $TLE52 = 'file';
4834 // $TLE53 = wfgetnull();
4835 // $TLE54 = 'a';
4836 // unset($TSa55);
4837 // $TSa55 = (array) $TSa55;
4838 // $TSa55[] = $TLE52;
4839 // $TSa55[] = $TLE53;
4840 // $TSa55[] = $TLE54;
4841 // unset($TSa56);
4842 // $TSa56 = (array) $TSa56;
4843 // $TSa56[$TLE43] = $TSa46;
4844 // $TSa56[$TLE47] = $TSa50;
4845 // $TSa56[$TLE51] = $TSa55;
4846 // $descriptorspec = $TSa56;
4847 // goto L124;
4848 // L124:
4849 // if (stderr) goto L125 else goto L126;
4850 // L125:
4851 // $TEF4 = 2;
4852 // goto L127;
4853 // L126:
4854 // $TEF4 = 1;
4855 // goto L127;
4856 // L127:
4857 // $readpipe = $TEF4;
4858 // unset($TSa57);
4859 // $TSa57 = (array) $TSa57;
4860 // $pipes = $TSa57;
4861 // $TLE58 = 'proc_open';
4862 // $TLE59 = function_exists($TLE58);
4863 // if (TLE59) goto L151 else goto L152;
4864 // L151:
4865 // $TLE60 = ' -config ';
4866 // $TLE61 = ($wgTidyBin . $TLE60);
4867 // $TLE62 = ($TLE61 . $wgTidyConf);
4868 // $TLE63 = ' ';
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;
4875 // L148:
4876 // $TLE68 = 0;
4877 // $TLE96 = param_is_ref (NULL, "fwrite", 0);
4878 // ;
4879 // if (TLE96) goto L128 else goto L129;
4880 // L128:
4881 // $TMIi95 =& $pipes[$TLE68];
4882 // goto L130;
4883 // L129:
4884 // $TMIi95 = $pipes[$TLE68];
4885 // goto L130;
4886 // L130:
4887 // fwrite($TMIi95, $text);
4888 // $TLE69 = 0;
4889 // $TLE98 = param_is_ref (NULL, "fclose", 0);
4890 // ;
4891 // if (TLE98) goto L131 else goto L132;
4892 // L131:
4893 // $TMIi97 =& $pipes[$TLE69];
4894 // goto L133;
4895 // L132:
4896 // $TMIi97 = $pipes[$TLE69];
4897 // goto L133;
4898 // L133:
4899 // fclose($TMIi97);
4900 // L144:
4901 // $TLE100 = param_is_ref (NULL, "feof", 0);
4902 // ;
4903 // if (TLE100) goto L134 else goto L135;
4904 // L134:
4905 // $TMIi99 =& $pipes[$readpipe];
4906 // goto L136;
4907 // L135:
4908 // $TMIi99 = $pipes[$readpipe];
4909 // goto L136;
4910 // L136:
4911 // $TLE70 = feof($TMIi99);
4912 // $TLE71 = !$TLE70;
4913 // $TLE72 = !$TLE71;
4914 // if (TLE72) goto L138 else goto L139;
4915 // L138:
4916 // goto L137;
4917 // goto L140;
4918 // L139:
4919 // goto L140;
4920 // L140:
4921 // $TLE73 = 1024;
4922 // $TLE102 = param_is_ref (NULL, "fgets", 0);
4923 // ;
4924 // if (TLE102) goto L141 else goto L142;
4925 // L141:
4926 // $TMIi101 =& $pipes[$readpipe];
4927 // goto L143;
4928 // L142:
4929 // $TMIi101 = $pipes[$readpipe];
4930 // goto L143;
4931 // L143:
4932 // $TLE74 = fgets($TMIi101, $TLE73);
4933 // $cleansource = ($cleansource . $TLE74);
4934 // goto L144;
4935 // L137:
4936 // $TLE104 = param_is_ref (NULL, "fclose", 0);
4937 // ;
4938 // if (TLE104) goto L145 else goto L146;
4939 // L145:
4940 // $TMIi103 =& $pipes[$readpipe];
4941 // goto L147;
4942 // L146:
4943 // $TMIi103 = $pipes[$readpipe];
4944 // goto L147;
4945 // L147:
4946 // fclose($TMIi103);
4947 // $retval = proc_close($process);
4948 // goto L150;
4949 // L149:
4950 // $retval = -1;
4951 // goto L150;
4952 // L150:
4953 // goto L153;
4954 // L152:
4955 // $retval = -1;
4956 // goto L153;
4957 // L153:
4958 // $TLE75 = 'MWTidy::execExternalTidy';
4959 // wfprofileout($TLE75);
4960 // $TLE5 = !$stderr;
4961 // if (TLE5) goto L154 else goto L155;
4962 // L154:
4963 // $TLE76 = '';
4964 // $TEF6 = ($cleansource == $TLE76);
4965 // goto L156;
4966 // L155:
4967 // $TEF6 = $TLE5;
4968 // goto L156;
4969 // L156:
4970 // $TLE7 = (bool) $TEF6;
4971 // if (TLE7) goto L157 else goto L158;
4972 // L157:
4973 // $TLE77 = '';
4974 // $TEF8 = ($text != $TLE77);
4975 // goto L159;
4976 // L158:
4977 // $TEF8 = $TLE7;
4978 // goto L159;
4979 // L159:
4980 // $TLE78 = (bool) $TEF8;
4981 // if (TLE78) goto L160 else goto L161;
4982 // L160:
4983 // $TLE79 = NULL;
4984 // return $TLE79;
4985 // goto L162;
4986 // L161:
4987 // return $cleansource;
4988 // goto L162;
4989 // L162:
4990 // }
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 ();
5075 zval* params[3];
5076 zend_get_parameters_array(0, num_args, params);
5077 // param 0
5078 params[0]->refcount++;
5079 if (local_text != NULL)
5081 zval_ptr_dtor (&local_text);
5083 local_text = params[0];
5084 // param 1
5085 if (num_args <= 1)
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__;
5099 zval* value;
5100 if ((*p_lhs)->is_ref)
5102 // Always overwrite the current value
5103 value = *p_lhs;
5104 zval_dtor (value);
5106 else
5108 ALLOC_INIT_ZVAL (value);
5109 zval_ptr_dtor (p_lhs);
5110 *p_lhs = value;
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];
5134 // param 2
5135 if (num_args <= 2)
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__;
5149 zval* value;
5150 if ((*p_lhs)->is_ref)
5152 // Always overwrite the current value
5153 value = *p_lhs;
5154 zval_dtor (value);
5156 else
5158 ALLOC_INIT_ZVAL (value);
5159 zval_ptr_dtor (p_lhs);
5160 *p_lhs = value;
5163 ZVAL_NULL (value);
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];
5185 // Function body
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;
5240 zval* value;
5241 if ((*p_lhs)->is_ref)
5243 // Always overwrite the current value
5244 value = *p_lhs;
5245 zval_dtor (value);
5247 else
5249 ALLOC_INIT_ZVAL (value);
5250 zval_ptr_dtor (p_lhs);
5251 *p_lhs = value;
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
5264 int by_ref[1];
5265 int abr_index = 0;
5266 // TODO: find names to replace index
5267 if (arg_info)
5269 by_ref[abr_index] = arg_info->pass_by_reference;
5270 arg_info++;
5272 else
5273 by_ref[abr_index] = signature->common.pass_rest_by_reference;
5275 abr_index++;
5278 // Setup array of arguments
5279 // TODO: i think arrays of size 0 is an error
5280 int destruct [1];
5281 zval* args [1];
5282 zval** args_ind [1];
5284 int af_index = 0;
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];
5299 else
5301 zval* arg;
5302 if (local_TLE28 == NULL)
5303 arg = EG (uninitialized_zval_ptr);
5304 else
5305 arg = local_TLE28;
5307 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
5308 args_ind[af_index] = &args[af_index];
5310 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;
5320 zval* rhs = NULL;
5322 // set up params
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);
5331 // restore params
5332 wfprofilein_fci.params = params_save;
5333 wfprofilein_fci.param_count = param_count_save;
5334 wfprofilein_fci.retval_ptr_ptr = retval_save;
5336 // unset the errors
5337 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
5339 int i;
5340 for (i = 0; i < 1; i++)
5342 if (destruct[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));
5371 rhs->is_ref = 1;
5372 if (saved_refcount != 0)
5374 rhs->refcount = saved_refcount;
5376 rhs->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;
5397 zval* value;
5398 if ((*p_lhs)->is_ref)
5400 // Always overwrite the current value
5401 value = *p_lhs;
5402 zval_dtor (value);
5404 else
5406 ALLOC_INIT_ZVAL (value);
5407 zval_ptr_dtor (p_lhs);
5408 *p_lhs = value;
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;
5424 zval* value;
5425 if ((*p_lhs)->is_ref)
5427 // Always overwrite the current value
5428 value = *p_lhs;
5429 zval_dtor (value);
5431 else
5433 ALLOC_INIT_ZVAL (value);
5434 zval_ptr_dtor (p_lhs);
5435 *p_lhs = value;
5438 ZVAL_STRINGL(value, " -utf8", 6, 1);
5440 phc_check_invariants (TSRMLS_C);
5442 // if (stderr) goto L122 else goto L123;
5444 zval* p_cond;
5445 if (local_stderr == NULL)
5446 p_cond = EG (uninitialized_zval_ptr);
5447 else
5448 p_cond = local_stderr;
5450 zend_bool bcond = zend_is_true (p_cond);
5451 if (bcond)
5452 goto L122;
5453 else
5454 goto L123;
5455 phc_check_invariants (TSRMLS_C);
5457 // L122:
5458 L122:;
5459 // $TLE29 = 0;
5461 if (local_TLE29 == NULL)
5463 local_TLE29 = EG (uninitialized_zval_ptr);
5464 local_TLE29->refcount++;
5466 zval** p_lhs = &local_TLE29;
5468 zval* value;
5469 if ((*p_lhs)->is_ref)
5471 // Always overwrite the current value
5472 value = *p_lhs;
5473 zval_dtor (value);
5475 else
5477 ALLOC_INIT_ZVAL (value);
5478 zval_ptr_dtor (p_lhs);
5479 *p_lhs = value;
5482 ZVAL_LONG (value, 0);
5484 phc_check_invariants (TSRMLS_C);
5486 // $TLE30 = 'pipe';
5488 if (local_TLE30 == NULL)
5490 local_TLE30 = EG (uninitialized_zval_ptr);
5491 local_TLE30->refcount++;
5493 zval** p_lhs = &local_TLE30;
5495 zval* value;
5496 if ((*p_lhs)->is_ref)
5498 // Always overwrite the current value
5499 value = *p_lhs;
5500 zval_dtor (value);
5502 else
5504 ALLOC_INIT_ZVAL (value);
5505 zval_ptr_dtor (p_lhs);
5506 *p_lhs = value;
5509 ZVAL_STRINGL(value, "pipe", 4, 1);
5511 phc_check_invariants (TSRMLS_C);
5513 // $TLE31 = 'r';
5515 if (local_TLE31 == NULL)
5517 local_TLE31 = EG (uninitialized_zval_ptr);
5518 local_TLE31->refcount++;
5520 zval** p_lhs = &local_TLE31;
5522 zval* value;
5523 if ((*p_lhs)->is_ref)
5525 // Always overwrite the current value
5526 value = *p_lhs;
5527 zval_dtor (value);
5529 else
5531 ALLOC_INIT_ZVAL (value);
5532 zval_ptr_dtor (p_lhs);
5533 *p_lhs = value;
5536 ZVAL_STRINGL(value, "r", 1, 1);
5538 phc_check_invariants (TSRMLS_C);
5540 // unset($TSa32);
5542 if (local_TSa32 != NULL)
5544 zval_ptr_dtor (&local_TSa32);
5545 local_TSa32 = NULL;
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;
5558 zval* rhs;
5559 if (local_TSa32 == NULL)
5560 rhs = EG (uninitialized_zval_ptr);
5561 else
5562 rhs = local_TSa32;
5564 if (*p_lhs != rhs)
5566 if ((*p_lhs)->is_ref)
5567 overwrite_lhs (*p_lhs, rhs);
5568 else
5570 zval_ptr_dtor (p_lhs);
5571 if (rhs->is_ref)
5573 // Take a copy of RHS for LHS
5574 *p_lhs = zvp_clone_ex (rhs);
5576 else
5578 // Share a copy
5579 rhs->refcount++;
5580 *p_lhs = 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);
5607 if (p_lhs != NULL)
5609 zval* rhs;
5610 if (local_TLE30 == NULL)
5611 rhs = EG (uninitialized_zval_ptr);
5612 else
5613 rhs = local_TLE30;
5615 if (*p_lhs != rhs)
5616 write_var (p_lhs, rhs);
5618 // I think if this is NULL, then the LHS is a bool or similar, and you cant
5619 // push onto it.
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);
5633 if (p_lhs != NULL)
5635 zval* rhs;
5636 if (local_TLE31 == NULL)
5637 rhs = EG (uninitialized_zval_ptr);
5638 else
5639 rhs = local_TLE31;
5641 if (*p_lhs != rhs)
5642 write_var (p_lhs, rhs);
5644 // I think if this is NULL, then the LHS is a bool or similar, and you cant
5645 // push onto it.
5646 phc_check_invariants (TSRMLS_C);
5648 // $TLE33 = 1;
5650 if (local_TLE33 == NULL)
5652 local_TLE33 = EG (uninitialized_zval_ptr);
5653 local_TLE33->refcount++;
5655 zval** p_lhs = &local_TLE33;
5657 zval* value;
5658 if ((*p_lhs)->is_ref)
5660 // Always overwrite the current value
5661 value = *p_lhs;
5662 zval_dtor (value);
5664 else
5666 ALLOC_INIT_ZVAL (value);
5667 zval_ptr_dtor (p_lhs);
5668 *p_lhs = value;
5671 ZVAL_LONG (value, 1);
5673 phc_check_invariants (TSRMLS_C);
5675 // $TLE34 = 'file';
5677 if (local_TLE34 == NULL)
5679 local_TLE34 = EG (uninitialized_zval_ptr);
5680 local_TLE34->refcount++;
5682 zval** p_lhs = &local_TLE34;
5684 zval* value;
5685 if ((*p_lhs)->is_ref)
5687 // Always overwrite the current value
5688 value = *p_lhs;
5689 zval_dtor (value);
5691 else
5693 ALLOC_INIT_ZVAL (value);
5694 zval_ptr_dtor (p_lhs);
5695 *p_lhs = value;
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
5708 int by_ref[0];
5709 int abr_index = 0;
5712 // Setup array of arguments
5713 // TODO: i think arrays of size 0 is an error
5714 int destruct [0];
5715 zval* args [0];
5716 zval** args_ind [0];
5718 int af_index = 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;
5728 zval* rhs = NULL;
5730 // set up params
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);
5739 // restore params
5740 wfgetnull_fci.params = params_save;
5741 wfgetnull_fci.param_count = param_count_save;
5742 wfgetnull_fci.retval_ptr_ptr = retval_save;
5744 // unset the errors
5745 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
5747 int i;
5748 for (i = 0; i < 0; i++)
5750 if (destruct[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));
5779 rhs->is_ref = 1;
5780 if (saved_refcount != 0)
5782 rhs->refcount = saved_refcount;
5784 rhs->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);
5804 // $TLE36 = 'a';
5806 if (local_TLE36 == NULL)
5808 local_TLE36 = EG (uninitialized_zval_ptr);
5809 local_TLE36->refcount++;
5811 zval** p_lhs = &local_TLE36;
5813 zval* value;
5814 if ((*p_lhs)->is_ref)
5816 // Always overwrite the current value
5817 value = *p_lhs;
5818 zval_dtor (value);
5820 else
5822 ALLOC_INIT_ZVAL (value);
5823 zval_ptr_dtor (p_lhs);
5824 *p_lhs = value;
5827 ZVAL_STRINGL(value, "a", 1, 1);
5829 phc_check_invariants (TSRMLS_C);
5831 // unset($TSa37);
5833 if (local_TSa37 != NULL)
5835 zval_ptr_dtor (&local_TSa37);
5836 local_TSa37 = NULL;
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;
5849 zval* rhs;
5850 if (local_TSa37 == NULL)
5851 rhs = EG (uninitialized_zval_ptr);
5852 else
5853 rhs = local_TSa37;
5855 if (*p_lhs != rhs)
5857 if ((*p_lhs)->is_ref)
5858 overwrite_lhs (*p_lhs, rhs);
5859 else
5861 zval_ptr_dtor (p_lhs);
5862 if (rhs->is_ref)
5864 // Take a copy of RHS for LHS
5865 *p_lhs = zvp_clone_ex (rhs);
5867 else
5869 // Share a copy
5870 rhs->refcount++;
5871 *p_lhs = 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);
5898 if (p_lhs != NULL)
5900 zval* rhs;
5901 if (local_TLE34 == NULL)
5902 rhs = EG (uninitialized_zval_ptr);
5903 else
5904 rhs = local_TLE34;
5906 if (*p_lhs != rhs)
5907 write_var (p_lhs, rhs);
5909 // I think if this is NULL, then the LHS is a bool or similar, and you cant
5910 // push onto it.
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);
5924 if (p_lhs != NULL)
5926 zval* rhs;
5927 if (local_TLE35 == NULL)
5928 rhs = EG (uninitialized_zval_ptr);
5929 else
5930 rhs = local_TLE35;
5932 if (*p_lhs != rhs)
5933 write_var (p_lhs, rhs);
5935 // I think if this is NULL, then the LHS is a bool or similar, and you cant
5936 // push onto it.
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);
5950 if (p_lhs != NULL)
5952 zval* rhs;
5953 if (local_TLE36 == NULL)
5954 rhs = EG (uninitialized_zval_ptr);
5955 else
5956 rhs = local_TLE36;
5958 if (*p_lhs != rhs)
5959 write_var (p_lhs, rhs);
5961 // I think if this is NULL, then the LHS is a bool or similar, and you cant
5962 // push onto it.
5963 phc_check_invariants (TSRMLS_C);
5965 // $TLE38 = 2;
5967 if (local_TLE38 == NULL)
5969 local_TLE38 = EG (uninitialized_zval_ptr);
5970 local_TLE38->refcount++;
5972 zval** p_lhs = &local_TLE38;
5974 zval* value;
5975 if ((*p_lhs)->is_ref)
5977 // Always overwrite the current value
5978 value = *p_lhs;
5979 zval_dtor (value);
5981 else
5983 ALLOC_INIT_ZVAL (value);
5984 zval_ptr_dtor (p_lhs);
5985 *p_lhs = value;
5988 ZVAL_LONG (value, 2);
5990 phc_check_invariants (TSRMLS_C);
5992 // $TLE39 = 'pipe';
5994 if (local_TLE39 == NULL)
5996 local_TLE39 = EG (uninitialized_zval_ptr);
5997 local_TLE39->refcount++;
5999 zval** p_lhs = &local_TLE39;
6001 zval* value;
6002 if ((*p_lhs)->is_ref)
6004 // Always overwrite the current value
6005 value = *p_lhs;
6006 zval_dtor (value);
6008 else
6010 ALLOC_INIT_ZVAL (value);
6011 zval_ptr_dtor (p_lhs);
6012 *p_lhs = value;
6015 ZVAL_STRINGL(value, "pipe", 4, 1);
6017 phc_check_invariants (TSRMLS_C);
6019 // $TLE40 = 'w';
6021 if (local_TLE40 == NULL)
6023 local_TLE40 = EG (uninitialized_zval_ptr);
6024 local_TLE40->refcount++;
6026 zval** p_lhs = &local_TLE40;
6028 zval* value;
6029 if ((*p_lhs)->is_ref)
6031 // Always overwrite the current value
6032 value = *p_lhs;
6033 zval_dtor (value);
6035 else
6037 ALLOC_INIT_ZVAL (value);
6038 zval_ptr_dtor (p_lhs);
6039 *p_lhs = value;
6042 ZVAL_STRINGL(value, "w", 1, 1);
6044 phc_check_invariants (TSRMLS_C);
6046 // unset($TSa41);
6048 if (local_TSa41 != NULL)
6050 zval_ptr_dtor (&local_TSa41);
6051 local_TSa41 = NULL;
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;
6064 zval* rhs;
6065 if (local_TSa41 == NULL)
6066 rhs = EG (uninitialized_zval_ptr);
6067 else
6068 rhs = local_TSa41;
6070 if (*p_lhs != rhs)
6072 if ((*p_lhs)->is_ref)
6073 overwrite_lhs (*p_lhs, rhs);
6074 else
6076 zval_ptr_dtor (p_lhs);
6077 if (rhs->is_ref)
6079 // Take a copy of RHS for LHS
6080 *p_lhs = zvp_clone_ex (rhs);
6082 else
6084 // Share a copy
6085 rhs->refcount++;
6086 *p_lhs = 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);
6113 if (p_lhs != NULL)
6115 zval* rhs;
6116 if (local_TLE39 == NULL)
6117 rhs = EG (uninitialized_zval_ptr);
6118 else
6119 rhs = local_TLE39;
6121 if (*p_lhs != rhs)
6122 write_var (p_lhs, rhs);
6124 // I think if this is NULL, then the LHS is a bool or similar, and you cant
6125 // push onto it.
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);
6139 if (p_lhs != NULL)
6141 zval* rhs;
6142 if (local_TLE40 == NULL)
6143 rhs = EG (uninitialized_zval_ptr);
6144 else
6145 rhs = local_TLE40;
6147 if (*p_lhs != rhs)
6148 write_var (p_lhs, rhs);
6150 // I think if this is NULL, then the LHS is a bool or similar, and you cant
6151 // push onto it.
6152 phc_check_invariants (TSRMLS_C);
6154 // unset($TSa42);
6156 if (local_TSa42 != NULL)
6158 zval_ptr_dtor (&local_TSa42);
6159 local_TSa42 = NULL;
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;
6172 zval* rhs;
6173 if (local_TSa42 == NULL)
6174 rhs = EG (uninitialized_zval_ptr);
6175 else
6176 rhs = local_TSa42;
6178 if (*p_lhs != rhs)
6180 if ((*p_lhs)->is_ref)
6181 overwrite_lhs (*p_lhs, rhs);
6182 else
6184 zval_ptr_dtor (p_lhs);
6185 if (rhs->is_ref)
6187 // Take a copy of RHS for LHS
6188 *p_lhs = zvp_clone_ex (rhs);
6190 else
6192 // Share a copy
6193 rhs->refcount++;
6194 *p_lhs = 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);
6221 zval* index;
6222 if (local_TLE29 == NULL)
6223 index = EG (uninitialized_zval_ptr);
6224 else
6225 index = local_TLE29;
6228 // String indexing
6229 if (Z_TYPE_PP (p_array) == IS_STRING && Z_STRLEN_PP (p_array) > 0)
6231 zval* rhs;
6232 if (local_TSa32 == NULL)
6233 rhs = EG (uninitialized_zval_ptr);
6234 else
6235 rhs = local_TSa32;
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);
6242 zval* rhs;
6243 if (local_TSa32 == NULL)
6244 rhs = EG (uninitialized_zval_ptr);
6245 else
6246 rhs = local_TSa32;
6248 if (*p_lhs != rhs)
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);
6266 zval* index;
6267 if (local_TLE33 == NULL)
6268 index = EG (uninitialized_zval_ptr);
6269 else
6270 index = local_TLE33;
6273 // String indexing
6274 if (Z_TYPE_PP (p_array) == IS_STRING && Z_STRLEN_PP (p_array) > 0)
6276 zval* rhs;
6277 if (local_TSa37 == NULL)
6278 rhs = EG (uninitialized_zval_ptr);
6279 else
6280 rhs = local_TSa37;
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);
6287 zval* rhs;
6288 if (local_TSa37 == NULL)
6289 rhs = EG (uninitialized_zval_ptr);
6290 else
6291 rhs = local_TSa37;
6293 if (*p_lhs != rhs)
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);
6311 zval* index;
6312 if (local_TLE38 == NULL)
6313 index = EG (uninitialized_zval_ptr);
6314 else
6315 index = local_TLE38;
6318 // String indexing
6319 if (Z_TYPE_PP (p_array) == IS_STRING && Z_STRLEN_PP (p_array) > 0)
6321 zval* rhs;
6322 if (local_TSa41 == NULL)
6323 rhs = EG (uninitialized_zval_ptr);
6324 else
6325 rhs = local_TSa41;
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);
6332 zval* rhs;
6333 if (local_TSa41 == NULL)
6334 rhs = EG (uninitialized_zval_ptr);
6335 else
6336 rhs = local_TSa41;
6338 if (*p_lhs != rhs)
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;
6354 zval* rhs;
6355 if (local_TSa42 == NULL)
6356 rhs = EG (uninitialized_zval_ptr);
6357 else
6358 rhs = local_TSa42;
6360 if (*p_lhs != rhs)
6362 if ((*p_lhs)->is_ref)
6363 overwrite_lhs (*p_lhs, rhs);
6364 else
6366 zval_ptr_dtor (p_lhs);
6367 if (rhs->is_ref)
6369 // Take a copy of RHS for LHS
6370 *p_lhs = zvp_clone_ex (rhs);
6372 else
6374 // Share a copy
6375 rhs->refcount++;
6376 *p_lhs = rhs;
6382 phc_check_invariants (TSRMLS_C);
6384 // goto L124;
6386 goto L124;
6387 phc_check_invariants (TSRMLS_C);
6389 // L123:
6390 L123:;
6391 // $TLE43 = 0;
6393 if (local_TLE43 == NULL)
6395 local_TLE43 = EG (uninitialized_zval_ptr);
6396 local_TLE43->refcount++;
6398 zval** p_lhs = &local_TLE43;
6400 zval* value;
6401 if ((*p_lhs)->is_ref)
6403 // Always overwrite the current value
6404 value = *p_lhs;
6405 zval_dtor (value);
6407 else
6409 ALLOC_INIT_ZVAL (value);
6410 zval_ptr_dtor (p_lhs);
6411 *p_lhs = value;
6414 ZVAL_LONG (value, 0);
6416 phc_check_invariants (TSRMLS_C);
6418 // $TLE44 = 'pipe';
6420 if (local_TLE44 == NULL)
6422 local_TLE44 = EG (uninitialized_zval_ptr);
6423 local_TLE44->refcount++;
6425 zval** p_lhs = &local_TLE44;
6427 zval* value;
6428 if ((*p_lhs)->is_ref)
6430 // Always overwrite the current value
6431 value = *p_lhs;
6432 zval_dtor (value);
6434 else
6436 ALLOC_INIT_ZVAL (value);
6437 zval_ptr_dtor (p_lhs);
6438 *p_lhs = value;
6441 ZVAL_STRINGL(value, "pipe", 4, 1);
6443 phc_check_invariants (TSRMLS_C);
6445 // $TLE45 = 'r';
6447 if (local_TLE45 == NULL)
6449 local_TLE45 = EG (uninitialized_zval_ptr);
6450 local_TLE45->refcount++;
6452 zval** p_lhs = &local_TLE45;
6454 zval* value;
6455 if ((*p_lhs)->is_ref)
6457 // Always overwrite the current value
6458 value = *p_lhs;
6459 zval_dtor (value);
6461 else
6463 ALLOC_INIT_ZVAL (value);
6464 zval_ptr_dtor (p_lhs);
6465 *p_lhs = value;
6468 ZVAL_STRINGL(value, "r", 1, 1);
6470 phc_check_invariants (TSRMLS_C);
6472 // unset($TSa46);
6474 if (local_TSa46 != NULL)
6476 zval_ptr_dtor (&local_TSa46);
6477 local_TSa46 = NULL;
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;
6490 zval* rhs;
6491 if (local_TSa46 == NULL)
6492 rhs = EG (uninitialized_zval_ptr);
6493 else
6494 rhs = local_TSa46;
6496 if (*p_lhs != rhs)
6498 if ((*p_lhs)->is_ref)
6499 overwrite_lhs (*p_lhs, rhs);
6500 else
6502 zval_ptr_dtor (p_lhs);
6503 if (rhs->is_ref)
6505 // Take a copy of RHS for LHS
6506 *p_lhs = zvp_clone_ex (rhs);
6508 else
6510 // Share a copy
6511 rhs->refcount++;
6512 *p_lhs = 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);
6539 if (p_lhs != NULL)
6541 zval* rhs;
6542 if (local_TLE44 == NULL)
6543 rhs = EG (uninitialized_zval_ptr);
6544 else
6545 rhs = local_TLE44;
6547 if (*p_lhs != rhs)
6548 write_var (p_lhs, rhs);
6550 // I think if this is NULL, then the LHS is a bool or similar, and you cant
6551 // push onto it.
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);
6565 if (p_lhs != NULL)
6567 zval* rhs;
6568 if (local_TLE45 == NULL)
6569 rhs = EG (uninitialized_zval_ptr);
6570 else
6571 rhs = local_TLE45;
6573 if (*p_lhs != rhs)
6574 write_var (p_lhs, rhs);
6576 // I think if this is NULL, then the LHS is a bool or similar, and you cant
6577 // push onto it.
6578 phc_check_invariants (TSRMLS_C);
6580 // $TLE47 = 1;
6582 if (local_TLE47 == NULL)
6584 local_TLE47 = EG (uninitialized_zval_ptr);
6585 local_TLE47->refcount++;
6587 zval** p_lhs = &local_TLE47;
6589 zval* value;
6590 if ((*p_lhs)->is_ref)
6592 // Always overwrite the current value
6593 value = *p_lhs;
6594 zval_dtor (value);
6596 else
6598 ALLOC_INIT_ZVAL (value);
6599 zval_ptr_dtor (p_lhs);
6600 *p_lhs = value;
6603 ZVAL_LONG (value, 1);
6605 phc_check_invariants (TSRMLS_C);
6607 // $TLE48 = 'pipe';
6609 if (local_TLE48 == NULL)
6611 local_TLE48 = EG (uninitialized_zval_ptr);
6612 local_TLE48->refcount++;
6614 zval** p_lhs = &local_TLE48;
6616 zval* value;
6617 if ((*p_lhs)->is_ref)
6619 // Always overwrite the current value
6620 value = *p_lhs;
6621 zval_dtor (value);
6623 else
6625 ALLOC_INIT_ZVAL (value);
6626 zval_ptr_dtor (p_lhs);
6627 *p_lhs = value;
6630 ZVAL_STRINGL(value, "pipe", 4, 1);
6632 phc_check_invariants (TSRMLS_C);
6634 // $TLE49 = 'w';
6636 if (local_TLE49 == NULL)
6638 local_TLE49 = EG (uninitialized_zval_ptr);
6639 local_TLE49->refcount++;
6641 zval** p_lhs = &local_TLE49;
6643 zval* value;
6644 if ((*p_lhs)->is_ref)
6646 // Always overwrite the current value
6647 value = *p_lhs;
6648 zval_dtor (value);
6650 else
6652 ALLOC_INIT_ZVAL (value);
6653 zval_ptr_dtor (p_lhs);
6654 *p_lhs = value;
6657 ZVAL_STRINGL(value, "w", 1, 1);
6659 phc_check_invariants (TSRMLS_C);
6661 // unset($TSa50);
6663 if (local_TSa50 != NULL)
6665 zval_ptr_dtor (&local_TSa50);
6666 local_TSa50 = NULL;
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;
6679 zval* rhs;
6680 if (local_TSa50 == NULL)
6681 rhs = EG (uninitialized_zval_ptr);
6682 else
6683 rhs = local_TSa50;
6685 if (*p_lhs != rhs)
6687 if ((*p_lhs)->is_ref)
6688 overwrite_lhs (*p_lhs, rhs);
6689 else
6691 zval_ptr_dtor (p_lhs);
6692 if (rhs->is_ref)
6694 // Take a copy of RHS for LHS
6695 *p_lhs = zvp_clone_ex (rhs);
6697 else
6699 // Share a copy
6700 rhs->refcount++;
6701 *p_lhs = 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);
6728 if (p_lhs != NULL)
6730 zval* rhs;
6731 if (local_TLE48 == NULL)
6732 rhs = EG (uninitialized_zval_ptr);
6733 else
6734 rhs = local_TLE48;
6736 if (*p_lhs != rhs)
6737 write_var (p_lhs, rhs);
6739 // I think if this is NULL, then the LHS is a bool or similar, and you cant
6740 // push onto it.
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);
6754 if (p_lhs != NULL)
6756 zval* rhs;
6757 if (local_TLE49 == NULL)
6758 rhs = EG (uninitialized_zval_ptr);
6759 else
6760 rhs = local_TLE49;
6762 if (*p_lhs != rhs)
6763 write_var (p_lhs, rhs);
6765 // I think if this is NULL, then the LHS is a bool or similar, and you cant
6766 // push onto it.
6767 phc_check_invariants (TSRMLS_C);
6769 // $TLE51 = 2;
6771 if (local_TLE51 == NULL)
6773 local_TLE51 = EG (uninitialized_zval_ptr);
6774 local_TLE51->refcount++;
6776 zval** p_lhs = &local_TLE51;
6778 zval* value;
6779 if ((*p_lhs)->is_ref)
6781 // Always overwrite the current value
6782 value = *p_lhs;
6783 zval_dtor (value);
6785 else
6787 ALLOC_INIT_ZVAL (value);
6788 zval_ptr_dtor (p_lhs);
6789 *p_lhs = value;
6792 ZVAL_LONG (value, 2);
6794 phc_check_invariants (TSRMLS_C);
6796 // $TLE52 = 'file';
6798 if (local_TLE52 == NULL)
6800 local_TLE52 = EG (uninitialized_zval_ptr);
6801 local_TLE52->refcount++;
6803 zval** p_lhs = &local_TLE52;
6805 zval* value;
6806 if ((*p_lhs)->is_ref)
6808 // Always overwrite the current value
6809 value = *p_lhs;
6810 zval_dtor (value);
6812 else
6814 ALLOC_INIT_ZVAL (value);
6815 zval_ptr_dtor (p_lhs);
6816 *p_lhs = value;
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
6829 int by_ref[0];
6830 int abr_index = 0;
6833 // Setup array of arguments
6834 // TODO: i think arrays of size 0 is an error
6835 int destruct [0];
6836 zval* args [0];
6837 zval** args_ind [0];
6839 int af_index = 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;
6849 zval* rhs = NULL;
6851 // set up params
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);
6860 // restore params
6861 wfgetnull_fci.params = params_save;
6862 wfgetnull_fci.param_count = param_count_save;
6863 wfgetnull_fci.retval_ptr_ptr = retval_save;
6865 // unset the errors
6866 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
6868 int i;
6869 for (i = 0; i < 0; i++)
6871 if (destruct[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));
6900 rhs->is_ref = 1;
6901 if (saved_refcount != 0)
6903 rhs->refcount = saved_refcount;
6905 rhs->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);
6925 // $TLE54 = 'a';
6927 if (local_TLE54 == NULL)
6929 local_TLE54 = EG (uninitialized_zval_ptr);
6930 local_TLE54->refcount++;
6932 zval** p_lhs = &local_TLE54;
6934 zval* value;
6935 if ((*p_lhs)->is_ref)
6937 // Always overwrite the current value
6938 value = *p_lhs;
6939 zval_dtor (value);
6941 else
6943 ALLOC_INIT_ZVAL (value);
6944 zval_ptr_dtor (p_lhs);
6945 *p_lhs = value;
6948 ZVAL_STRINGL(value, "a", 1, 1);
6950 phc_check_invariants (TSRMLS_C);
6952 // unset($TSa55);
6954 if (local_TSa55 != NULL)
6956 zval_ptr_dtor (&local_TSa55);
6957 local_TSa55 = NULL;
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;
6970 zval* rhs;
6971 if (local_TSa55 == NULL)
6972 rhs = EG (uninitialized_zval_ptr);
6973 else
6974 rhs = local_TSa55;
6976 if (*p_lhs != rhs)
6978 if ((*p_lhs)->is_ref)
6979 overwrite_lhs (*p_lhs, rhs);
6980 else
6982 zval_ptr_dtor (p_lhs);
6983 if (rhs->is_ref)
6985 // Take a copy of RHS for LHS
6986 *p_lhs = zvp_clone_ex (rhs);
6988 else
6990 // Share a copy
6991 rhs->refcount++;
6992 *p_lhs = 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);
7019 if (p_lhs != NULL)
7021 zval* rhs;
7022 if (local_TLE52 == NULL)
7023 rhs = EG (uninitialized_zval_ptr);
7024 else
7025 rhs = local_TLE52;
7027 if (*p_lhs != rhs)
7028 write_var (p_lhs, rhs);
7030 // I think if this is NULL, then the LHS is a bool or similar, and you cant
7031 // push onto it.
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);
7045 if (p_lhs != NULL)
7047 zval* rhs;
7048 if (local_TLE53 == NULL)
7049 rhs = EG (uninitialized_zval_ptr);
7050 else
7051 rhs = local_TLE53;
7053 if (*p_lhs != rhs)
7054 write_var (p_lhs, rhs);
7056 // I think if this is NULL, then the LHS is a bool or similar, and you cant
7057 // push onto it.
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);
7071 if (p_lhs != NULL)
7073 zval* rhs;
7074 if (local_TLE54 == NULL)
7075 rhs = EG (uninitialized_zval_ptr);
7076 else
7077 rhs = local_TLE54;
7079 if (*p_lhs != rhs)
7080 write_var (p_lhs, rhs);
7082 // I think if this is NULL, then the LHS is a bool or similar, and you cant
7083 // push onto it.
7084 phc_check_invariants (TSRMLS_C);
7086 // unset($TSa56);
7088 if (local_TSa56 != NULL)
7090 zval_ptr_dtor (&local_TSa56);
7091 local_TSa56 = NULL;
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;
7104 zval* rhs;
7105 if (local_TSa56 == NULL)
7106 rhs = EG (uninitialized_zval_ptr);
7107 else
7108 rhs = local_TSa56;
7110 if (*p_lhs != rhs)
7112 if ((*p_lhs)->is_ref)
7113 overwrite_lhs (*p_lhs, rhs);
7114 else
7116 zval_ptr_dtor (p_lhs);
7117 if (rhs->is_ref)
7119 // Take a copy of RHS for LHS
7120 *p_lhs = zvp_clone_ex (rhs);
7122 else
7124 // Share a copy
7125 rhs->refcount++;
7126 *p_lhs = 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);
7153 zval* index;
7154 if (local_TLE43 == NULL)
7155 index = EG (uninitialized_zval_ptr);
7156 else
7157 index = local_TLE43;
7160 // String indexing
7161 if (Z_TYPE_PP (p_array) == IS_STRING && Z_STRLEN_PP (p_array) > 0)
7163 zval* rhs;
7164 if (local_TSa46 == NULL)
7165 rhs = EG (uninitialized_zval_ptr);
7166 else
7167 rhs = local_TSa46;
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);
7174 zval* rhs;
7175 if (local_TSa46 == NULL)
7176 rhs = EG (uninitialized_zval_ptr);
7177 else
7178 rhs = local_TSa46;
7180 if (*p_lhs != rhs)
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);
7198 zval* index;
7199 if (local_TLE47 == NULL)
7200 index = EG (uninitialized_zval_ptr);
7201 else
7202 index = local_TLE47;
7205 // String indexing
7206 if (Z_TYPE_PP (p_array) == IS_STRING && Z_STRLEN_PP (p_array) > 0)
7208 zval* rhs;
7209 if (local_TSa50 == NULL)
7210 rhs = EG (uninitialized_zval_ptr);
7211 else
7212 rhs = local_TSa50;
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);
7219 zval* rhs;
7220 if (local_TSa50 == NULL)
7221 rhs = EG (uninitialized_zval_ptr);
7222 else
7223 rhs = local_TSa50;
7225 if (*p_lhs != rhs)
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);
7243 zval* index;
7244 if (local_TLE51 == NULL)
7245 index = EG (uninitialized_zval_ptr);
7246 else
7247 index = local_TLE51;
7250 // String indexing
7251 if (Z_TYPE_PP (p_array) == IS_STRING && Z_STRLEN_PP (p_array) > 0)
7253 zval* rhs;
7254 if (local_TSa55 == NULL)
7255 rhs = EG (uninitialized_zval_ptr);
7256 else
7257 rhs = local_TSa55;
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);
7264 zval* rhs;
7265 if (local_TSa55 == NULL)
7266 rhs = EG (uninitialized_zval_ptr);
7267 else
7268 rhs = local_TSa55;
7270 if (*p_lhs != rhs)
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;
7286 zval* rhs;
7287 if (local_TSa56 == NULL)
7288 rhs = EG (uninitialized_zval_ptr);
7289 else
7290 rhs = local_TSa56;
7292 if (*p_lhs != rhs)
7294 if ((*p_lhs)->is_ref)
7295 overwrite_lhs (*p_lhs, rhs);
7296 else
7298 zval_ptr_dtor (p_lhs);
7299 if (rhs->is_ref)
7301 // Take a copy of RHS for LHS
7302 *p_lhs = zvp_clone_ex (rhs);
7304 else
7306 // Share a copy
7307 rhs->refcount++;
7308 *p_lhs = rhs;
7314 phc_check_invariants (TSRMLS_C);
7316 // goto L124;
7318 goto L124;
7319 phc_check_invariants (TSRMLS_C);
7321 // L124:
7322 L124:;
7323 // if (stderr) goto L125 else goto L126;
7325 zval* p_cond;
7326 if (local_stderr == NULL)
7327 p_cond = EG (uninitialized_zval_ptr);
7328 else
7329 p_cond = local_stderr;
7331 zend_bool bcond = zend_is_true (p_cond);
7332 if (bcond)
7333 goto L125;
7334 else
7335 goto L126;
7336 phc_check_invariants (TSRMLS_C);
7338 // L125:
7339 L125:;
7340 // $TEF4 = 2;
7342 if (local_TEF4 == NULL)
7344 local_TEF4 = EG (uninitialized_zval_ptr);
7345 local_TEF4->refcount++;
7347 zval** p_lhs = &local_TEF4;
7349 zval* value;
7350 if ((*p_lhs)->is_ref)
7352 // Always overwrite the current value
7353 value = *p_lhs;
7354 zval_dtor (value);
7356 else
7358 ALLOC_INIT_ZVAL (value);
7359 zval_ptr_dtor (p_lhs);
7360 *p_lhs = value;
7363 ZVAL_LONG (value, 2);
7365 phc_check_invariants (TSRMLS_C);
7367 // goto L127;
7369 goto L127;
7370 phc_check_invariants (TSRMLS_C);
7372 // L126:
7373 L126:;
7374 // $TEF4 = 1;
7376 if (local_TEF4 == NULL)
7378 local_TEF4 = EG (uninitialized_zval_ptr);
7379 local_TEF4->refcount++;
7381 zval** p_lhs = &local_TEF4;
7383 zval* value;
7384 if ((*p_lhs)->is_ref)
7386 // Always overwrite the current value
7387 value = *p_lhs;
7388 zval_dtor (value);
7390 else
7392 ALLOC_INIT_ZVAL (value);
7393 zval_ptr_dtor (p_lhs);
7394 *p_lhs = value;
7397 ZVAL_LONG (value, 1);
7399 phc_check_invariants (TSRMLS_C);
7401 // goto L127;
7403 goto L127;
7404 phc_check_invariants (TSRMLS_C);
7406 // L127:
7407 L127:;
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;
7417 zval* rhs;
7418 if (local_TEF4 == NULL)
7419 rhs = EG (uninitialized_zval_ptr);
7420 else
7421 rhs = local_TEF4;
7423 if (*p_lhs != rhs)
7425 if ((*p_lhs)->is_ref)
7426 overwrite_lhs (*p_lhs, rhs);
7427 else
7429 zval_ptr_dtor (p_lhs);
7430 if (rhs->is_ref)
7432 // Take a copy of RHS for LHS
7433 *p_lhs = zvp_clone_ex (rhs);
7435 else
7437 // Share a copy
7438 rhs->refcount++;
7439 *p_lhs = rhs;
7445 phc_check_invariants (TSRMLS_C);
7447 // unset($TSa57);
7449 if (local_TSa57 != NULL)
7451 zval_ptr_dtor (&local_TSa57);
7452 local_TSa57 = NULL;
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;
7465 zval* rhs;
7466 if (local_TSa57 == NULL)
7467 rhs = EG (uninitialized_zval_ptr);
7468 else
7469 rhs = local_TSa57;
7471 if (*p_lhs != rhs)
7473 if ((*p_lhs)->is_ref)
7474 overwrite_lhs (*p_lhs, rhs);
7475 else
7477 zval_ptr_dtor (p_lhs);
7478 if (rhs->is_ref)
7480 // Take a copy of RHS for LHS
7481 *p_lhs = zvp_clone_ex (rhs);
7483 else
7485 // Share a copy
7486 rhs->refcount++;
7487 *p_lhs = 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);
7503 // $pipes = $TSa57;
7505 if (local_pipes == NULL)
7507 local_pipes = EG (uninitialized_zval_ptr);
7508 local_pipes->refcount++;
7510 zval** p_lhs = &local_pipes;
7512 zval* rhs;
7513 if (local_TSa57 == NULL)
7514 rhs = EG (uninitialized_zval_ptr);
7515 else
7516 rhs = local_TSa57;
7518 if (*p_lhs != rhs)
7520 if ((*p_lhs)->is_ref)
7521 overwrite_lhs (*p_lhs, rhs);
7522 else
7524 zval_ptr_dtor (p_lhs);
7525 if (rhs->is_ref)
7527 // Take a copy of RHS for LHS
7528 *p_lhs = zvp_clone_ex (rhs);
7530 else
7532 // Share a copy
7533 rhs->refcount++;
7534 *p_lhs = 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;
7551 zval* value;
7552 if ((*p_lhs)->is_ref)
7554 // Always overwrite the current value
7555 value = *p_lhs;
7556 zval_dtor (value);
7558 else
7560 ALLOC_INIT_ZVAL (value);
7561 zval_ptr_dtor (p_lhs);
7562 *p_lhs = value;
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
7575 int by_ref[1];
7576 int abr_index = 0;
7577 // TODO: find names to replace index
7578 if (arg_info)
7580 by_ref[abr_index] = arg_info->pass_by_reference;
7581 arg_info++;
7583 else
7584 by_ref[abr_index] = signature->common.pass_rest_by_reference;
7586 abr_index++;
7589 // Setup array of arguments
7590 // TODO: i think arrays of size 0 is an error
7591 int destruct [1];
7592 zval* args [1];
7593 zval** args_ind [1];
7595 int af_index = 0;
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];
7610 else
7612 zval* arg;
7613 if (local_TLE58 == NULL)
7614 arg = EG (uninitialized_zval_ptr);
7615 else
7616 arg = local_TLE58;
7618 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
7619 args_ind[af_index] = &args[af_index];
7621 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;
7631 zval* rhs = NULL;
7633 // set up params
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);
7642 // restore params
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;
7647 // unset the errors
7648 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
7650 int i;
7651 for (i = 0; i < 1; i++)
7653 if (destruct[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));
7682 rhs->is_ref = 1;
7683 if (saved_refcount != 0)
7685 rhs->refcount = saved_refcount;
7687 rhs->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;
7709 zval* p_cond;
7710 if (local_TLE59 == NULL)
7711 p_cond = EG (uninitialized_zval_ptr);
7712 else
7713 p_cond = local_TLE59;
7715 zend_bool bcond = zend_is_true (p_cond);
7716 if (bcond)
7717 goto L151;
7718 else
7719 goto L152;
7720 phc_check_invariants (TSRMLS_C);
7722 // L151:
7723 L151:;
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;
7733 zval* value;
7734 if ((*p_lhs)->is_ref)
7736 // Always overwrite the current value
7737 value = *p_lhs;
7738 zval_dtor (value);
7740 else
7742 ALLOC_INIT_ZVAL (value);
7743 zval_ptr_dtor (p_lhs);
7744 *p_lhs = value;
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;
7760 zval* left;
7761 if (local_wgTidyBin == NULL)
7762 left = EG (uninitialized_zval_ptr);
7763 else
7764 left = local_wgTidyBin;
7766 zval* right;
7767 if (local_TLE60 == NULL)
7768 right = EG (uninitialized_zval_ptr);
7769 else
7770 right = local_TLE60;
7772 if (in_copy_on_write (*p_lhs))
7774 zval_ptr_dtor (p_lhs);
7775 ALLOC_INIT_ZVAL (*p_lhs);
7778 zval old = **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)
7785 zval_dtor (&old);
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;
7797 zval* left;
7798 if (local_TLE61 == NULL)
7799 left = EG (uninitialized_zval_ptr);
7800 else
7801 left = local_TLE61;
7803 zval* right;
7804 if (local_wgTidyConf == NULL)
7805 right = EG (uninitialized_zval_ptr);
7806 else
7807 right = local_wgTidyConf;
7809 if (in_copy_on_write (*p_lhs))
7811 zval_ptr_dtor (p_lhs);
7812 ALLOC_INIT_ZVAL (*p_lhs);
7815 zval old = **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)
7822 zval_dtor (&old);
7823 phc_check_invariants (TSRMLS_C);
7825 // $TLE63 = ' ';
7827 if (local_TLE63 == NULL)
7829 local_TLE63 = EG (uninitialized_zval_ptr);
7830 local_TLE63->refcount++;
7832 zval** p_lhs = &local_TLE63;
7834 zval* value;
7835 if ((*p_lhs)->is_ref)
7837 // Always overwrite the current value
7838 value = *p_lhs;
7839 zval_dtor (value);
7841 else
7843 ALLOC_INIT_ZVAL (value);
7844 zval_ptr_dtor (p_lhs);
7845 *p_lhs = value;
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;
7861 zval* left;
7862 if (local_TLE62 == NULL)
7863 left = EG (uninitialized_zval_ptr);
7864 else
7865 left = local_TLE62;
7867 zval* right;
7868 if (local_TLE63 == NULL)
7869 right = EG (uninitialized_zval_ptr);
7870 else
7871 right = local_TLE63;
7873 if (in_copy_on_write (*p_lhs))
7875 zval_ptr_dtor (p_lhs);
7876 ALLOC_INIT_ZVAL (*p_lhs);
7879 zval old = **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)
7886 zval_dtor (&old);
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;
7898 zval* left;
7899 if (local_TLE64 == NULL)
7900 left = EG (uninitialized_zval_ptr);
7901 else
7902 left = local_TLE64;
7904 zval* right;
7905 if (local_wgTidyOpts == NULL)
7906 right = EG (uninitialized_zval_ptr);
7907 else
7908 right = local_wgTidyOpts;
7910 if (in_copy_on_write (*p_lhs))
7912 zval_ptr_dtor (p_lhs);
7913 ALLOC_INIT_ZVAL (*p_lhs);
7916 zval old = **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)
7923 zval_dtor (&old);
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;
7935 zval* left;
7936 if (local_TLE65 == NULL)
7937 left = EG (uninitialized_zval_ptr);
7938 else
7939 left = local_TLE65;
7941 zval* right;
7942 if (local_opts == NULL)
7943 right = EG (uninitialized_zval_ptr);
7944 else
7945 right = local_opts;
7947 if (in_copy_on_write (*p_lhs))
7949 zval_ptr_dtor (p_lhs);
7950 ALLOC_INIT_ZVAL (*p_lhs);
7953 zval old = **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)
7960 zval_dtor (&old);
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
7969 int by_ref[3];
7970 int abr_index = 0;
7971 // TODO: find names to replace index
7972 if (arg_info)
7974 by_ref[abr_index] = arg_info->pass_by_reference;
7975 arg_info++;
7977 else
7978 by_ref[abr_index] = signature->common.pass_rest_by_reference;
7980 abr_index++;
7981 // TODO: find names to replace index
7982 if (arg_info)
7984 by_ref[abr_index] = arg_info->pass_by_reference;
7985 arg_info++;
7987 else
7988 by_ref[abr_index] = signature->common.pass_rest_by_reference;
7990 abr_index++;
7991 // TODO: find names to replace index
7992 if (arg_info)
7994 by_ref[abr_index] = arg_info->pass_by_reference;
7995 arg_info++;
7997 else
7998 by_ref[abr_index] = signature->common.pass_rest_by_reference;
8000 abr_index++;
8003 // Setup array of arguments
8004 // TODO: i think arrays of size 0 is an error
8005 int destruct [3];
8006 zval* args [3];
8007 zval** args_ind [3];
8009 int af_index = 0;
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];
8024 else
8026 zval* arg;
8027 if (local_TLE66 == NULL)
8028 arg = EG (uninitialized_zval_ptr);
8029 else
8030 arg = local_TLE66;
8032 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
8033 args_ind[af_index] = &args[af_index];
8035 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];
8050 else
8052 zval* arg;
8053 if (local_descriptorspec == NULL)
8054 arg = EG (uninitialized_zval_ptr);
8055 else
8056 arg = local_descriptorspec;
8058 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
8059 args_ind[af_index] = &args[af_index];
8061 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];
8076 else
8078 zval* arg;
8079 if (local_pipes == NULL)
8080 arg = EG (uninitialized_zval_ptr);
8081 else
8082 arg = local_pipes;
8084 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
8085 args_ind[af_index] = &args[af_index];
8087 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;
8097 zval* rhs = NULL;
8099 // set up params
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);
8108 // restore params
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;
8113 // unset the errors
8114 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
8116 int i;
8117 for (i = 0; i < 3; i++)
8119 if (destruct[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));
8148 rhs->is_ref = 1;
8149 if (saved_refcount != 0)
8151 rhs->refcount = saved_refcount;
8153 rhs->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
8179 int by_ref[1];
8180 int abr_index = 0;
8181 // TODO: find names to replace index
8182 if (arg_info)
8184 by_ref[abr_index] = arg_info->pass_by_reference;
8185 arg_info++;
8187 else
8188 by_ref[abr_index] = signature->common.pass_rest_by_reference;
8190 abr_index++;
8193 // Setup array of arguments
8194 // TODO: i think arrays of size 0 is an error
8195 int destruct [1];
8196 zval* args [1];
8197 zval** args_ind [1];
8199 int af_index = 0;
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];
8214 else
8216 zval* arg;
8217 if (local_process == NULL)
8218 arg = EG (uninitialized_zval_ptr);
8219 else
8220 arg = local_process;
8222 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
8223 args_ind[af_index] = &args[af_index];
8225 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;
8235 zval* rhs = NULL;
8237 // set up params
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);
8246 // restore params
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;
8251 // unset the errors
8252 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
8254 int i;
8255 for (i = 0; i < 1; i++)
8257 if (destruct[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));
8286 rhs->is_ref = 1;
8287 if (saved_refcount != 0)
8289 rhs->refcount = saved_refcount;
8291 rhs->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;
8313 zval* p_cond;
8314 if (local_TLE67 == NULL)
8315 p_cond = EG (uninitialized_zval_ptr);
8316 else
8317 p_cond = local_TLE67;
8319 zend_bool bcond = zend_is_true (p_cond);
8320 if (bcond)
8321 goto L148;
8322 else
8323 goto L149;
8324 phc_check_invariants (TSRMLS_C);
8326 // L148:
8327 L148:;
8328 // $TLE68 = 0;
8330 if (local_TLE68 == NULL)
8332 local_TLE68 = EG (uninitialized_zval_ptr);
8333 local_TLE68->refcount++;
8335 zval** p_lhs = &local_TLE68;
8337 zval* value;
8338 if ((*p_lhs)->is_ref)
8340 // Always overwrite the current value
8341 value = *p_lhs;
8342 zval_dtor (value);
8344 else
8346 ALLOC_INIT_ZVAL (value);
8347 zval_ptr_dtor (p_lhs);
8348 *p_lhs = value;
8351 ZVAL_LONG (value, 0);
8353 phc_check_invariants (TSRMLS_C);
8355 // $TLE96 = param_is_ref (NULL, "fwrite", 0);
8356 // ;
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;
8361 int count = 0;
8362 while (arg_info && count < 0)
8364 count++;
8365 arg_info++;
8368 if (local_TLE96 == NULL)
8370 local_TLE96 = EG (uninitialized_zval_ptr);
8371 local_TLE96->refcount++;
8373 zval** p_lhs = &local_TLE96;
8375 zval* rhs;
8376 ALLOC_INIT_ZVAL (rhs);
8377 if (arg_info && count == 0)
8379 ZVAL_BOOL (rhs, arg_info->pass_by_reference);
8381 else
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;
8391 zval* p_cond;
8392 if (local_TLE96 == NULL)
8393 p_cond = EG (uninitialized_zval_ptr);
8394 else
8395 p_cond = local_TLE96;
8397 zend_bool bcond = zend_is_true (p_cond);
8398 if (bcond)
8399 goto L128;
8400 else
8401 goto L129;
8402 phc_check_invariants (TSRMLS_C);
8404 // L128:
8405 L128:;
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;
8422 zval* r_index;
8423 if (local_TLE68 == NULL)
8424 r_index = EG (uninitialized_zval_ptr);
8425 else
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);
8434 // goto L130;
8436 goto L130;
8437 phc_check_invariants (TSRMLS_C);
8439 // L129:
8440 L129:;
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;
8450 zval* r_array;
8451 if (local_pipes == NULL)
8452 r_array = EG (uninitialized_zval_ptr);
8453 else
8454 r_array = local_pipes;
8456 zval* r_index;
8457 if (local_TLE68 == NULL)
8458 r_index = EG (uninitialized_zval_ptr);
8459 else
8460 r_index = local_TLE68;
8463 zval* rhs;
8464 int is_rhs_new = 0;
8465 if (Z_TYPE_P (r_array) != IS_ARRAY)
8467 if (Z_TYPE_P (r_array) == IS_STRING)
8469 is_rhs_new = 1;
8470 rhs = read_string_index (r_array, r_index TSRMLS_CC);
8472 else
8473 // TODO: warning here?
8474 rhs = EG (uninitialized_zval_ptr);
8476 else
8478 if (check_array_index_type (r_index TSRMLS_CC))
8480 // Read array variable
8481 read_array (&rhs, r_array, r_index TSRMLS_CC);
8483 else
8484 rhs = *p_lhs; // HACK to fail *p_lhs != rhs
8487 if (*p_lhs != rhs)
8488 write_var (p_lhs, rhs);
8490 if (is_rhs_new) zval_ptr_dtor (&rhs);
8491 phc_check_invariants (TSRMLS_C);
8493 // goto L130;
8495 goto L130;
8496 phc_check_invariants (TSRMLS_C);
8498 // L130:
8499 L130:;
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
8506 int by_ref[2];
8507 int abr_index = 0;
8508 // TODO: find names to replace index
8509 if (arg_info)
8511 by_ref[abr_index] = arg_info->pass_by_reference;
8512 arg_info++;
8514 else
8515 by_ref[abr_index] = signature->common.pass_rest_by_reference;
8517 abr_index++;
8518 // TODO: find names to replace index
8519 if (arg_info)
8521 by_ref[abr_index] = arg_info->pass_by_reference;
8522 arg_info++;
8524 else
8525 by_ref[abr_index] = signature->common.pass_rest_by_reference;
8527 abr_index++;
8530 // Setup array of arguments
8531 // TODO: i think arrays of size 0 is an error
8532 int destruct [2];
8533 zval* args [2];
8534 zval** args_ind [2];
8536 int af_index = 0;
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];
8551 else
8553 zval* arg;
8554 if (local_TMIi95 == NULL)
8555 arg = EG (uninitialized_zval_ptr);
8556 else
8557 arg = local_TMIi95;
8559 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
8560 args_ind[af_index] = &args[af_index];
8562 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];
8577 else
8579 zval* arg;
8580 if (local_text == NULL)
8581 arg = EG (uninitialized_zval_ptr);
8582 else
8583 arg = local_text;
8585 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
8586 args_ind[af_index] = &args[af_index];
8588 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;
8598 zval* rhs = NULL;
8600 // set up params
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);
8609 // restore params
8610 fwrite_fci.params = params_save;
8611 fwrite_fci.param_count = param_count_save;
8612 fwrite_fci.retval_ptr_ptr = retval_save;
8614 // unset the errors
8615 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
8617 int i;
8618 for (i = 0; i < 2; i++)
8620 if (destruct[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));
8649 rhs->is_ref = 1;
8650 if (saved_refcount != 0)
8652 rhs->refcount = saved_refcount;
8654 rhs->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);
8666 // $TLE69 = 0;
8668 if (local_TLE69 == NULL)
8670 local_TLE69 = EG (uninitialized_zval_ptr);
8671 local_TLE69->refcount++;
8673 zval** p_lhs = &local_TLE69;
8675 zval* value;
8676 if ((*p_lhs)->is_ref)
8678 // Always overwrite the current value
8679 value = *p_lhs;
8680 zval_dtor (value);
8682 else
8684 ALLOC_INIT_ZVAL (value);
8685 zval_ptr_dtor (p_lhs);
8686 *p_lhs = value;
8689 ZVAL_LONG (value, 0);
8691 phc_check_invariants (TSRMLS_C);
8693 // $TLE98 = param_is_ref (NULL, "fclose", 0);
8694 // ;
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;
8699 int count = 0;
8700 while (arg_info && count < 0)
8702 count++;
8703 arg_info++;
8706 if (local_TLE98 == NULL)
8708 local_TLE98 = EG (uninitialized_zval_ptr);
8709 local_TLE98->refcount++;
8711 zval** p_lhs = &local_TLE98;
8713 zval* rhs;
8714 ALLOC_INIT_ZVAL (rhs);
8715 if (arg_info && count == 0)
8717 ZVAL_BOOL (rhs, arg_info->pass_by_reference);
8719 else
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;
8729 zval* p_cond;
8730 if (local_TLE98 == NULL)
8731 p_cond = EG (uninitialized_zval_ptr);
8732 else
8733 p_cond = local_TLE98;
8735 zend_bool bcond = zend_is_true (p_cond);
8736 if (bcond)
8737 goto L131;
8738 else
8739 goto L132;
8740 phc_check_invariants (TSRMLS_C);
8742 // L131:
8743 L131:;
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;
8760 zval* r_index;
8761 if (local_TLE69 == NULL)
8762 r_index = EG (uninitialized_zval_ptr);
8763 else
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);
8772 // goto L133;
8774 goto L133;
8775 phc_check_invariants (TSRMLS_C);
8777 // L132:
8778 L132:;
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;
8788 zval* r_array;
8789 if (local_pipes == NULL)
8790 r_array = EG (uninitialized_zval_ptr);
8791 else
8792 r_array = local_pipes;
8794 zval* r_index;
8795 if (local_TLE69 == NULL)
8796 r_index = EG (uninitialized_zval_ptr);
8797 else
8798 r_index = local_TLE69;
8801 zval* rhs;
8802 int is_rhs_new = 0;
8803 if (Z_TYPE_P (r_array) != IS_ARRAY)
8805 if (Z_TYPE_P (r_array) == IS_STRING)
8807 is_rhs_new = 1;
8808 rhs = read_string_index (r_array, r_index TSRMLS_CC);
8810 else
8811 // TODO: warning here?
8812 rhs = EG (uninitialized_zval_ptr);
8814 else
8816 if (check_array_index_type (r_index TSRMLS_CC))
8818 // Read array variable
8819 read_array (&rhs, r_array, r_index TSRMLS_CC);
8821 else
8822 rhs = *p_lhs; // HACK to fail *p_lhs != rhs
8825 if (*p_lhs != rhs)
8826 write_var (p_lhs, rhs);
8828 if (is_rhs_new) zval_ptr_dtor (&rhs);
8829 phc_check_invariants (TSRMLS_C);
8831 // goto L133;
8833 goto L133;
8834 phc_check_invariants (TSRMLS_C);
8836 // L133:
8837 L133:;
8838 // fclose($TMIi97);
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
8844 int by_ref[1];
8845 int abr_index = 0;
8846 // TODO: find names to replace index
8847 if (arg_info)
8849 by_ref[abr_index] = arg_info->pass_by_reference;
8850 arg_info++;
8852 else
8853 by_ref[abr_index] = signature->common.pass_rest_by_reference;
8855 abr_index++;
8858 // Setup array of arguments
8859 // TODO: i think arrays of size 0 is an error
8860 int destruct [1];
8861 zval* args [1];
8862 zval** args_ind [1];
8864 int af_index = 0;
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];
8879 else
8881 zval* arg;
8882 if (local_TMIi97 == NULL)
8883 arg = EG (uninitialized_zval_ptr);
8884 else
8885 arg = local_TMIi97;
8887 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
8888 args_ind[af_index] = &args[af_index];
8890 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;
8900 zval* rhs = NULL;
8902 // set up params
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);
8911 // restore params
8912 fclose_fci.params = params_save;
8913 fclose_fci.param_count = param_count_save;
8914 fclose_fci.retval_ptr_ptr = retval_save;
8916 // unset the errors
8917 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
8919 int i;
8920 for (i = 0; i < 1; i++)
8922 if (destruct[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));
8951 rhs->is_ref = 1;
8952 if (saved_refcount != 0)
8954 rhs->refcount = saved_refcount;
8956 rhs->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);
8968 // L144:
8969 L144:;
8970 // $TLE100 = param_is_ref (NULL, "feof", 0);
8971 // ;
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;
8976 int count = 0;
8977 while (arg_info && count < 0)
8979 count++;
8980 arg_info++;
8983 if (local_TLE100 == NULL)
8985 local_TLE100 = EG (uninitialized_zval_ptr);
8986 local_TLE100->refcount++;
8988 zval** p_lhs = &local_TLE100;
8990 zval* rhs;
8991 ALLOC_INIT_ZVAL (rhs);
8992 if (arg_info && count == 0)
8994 ZVAL_BOOL (rhs, arg_info->pass_by_reference);
8996 else
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;
9006 zval* p_cond;
9007 if (local_TLE100 == NULL)
9008 p_cond = EG (uninitialized_zval_ptr);
9009 else
9010 p_cond = local_TLE100;
9012 zend_bool bcond = zend_is_true (p_cond);
9013 if (bcond)
9014 goto L134;
9015 else
9016 goto L135;
9017 phc_check_invariants (TSRMLS_C);
9019 // L134:
9020 L134:;
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;
9037 zval* r_index;
9038 if (local_readpipe == NULL)
9039 r_index = EG (uninitialized_zval_ptr);
9040 else
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);
9049 // goto L136;
9051 goto L136;
9052 phc_check_invariants (TSRMLS_C);
9054 // L135:
9055 L135:;
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;
9065 zval* r_array;
9066 if (local_pipes == NULL)
9067 r_array = EG (uninitialized_zval_ptr);
9068 else
9069 r_array = local_pipes;
9071 zval* r_index;
9072 if (local_readpipe == NULL)
9073 r_index = EG (uninitialized_zval_ptr);
9074 else
9075 r_index = local_readpipe;
9078 zval* rhs;
9079 int is_rhs_new = 0;
9080 if (Z_TYPE_P (r_array) != IS_ARRAY)
9082 if (Z_TYPE_P (r_array) == IS_STRING)
9084 is_rhs_new = 1;
9085 rhs = read_string_index (r_array, r_index TSRMLS_CC);
9087 else
9088 // TODO: warning here?
9089 rhs = EG (uninitialized_zval_ptr);
9091 else
9093 if (check_array_index_type (r_index TSRMLS_CC))
9095 // Read array variable
9096 read_array (&rhs, r_array, r_index TSRMLS_CC);
9098 else
9099 rhs = *p_lhs; // HACK to fail *p_lhs != rhs
9102 if (*p_lhs != rhs)
9103 write_var (p_lhs, rhs);
9105 if (is_rhs_new) zval_ptr_dtor (&rhs);
9106 phc_check_invariants (TSRMLS_C);
9108 // goto L136;
9110 goto L136;
9111 phc_check_invariants (TSRMLS_C);
9113 // L136:
9114 L136:;
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
9121 int by_ref[1];
9122 int abr_index = 0;
9123 // TODO: find names to replace index
9124 if (arg_info)
9126 by_ref[abr_index] = arg_info->pass_by_reference;
9127 arg_info++;
9129 else
9130 by_ref[abr_index] = signature->common.pass_rest_by_reference;
9132 abr_index++;
9135 // Setup array of arguments
9136 // TODO: i think arrays of size 0 is an error
9137 int destruct [1];
9138 zval* args [1];
9139 zval** args_ind [1];
9141 int af_index = 0;
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];
9156 else
9158 zval* arg;
9159 if (local_TMIi99 == NULL)
9160 arg = EG (uninitialized_zval_ptr);
9161 else
9162 arg = local_TMIi99;
9164 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
9165 args_ind[af_index] = &args[af_index];
9167 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;
9177 zval* rhs = NULL;
9179 // set up params
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);
9188 // restore params
9189 feof_fci.params = params_save;
9190 feof_fci.param_count = param_count_save;
9191 feof_fci.retval_ptr_ptr = retval_save;
9193 // unset the errors
9194 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
9196 int i;
9197 for (i = 0; i < 1; i++)
9199 if (destruct[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));
9228 rhs->is_ref = 1;
9229 if (saved_refcount != 0)
9231 rhs->refcount = saved_refcount;
9233 rhs->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;
9262 zval* rhs;
9263 if (local_TLE70 == NULL)
9264 rhs = EG (uninitialized_zval_ptr);
9265 else
9266 rhs = local_TLE70;
9268 if (in_copy_on_write (*p_lhs))
9270 zval_ptr_dtor (p_lhs);
9271 ALLOC_INIT_ZVAL (*p_lhs);
9274 zval old = **p_lhs;
9275 int result_is_operand = (*p_lhs == rhs);
9276 boolean_not_function (*p_lhs, rhs TSRMLS_CC);
9277 if (!result_is_operand)
9278 zval_dtor (&old);
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;
9290 zval* rhs;
9291 if (local_TLE71 == NULL)
9292 rhs = EG (uninitialized_zval_ptr);
9293 else
9294 rhs = local_TLE71;
9296 if (in_copy_on_write (*p_lhs))
9298 zval_ptr_dtor (p_lhs);
9299 ALLOC_INIT_ZVAL (*p_lhs);
9302 zval old = **p_lhs;
9303 int result_is_operand = (*p_lhs == rhs);
9304 boolean_not_function (*p_lhs, rhs TSRMLS_CC);
9305 if (!result_is_operand)
9306 zval_dtor (&old);
9307 phc_check_invariants (TSRMLS_C);
9309 // if (TLE72) goto L138 else goto L139;
9311 zval* p_cond;
9312 if (local_TLE72 == NULL)
9313 p_cond = EG (uninitialized_zval_ptr);
9314 else
9315 p_cond = local_TLE72;
9317 zend_bool bcond = zend_is_true (p_cond);
9318 if (bcond)
9319 goto L138;
9320 else
9321 goto L139;
9322 phc_check_invariants (TSRMLS_C);
9324 // L138:
9325 L138:;
9326 // goto L137;
9328 goto L137;
9329 phc_check_invariants (TSRMLS_C);
9331 // goto L140;
9333 goto L140;
9334 phc_check_invariants (TSRMLS_C);
9336 // L139:
9337 L139:;
9338 // goto L140;
9340 goto L140;
9341 phc_check_invariants (TSRMLS_C);
9343 // L140:
9344 L140:;
9345 // $TLE73 = 1024;
9347 if (local_TLE73 == NULL)
9349 local_TLE73 = EG (uninitialized_zval_ptr);
9350 local_TLE73->refcount++;
9352 zval** p_lhs = &local_TLE73;
9354 zval* value;
9355 if ((*p_lhs)->is_ref)
9357 // Always overwrite the current value
9358 value = *p_lhs;
9359 zval_dtor (value);
9361 else
9363 ALLOC_INIT_ZVAL (value);
9364 zval_ptr_dtor (p_lhs);
9365 *p_lhs = value;
9368 ZVAL_LONG (value, 1024);
9370 phc_check_invariants (TSRMLS_C);
9372 // $TLE102 = param_is_ref (NULL, "fgets", 0);
9373 // ;
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;
9378 int count = 0;
9379 while (arg_info && count < 0)
9381 count++;
9382 arg_info++;
9385 if (local_TLE102 == NULL)
9387 local_TLE102 = EG (uninitialized_zval_ptr);
9388 local_TLE102->refcount++;
9390 zval** p_lhs = &local_TLE102;
9392 zval* rhs;
9393 ALLOC_INIT_ZVAL (rhs);
9394 if (arg_info && count == 0)
9396 ZVAL_BOOL (rhs, arg_info->pass_by_reference);
9398 else
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;
9408 zval* p_cond;
9409 if (local_TLE102 == NULL)
9410 p_cond = EG (uninitialized_zval_ptr);
9411 else
9412 p_cond = local_TLE102;
9414 zend_bool bcond = zend_is_true (p_cond);
9415 if (bcond)
9416 goto L141;
9417 else
9418 goto L142;
9419 phc_check_invariants (TSRMLS_C);
9421 // L141:
9422 L141:;
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;
9439 zval* r_index;
9440 if (local_readpipe == NULL)
9441 r_index = EG (uninitialized_zval_ptr);
9442 else
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);
9451 // goto L143;
9453 goto L143;
9454 phc_check_invariants (TSRMLS_C);
9456 // L142:
9457 L142:;
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;
9467 zval* r_array;
9468 if (local_pipes == NULL)
9469 r_array = EG (uninitialized_zval_ptr);
9470 else
9471 r_array = local_pipes;
9473 zval* r_index;
9474 if (local_readpipe == NULL)
9475 r_index = EG (uninitialized_zval_ptr);
9476 else
9477 r_index = local_readpipe;
9480 zval* rhs;
9481 int is_rhs_new = 0;
9482 if (Z_TYPE_P (r_array) != IS_ARRAY)
9484 if (Z_TYPE_P (r_array) == IS_STRING)
9486 is_rhs_new = 1;
9487 rhs = read_string_index (r_array, r_index TSRMLS_CC);
9489 else
9490 // TODO: warning here?
9491 rhs = EG (uninitialized_zval_ptr);
9493 else
9495 if (check_array_index_type (r_index TSRMLS_CC))
9497 // Read array variable
9498 read_array (&rhs, r_array, r_index TSRMLS_CC);
9500 else
9501 rhs = *p_lhs; // HACK to fail *p_lhs != rhs
9504 if (*p_lhs != rhs)
9505 write_var (p_lhs, rhs);
9507 if (is_rhs_new) zval_ptr_dtor (&rhs);
9508 phc_check_invariants (TSRMLS_C);
9510 // goto L143;
9512 goto L143;
9513 phc_check_invariants (TSRMLS_C);
9515 // L143:
9516 L143:;
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
9523 int by_ref[2];
9524 int abr_index = 0;
9525 // TODO: find names to replace index
9526 if (arg_info)
9528 by_ref[abr_index] = arg_info->pass_by_reference;
9529 arg_info++;
9531 else
9532 by_ref[abr_index] = signature->common.pass_rest_by_reference;
9534 abr_index++;
9535 // TODO: find names to replace index
9536 if (arg_info)
9538 by_ref[abr_index] = arg_info->pass_by_reference;
9539 arg_info++;
9541 else
9542 by_ref[abr_index] = signature->common.pass_rest_by_reference;
9544 abr_index++;
9547 // Setup array of arguments
9548 // TODO: i think arrays of size 0 is an error
9549 int destruct [2];
9550 zval* args [2];
9551 zval** args_ind [2];
9553 int af_index = 0;
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];
9568 else
9570 zval* arg;
9571 if (local_TMIi101 == NULL)
9572 arg = EG (uninitialized_zval_ptr);
9573 else
9574 arg = local_TMIi101;
9576 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
9577 args_ind[af_index] = &args[af_index];
9579 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];
9594 else
9596 zval* arg;
9597 if (local_TLE73 == NULL)
9598 arg = EG (uninitialized_zval_ptr);
9599 else
9600 arg = local_TLE73;
9602 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
9603 args_ind[af_index] = &args[af_index];
9605 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;
9615 zval* rhs = NULL;
9617 // set up params
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);
9626 // restore params
9627 fgets_fci.params = params_save;
9628 fgets_fci.param_count = param_count_save;
9629 fgets_fci.retval_ptr_ptr = retval_save;
9631 // unset the errors
9632 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
9634 int i;
9635 for (i = 0; i < 2; i++)
9637 if (destruct[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));
9666 rhs->is_ref = 1;
9667 if (saved_refcount != 0)
9669 rhs->refcount = saved_refcount;
9671 rhs->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;
9700 zval* left;
9701 if (local_cleansource == NULL)
9702 left = EG (uninitialized_zval_ptr);
9703 else
9704 left = local_cleansource;
9706 zval* right;
9707 if (local_TLE74 == NULL)
9708 right = EG (uninitialized_zval_ptr);
9709 else
9710 right = local_TLE74;
9712 if (in_copy_on_write (*p_lhs))
9714 zval_ptr_dtor (p_lhs);
9715 ALLOC_INIT_ZVAL (*p_lhs);
9718 zval old = **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)
9725 zval_dtor (&old);
9726 phc_check_invariants (TSRMLS_C);
9728 // goto L144;
9730 goto L144;
9731 phc_check_invariants (TSRMLS_C);
9733 // L137:
9734 L137:;
9735 // $TLE104 = param_is_ref (NULL, "fclose", 0);
9736 // ;
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;
9741 int count = 0;
9742 while (arg_info && count < 0)
9744 count++;
9745 arg_info++;
9748 if (local_TLE104 == NULL)
9750 local_TLE104 = EG (uninitialized_zval_ptr);
9751 local_TLE104->refcount++;
9753 zval** p_lhs = &local_TLE104;
9755 zval* rhs;
9756 ALLOC_INIT_ZVAL (rhs);
9757 if (arg_info && count == 0)
9759 ZVAL_BOOL (rhs, arg_info->pass_by_reference);
9761 else
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;
9771 zval* p_cond;
9772 if (local_TLE104 == NULL)
9773 p_cond = EG (uninitialized_zval_ptr);
9774 else
9775 p_cond = local_TLE104;
9777 zend_bool bcond = zend_is_true (p_cond);
9778 if (bcond)
9779 goto L145;
9780 else
9781 goto L146;
9782 phc_check_invariants (TSRMLS_C);
9784 // L145:
9785 L145:;
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;
9802 zval* r_index;
9803 if (local_readpipe == NULL)
9804 r_index = EG (uninitialized_zval_ptr);
9805 else
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);
9814 // goto L147;
9816 goto L147;
9817 phc_check_invariants (TSRMLS_C);
9819 // L146:
9820 L146:;
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;
9830 zval* r_array;
9831 if (local_pipes == NULL)
9832 r_array = EG (uninitialized_zval_ptr);
9833 else
9834 r_array = local_pipes;
9836 zval* r_index;
9837 if (local_readpipe == NULL)
9838 r_index = EG (uninitialized_zval_ptr);
9839 else
9840 r_index = local_readpipe;
9843 zval* rhs;
9844 int is_rhs_new = 0;
9845 if (Z_TYPE_P (r_array) != IS_ARRAY)
9847 if (Z_TYPE_P (r_array) == IS_STRING)
9849 is_rhs_new = 1;
9850 rhs = read_string_index (r_array, r_index TSRMLS_CC);
9852 else
9853 // TODO: warning here?
9854 rhs = EG (uninitialized_zval_ptr);
9856 else
9858 if (check_array_index_type (r_index TSRMLS_CC))
9860 // Read array variable
9861 read_array (&rhs, r_array, r_index TSRMLS_CC);
9863 else
9864 rhs = *p_lhs; // HACK to fail *p_lhs != rhs
9867 if (*p_lhs != rhs)
9868 write_var (p_lhs, rhs);
9870 if (is_rhs_new) zval_ptr_dtor (&rhs);
9871 phc_check_invariants (TSRMLS_C);
9873 // goto L147;
9875 goto L147;
9876 phc_check_invariants (TSRMLS_C);
9878 // L147:
9879 L147:;
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
9886 int by_ref[1];
9887 int abr_index = 0;
9888 // TODO: find names to replace index
9889 if (arg_info)
9891 by_ref[abr_index] = arg_info->pass_by_reference;
9892 arg_info++;
9894 else
9895 by_ref[abr_index] = signature->common.pass_rest_by_reference;
9897 abr_index++;
9900 // Setup array of arguments
9901 // TODO: i think arrays of size 0 is an error
9902 int destruct [1];
9903 zval* args [1];
9904 zval** args_ind [1];
9906 int af_index = 0;
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];
9921 else
9923 zval* arg;
9924 if (local_TMIi103 == NULL)
9925 arg = EG (uninitialized_zval_ptr);
9926 else
9927 arg = local_TMIi103;
9929 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
9930 args_ind[af_index] = &args[af_index];
9932 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;
9942 zval* rhs = NULL;
9944 // set up params
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);
9953 // restore params
9954 fclose_fci.params = params_save;
9955 fclose_fci.param_count = param_count_save;
9956 fclose_fci.retval_ptr_ptr = retval_save;
9958 // unset the errors
9959 phc_setup_error (0, NULL, 0, NULL TSRMLS_CC);
9961 int i;
9962 for (i = 0; i < 1; i++)
9964 if (destruct[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));
9993 rhs->is_ref = 1;
9994 if (saved_refcount != 0)
9996 rhs->refcount = saved_refcount;
9998 rhs->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
10016 int by_ref[1];
10017 int abr_index = 0;
10018 // TODO: find names to replace index
10019 if (arg_info)
10021 by_ref[abr_index] = arg_info->pass_by_reference;
10022 arg_info++;
10024 else
10025 by_ref[abr_index] = signature->common.pass_rest_by_reference;
10027 abr_index++;
10030 // Setup array of arguments
10031 // TODO: i think arrays of size 0 is an error
10032 int destruct [1];
10033 zval* args [1];
10034 zval** args_ind [1];
10036 int af_index = 0;
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];
10051 else
10053 zval* arg;
10054 if (local_process == NULL)
10055 arg = EG (uninitialized_zval_ptr);
10056 else
10057 arg = local_process;
10059 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
10060 args_ind[af_index] = &args[af_index];
10062 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;
10072 zval* rhs = NULL;
10074 // set up params
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);
10083 // restore params
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);
10091 int i;
10092 for (i = 0; i < 1; i++)
10094 if (destruct[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));
10123 rhs->is_ref = 1;
10124 if (saved_refcount != 0)
10126 rhs->refcount = saved_refcount;
10128 rhs->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);
10148 // goto L150;
10150 goto L150;
10151 phc_check_invariants (TSRMLS_C);
10153 // L149:
10154 L149:;
10155 // $retval = -1;
10157 if (local_retval == NULL)
10159 local_retval = EG (uninitialized_zval_ptr);
10160 local_retval->refcount++;
10162 zval** p_lhs = &local_retval;
10164 zval* value;
10165 if ((*p_lhs)->is_ref)
10167 // Always overwrite the current value
10168 value = *p_lhs;
10169 zval_dtor (value);
10171 else
10173 ALLOC_INIT_ZVAL (value);
10174 zval_ptr_dtor (p_lhs);
10175 *p_lhs = value;
10178 ZVAL_LONG (value, -1);
10180 phc_check_invariants (TSRMLS_C);
10182 // goto L150;
10184 goto L150;
10185 phc_check_invariants (TSRMLS_C);
10187 // L150:
10188 L150:;
10189 // goto L153;
10191 goto L153;
10192 phc_check_invariants (TSRMLS_C);
10194 // L152:
10195 L152:;
10196 // $retval = -1;
10198 if (local_retval == NULL)
10200 local_retval = EG (uninitialized_zval_ptr);
10201 local_retval->refcount++;
10203 zval** p_lhs = &local_retval;
10205 zval* value;
10206 if ((*p_lhs)->is_ref)
10208 // Always overwrite the current value
10209 value = *p_lhs;
10210 zval_dtor (value);
10212 else
10214 ALLOC_INIT_ZVAL (value);
10215 zval_ptr_dtor (p_lhs);
10216 *p_lhs = value;
10219 ZVAL_LONG (value, -1);
10221 phc_check_invariants (TSRMLS_C);
10223 // goto L153;
10225 goto L153;
10226 phc_check_invariants (TSRMLS_C);
10228 // L153:
10229 L153:;
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;
10239 zval* value;
10240 if ((*p_lhs)->is_ref)
10242 // Always overwrite the current value
10243 value = *p_lhs;
10244 zval_dtor (value);
10246 else
10248 ALLOC_INIT_ZVAL (value);
10249 zval_ptr_dtor (p_lhs);
10250 *p_lhs = value;
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
10263 int by_ref[1];
10264 int abr_index = 0;
10265 // TODO: find names to replace index
10266 if (arg_info)
10268 by_ref[abr_index] = arg_info->pass_by_reference;
10269 arg_info++;
10271 else
10272 by_ref[abr_index] = signature->common.pass_rest_by_reference;
10274 abr_index++;
10277 // Setup array of arguments
10278 // TODO: i think arrays of size 0 is an error
10279 int destruct [1];
10280 zval* args [1];
10281 zval** args_ind [1];
10283 int af_index = 0;
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];
10298 else
10300 zval* arg;
10301 if (local_TLE75 == NULL)
10302 arg = EG (uninitialized_zval_ptr);
10303 else
10304 arg = local_TLE75;
10306 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
10307 args_ind[af_index] = &args[af_index];
10309 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;
10319 zval* rhs = NULL;
10321 // set up params
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);
10330 // restore params
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);
10338 int i;
10339 for (i = 0; i < 1; i++)
10341 if (destruct[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));
10370 rhs->is_ref = 1;
10371 if (saved_refcount != 0)
10373 rhs->refcount = saved_refcount;
10375 rhs->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;
10396 zval* rhs;
10397 if (local_stderr == NULL)
10398 rhs = EG (uninitialized_zval_ptr);
10399 else
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)
10412 zval_dtor (&old);
10413 phc_check_invariants (TSRMLS_C);
10415 // if (TLE5) goto L154 else goto L155;
10417 zval* p_cond;
10418 if (local_TLE5 == NULL)
10419 p_cond = EG (uninitialized_zval_ptr);
10420 else
10421 p_cond = local_TLE5;
10423 zend_bool bcond = zend_is_true (p_cond);
10424 if (bcond)
10425 goto L154;
10426 else
10427 goto L155;
10428 phc_check_invariants (TSRMLS_C);
10430 // L154:
10431 L154:;
10432 // $TLE76 = '';
10434 if (local_TLE76 == NULL)
10436 local_TLE76 = EG (uninitialized_zval_ptr);
10437 local_TLE76->refcount++;
10439 zval** p_lhs = &local_TLE76;
10441 zval* value;
10442 if ((*p_lhs)->is_ref)
10444 // Always overwrite the current value
10445 value = *p_lhs;
10446 zval_dtor (value);
10448 else
10450 ALLOC_INIT_ZVAL (value);
10451 zval_ptr_dtor (p_lhs);
10452 *p_lhs = value;
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;
10468 zval* left;
10469 if (local_cleansource == NULL)
10470 left = EG (uninitialized_zval_ptr);
10471 else
10472 left = local_cleansource;
10474 zval* right;
10475 if (local_TLE76 == NULL)
10476 right = EG (uninitialized_zval_ptr);
10477 else
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)
10493 zval_dtor (&old);
10494 phc_check_invariants (TSRMLS_C);
10496 // goto L156;
10498 goto L156;
10499 phc_check_invariants (TSRMLS_C);
10501 // L155:
10502 L155:;
10503 // $TEF6 = $TLE5;
10505 if (local_TEF6 == NULL)
10507 local_TEF6 = EG (uninitialized_zval_ptr);
10508 local_TEF6->refcount++;
10510 zval** p_lhs = &local_TEF6;
10512 zval* rhs;
10513 if (local_TLE5 == NULL)
10514 rhs = EG (uninitialized_zval_ptr);
10515 else
10516 rhs = local_TLE5;
10518 if (*p_lhs != rhs)
10520 if ((*p_lhs)->is_ref)
10521 overwrite_lhs (*p_lhs, rhs);
10522 else
10524 zval_ptr_dtor (p_lhs);
10525 if (rhs->is_ref)
10527 // Take a copy of RHS for LHS
10528 *p_lhs = zvp_clone_ex (rhs);
10530 else
10532 // Share a copy
10533 rhs->refcount++;
10534 *p_lhs = rhs;
10540 phc_check_invariants (TSRMLS_C);
10542 // goto L156;
10544 goto L156;
10545 phc_check_invariants (TSRMLS_C);
10547 // L156:
10548 L156:;
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;
10558 zval* rhs;
10559 if (local_TEF6 == NULL)
10560 rhs = EG (uninitialized_zval_ptr);
10561 else
10562 rhs = local_TEF6;
10564 if (*p_lhs != rhs)
10566 if ((*p_lhs)->is_ref)
10567 overwrite_lhs (*p_lhs, rhs);
10568 else
10570 zval_ptr_dtor (p_lhs);
10571 if (rhs->is_ref)
10573 // Take a copy of RHS for LHS
10574 *p_lhs = zvp_clone_ex (rhs);
10576 else
10578 // Share a copy
10579 rhs->refcount++;
10580 *p_lhs = 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;
10598 zval* p_cond;
10599 if (local_TLE7 == NULL)
10600 p_cond = EG (uninitialized_zval_ptr);
10601 else
10602 p_cond = local_TLE7;
10604 zend_bool bcond = zend_is_true (p_cond);
10605 if (bcond)
10606 goto L157;
10607 else
10608 goto L158;
10609 phc_check_invariants (TSRMLS_C);
10611 // L157:
10612 L157:;
10613 // $TLE77 = '';
10615 if (local_TLE77 == NULL)
10617 local_TLE77 = EG (uninitialized_zval_ptr);
10618 local_TLE77->refcount++;
10620 zval** p_lhs = &local_TLE77;
10622 zval* value;
10623 if ((*p_lhs)->is_ref)
10625 // Always overwrite the current value
10626 value = *p_lhs;
10627 zval_dtor (value);
10629 else
10631 ALLOC_INIT_ZVAL (value);
10632 zval_ptr_dtor (p_lhs);
10633 *p_lhs = value;
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;
10649 zval* left;
10650 if (local_text == NULL)
10651 left = EG (uninitialized_zval_ptr);
10652 else
10653 left = local_text;
10655 zval* right;
10656 if (local_TLE77 == NULL)
10657 right = EG (uninitialized_zval_ptr);
10658 else
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)
10674 zval_dtor (&old);
10675 phc_check_invariants (TSRMLS_C);
10677 // goto L159;
10679 goto L159;
10680 phc_check_invariants (TSRMLS_C);
10682 // L158:
10683 L158:;
10684 // $TEF8 = $TLE7;
10686 if (local_TEF8 == NULL)
10688 local_TEF8 = EG (uninitialized_zval_ptr);
10689 local_TEF8->refcount++;
10691 zval** p_lhs = &local_TEF8;
10693 zval* rhs;
10694 if (local_TLE7 == NULL)
10695 rhs = EG (uninitialized_zval_ptr);
10696 else
10697 rhs = local_TLE7;
10699 if (*p_lhs != rhs)
10701 if ((*p_lhs)->is_ref)
10702 overwrite_lhs (*p_lhs, rhs);
10703 else
10705 zval_ptr_dtor (p_lhs);
10706 if (rhs->is_ref)
10708 // Take a copy of RHS for LHS
10709 *p_lhs = zvp_clone_ex (rhs);
10711 else
10713 // Share a copy
10714 rhs->refcount++;
10715 *p_lhs = rhs;
10721 phc_check_invariants (TSRMLS_C);
10723 // goto L159;
10725 goto L159;
10726 phc_check_invariants (TSRMLS_C);
10728 // L159:
10729 L159:;
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;
10739 zval* rhs;
10740 if (local_TEF8 == NULL)
10741 rhs = EG (uninitialized_zval_ptr);
10742 else
10743 rhs = local_TEF8;
10745 if (*p_lhs != rhs)
10747 if ((*p_lhs)->is_ref)
10748 overwrite_lhs (*p_lhs, rhs);
10749 else
10751 zval_ptr_dtor (p_lhs);
10752 if (rhs->is_ref)
10754 // Take a copy of RHS for LHS
10755 *p_lhs = zvp_clone_ex (rhs);
10757 else
10759 // Share a copy
10760 rhs->refcount++;
10761 *p_lhs = 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;
10779 zval* p_cond;
10780 if (local_TLE78 == NULL)
10781 p_cond = EG (uninitialized_zval_ptr);
10782 else
10783 p_cond = local_TLE78;
10785 zend_bool bcond = zend_is_true (p_cond);
10786 if (bcond)
10787 goto L160;
10788 else
10789 goto L161;
10790 phc_check_invariants (TSRMLS_C);
10792 // L160:
10793 L160:;
10794 // $TLE79 = NULL;
10796 if (local_TLE79 == NULL)
10798 local_TLE79 = EG (uninitialized_zval_ptr);
10799 local_TLE79->refcount++;
10801 zval** p_lhs = &local_TLE79;
10803 zval* value;
10804 if ((*p_lhs)->is_ref)
10806 // Always overwrite the current value
10807 value = *p_lhs;
10808 zval_dtor (value);
10810 else
10812 ALLOC_INIT_ZVAL (value);
10813 zval_ptr_dtor (p_lhs);
10814 *p_lhs = value;
10817 ZVAL_NULL (value);
10819 phc_check_invariants (TSRMLS_C);
10821 // return $TLE79;
10823 zval* rhs;
10824 if (local_TLE79 == NULL)
10825 rhs = EG (uninitialized_zval_ptr);
10826 else
10827 rhs = local_TLE79;
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);
10840 // goto L162;
10842 goto L162;
10843 phc_check_invariants (TSRMLS_C);
10845 // L161:
10846 L161:;
10847 // return $cleansource;
10849 zval* rhs;
10850 if (local_cleansource == NULL)
10851 rhs = EG (uninitialized_zval_ptr);
10852 else
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);
10866 // goto L162;
10868 goto L162;
10869 phc_check_invariants (TSRMLS_C);
10871 // L162:
10872 L162:;
10873 // Method exit
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)
11193 // {
11194 // global $wgTidyConf;
11195 // global $IP;
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;
11203 // L175:
11204 // $retval = $tidy->getstatus();
11205 // $TSt82 = $tidy->errorBuffer;
11206 // return $TSt82;
11207 // goto L177;
11208 // L176:
11209 // $tidy->cleanrepair();
11210 // $retval = $tidy->getstatus();
11211 // $TLE83 = 2;
11212 // $TLE84 = ($retval == $TLE83);
11213 // if (TLE84) goto L163 else goto L164;
11214 // L163:
11215 // $cleansource = NULL;
11216 // goto L165;
11217 // L164:
11218 // $cleansource = tidy_get_output($tidy);
11219 // goto L165;
11220 // L165:
11221 // $TLE9 = $wgDebugTidy;
11222 // if (TLE9) goto L166 else goto L167;
11223 // L166:
11224 // $TLE85 = 0;
11225 // $TEF10 = ($TLE85 < $retval);
11226 // goto L168;
11227 // L167:
11228 // $TEF10 = $TLE9;
11229 // goto L168;
11230 // L168:
11231 // $TLE86 = (bool) $TEF10;
11232 // if (TLE86) goto L172 else goto L173;
11233 // L172:
11234 // $TLE87 = '<!--
11235 // Tidy reports:
11236 // ';
11237 // $TLE88 = '-->';
11238 // $TLE89 = '--&gt;';
11239 // $TLE106 = param_is_ref (NULL, "str_replace", 0);
11240 // ;
11241 // if (TLE106) goto L169 else goto L170;
11242 // L169:
11243 // $TMIt105 =& $tidy->errorBuffer;
11244 // goto L171;
11245 // L170:
11246 // $TMIt105 = $tidy->errorBuffer;
11247 // goto L171;
11248 // L171:
11249 // $TLE90 = str_replace($TLE88, $TLE89, $TMIt105);
11250 // $TLE91 = ($TLE87 . $TLE90);
11251 // $TLE92 = '
11252 // -->';
11253 // $TLE93 = ($TLE91 . $TLE92);
11254 // $cleansource = ($cleansource . $TLE93);
11255 // goto L174;
11256 // L173:
11257 // goto L174;
11258 // L174:
11259 // $TLE94 = 'MWTidy::execInternalTidy';
11260 // wfprofileout($TLE94);
11261 // return $cleansource;
11262 // goto L177;
11263 // L177:
11264 // }
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 ();
11297 zval* params[3];
11298 zend_get_parameters_array(0, num_args, params);
11299 // param 0
11300 params[0]->refcount++;
11301 if (local_text != NULL)
11303 zval_ptr_dtor (&local_text);
11305 local_text = params[0];
11306 // param 1
11307 if (num_args <= 1)
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__;
11321 zval* value;
11322 if ((*p_lhs)->is_ref)
11324 // Always overwrite the current value
11325 value = *p_lhs;
11326 zval_dtor (value);
11328 else
11330 ALLOC_INIT_ZVAL (value);
11331 zval_ptr_dtor (p_lhs);
11332 *p_lhs = value;
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];
11356 // param 2
11357 if (num_args <= 2)
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__;
11371 zval* value;
11372 if ((*p_lhs)->is_ref)
11374 // Always overwrite the current value
11375 value = *p_lhs;
11376 zval_dtor (value);
11378 else
11380 ALLOC_INIT_ZVAL (value);
11381 zval_ptr_dtor (p_lhs);
11382 *p_lhs = value;
11385 ZVAL_NULL (value);
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];
11407 // Function body
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);
11423 // global $IP;
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;
11462 zval* value;
11463 if ((*p_lhs)->is_ref)
11465 // Always overwrite the current value
11466 value = *p_lhs;
11467 zval_dtor (value);
11469 else
11471 ALLOC_INIT_ZVAL (value);
11472 zval_ptr_dtor (p_lhs);
11473 *p_lhs = value;
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
11486 int by_ref[1];
11487 int abr_index = 0;
11488 // TODO: find names to replace index
11489 if (arg_info)
11491 by_ref[abr_index] = arg_info->pass_by_reference;
11492 arg_info++;
11494 else
11495 by_ref[abr_index] = signature->common.pass_rest_by_reference;
11497 abr_index++;
11500 // Setup array of arguments
11501 // TODO: i think arrays of size 0 is an error
11502 int destruct [1];
11503 zval* args [1];
11504 zval** args_ind [1];
11506 int af_index = 0;
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];
11521 else
11523 zval* arg;
11524 if (local_TLE80 == NULL)
11525 arg = EG (uninitialized_zval_ptr);
11526 else
11527 arg = local_TLE80;
11529 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
11530 args_ind[af_index] = &args[af_index];
11532 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;
11542 zval* rhs = NULL;
11544 // set up params
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);
11553 // restore params
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);
11561 int i;
11562 for (i = 0; i < 1; i++)
11564 if (destruct[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));
11593 rhs->is_ref = 1;
11594 if (saved_refcount != 0)
11596 rhs->refcount = saved_refcount;
11598 rhs->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;
11619 zval* lhs;
11620 if ((*p_lhs)->is_ref)
11622 // Always overwrite the current value
11623 lhs = *p_lhs;
11624 zval_dtor (lhs);
11626 else
11628 ALLOC_INIT_ZVAL (lhs);
11629 zval_ptr_dtor (p_lhs);
11630 *p_lhs = 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
11654 int by_ref[0];
11655 int abr_index = 0;
11658 // Setup array of arguments
11659 // TODO: i think arrays of size 0 is an error
11660 int destruct [0];
11661 zval* args [0];
11662 zval** args_ind [0];
11664 int af_index = 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;
11674 zval* rhs = NULL;
11676 // set up params
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);
11685 // restore params
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);
11693 int i;
11694 for (i = 0; i < 0; i++)
11696 if (destruct[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));
11725 rhs->is_ref = 1;
11726 if (saved_refcount != 0)
11728 rhs->refcount = saved_refcount;
11730 rhs->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;
11752 zval* value;
11753 if ((*p_lhs)->is_ref)
11755 // Always overwrite the current value
11756 value = *p_lhs;
11757 zval_dtor (value);
11759 else
11761 ALLOC_INIT_ZVAL (value);
11762 zval_ptr_dtor (p_lhs);
11763 *p_lhs = value;
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
11785 int by_ref[3];
11786 int abr_index = 0;
11787 // TODO: find names to replace index
11788 if (arg_info)
11790 by_ref[abr_index] = arg_info->pass_by_reference;
11791 arg_info++;
11793 else
11794 by_ref[abr_index] = signature->common.pass_rest_by_reference;
11796 abr_index++;
11797 // TODO: find names to replace index
11798 if (arg_info)
11800 by_ref[abr_index] = arg_info->pass_by_reference;
11801 arg_info++;
11803 else
11804 by_ref[abr_index] = signature->common.pass_rest_by_reference;
11806 abr_index++;
11807 // TODO: find names to replace index
11808 if (arg_info)
11810 by_ref[abr_index] = arg_info->pass_by_reference;
11811 arg_info++;
11813 else
11814 by_ref[abr_index] = signature->common.pass_rest_by_reference;
11816 abr_index++;
11819 // Setup array of arguments
11820 // TODO: i think arrays of size 0 is an error
11821 int destruct [3];
11822 zval* args [3];
11823 zval** args_ind [3];
11825 int af_index = 0;
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];
11840 else
11842 zval* arg;
11843 if (local_text == NULL)
11844 arg = EG (uninitialized_zval_ptr);
11845 else
11846 arg = local_text;
11848 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
11849 args_ind[af_index] = &args[af_index];
11851 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];
11866 else
11868 zval* arg;
11869 if (local_wgTidyConf == NULL)
11870 arg = EG (uninitialized_zval_ptr);
11871 else
11872 arg = local_wgTidyConf;
11874 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
11875 args_ind[af_index] = &args[af_index];
11877 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];
11892 else
11894 zval* arg;
11895 if (local_TLE81 == NULL)
11896 arg = EG (uninitialized_zval_ptr);
11897 else
11898 arg = local_TLE81;
11900 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
11901 args_ind[af_index] = &args[af_index];
11903 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;
11913 zval* rhs = NULL;
11915 // set up params
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);
11924 // restore params
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);
11932 int i;
11933 for (i = 0; i < 3; i++)
11935 if (destruct[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));
11964 rhs->is_ref = 1;
11965 if (saved_refcount != 0)
11967 rhs->refcount = saved_refcount;
11969 rhs->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;
11983 zval* p_cond;
11984 if (local_stderr == NULL)
11985 p_cond = EG (uninitialized_zval_ptr);
11986 else
11987 p_cond = local_stderr;
11989 zend_bool bcond = zend_is_true (p_cond);
11990 if (bcond)
11991 goto L175;
11992 else
11993 goto L176;
11994 phc_check_invariants (TSRMLS_C);
11996 // L175:
11997 L175:;
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
12013 int by_ref[0];
12014 int abr_index = 0;
12017 // Setup array of arguments
12018 // TODO: i think arrays of size 0 is an error
12019 int destruct [0];
12020 zval* args [0];
12021 zval** args_ind [0];
12023 int af_index = 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;
12033 zval* rhs = NULL;
12035 // set up params
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);
12044 // restore params
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);
12052 int i;
12053 for (i = 0; i < 0; i++)
12055 if (destruct[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));
12084 rhs->is_ref = 1;
12085 if (saved_refcount != 0)
12087 rhs->refcount = saved_refcount;
12089 rhs->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;
12118 zval field_name;
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);
12134 // return $TSt82;
12136 zval* rhs;
12137 if (local_TSt82 == NULL)
12138 rhs = EG (uninitialized_zval_ptr);
12139 else
12140 rhs = local_TSt82;
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);
12153 // goto L177;
12155 goto L177;
12156 phc_check_invariants (TSRMLS_C);
12158 // L176:
12159 L176:;
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
12175 int by_ref[0];
12176 int abr_index = 0;
12179 // Setup array of arguments
12180 // TODO: i think arrays of size 0 is an error
12181 int destruct [0];
12182 zval* args [0];
12183 zval** args_ind [0];
12185 int af_index = 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;
12195 zval* rhs = NULL;
12197 // set up params
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);
12206 // restore params
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);
12214 int i;
12215 for (i = 0; i < 0; i++)
12217 if (destruct[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));
12246 rhs->is_ref = 1;
12247 if (saved_refcount != 0)
12249 rhs->refcount = saved_refcount;
12251 rhs->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
12278 int by_ref[0];
12279 int abr_index = 0;
12282 // Setup array of arguments
12283 // TODO: i think arrays of size 0 is an error
12284 int destruct [0];
12285 zval* args [0];
12286 zval** args_ind [0];
12288 int af_index = 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;
12298 zval* rhs = NULL;
12300 // set up params
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);
12309 // restore params
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);
12317 int i;
12318 for (i = 0; i < 0; i++)
12320 if (destruct[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));
12349 rhs->is_ref = 1;
12350 if (saved_refcount != 0)
12352 rhs->refcount = saved_refcount;
12354 rhs->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);
12374 // $TLE83 = 2;
12376 if (local_TLE83 == NULL)
12378 local_TLE83 = EG (uninitialized_zval_ptr);
12379 local_TLE83->refcount++;
12381 zval** p_lhs = &local_TLE83;
12383 zval* value;
12384 if ((*p_lhs)->is_ref)
12386 // Always overwrite the current value
12387 value = *p_lhs;
12388 zval_dtor (value);
12390 else
12392 ALLOC_INIT_ZVAL (value);
12393 zval_ptr_dtor (p_lhs);
12394 *p_lhs = value;
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;
12410 zval* left;
12411 if (local_retval == NULL)
12412 left = EG (uninitialized_zval_ptr);
12413 else
12414 left = local_retval;
12416 zval* right;
12417 if (local_TLE83 == NULL)
12418 right = EG (uninitialized_zval_ptr);
12419 else
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)
12435 zval_dtor (&old);
12436 phc_check_invariants (TSRMLS_C);
12438 // if (TLE84) goto L163 else goto L164;
12440 zval* p_cond;
12441 if (local_TLE84 == NULL)
12442 p_cond = EG (uninitialized_zval_ptr);
12443 else
12444 p_cond = local_TLE84;
12446 zend_bool bcond = zend_is_true (p_cond);
12447 if (bcond)
12448 goto L163;
12449 else
12450 goto L164;
12451 phc_check_invariants (TSRMLS_C);
12453 // L163:
12454 L163:;
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;
12464 zval* value;
12465 if ((*p_lhs)->is_ref)
12467 // Always overwrite the current value
12468 value = *p_lhs;
12469 zval_dtor (value);
12471 else
12473 ALLOC_INIT_ZVAL (value);
12474 zval_ptr_dtor (p_lhs);
12475 *p_lhs = value;
12478 ZVAL_NULL (value);
12480 phc_check_invariants (TSRMLS_C);
12482 // goto L165;
12484 goto L165;
12485 phc_check_invariants (TSRMLS_C);
12487 // L164:
12488 L164:;
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
12495 int by_ref[1];
12496 int abr_index = 0;
12497 // TODO: find names to replace index
12498 if (arg_info)
12500 by_ref[abr_index] = arg_info->pass_by_reference;
12501 arg_info++;
12503 else
12504 by_ref[abr_index] = signature->common.pass_rest_by_reference;
12506 abr_index++;
12509 // Setup array of arguments
12510 // TODO: i think arrays of size 0 is an error
12511 int destruct [1];
12512 zval* args [1];
12513 zval** args_ind [1];
12515 int af_index = 0;
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];
12530 else
12532 zval* arg;
12533 if (local_tidy == NULL)
12534 arg = EG (uninitialized_zval_ptr);
12535 else
12536 arg = local_tidy;
12538 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
12539 args_ind[af_index] = &args[af_index];
12541 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;
12551 zval* rhs = NULL;
12553 // set up params
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);
12562 // restore params
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);
12570 int i;
12571 for (i = 0; i < 1; i++)
12573 if (destruct[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));
12602 rhs->is_ref = 1;
12603 if (saved_refcount != 0)
12605 rhs->refcount = saved_refcount;
12607 rhs->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);
12627 // goto L165;
12629 goto L165;
12630 phc_check_invariants (TSRMLS_C);
12632 // L165:
12633 L165:;
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;
12643 zval* rhs;
12644 if (local_wgDebugTidy == NULL)
12645 rhs = EG (uninitialized_zval_ptr);
12646 else
12647 rhs = local_wgDebugTidy;
12649 if (*p_lhs != rhs)
12651 if ((*p_lhs)->is_ref)
12652 overwrite_lhs (*p_lhs, rhs);
12653 else
12655 zval_ptr_dtor (p_lhs);
12656 if (rhs->is_ref)
12658 // Take a copy of RHS for LHS
12659 *p_lhs = zvp_clone_ex (rhs);
12661 else
12663 // Share a copy
12664 rhs->refcount++;
12665 *p_lhs = rhs;
12671 phc_check_invariants (TSRMLS_C);
12673 // if (TLE9) goto L166 else goto L167;
12675 zval* p_cond;
12676 if (local_TLE9 == NULL)
12677 p_cond = EG (uninitialized_zval_ptr);
12678 else
12679 p_cond = local_TLE9;
12681 zend_bool bcond = zend_is_true (p_cond);
12682 if (bcond)
12683 goto L166;
12684 else
12685 goto L167;
12686 phc_check_invariants (TSRMLS_C);
12688 // L166:
12689 L166:;
12690 // $TLE85 = 0;
12692 if (local_TLE85 == NULL)
12694 local_TLE85 = EG (uninitialized_zval_ptr);
12695 local_TLE85->refcount++;
12697 zval** p_lhs = &local_TLE85;
12699 zval* value;
12700 if ((*p_lhs)->is_ref)
12702 // Always overwrite the current value
12703 value = *p_lhs;
12704 zval_dtor (value);
12706 else
12708 ALLOC_INIT_ZVAL (value);
12709 zval_ptr_dtor (p_lhs);
12710 *p_lhs = value;
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;
12726 zval* left;
12727 if (local_TLE85 == NULL)
12728 left = EG (uninitialized_zval_ptr);
12729 else
12730 left = local_TLE85;
12732 zval* right;
12733 if (local_retval == NULL)
12734 right = EG (uninitialized_zval_ptr);
12735 else
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)
12751 zval_dtor (&old);
12752 phc_check_invariants (TSRMLS_C);
12754 // goto L168;
12756 goto L168;
12757 phc_check_invariants (TSRMLS_C);
12759 // L167:
12760 L167:;
12761 // $TEF10 = $TLE9;
12763 if (local_TEF10 == NULL)
12765 local_TEF10 = EG (uninitialized_zval_ptr);
12766 local_TEF10->refcount++;
12768 zval** p_lhs = &local_TEF10;
12770 zval* rhs;
12771 if (local_TLE9 == NULL)
12772 rhs = EG (uninitialized_zval_ptr);
12773 else
12774 rhs = local_TLE9;
12776 if (*p_lhs != rhs)
12778 if ((*p_lhs)->is_ref)
12779 overwrite_lhs (*p_lhs, rhs);
12780 else
12782 zval_ptr_dtor (p_lhs);
12783 if (rhs->is_ref)
12785 // Take a copy of RHS for LHS
12786 *p_lhs = zvp_clone_ex (rhs);
12788 else
12790 // Share a copy
12791 rhs->refcount++;
12792 *p_lhs = rhs;
12798 phc_check_invariants (TSRMLS_C);
12800 // goto L168;
12802 goto L168;
12803 phc_check_invariants (TSRMLS_C);
12805 // L168:
12806 L168:;
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;
12816 zval* rhs;
12817 if (local_TEF10 == NULL)
12818 rhs = EG (uninitialized_zval_ptr);
12819 else
12820 rhs = local_TEF10;
12822 if (*p_lhs != rhs)
12824 if ((*p_lhs)->is_ref)
12825 overwrite_lhs (*p_lhs, rhs);
12826 else
12828 zval_ptr_dtor (p_lhs);
12829 if (rhs->is_ref)
12831 // Take a copy of RHS for LHS
12832 *p_lhs = zvp_clone_ex (rhs);
12834 else
12836 // Share a copy
12837 rhs->refcount++;
12838 *p_lhs = 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;
12856 zval* p_cond;
12857 if (local_TLE86 == NULL)
12858 p_cond = EG (uninitialized_zval_ptr);
12859 else
12860 p_cond = local_TLE86;
12862 zend_bool bcond = zend_is_true (p_cond);
12863 if (bcond)
12864 goto L172;
12865 else
12866 goto L173;
12867 phc_check_invariants (TSRMLS_C);
12869 // L172:
12870 L172:;
12871 // $TLE87 = '<!--
12872 // Tidy reports:
12873 // ';
12875 if (local_TLE87 == NULL)
12877 local_TLE87 = EG (uninitialized_zval_ptr);
12878 local_TLE87->refcount++;
12880 zval** p_lhs = &local_TLE87;
12882 zval* value;
12883 if ((*p_lhs)->is_ref)
12885 // Always overwrite the current value
12886 value = *p_lhs;
12887 zval_dtor (value);
12889 else
12891 ALLOC_INIT_ZVAL (value);
12892 zval_ptr_dtor (p_lhs);
12893 *p_lhs = value;
12896 ZVAL_STRINGL(value, "<!--\012Tidy reports:\012", 19, 1);
12898 phc_check_invariants (TSRMLS_C);
12900 // $TLE88 = '-->';
12902 if (local_TLE88 == NULL)
12904 local_TLE88 = EG (uninitialized_zval_ptr);
12905 local_TLE88->refcount++;
12907 zval** p_lhs = &local_TLE88;
12909 zval* value;
12910 if ((*p_lhs)->is_ref)
12912 // Always overwrite the current value
12913 value = *p_lhs;
12914 zval_dtor (value);
12916 else
12918 ALLOC_INIT_ZVAL (value);
12919 zval_ptr_dtor (p_lhs);
12920 *p_lhs = value;
12923 ZVAL_STRINGL(value, "-->", 3, 1);
12925 phc_check_invariants (TSRMLS_C);
12927 // $TLE89 = '--&gt;';
12929 if (local_TLE89 == NULL)
12931 local_TLE89 = EG (uninitialized_zval_ptr);
12932 local_TLE89->refcount++;
12934 zval** p_lhs = &local_TLE89;
12936 zval* value;
12937 if ((*p_lhs)->is_ref)
12939 // Always overwrite the current value
12940 value = *p_lhs;
12941 zval_dtor (value);
12943 else
12945 ALLOC_INIT_ZVAL (value);
12946 zval_ptr_dtor (p_lhs);
12947 *p_lhs = value;
12950 ZVAL_STRINGL(value, "--&gt;", 6, 1);
12952 phc_check_invariants (TSRMLS_C);
12954 // $TLE106 = param_is_ref (NULL, "str_replace", 0);
12955 // ;
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;
12960 int count = 0;
12961 while (arg_info && count < 0)
12963 count++;
12964 arg_info++;
12967 if (local_TLE106 == NULL)
12969 local_TLE106 = EG (uninitialized_zval_ptr);
12970 local_TLE106->refcount++;
12972 zval** p_lhs = &local_TLE106;
12974 zval* rhs;
12975 ALLOC_INIT_ZVAL (rhs);
12976 if (arg_info && count == 0)
12978 ZVAL_BOOL (rhs, arg_info->pass_by_reference);
12980 else
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;
12990 zval* p_cond;
12991 if (local_TLE106 == NULL)
12992 p_cond = EG (uninitialized_zval_ptr);
12993 else
12994 p_cond = local_TLE106;
12996 zend_bool bcond = zend_is_true (p_cond);
12997 if (bcond)
12998 goto L169;
12999 else
13000 goto L170;
13001 phc_check_invariants (TSRMLS_C);
13003 // L169:
13004 L169:;
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;
13014 zval field_name;
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);
13030 // goto L171;
13032 goto L171;
13033 phc_check_invariants (TSRMLS_C);
13035 // L170:
13036 L170:;
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;
13046 zval field_name;
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);
13062 // goto L171;
13064 goto L171;
13065 phc_check_invariants (TSRMLS_C);
13067 // L171:
13068 L171:;
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
13075 int by_ref[3];
13076 int abr_index = 0;
13077 // TODO: find names to replace index
13078 if (arg_info)
13080 by_ref[abr_index] = arg_info->pass_by_reference;
13081 arg_info++;
13083 else
13084 by_ref[abr_index] = signature->common.pass_rest_by_reference;
13086 abr_index++;
13087 // TODO: find names to replace index
13088 if (arg_info)
13090 by_ref[abr_index] = arg_info->pass_by_reference;
13091 arg_info++;
13093 else
13094 by_ref[abr_index] = signature->common.pass_rest_by_reference;
13096 abr_index++;
13097 // TODO: find names to replace index
13098 if (arg_info)
13100 by_ref[abr_index] = arg_info->pass_by_reference;
13101 arg_info++;
13103 else
13104 by_ref[abr_index] = signature->common.pass_rest_by_reference;
13106 abr_index++;
13109 // Setup array of arguments
13110 // TODO: i think arrays of size 0 is an error
13111 int destruct [3];
13112 zval* args [3];
13113 zval** args_ind [3];
13115 int af_index = 0;
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];
13130 else
13132 zval* arg;
13133 if (local_TLE88 == NULL)
13134 arg = EG (uninitialized_zval_ptr);
13135 else
13136 arg = local_TLE88;
13138 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
13139 args_ind[af_index] = &args[af_index];
13141 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];
13156 else
13158 zval* arg;
13159 if (local_TLE89 == NULL)
13160 arg = EG (uninitialized_zval_ptr);
13161 else
13162 arg = local_TLE89;
13164 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
13165 args_ind[af_index] = &args[af_index];
13167 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];
13182 else
13184 zval* arg;
13185 if (local_TMIt105 == NULL)
13186 arg = EG (uninitialized_zval_ptr);
13187 else
13188 arg = local_TMIt105;
13190 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
13191 args_ind[af_index] = &args[af_index];
13193 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;
13203 zval* rhs = NULL;
13205 // set up params
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);
13214 // restore params
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);
13222 int i;
13223 for (i = 0; i < 3; i++)
13225 if (destruct[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));
13254 rhs->is_ref = 1;
13255 if (saved_refcount != 0)
13257 rhs->refcount = saved_refcount;
13259 rhs->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;
13288 zval* left;
13289 if (local_TLE87 == NULL)
13290 left = EG (uninitialized_zval_ptr);
13291 else
13292 left = local_TLE87;
13294 zval* right;
13295 if (local_TLE90 == NULL)
13296 right = EG (uninitialized_zval_ptr);
13297 else
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)
13313 zval_dtor (&old);
13314 phc_check_invariants (TSRMLS_C);
13316 // $TLE92 = '
13317 // -->';
13319 if (local_TLE92 == NULL)
13321 local_TLE92 = EG (uninitialized_zval_ptr);
13322 local_TLE92->refcount++;
13324 zval** p_lhs = &local_TLE92;
13326 zval* value;
13327 if ((*p_lhs)->is_ref)
13329 // Always overwrite the current value
13330 value = *p_lhs;
13331 zval_dtor (value);
13333 else
13335 ALLOC_INIT_ZVAL (value);
13336 zval_ptr_dtor (p_lhs);
13337 *p_lhs = value;
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;
13353 zval* left;
13354 if (local_TLE91 == NULL)
13355 left = EG (uninitialized_zval_ptr);
13356 else
13357 left = local_TLE91;
13359 zval* right;
13360 if (local_TLE92 == NULL)
13361 right = EG (uninitialized_zval_ptr);
13362 else
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)
13378 zval_dtor (&old);
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;
13390 zval* left;
13391 if (local_cleansource == NULL)
13392 left = EG (uninitialized_zval_ptr);
13393 else
13394 left = local_cleansource;
13396 zval* right;
13397 if (local_TLE93 == NULL)
13398 right = EG (uninitialized_zval_ptr);
13399 else
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)
13415 zval_dtor (&old);
13416 phc_check_invariants (TSRMLS_C);
13418 // goto L174;
13420 goto L174;
13421 phc_check_invariants (TSRMLS_C);
13423 // L173:
13424 L173:;
13425 // goto L174;
13427 goto L174;
13428 phc_check_invariants (TSRMLS_C);
13430 // L174:
13431 L174:;
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;
13441 zval* value;
13442 if ((*p_lhs)->is_ref)
13444 // Always overwrite the current value
13445 value = *p_lhs;
13446 zval_dtor (value);
13448 else
13450 ALLOC_INIT_ZVAL (value);
13451 zval_ptr_dtor (p_lhs);
13452 *p_lhs = value;
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
13465 int by_ref[1];
13466 int abr_index = 0;
13467 // TODO: find names to replace index
13468 if (arg_info)
13470 by_ref[abr_index] = arg_info->pass_by_reference;
13471 arg_info++;
13473 else
13474 by_ref[abr_index] = signature->common.pass_rest_by_reference;
13476 abr_index++;
13479 // Setup array of arguments
13480 // TODO: i think arrays of size 0 is an error
13481 int destruct [1];
13482 zval* args [1];
13483 zval** args_ind [1];
13485 int af_index = 0;
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];
13500 else
13502 zval* arg;
13503 if (local_TLE94 == NULL)
13504 arg = EG (uninitialized_zval_ptr);
13505 else
13506 arg = local_TLE94;
13508 args[af_index] = fetch_var_arg (arg, &destruct[af_index]);
13509 args_ind[af_index] = &args[af_index];
13511 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;
13521 zval* rhs = NULL;
13523 // set up params
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);
13532 // restore params
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);
13540 int i;
13541 for (i = 0; i < 1; i++)
13543 if (destruct[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));
13572 rhs->is_ref = 1;
13573 if (saved_refcount != 0)
13575 rhs->refcount = saved_refcount;
13577 rhs->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;
13591 zval* rhs;
13592 if (local_cleansource == NULL)
13593 rhs = EG (uninitialized_zval_ptr);
13594 else
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);
13608 // goto L177;
13610 goto L177;
13611 phc_check_invariants (TSRMLS_C);
13613 // L177:
13614 L177:;
13615 // Method exit
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__()
13756 // {
13757 // }
13758 PHP_FUNCTION(__MAIN__)
13760 // Function body
13761 // Method exit
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,
13784 "app",
13785 app_functions,
13786 PHP_MINIT(app), /* MINIT */
13787 NULL, /* MSHUTDOWN */
13788 NULL, /* RINIT */
13789 NULL, /* RSHUTDOWN */
13790 NULL, /* MINFO */
13791 "1.0",
13792 STANDARD_MODULE_PROPERTIES
13794 #include <sapi/embed/php_embed.h>
13795 #include <signal.h>
13797 void sighandler(int signum)
13799 switch(signum)
13801 case SIGABRT:
13802 printf("SIGABRT received!\n");
13803 break;
13804 case SIGSEGV:
13805 printf("SIGSEGV received!\n");
13806 break;
13807 default:
13808 printf("Unknown signal received!\n");
13809 break;
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");
13814 exit(-1);
13818 main (int argc, char* argv[])
13820 int phc_exit_status;
13821 signal(SIGABRT, sighandler);
13822 signal(SIGSEGV, sighandler);
13824 TSRMLS_D;
13825 int dealloc_pools = 1;
13826 php_embed_init (argc, argv PTSRMLS_CC);
13827 zend_first_try
13830 // initialize the phc runtime
13831 init_runtime();
13833 // load the compiled extension
13834 zend_startup_module (&app_module_entry);
13836 zval main_name;
13837 ZVAL_STRING (&main_name, "__MAIN__", NULL);
13839 zval retval;
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;
13848 // call __MAIN__
13849 int success = call_user_function(
13850 EG (function_table),
13851 NULL,
13852 &main_name,
13853 &retval,
13855 NULL
13856 TSRMLS_CC);
13858 assert (success == SUCCESS);
13860 // finalize the runtime
13861 finalize_runtime();
13864 zend_catch
13866 dealloc_pools = 0;
13868 zend_end_try ();
13869 if (dealloc_pools)
13872 phc_exit_status = EG(exit_status);
13873 php_embed_shutdown (TSRMLS_C);
13875 return phc_exit_status;