From: Andi Gutmans Date: Fri, 1 Mar 2002 14:04:51 +0000 (+0000) Subject: - Fix bug in nested try/catch's X-Git-Tag: php-4.2.0RC1~217 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d1eea3de9c9a1e92a5cd0813c4608b9defef4927;p=php - Fix bug in nested try/catch's - Infrastructure for implementing imports of methods. --- diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 7e03e22d4f..32af0185e9 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -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); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 96a92b7356..da02140373 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -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))) { diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 0a07932ee7..421f83645b 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -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; diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 8975871f37..2c0d78c0d1 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -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); } ; diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index d995065119..672a55bf8f 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -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;