Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39071 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63001 invoked from network); 17 Jul 2008 23:27:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jul 2008 23:27:57 -0000 Authentication-Results: pb1.pair.com smtp.mail=moriyoshi@at.wakwak.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=moriyoshi@at.wakwak.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain at.wakwak.com designates 219.103.130.24 as permitted sender) X-PHP-List-Original-Sender: moriyoshi@at.wakwak.com X-Host-Fingerprint: 219.103.130.24 mgdnp1.nw.wakwak.com Received: from [219.103.130.24] ([219.103.130.24:64047] helo=mgdnp1.nw.wakwak.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 55/39-31728-975DF784 for ; Thu, 17 Jul 2008 19:27:55 -0400 Received: from vckyb1.nw.wakwak.com (postfix@vckyb1.nw.wakwak.com [211.9.230.144]) by mgdnp1.nw.wakwak.com (8.14.3/8.14.3/2008-07-17) with SMTP id m6HNRo2x073690 for ; Fri, 18 Jul 2008 08:27:50 +0900 (JST) (envelope-from moriyoshi@at.wakwak.com) Received: from at.wakwak.com (at.wakwak.com [211.9.230.135]) by vckyb1.nw.wakwak.com (Postfix) with ESMTP id 206B630060 for ; Fri, 18 Jul 2008 08:27:50 +0900 (JST) Received: from [10.1.6.29] (c-gate0.bioinfo.sfc.keio.ac.jp [133.27.19.40]) (user=moriyoshi mech=CRAM-MD5) by at.wakwak.com (8.14.3/8.14.3/2008-07-15) with ESMTP/inet id m6HNRn1F094049 for ; Fri, 18 Jul 2008 08:27:50 +0900 (JST) (envelope-from moriyoshi@at.wakwak.com) Mime-Version: 1.0 (Apple Message framework v753.1) To: internals@lists.php.net Message-ID: <54FF091B-A4BE-4C3E-9783-D2DE93D6AF31@at.wakwak.com> Content-Type: multipart/mixed; boundary=Apple-Mail-1--340873536 Date: Fri, 18 Jul 2008 08:23:31 +0900 X-Mailer: Apple Mail (2.753.1) Subject: [PATCH] Allow use($var..) statement ubiquitously From: moriyoshi@at.wakwak.com (Moriyoshi Koizumi) --Apple-Mail-1--340873536 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed Hi, Attached are the patches that allow the "use" statement that was introduced with closures to appear within every function statement except method definitions. I think this feature is a good addition because it resolves inconsistency between closures and unticked functions. In a nutshell, is equivalent to While, and are of course not the same. --Apple-Mail-1--340873536 Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0644; name=php-ubiquitous-use-statement-HEAD-20080718.patch.diff.txt Content-Disposition: attachment; filename=php-ubiquitous-use-statement-HEAD-20080718.patch.diff.txt ? .gdb_history Index: Zend/zend_closures.c =================================================================== RCS file: /repository/ZendEngine2/zend_closures.c,v retrieving revision 1.4 diff -u -r1.4 zend_closures.c --- Zend/zend_closures.c 14 Jul 2008 12:17:16 -0000 1.4 +++ Zend/zend_closures.c 17 Jul 2008 23:16:29 -0000 @@ -213,44 +213,6 @@ } /* }}} */ -static int zval_copy_static_var(zval **p, int num_args, va_list args, zend_hash_key *key) /* {{{ */ -{ - HashTable *target = va_arg(args, HashTable*); - zend_bool is_ref; - TSRMLS_FETCH(); - - if (Z_TYPE_PP(p) & (IS_LEXICAL_VAR|IS_LEXICAL_REF)) { - is_ref = Z_TYPE_PP(p) & IS_LEXICAL_REF; - - if (!EG(active_symbol_table)) { - zend_rebuild_symbol_table(TSRMLS_C); - } - if (zend_u_hash_quick_find(EG(active_symbol_table), key->type, key->arKey, key->nKeyLength, key->h, (void **) &p) == FAILURE) { - if (is_ref) { - zval *tmp; - - ALLOC_INIT_ZVAL(tmp); - Z_SET_ISREF_P(tmp); - zend_u_hash_quick_add(EG(active_symbol_table), key->type, key->arKey, key->nKeyLength, key->h, &tmp, sizeof(zval*), (void**)&p); - } else { - p = &EG(uninitialized_zval_ptr); - zend_error(E_NOTICE,"Undefined variable: %s", key->arKey); - } - } else { - if (is_ref) { - SEPARATE_ZVAL_TO_MAKE_IS_REF(p); - } else if (Z_ISREF_PP(p)) { - SEPARATE_ZVAL(p); - } - } - } - if (zend_u_hash_quick_add(target, key->type, key->arKey, key->nKeyLength, key->h, p, sizeof(zval*), NULL) == SUCCESS) { - Z_ADDREF_PP(p); - } - return ZEND_HASH_APPLY_KEEP; -} -/* }}} */ - ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_entry *scope, zval *this_ptr TSRMLS_DC) /* {{{ */ { zend_closure *closure; @@ -263,11 +225,8 @@ if (closure->func.type == ZEND_USER_FUNCTION) { if (closure->func.op_array.static_variables) { - HashTable *static_variables = closure->func.op_array.static_variables; - - ALLOC_HASHTABLE(closure->func.op_array.static_variables); - zend_u_hash_init(closure->func.op_array.static_variables, zend_hash_num_elements(static_variables), NULL, ZVAL_PTR_DTOR, 0, UG(unicode)); - zend_hash_apply_with_arguments(static_variables, (apply_func_args_t)zval_copy_static_var, 1, closure->func.op_array.static_variables); + zend_do_bind_static_variables(&closure->func.op_array TSRMLS_CC); + func->op_array.static_variables = NULL; } (*closure->func.op_array.refcount)++; } Index: Zend/zend_compile.c =================================================================== RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.829 diff -u -r1.829 zend_compile.c --- Zend/zend_compile.c 14 Jul 2008 12:17:16 -0000 1.829 +++ Zend/zend_compile.c 17 Jul 2008 23:16:30 -0000 @@ -1511,7 +1511,7 @@ } /* }}} */ -void zend_do_end_function_declaration(znode *function_token TSRMLS_DC) /* {{{ */ +void zend_do_end_function_declaration(znode *function_token, zend_bool is_closure TSRMLS_DC) /* {{{ */ { unsigned int lcname_len; zstr lcname; @@ -1554,6 +1554,9 @@ } CG(active_op_array)->line_end = zend_get_compiled_lineno(TSRMLS_C); + if (is_closure) { + CG(active_op_array)->fn_flags |= ZEND_ACC_CLOSURE; + } CG(active_op_array) = function_token->u.op_array; @@ -1679,7 +1682,8 @@ lcname = zend_u_str_case_fold(Z_TYPE(function_name->u.constant), Z_UNIVAL(function_name->u.constant), Z_UNILEN(function_name->u.constant), 0, &lcname_len); if ((zend_u_hash_find(CG(function_table), Z_TYPE(function_name->u.constant), lcname, lcname_len+1, (void **) &function)==FAILURE) || ((CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS) && - (function->type == ZEND_INTERNAL_FUNCTION))) { + (function->type == ZEND_INTERNAL_FUNCTION)) || + (function->common.fn_flags & ZEND_ACC_CLOSURE)) { zend_do_begin_dynamic_function_call(function_name, prefix_len TSRMLS_CC); efree(lcname.v); return 1; /* Dynamic */ @@ -2988,6 +2992,53 @@ } /* }}} */ + +static int zval_copy_static_var(zval **p, int num_args, va_list args, zend_hash_key *key) /* {{{ */ +{ + TSRMLS_FETCH_FROM_CTX(va_arg(args, void*)); + zend_bool is_ref; + + if (Z_TYPE_PP(p) & (IS_LEXICAL_VAR|IS_LEXICAL_REF)) { + zval **src; + TSRMLS_FETCH(); + is_ref = Z_TYPE_PP(p) & IS_LEXICAL_REF; + + if (!EG(active_symbol_table)) { + zend_rebuild_symbol_table(TSRMLS_C); + } + if (zend_u_hash_quick_find(EG(active_symbol_table), key->type, key->arKey, key->nKeyLength, key->h, (void **) &src) == FAILURE) { + if (is_ref) { + zval *tmp; + + ALLOC_INIT_ZVAL(tmp); + Z_SET_ISREF_P(tmp); + zend_u_hash_quick_add(EG(active_symbol_table), key->type, key->arKey, key->nKeyLength, key->h, &tmp, sizeof(zval*), (void**)&src); + } else { + src = &EG(uninitialized_zval_ptr); + zend_error(E_NOTICE,"Undefined variable: %s", key->arKey); + } + } else { + if (is_ref) { + SEPARATE_ZVAL_TO_MAKE_IS_REF(src); + } else if (Z_ISREF_PP(p)) { + SEPARATE_ZVAL(src); + } + } + Z_ADDREF_PP(src); + zval_ptr_dtor(p); + *p = *src; + } + return ZEND_HASH_APPLY_KEEP; +} +/* }}} */ + + +ZEND_API void zend_do_bind_static_variables(zend_op_array *op_array TSRMLS_DC) +{ + zend_hash_apply_with_arguments(op_array->static_variables, (apply_func_args_t)zval_copy_static_var, 1 TSRMLS_CC); +} + + ZEND_API int do_bind_function(zend_op *opline, HashTable *function_table, zend_bool compile_time) /* {{{ */ { zend_function *function; @@ -2997,6 +3048,12 @@ } zend_u_hash_find(function_table, Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (void *) &function); + + /* closures cannot be bound beforehand */ + if ((function->common.fn_flags & ZEND_ACC_CLOSURE) && compile_time) { + return FAILURE; + } + if (zend_u_hash_add(function_table, Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(opline->op2.u.constant)+1, function, sizeof(zend_function), NULL)==FAILURE) { int error_level = compile_time ? E_COMPILE_ERROR : E_ERROR; zend_function *function; @@ -3018,6 +3075,11 @@ return FAILURE; } else { (*function->op_array.refcount)++; + if ((function->common.fn_flags & ZEND_ACC_CLOSURE) && + function->op_array.static_variables) { + TSRMLS_FETCH(); + zend_do_bind_static_variables(&function->op_array TSRMLS_CC); + } function->op_array.static_variables = NULL; /* NULL out the unbound function */ return SUCCESS; } Index: Zend/zend_compile.h =================================================================== RCS file: /repository/ZendEngine2/zend_compile.h,v retrieving revision 1.383 diff -u -r1.383 zend_compile.h --- Zend/zend_compile.h 8 Jul 2008 07:05:03 -0000 1.383 +++ Zend/zend_compile.h 17 Jul 2008 23:16:30 -0000 @@ -241,6 +241,9 @@ #define ZEND_RETURN_VALUE 0 #define ZEND_RETURN_REFERENCE 1 +#define ZEND_NO_LEXICAL_VARS 0 +#define ZEND_LEXICAL_VARS 1 + typedef struct _zend_internal_function { /* Common elements */ zend_uchar type; @@ -426,7 +429,7 @@ int zend_do_verify_access_types(znode *current_access_type, znode *new_modifier); void zend_do_begin_function_declaration(znode *function_token, znode *function_name, int is_method, int return_reference, znode *fn_flags_znode TSRMLS_DC); -void zend_do_end_function_declaration(znode *function_token TSRMLS_DC); +void zend_do_end_function_declaration(znode *function_token, zend_bool is_closure TSRMLS_DC); void zend_do_receive_arg(zend_uchar op, znode *var, znode *offset, znode *initialization, znode *class_type, znode *varname, zend_bool pass_by_reference TSRMLS_DC); int zend_do_begin_function_call(znode *function_name, zend_bool check_namespace TSRMLS_DC); void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC); @@ -452,6 +455,7 @@ ZEND_API zend_class_entry *do_bind_inherited_class(zend_op *opline, HashTable *class_table, zend_class_entry *parent_ce, zend_bool compile_time TSRMLS_DC); ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC); ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC); +ZEND_API void zend_do_bind_static_variables(zend_op_array *op_array TSRMLS_DC); void zend_do_implements_interface(znode *interface_znode TSRMLS_DC); ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce TSRMLS_DC); Index: Zend/zend_language_parser.y =================================================================== RCS file: /repository/ZendEngine2/zend_language_parser.y,v retrieving revision 1.207 diff -u -r1.207 zend_language_parser.y --- Zend/zend_language_parser.y 8 Jul 2008 07:05:03 -0000 1.207 +++ Zend/zend_language_parser.y 17 Jul 2008 23:16:30 -0000 @@ -305,7 +305,7 @@ unticked_function_declaration_statement: function is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$3, 0, $2.op_type, NULL TSRMLS_CC); } - '(' parameter_list ')' '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); } + '(' parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1, $7.op_type TSRMLS_CC); } ; unticked_class_declaration_statement: @@ -513,7 +513,7 @@ variable_modifiers { CG(access_type) = Z_LVAL($1.u.constant); } class_variable_declaration ';' | class_constant_declaration ';' | method_modifiers function is_reference T_STRING { zend_do_begin_function_declaration(&$2, &$4, 1, $3.op_type, &$1 TSRMLS_CC); } '(' - parameter_list ')' method_body { zend_do_abstract_method(&$4, &$1, &$9 TSRMLS_CC); zend_do_end_function_declaration(&$2 TSRMLS_CC); } + parameter_list ')' method_body { zend_do_abstract_method(&$4, &$1, &$9 TSRMLS_CC); zend_do_end_function_declaration(&$2, 0 TSRMLS_CC); } ; @@ -648,9 +648,9 @@ | '`' { CG(literal_type) = UG(unicode)?IS_UNICODE:IS_STRING; } encaps_list '`' { zend_do_shell_exec(&$$, &$3 TSRMLS_CC); } | T_PRINT expr { zend_do_print(&$$, &$2 TSRMLS_CC); } | function is_reference '(' { zend_do_begin_lambda_function_declaration(&$$, &$1, $2.op_type, 0 TSRMLS_CC); } - parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); $$ = $4; } + parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1, 1 TSRMLS_CC); $$ = $4; } | T_STATIC function is_reference '(' { zend_do_begin_lambda_function_declaration(&$$, &$2, $3.op_type, 1 TSRMLS_CC); } - parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$2 TSRMLS_CC); $$ = $5; } + parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$2, 1 TSRMLS_CC); $$ = $5; } ; function: @@ -658,8 +658,8 @@ ; lexical_vars: - /* emptry */ - | T_USE '(' lexical_var_list ')' + /* emptry */ { $$.op_type = ZEND_NO_LEXICAL_VARS; } + | T_USE '(' lexical_var_list ')' { $$.op_type = ZEND_LEXICAL_VARS; } ; lexical_var_list: --Apple-Mail-1--340873536 Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0644; name=php-ubiquitous-use-statement-PHP_5.3-20080718.patch.diff.txt Content-Disposition: attachment; filename=php-ubiquitous-use-statement-PHP_5.3-20080718.patch.diff.txt diff -r 28a314562273 Zend/zend_closures.c --- a/Zend/zend_closures.c Fri Jul 18 07:16:51 2008 +0900 +++ b/Zend/zend_closures.c Fri Jul 18 08:01:06 2008 +0900 @@ -201,44 +201,6 @@ void zend_register_closure_ce(TSRMLS_D) } /* }}} */ -static int zval_copy_static_var(zval **p, int num_args, va_list args, zend_hash_key *key) /* {{{ */ -{ - HashTable *target = va_arg(args, HashTable*); - zend_bool is_ref; - - if (Z_TYPE_PP(p) & (IS_LEXICAL_VAR|IS_LEXICAL_REF)) { - TSRMLS_FETCH(); - is_ref = Z_TYPE_PP(p) & IS_LEXICAL_REF; - - if (!EG(active_symbol_table)) { - zend_rebuild_symbol_table(TSRMLS_C); - } - if (zend_hash_quick_find(EG(active_symbol_table), key->arKey, key->nKeyLength, key->h, (void **) &p) == FAILURE) { - if (is_ref) { - zval *tmp; - - ALLOC_INIT_ZVAL(tmp); - Z_SET_ISREF_P(tmp); - zend_hash_quick_add(EG(active_symbol_table), key->arKey, key->nKeyLength, key->h, &tmp, sizeof(zval*), (void**)&p); - } else { - p = &EG(uninitialized_zval_ptr); - zend_error(E_NOTICE,"Undefined variable: %s", key->arKey); - } - } else { - if (is_ref) { - SEPARATE_ZVAL_TO_MAKE_IS_REF(p); - } else if (Z_ISREF_PP(p)) { - SEPARATE_ZVAL(p); - } - } - } - if (zend_hash_quick_add(target, key->arKey, key->nKeyLength, key->h, p, sizeof(zval*), NULL) == SUCCESS) { - Z_ADDREF_PP(p); - } - return ZEND_HASH_APPLY_KEEP; -} -/* }}} */ - ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_entry *scope, zval *this_ptr TSRMLS_DC) /* {{{ */ { zend_closure *closure; @@ -251,11 +213,8 @@ ZEND_API void zend_create_closure(zval * if (closure->func.type == ZEND_USER_FUNCTION) { if (closure->func.op_array.static_variables) { - HashTable *static_variables = closure->func.op_array.static_variables; - - ALLOC_HASHTABLE(closure->func.op_array.static_variables); - zend_hash_init(closure->func.op_array.static_variables, zend_hash_num_elements(static_variables), NULL, ZVAL_PTR_DTOR, 0); - zend_hash_apply_with_arguments(static_variables, (apply_func_args_t)zval_copy_static_var, 1, closure->func.op_array.static_variables); + zend_do_bind_static_variables(&closure->func.op_array TSRMLS_CC); + func->op_array.static_variables = NULL; } (*closure->func.op_array.refcount)++; } diff -r 28a314562273 Zend/zend_compile.c --- a/Zend/zend_compile.c Fri Jul 18 07:16:51 2008 +0900 +++ b/Zend/zend_compile.c Fri Jul 18 08:01:06 2008 +0900 @@ -1438,7 +1438,7 @@ void zend_do_handle_exception(TSRMLS_D) } -void zend_do_end_function_declaration(znode *function_token TSRMLS_DC) +void zend_do_end_function_declaration(znode *function_token, zend_bool is_closure TSRMLS_DC) { char lcname[16]; int name_len; @@ -1463,6 +1463,9 @@ void zend_do_end_function_declaration(zn } CG(active_op_array)->line_end = zend_get_compiled_lineno(TSRMLS_C); + if (is_closure) { + CG(active_op_array)->fn_flags |= ZEND_ACC_CLOSURE; + } CG(active_op_array) = function_token->u.op_array; @@ -1577,7 +1580,8 @@ int zend_do_begin_function_call(znode *f lcname = zend_str_tolower_dup(function_name->u.constant.value.str.val, function_name->u.constant.value.str.len); if ((zend_hash_find(CG(function_table), lcname, function_name->u.constant.value.str.len+1, (void **) &function)==FAILURE) || ((CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS) && - (function->type == ZEND_INTERNAL_FUNCTION))) { + (function->type == ZEND_INTERNAL_FUNCTION)) || + (function->common.fn_flags & ZEND_ACC_CLOSURE)) { zend_do_begin_dynamic_function_call(function_name, prefix_len TSRMLS_CC); efree(lcname); return 1; /* Dynamic */ @@ -2880,6 +2884,52 @@ ZEND_API void zend_do_implement_interfac } +static int zval_copy_static_var(zval **p, int num_args, va_list args, zend_hash_key *key) /* {{{ */ +{ + TSRMLS_FETCH_FROM_CTX(va_arg(args, void*)); + zend_bool is_ref; + + if (Z_TYPE_PP(p) & (IS_LEXICAL_VAR|IS_LEXICAL_REF)) { + zval **src; + TSRMLS_FETCH(); + is_ref = Z_TYPE_PP(p) & IS_LEXICAL_REF; + + if (!EG(active_symbol_table)) { + zend_rebuild_symbol_table(TSRMLS_C); + } + if (zend_hash_quick_find(EG(active_symbol_table), key->arKey, key->nKeyLength, key->h, (void **) &src) == FAILURE) { + if (is_ref) { + zval *tmp; + + ALLOC_INIT_ZVAL(tmp); + Z_SET_ISREF_P(tmp); + zend_hash_quick_add(EG(active_symbol_table), key->arKey, key->nKeyLength, key->h, &tmp, sizeof(zval*), (void**)&src); + } else { + src = &EG(uninitialized_zval_ptr); + zend_error(E_NOTICE,"Undefined variable: %s", key->arKey); + } + } else { + if (is_ref) { + SEPARATE_ZVAL_TO_MAKE_IS_REF(src); + } else if (Z_ISREF_PP(p)) { + SEPARATE_ZVAL(src); + } + } + Z_ADDREF_PP(src); + zval_ptr_dtor(p); + *p = *src; + } + return ZEND_HASH_APPLY_KEEP; +} +/* }}} */ + + +ZEND_API void zend_do_bind_static_variables(zend_op_array *op_array TSRMLS_DC) +{ + zend_hash_apply_with_arguments(op_array->static_variables, (apply_func_args_t)zval_copy_static_var, 1 TSRMLS_CC); +} + + ZEND_API int do_bind_function(zend_op *opline, HashTable *function_table, zend_bool compile_time) { zend_function *function; @@ -2889,6 +2939,12 @@ ZEND_API int do_bind_function(zend_op *o } zend_hash_find(function_table, opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len, (void *) &function); + + /* closures cannot be bound beforehand */ + if ((function->common.fn_flags & ZEND_ACC_CLOSURE) && compile_time) { + return FAILURE; + } + if (zend_hash_add(function_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, function, sizeof(zend_function), NULL)==FAILURE) { int error_level = compile_time ? E_COMPILE_ERROR : E_ERROR; zend_function *function; @@ -2906,6 +2962,11 @@ ZEND_API int do_bind_function(zend_op *o return FAILURE; } else { (*function->op_array.refcount)++; + if ((function->common.fn_flags & ZEND_ACC_CLOSURE) && + function->op_array.static_variables) { + TSRMLS_FETCH(); + zend_do_bind_static_variables(&function->op_array TSRMLS_CC); + } function->op_array.static_variables = NULL; /* NULL out the unbound function */ return SUCCESS; } diff -r 28a314562273 Zend/zend_compile.h --- a/Zend/zend_compile.h Fri Jul 18 07:16:51 2008 +0900 +++ b/Zend/zend_compile.h Fri Jul 18 08:01:06 2008 +0900 @@ -241,6 +241,9 @@ struct _zend_op_array { #define ZEND_RETURN_VALUE 0 #define ZEND_RETURN_REFERENCE 1 +#define ZEND_NO_LEXICAL_VARS 0 +#define ZEND_LEXICAL_VARS 1 + typedef struct _zend_internal_function { /* Common elements */ zend_uchar type; @@ -418,7 +421,7 @@ void zend_do_add_variable(znode *result, int zend_do_verify_access_types(znode *current_access_type, znode *new_modifier); void zend_do_begin_function_declaration(znode *function_token, znode *function_name, int is_method, int return_reference, znode *fn_flags_znode TSRMLS_DC); -void zend_do_end_function_declaration(znode *function_token TSRMLS_DC); +void zend_do_end_function_declaration(znode *function_token, zend_bool is_closure TSRMLS_DC); void zend_do_receive_arg(zend_uchar op, znode *var, znode *offset, znode *initialization, znode *class_type, znode *varname, zend_bool pass_by_reference TSRMLS_DC); int zend_do_begin_function_call(znode *function_name, zend_bool check_namespace TSRMLS_DC); void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC); @@ -444,6 +447,7 @@ ZEND_API zend_class_entry *do_bind_inher ZEND_API zend_class_entry *do_bind_inherited_class(zend_op *opline, HashTable *class_table, zend_class_entry *parent_ce, zend_bool compile_time TSRMLS_DC); ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC); ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC); +ZEND_API void zend_do_bind_static_variables(zend_op_array *op_array TSRMLS_DC); void zend_do_implements_interface(znode *interface_znode TSRMLS_DC); ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce TSRMLS_DC); diff -r 28a314562273 Zend/zend_language_parser.y --- a/Zend/zend_language_parser.y Fri Jul 18 07:16:51 2008 +0900 +++ b/Zend/zend_language_parser.y Fri Jul 18 08:01:06 2008 +0900 @@ -303,7 +303,7 @@ is_reference: unticked_function_declaration_statement: function is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$3, 0, $2.op_type, NULL TSRMLS_CC); } - '(' parameter_list ')' '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); } + '(' parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1, $7.op_type TSRMLS_CC); } ; unticked_class_declaration_statement: @@ -511,7 +511,7 @@ class_statement: variable_modifiers { CG(access_type) = Z_LVAL($1.u.constant); } class_variable_declaration ';' | class_constant_declaration ';' | method_modifiers function is_reference T_STRING { zend_do_begin_function_declaration(&$2, &$4, 1, $3.op_type, &$1 TSRMLS_CC); } '(' - parameter_list ')' method_body { zend_do_abstract_method(&$4, &$1, &$9 TSRMLS_CC); zend_do_end_function_declaration(&$2 TSRMLS_CC); } + parameter_list ')' method_body { zend_do_abstract_method(&$4, &$1, &$9 TSRMLS_CC); zend_do_end_function_declaration(&$2, 0 TSRMLS_CC); } ; @@ -644,9 +644,9 @@ expr_without_variable: | '`' encaps_list '`' { zend_do_shell_exec(&$$, &$2 TSRMLS_CC); } | T_PRINT expr { zend_do_print(&$$, &$2 TSRMLS_CC); } | function is_reference '(' { zend_do_begin_lambda_function_declaration(&$$, &$1, $2.op_type, 0 TSRMLS_CC); } - parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); $$ = $4; } + parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1, 1 TSRMLS_CC); $$ = $4; } | T_STATIC function is_reference '(' { zend_do_begin_lambda_function_declaration(&$$, &$2, $3.op_type, 1 TSRMLS_CC); } - parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$2 TSRMLS_CC); $$ = $5; } + parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$2, 1 TSRMLS_CC); $$ = $5; } ; function: @@ -654,8 +654,8 @@ function: ; lexical_vars: - /* emptry */ - | T_USE '(' lexical_var_list ')' + /* emptry */ { $$.op_type = ZEND_NO_LEXICAL_VARS; } + | T_USE '(' lexical_var_list ')' { $$.op_type = ZEND_LEXICAL_VARS; } ; lexical_var_list: diff -r 28a314562273 ext/phar/phar.phar Binary file ext/phar/phar.phar has changed --Apple-Mail-1--340873536 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1; format=flowed Moriyoshi --Apple-Mail-1--340873536--