]> granicus.if.org Git - php/commitdiff
- Fix bug in nested try/catch's
authorAndi Gutmans <andi@php.net>
Fri, 1 Mar 2002 14:04:51 +0000 (14:04 +0000)
committerAndi Gutmans <andi@php.net>
Fri, 1 Mar 2002 14:04:51 +0000 (14:04 +0000)
- Infrastructure for implementing imports of methods.

Zend/zend_API.c
Zend/zend_compile.c
Zend/zend_compile.h
Zend/zend_language_parser.y
Zend/zend_opcode.c

index 7e03e22d4fa4a070a6a151246d86c2e421c7a2b8..32af0185e99d13d16612eae41cd94ccf6581c385 100644 (file)
@@ -1046,6 +1046,7 @@ int zend_register_functions(zend_function_entry *functions, HashTable *function_
                internal_function->handler = ptr->handler;
                internal_function->arg_types = ptr->func_arg_types;
                internal_function->function_name = ptr->fname;
+               internal_function->scope = NULL;
                if (!internal_function->handler) {
                        zend_error(error_type, "Null function defined as active function");
                        zend_unregister_functions(functions, count, target_function_table TSRMLS_CC);
index 96a92b73567a6a1abfe4e5811511279a2d219db9..da02140373efe34981f27a556ba2c7eb63d1bfe8 100644 (file)
@@ -762,6 +762,8 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
        op_array.arg_types = NULL;
        op_array.return_reference = return_reference;
 
+       op_array.scope = CG(active_class_entry);
+
        if (is_method) {
                zend_hash_update(&CG(active_class_entry)->function_table, name, name_len+1, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array));
                if ((CG(active_class_entry)->name_length == (uint) name_len) && (!memcmp(CG(active_class_entry)->name, name, name_len))) {
index 0a07932ee7a0ce3e5e71042d595c14895dd20e3f..421f83645b08b2b899b1b16290e551534cc9ccf0 100644 (file)
@@ -78,10 +78,11 @@ typedef struct _zend_brk_cont_element {
 
 
 struct _zend_op_array {
-       zend_uchar type;        /* MUST be the first element of this struct! */
+       zend_uchar type;                        /* MUST be the first element of this struct! */
 
        zend_uchar *arg_types;          /* MUST be the second element of this struct! */
-       char *function_name;                    /* MUST be the third element of this struct! */
+       char *function_name;            /* MUST be the third element of this struct! */
+       zend_class_entry *scope;        /* MUST be the fourth element of this struct! */
 
        zend_uint *refcount;
 
@@ -110,20 +111,22 @@ struct _zend_op_array {
 
 
 typedef struct _zend_internal_function {
-       zend_uchar type;        /* MUST be the first element of this struct! */
+       zend_uchar type;                        /* MUST be the first element of this struct! */
 
-       zend_uchar *arg_types;          /* MUST be the second element of this struct */
-       char *function_name;                    /* MUST be the third element of this struct */
+       zend_uchar *arg_types;          /* MUST be the second element of this struct! */
+       char *function_name;            /* MUST be the third element of this struct! */
+       zend_class_entry *scope;        /* MUST be the fourth element of this struct! */
 
        void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
 } zend_internal_function;
 
 
 typedef struct _zend_overloaded_function {
-       zend_uchar type;        /* MUST be the first element of this struct! */
+       zend_uchar type;                        /* MUST be the first element of this struct! */
 
-       zend_uchar *arg_types;          /* MUST be the second element of this struct */
-       char *function_name;            /* MUST be the third element of this struct */
+       zend_uchar *arg_types;          /* MUST be the second element of this struct! */
+       char *function_name;            /* MUST be the third element of this struct! */
+       zend_class_entry *scope;        /* MUST be the fourth element of this struct! */
 
        zend_uint var;
 } zend_overloaded_function;
@@ -131,10 +134,12 @@ typedef struct _zend_overloaded_function {
 
 typedef union _zend_function {
        zend_uchar type;        /* MUST be the first element of this struct! */
+
        struct {
                zend_uchar type;  /* never used */
                zend_uchar *arg_types;
                char *function_name;
+               zend_class_entry *scope;
        } common;
        
        zend_op_array op_array;
index 8975871f37aa4ec8a2ac85e5a37997dba6ef5c3c..2c0d78c0d15ccd87b44431a6ad47c79433f13849 100644 (file)
@@ -207,14 +207,20 @@ unticked_statement:
        |       T_DECLARE { zend_do_declare_begin(TSRMLS_C); } '(' declare_list ')' declare_statement { zend_do_declare_end(TSRMLS_C); }
        |       ';'             /* empty statement */
        |       T_TRY { zend_do_try(&$1 TSRMLS_CC); } '{' inner_statement_list '}'
-                       catches
+               T_CATCH '(' catch_class_entry T_VARIABLE ')' { zend_do_begin_catch(&$1, &$8, &$9, 1 TSRMLS_CC); } '{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); }
+               additional_catches
        |       T_THROW expr ';' { zend_do_throw(&$2 TSRMLS_CC); }
        |       T_DELETE  cvar  ';' { zend_do_end_variable_parse(BP_VAR_UNSET, 0 TSRMLS_CC); zend_do_unset(&$1, ZEND_UNSET_OBJ TSRMLS_CC); }
 ;
 
-catches:
-               catches T_CATCH '(' catch_class_entry T_VARIABLE ')' { zend_do_begin_catch(&$2, &$4, &$5, 0 TSRMLS_CC); } '{' inner_statement_list '}' { zend_do_end_catch(&$2 TSRMLS_CC); }
-       |       T_CATCH '(' catch_class_entry T_VARIABLE ')' { zend_do_begin_catch(&$1, &$3, &$4, 1 TSRMLS_CC); } '{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); }
+additional_catches:
+               non_empty_additional_catches
+       |       /* empty */
+;
+
+non_empty_additional_catches:
+               non_empty_additional_catches T_CATCH '(' catch_class_entry T_VARIABLE ')' { zend_do_begin_catch(&$2, &$4, &$5, 0 TSRMLS_CC); } '{' inner_statement_list '}' { zend_do_end_catch(&$2 TSRMLS_CC); }
+       |       T_CATCH '(' catch_class_entry T_VARIABLE ')' { zend_do_begin_catch(&$1, &$3, &$4, 0 TSRMLS_CC); } '{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); }
 ;
 
 
index d99506511984ad792ad2c95a81c7f7f6171e7998..672a55bf8f3cac277dc93838ea67d833782602d7 100644 (file)
@@ -76,6 +76,8 @@ void init_op_array(zend_op_array *op_array, int type, int initial_ops_size TSRML
 
        op_array->arg_types = NULL;
 
+       op_array->scope = NULL;
+
        op_array->brk_cont_array = NULL;
        op_array->last_brk_cont = 0;
        op_array->current_brk_cont = -1;