Skip to content
Browse files

- Fix bug in nested try/catch's

- Infrastructure for implementing imports of methods.
  • Loading branch information...
1 parent 6f6c4ec commit d1eea3de9c9a1e92a5cd0813c4608b9defef4927 @andigutmans andigutmans committed
Showing with 28 additions and 12 deletions.
  1. +1 −0 Zend/zend_API.c
  2. +2 −0 Zend/zend_compile.c
  3. +13 −8 Zend/zend_compile.h
  4. +10 −4 Zend/zend_language_parser.y
  5. +2 −0 Zend/zend_opcode.c
View
1 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);
View
2 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))) {
View
21 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;
View
14 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); }
;
View
2 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;

0 comments on commit d1eea3d

Please sign in to comment.
Something went wrong with that request. Please try again.