| Andi Gutmans 2004-07-29, 3:55 pm |
| Are you nuts!!!
The popular request happened when I was asleep?
At 03:23 PM 7/29/2004 +0000, Sara Golemon wrote:
>pollita Thu Jul 29 11:23:47 2004 EDT
>
> Modified files:
> /ZendEngine2 zend_compile.c zend_compile.h zend_execute.c
> zend_language_parser.y zend_language_scanner.l
> zend_opcode.c
> Log:
> Add goto operator by popular request.
>
>http://cvs.php.net/diff.php/ZendEng...8&r2=1.569&ty=u
>Index: ZendEngine2/zend_compile.c
>diff -u ZendEngine2/zend_compile.c:1.568 ZendEngine2/zend_compile.c:1.569
>--- ZendEngine2/zend_compile.c:1.568 Tue Jul 20 04:58:18 2004
>+++ ZendEngine2/zend_compile.c Thu Jul 29 11:23:47 2004
>@@ -17,7 +17,7 @@
> +----------------------------------------------------------------------+
> */
>
>-/* $Id: zend_compile.c,v 1.568 2004/07/20 08:58:18 stas Exp $ */
>+/* $Id: zend_compile.c,v 1.569 2004/07/29 15:23:47 pollita Exp $ */
>
> #include "zend_language_parser.h"
> #include "zend.h"
>@@ -3497,6 +3497,39 @@
> result->u.constant.value.lval = 1;
> }
>
>+void zend_do_label(znode *label TSRMLS_DC)
>+{
>+ zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
>+
>+ opline->opcode = ZEND_NOP;
>+ SET_UNUSED(opline->result);
>+ SET_UNUSED(opline->op1);
>+ SET_UNUSED(opline->op2);
>+
>+ if (label->op_type == IS_CONST) {
>+ if (!CG(active_op_array)->labels) {
>+ CG(active_op_array)->labels =
>emalloc(sizeof(HashTable));
>+ zend_hash_init(CG(active_op_array)->labels, 16,
>NULL, NULL, 0);
>+ }
>+ if (zend_hash_exists(CG(active_op_array)->labels,
>label->u.constant.value.str.val, label->u.constant.value.str.len + 1)) {
>+ zend_error(E_COMPILE_ERROR, "Label cannot be
>redefined.");
>+ } else {
>+ /* Point to our newly created NOP instruction */
>+ zend_hash_add(CG(active_op_array)->labels,
>label->u.constant.value.str.val, label->u.constant.value.str.len + 1,
>&opline, sizeof(zend_op*), NULL);
>+ }
>+ } else {
>+ zend_error(E_COMPILE_ERROR, "Invalid label identifier,
>expecting T_STRING");
>+ }
>+}
>+void zend_do_goto(znode *label TSRMLS_DC)
>+{
>+ zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
>+
>+ opline->opcode = ZEND_GOTO;
>+ SET_UNUSED(opline->result);
>+ opline->op1 = *label;
>+ SET_UNUSED(opline->op2);
>+}
>
> void zend_do_begin_silence(znode *strudel_token TSRMLS_DC)
> {
>http://cvs.php.net/diff.php/ZendEng...4&r2=1.285&ty=u
>Index: ZendEngine2/zend_compile.h
>diff -u ZendEngine2/zend_compile.h:1.284 ZendEngine2/zend_compile.h:1.285
>--- ZendEngine2/zend_compile.h:1.284 Sun Jun 6 04:37:12 2004
>+++ ZendEngine2/zend_compile.h Thu Jul 29 11:23:47 2004
>@@ -17,7 +17,7 @@
> +----------------------------------------------------------------------+
> */
>
>-/* $Id: zend_compile.h,v 1.284 2004/06/06 08:37:12 sesser Exp $ */
>+/* $Id: zend_compile.h,v 1.285 2004/07/29 15:23:47 pollita Exp $ */
>
> #ifndef ZEND_COMPILE_H
> #define ZEND_COMPILE_H
>@@ -170,6 +170,7 @@
> zend_uint *refcount;
>
> zend_op *opcodes;
>+ HashTable *labels;
> zend_uint last, size;
>
> zend_uint T;
>@@ -459,6 +460,8 @@
> void zend_do_end_heredoc(TSRMLS_D);
>
> void zend_do_exit(znode *result, znode *message TSRMLS_DC);
>+void zend_do_goto(znode *label TSRMLS_DC);
>+void zend_do_label(znode *label TSRMLS_DC);
>
> void zend_do_begin_silence(znode *strudel_token TSRMLS_DC);
> void zend_do_end_silence(znode *strudel_token TSRMLS_DC);
>@@ -714,6 +717,7 @@
>
> #define ZEND_HANDLE_EXCEPTION 149
>
>+#define ZEND_GOTO 150
> /* end of block */
> /* END: OPCODES */
>
>http://cvs.php.net/diff.php/ZendEng...6&r2=1.657&ty=u
>Index: ZendEngine2/zend_execute.c
>diff -u ZendEngine2/zend_execute.c:1.656 ZendEngine2/zend_execute.c:1.657
>--- ZendEngine2/zend_execute.c:1.656 Sun Jul 25 13:25:44 2004
>+++ ZendEngine2/zend_execute.c Thu Jul 29 11:23:47 2004
>@@ -17,7 +17,7 @@
> +----------------------------------------------------------------------+
> */
>
>-/* $Id: zend_execute.c,v 1.656 2004/07/25 17:25:44 helly Exp $ */
>+/* $Id: zend_execute.c,v 1.657 2004/07/29 15:23:47 pollita Exp $ */
>
> #define ZEND_INTENSIVE_DEBUGGING 0
>
>@@ -4064,6 +4064,29 @@
> return zend_isset_isempty_dim_prop_obj_handler(
1,
> ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
> }
>
>+int zend_goto_handler(ZEND_OPCODE_HANDLER_AR
GS)
>+{
>+ zend_op **target;
>+ zval *label = get_zval_ptr(&opline->op1, EX(Ts), &EG(free_op1),
>BP_VAR_R);
>+ zval tmp;
>+
>+ tmp = *label;
>+ zval_copy_ctor(&tmp);
>+ convert_to_string(&tmp);
>+ label = &tmp;
>+
>+ if (op_array->labels &&
>+ zend_hash_find(op_array->labels, label->value.str.val,
>label->value.str.len + 1, (void **)&target) == SUCCESS) {
>+#if DEBUG_ZEND>=2
>+ printf("Jumping on goto to opcode %08X\n", *target);
>+#endif
>+ SET_OPCODE(*target);
>+ return 0;
>+ }
>+
>+ zend_error(E_WARNING, "Unknown label %s", Z_STRVAL_P(label));
>+ NEXT_OPCODE();
>+}
>
> int zend_exit_handler(ZEND_OPCODE_HANDLER_AR
GS)
> {
>@@ -4438,6 +4461,8 @@
> zend_opcode_handlers[ZEND_ASSIGN_DIM] = zend_assign_dim_handler;
>
> zend_opcode_handlers[ZEND_HANDLE_EXCEPTI
ON] =
> zend_handle_exception_handler;
>+
>+ zend_opcode_handlers[ZEND_GOTO] = zend_goto_handler;
> }
>
> /*
>http://cvs.php.net/diff.php/ZendEng...5&r2=1.146&ty=u
>Index: ZendEngine2/zend_language_parser.y
>diff -u ZendEngine2/zend_language_parser.y:1.145
>ZendEngine2/zend_language_parser.y:1.146
>--- ZendEngine2/zend_language_parser.y:1.145 Fri Jul 16 02:50:57 2004
>+++ ZendEngine2/zend_language_parser.y Thu Jul 29 11:23:47 2004
>@@ -18,7 +18,7 @@
> +----------------------------------------------------------------------+
> */
>
>-/* $Id: zend_language_parser.y,v 1.145 2004/07/16 06:50:57 helly Exp $ */
>+/* $Id: zend_language_parser.y,v 1.146 2004/07/29 15:23:47 pollita Exp $ */
>
> /*
> * LALR shift/reduce conflicts and how they are resolved:
>@@ -145,6 +145,7 @@
> %token T_NULL
> %token T_FALSE
> %token T_TRUE
>+%token T_GOTO
>
> %% /* Rules */
>
>@@ -223,6 +224,8 @@
> '{' inner_statement_list '}' { zend_do_end_catch(&$1
> TSRMLS_CC); }
> additional_catches { zend_do_mark_last_catch(&$7, &$18
> TSRMLS_CC); }
> | T_THROW expr ';' { zend_do_throw(&$2 TSRMLS_CC); }
>+ | T_GOTO expr ';' { zend_do_goto(&$2 TSRMLS_CC); }
>+ | T_STRING ':' { zend_do_label(&$1 TSRMLS_CC); }
> ;
>
>
>http://cvs.php.net/diff.php/ZendEng...2&r2=1.113&ty=u
>Index: ZendEngine2/zend_language_scanner.l
>diff -u ZendEngine2/zend_language_scanner.l:1.112
>ZendEngine2/zend_language_scanner.l:1.113
>--- ZendEngine2/zend_language_scanner.l:1.112 Fri Jul 16 02:50:57 2004
>+++ ZendEngine2/zend_language_scanner.l Thu Jul 29 11:23:47 2004
>@@ -19,7 +19,7 @@
> +----------------------------------------------------------------------+
> */
>
>-/* $Id: zend_language_scanner.l,v 1.112 2004/07/16 06:50:57 helly Exp $ */
>+/* $Id: zend_language_scanner.l,v 1.113 2004/07/29 15:23:47 pollita Exp $ */
>
> #define yyleng SCNG(yy_leng)
> #define yytext SCNG(yy_text)
>@@ -761,6 +761,10 @@
> %option noyylineno
> %option noyywrap
> %%
>+
>+<ST_IN_SCRIPTING>"goto" {
>+ return T_GOTO;
>+}
>
> <ST_IN_SCRIPTING>"exit" {
> return T_EXIT;
>http://cvs.php.net/diff.php/ZendEng...3&r2=1.104&ty=u
>Index: ZendEngine2/zend_opcode.c
>diff -u ZendEngine2/zend_opcode.c:1.103 ZendEngine2/zend_opcode.c:1.104
>--- ZendEngine2/zend_opcode.c:1.103 Sun Jun 6 04:37:12 2004
>+++ ZendEngine2/zend_opcode.c Thu Jul 29 11:23:47 2004
>@@ -17,7 +17,7 @@
> +----------------------------------------------------------------------+
> */
>
>-/* $Id: zend_opcode.c,v 1.103 2004/06/06 08:37:12 sesser Exp $ */
>+/* $Id: zend_opcode.c,v 1.104 2004/07/29 15:23:47 pollita Exp $ */
>
> #include <stdio.h>
>
>@@ -63,6 +63,7 @@
> op_array->size = initial_ops_size;
> op_array->last = 0;
> op_array->opcodes = NULL;
>+ op_array->labels = NULL;
> op_array_alloc_ops(op_array);
>
> op_array->T = 0;
>@@ -223,6 +224,12 @@
> opline++;
> }
> efree(op_array->opcodes);
>+
>+ if (op_array->labels) {
>+ zend_hash_destroy(op_array->labels);
>+ efree(op_array->labels);
>+ }
>+
> if (op_array->function_name) {
> efree(op_array->function_name);
> }
>
>--
>Zend Engine CVS Mailing List (http://cvs.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
|