dmitry Tue Mar 7 08:43:21 2006 UTC
Removed files:
/ZendEngine2/tests break_label01.phpt break_label02.phpt
break_label03.phpt break_label04.phpt
break_label05.phpt break_label06.phpt
break_label07.phpt break_label08.inc
break_label08.phpt break_label09.phpt
break_label10.phpt break_label11.phpt
Modified files:
/php-src NEWS
/ZendEngine2 zend_compile.c zend_compile.h zend_globals.h
zend_language_parser.y
Log:
Reverted "break label"
http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2096&r2=1.2097&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2096 php-src/NEWS:1.2097
--- php-src/NEWS:1.2096 Tue Mar 7 00:55:23 2006
+++ php-src/NEWS Tue Mar 7 08:43:20 2006
@@ -10,9 +10,6 @@
for more details. (Dmitry)
- Removed support for "continue" and "break" operators with non-constant
operands. (Dmitry)
-- Added support for "continue" and "break" operators with labels. Each loop or
- switch statement can be marked by label and then it is possible to write
- "break <label>" instead of "break <number>". (Dmitry, Sara)
- Changed __toString() behavior to call it in all necessary places
(Marcus, Dmitry)
- Changed "instanceof" and "catch" operators, is_a() and is_subclass_of()
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_compile.c?r1=1.691&r2=1.692&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.691 ZendEngine2/zend_compile.c:1.692
--- ZendEngine2/zend_compile.c:1.691 Sun Mar 5 18:32:21 2006
+++ ZendEngine2/zend_compile.c Tue Mar 7 08:43:21 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.691 2006/03/05 18:32:21 helly Exp $ */
+/* $Id: zend_compile.c,v 1.692 2006/03/07 08:43:21 dmitry Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -148,9 +148,6 @@
CG(start_lineno) = 0;
init_compiler_declarables(TSRMLS_C);
zend_hash_apply(CG(auto_globals), (apply_func_t) zend_auto_global_arm TSRMLS_CC);
- zend_stack_init(&CG(labels_stack));
- CG(labels) = NULL;
- CG(last_label) = NULL;
}
@@ -177,7 +174,6 @@
zend_hash_destroy(&CG(script_encodings_table));
zend_hash_destroy(&CG(filenames_table));
zend_llist_destroy(&CG(open_files));
- zend_stack_destroy(&CG(labels_stack));
}
@@ -679,10 +675,6 @@
CG(active_op_array)->current_brk_cont = CG(active_op_array)->last_brk_cont;
brk_cont_element = get_next_brk_cont_element(CG(active_op_array));
brk_cont_element->parent = parent;
- if (CG(last_label)) {
- CG(last_label)->loop = CG(active_op_array)->current_brk_cont;
- CG(last_label) = NULL;
- }
}
@@ -1249,10 +1241,6 @@
CG(doc_comment) = NULL;
CG(doc_comment_len) = 0;
}
-
- zend_stack_push(&CG(labels_stack), (void *) &CG(labels), sizeof(HashTable*));
- CG(labels) = NULL;
- CG(last_label) = NULL;
}
void zend_do_handle_exception(TSRMLS_D)
@@ -1262,21 +1250,6 @@
opline->opcode = ZEND_HANDLE_EXCEPTION;
SET_UNUSED(opline->op1);
SET_UNUSED(opline->op2);
-
- if (CG(labels)) {
- zend_hash_destroy(CG(labels));
- FREE_HASHTABLE(CG(labels));
- }
- if (!zend_stack_is_empty(&CG(labels_stack))) {
- HashTable **pht;
-
- zend_stack_top(&CG(labels_stack), (void**)&pht);
- CG(labels) = *pht;
- zend_stack_del_top(&CG(labels_stack));
- } else {
- CG(labels) = NULL;
- }
- CG(last_label) = NULL;
}
@@ -2692,37 +2665,8 @@
if (expr) {
if (expr->op_type != IS_CONST) {
zend_error(E_COMPILE_ERROR, "'%s' operator with non-constant operand is no longer supported", op == ZEND_BRK ? "break" : "continue");
- } else {
- if (Z_TYPE(expr->u.constant) == IS_STRING ||
- Z_TYPE(expr->u.constant) == IS_UNICODE) {
- zend_label *label;
-
- if (CG(labels) == NULL ||
- zend_u_hash_find(CG(labels), Z_TYPE(expr->u.constant), Z_UNIVAL(expr->u.constant), Z_UNILEN(expr->u.constant)+1, (void**)&label) == FAILURE) {
- zend_error(E_COMPILE_ERROR, "%s to undefined label '%R'", op == ZEND_BRK ? "break" : "continue", Z_TYPE(expr->u.constant), Z_UNIVAL(expr->u.constant));
- }
-
- if (label->loop != -1) {
- long distance = 1;
- long current = CG(active_op_array)->current_brk_cont;
-
- while (current != -1) {
- if (label->loop == current) {
- zval_dtor(&expr->u.constant);
- Z_TYPE(expr->u.constant) = IS_LONG;
- Z_LVAL(expr->u.constant) = distance;
- break;
- }
- distance++;
- current = CG(active_op_array)->brk_cont_array[current].parent;
- }
- }
- if (Z_TYPE(expr->u.constant) != IS_LONG) {
- zend_error(E_COMPILE_ERROR, "%s to label '%R', that doesn't mark outer loop", op == ZEND_BRK ? "break" : "continue", Z_TYPE(expr->u.constant), Z_UNIVAL(expr->u.constant));
- }
- } else if (Z_TYPE(expr->u.constant) != IS_LONG || Z_LVAL(expr->u.constant) < 1) {
- zend_error(E_COMPILE_ERROR, "'%s' operator accepts only positive numbers and labels", op == ZEND_BRK ? "break" : "continue");
- }
+ } else if (Z_TYPE(expr->u.constant) != IS_LONG || Z_LVAL(expr->u.constant) < 1) {
+ zend_error(E_COMPILE_ERROR, "'%s' operator accepts only positive numbers", op == ZEND_BRK ? "break" : "continue");
}
opline->op2 = *expr;
} else {
@@ -4371,30 +4315,6 @@
*result = opline->result;
}
-void zend_do_label(znode *label TSRMLS_DC)
-{
- zend_op_array *oparray = CG(active_op_array);
- zend_label dest;
-
- if (!CG(labels)) {
- ALLOC_HASHTABLE(CG(labels));
- zend_hash_init(CG(labels), 4, NULL, NULL, 0);
- }
-
- dest.brk_cont = oparray->current_brk_cont;
- dest.loop = -1;
- dest.opline_num = get_next_op_number(oparray);
-
- if (zend_u_hash_add(CG(labels), Z_TYPE(label->u.constant), Z_UNIVAL(label->u.constant),
- Z_UNILEN(label->u.constant) + 1, (void**)&dest, sizeof(zend_label), (void**)&CG(last_label)) == FAILURE) {
- CG(last_label) = NULL;
- zend_error(E_COMPILE_ERROR, "Label '%R' already defined", Z_TYPE(label->u.constant), Z_UNIVAL(label->u.constant));
- }
-
- /* Done with label now */
- zval_dtor(&label->u.constant);
-}
-
/*
* Local variables:
* tab-width: 4
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_compile.h?r1=1.335&r2=1.336&diff_format=u
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.335 ZendEngine2/zend_compile.h:1.336
--- ZendEngine2/zend_compile.h:1.335 Fri Mar 3 13:09:13 2006
+++ ZendEngine2/zend_compile.h Tue Mar 7 08:43:21 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.h,v 1.335 2006/03/03 13:09:13 dmitry Exp $ */
+/* $Id: zend_compile.h,v 1.336 2006/03/07 08:43:21 dmitry Exp $ */
#ifndef ZEND_COMPILE_H
#define ZEND_COMPILE_H
@@ -94,11 +94,6 @@
int parent;
} zend_brk_cont_element;
-typedef struct _zend_label {
- int brk_cont;
- int loop;
- zend_uint opline_num;
-} zend_label;
typedef struct _zend_try_catch_element {
zend_uint try_op;
@@ -518,8 +513,6 @@
void zend_do_normalization(znode *result, znode *str TSRMLS_DC);
-void zend_do_label(znode *label TSRMLS_DC);
-
#define INITIAL_OP_ARRAY_SIZE 64
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_globals.h?r1=1.147&r2=1.148&diff_format=u
Index: ZendEngine2/zend_globals.h
diff -u ZendEngine2/zend_globals.h:1.147 ZendEngine2/zend_globals.h:1.148
--- ZendEngine2/zend_globals.h:1.147 Fri Mar 3 13:09:13 2006
+++ ZendEngine2/zend_globals.h Tue Mar 7 08:43:21 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_globals.h,v 1.147 2006/03/03 13:09:13 dmitry Exp $ */
+/* $Id: zend_globals.h,v 1.148 2006/03/07 08:43:21 dmitry Exp $ */
#ifndef ZEND_GLOBALS_H
#define ZEND_GLOBALS_H
@@ -136,10 +136,6 @@
HashTable script_encodings_table;
char *script_encoding;
- HashTable *labels;
- zend_label *last_label;
- zend_stack labels_stack;
-
#ifdef ZTS
HashTable **static_members;
int last_static_member;
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_language_parser.y?r1=1.170&r2=1.171&diff_format=u
Index: ZendEngine2/zend_language_parser.y
diff -u ZendEngine2/zend_language_parser.y:1.170 ZendEngine2/zend_language_parser.y:1.171
--- ZendEngine2/zend_language_parser.y:1.170 Fri Mar 3 13:09:13 2006
+++ ZendEngine2/zend_language_parser.y Tue Mar 7 08:43:21 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_language_parser.y,v 1.170 2006/03/03 13:09:13 dmitry Exp $ */
+/* $Id: zend_language_parser.y,v 1.171 2006/03/07 08:43:21 dmitry Exp $ */
/*
* LALR shift/reduce conflicts and how they are resolved:
@@ -183,12 +183,11 @@
statement:
- unticked_statement { CG(last_label) = NULL; zend_do_ticks(TSRMLS_C); }
- | T_STRING ':' { zend_do_label(&$1 TSRMLS_CC); }
+ unticked_statement { zend_do_ticks(TSRMLS_C); }
;
unticked_statement:
- '{' { CG(last_label) = NULL; } inner_statement_list '}'
+ '{' inner_statement_list '}'
| T_IF '(' expr ')' { zend_do_if_cond(&$3, &$4 TSRMLS_CC); } statement { zend_do_if_after_statement(&$4, 1 TSRMLS_CC); } elseif_list else_single { zend_do_if_end(TSRMLS_C); }
| T_IF '(' expr ')' ':' { zend_do_if_cond(&$3, &$4 TSRMLS_CC); } inner_statement_list { zend_do_if_after_statement(&$4, 1 TSRMLS_CC); } new_elseif_list new_else_single T_ENDIF ';' { zend_do_if_end(TSRMLS_C); }
| T_WHILE '(' { $1.u.opline_num = get_next_op_number(CG(active_op_array)); } expr ')' { zend_do_while_cond(&$4, &$5 TSRMLS_CC); } while_statement { zend_do_while_end(&$1, &$5 TSRMLS_CC); }
@@ -204,11 +203,9 @@
for_statement { zend_do_for_end(&$7 TSRMLS_CC); }
| T_SWITCH '(' expr ')' { zend_do_switch_cond(&$3 TSRMLS_CC); } switch_case_list { zend_do_switch_end(&$6 TSRMLS_CC); }
| T_BREAK ';' { zend_do_brk_cont(ZEND_BRK, NULL TSRMLS_CC); }
- | T_BREAK T_LNUMBER ';' { zend_do_brk_cont(ZEND_BRK, &$2 TSRMLS_CC); }
- | T_BREAK T_STRING ';' { zend_do_brk_cont(ZEND_BRK, &$2 TSRMLS_CC); }
+ | T_BREAK expr ';' { zend_do_brk_cont(ZEND_BRK, &$2 TSRMLS_CC); }
| T_CONTINUE ';' { zend_do_brk_cont(ZEND_CONT, NULL TSRMLS_CC); }
- | T_CONTINUE T_LNUMBER ';' { zend_do_brk_cont(ZEND_CONT, &$2 TSRMLS_CC); }
- | T_CONTINUE T_STRING ';' { zend_do_brk_cont(ZEND_CONT, &$2 TSRMLS_CC); }
+ | T_CONTINUE expr ';' { zend_do_brk_cont(ZEND_CONT, &$2 TSRMLS_CC); }
| T_RETURN ';' { zend_do_return(NULL, 0 TSRMLS_CC); }
| T_RETURN expr_without_variable ';' { zend_do_return(&$2, 0 TSRMLS_CC); }
| T_RETURN variable ';' { zend_do_return(&$2, 1 TSRMLS_CC); }