[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
pajoye Tue, 06 Sep 2011 06:32:00 + Revision: http://svn.php.net/viewvc?view=revisionrevision=316209 Log: - WS Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2011-09-06 05:31:08 UTC (rev 316208) +++ php/php-src/trunk/Zend/zend_compile.c 2011-09-06 06:32:00 UTC (rev 316209) @@ -5911,7 +5911,7 @@ znode dummy, value_node; zend_bool assign_by_ref=0; - opline = CG(active_op_array)-opcodes[as_token-u.op. opline_num]; + opline = CG(active_op_array)-opcodes[as_token-u.op.opline_num]; if (key-op_type != IS_UNUSED) { znode *tmp; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] svn: /php/php-src/trunk/ Zend/zend_compile.c Zend/zend_language_scanner.c Zend/zend_language_scanner.l Zend/zend_language_scanner_defs.h Zend/zend_multibyte.c Zend/zend_multibyte.h ext/m
Hi Moriyoshi, Thank you for fixing it. You have fixed the most problems. I hope I've just fixed the rest, so all the broken tests work again. Thanks. Dmitry. On 03/06/2011 10:00 AM, Moriyoshi Koizumi wrote: moriyoshiSun, 06 Mar 2011 07:00:30 + Revision: http://svn.php.net/viewvc?view=revisionrevision=308950 Log: Fix zend.multibyte oddities. Hope this will address all the known problems. Changed paths: U php/php-src/trunk/Zend/zend_compile.c U php/php-src/trunk/Zend/zend_language_scanner.c U php/php-src/trunk/Zend/zend_language_scanner.l U php/php-src/trunk/Zend/zend_language_scanner_defs.h U php/php-src/trunk/Zend/zend_multibyte.c U php/php-src/trunk/Zend/zend_multibyte.h U php/php-src/trunk/ext/mbstring/mbstring.c U php/php-src/trunk/ext/mbstring/mbstring.h U php/php-src/trunk/main/rfc1867.c U php/php-src/trunk/main/rfc1867.h -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
pajoye Wed, 19 Jan 2011 21:40:15 + Revision: http://svn.php.net/viewvc?view=revisionrevision=307600 Log: - fix warning about undefined zend_multibyte_set_filter and zend_multibyte_yyinput_again, why are they not in zend_multibyte.h btw? Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2011-01-19 21:19:45 UTC (rev 307599) +++ php/php-src/trunk/Zend/zend_compile.c 2011-01-19 21:40:15 UTC (rev 307600) @@ -28,6 +28,7 @@ #include zend_exceptions.h #include tsrm_virtual_cwd.h #include zend_multibyte.h +#include zend_language_scanner.h #define CONSTANT_EX(op_array, op) \ (op_array)-literals[op].constant -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
gron Mon, 20 Dec 2010 08:49:59 + Revision: http://svn.php.net/viewvc?view=revisionrevision=306489 Log: Removed dead code. # should not have been commited in the first place. Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-12-20 08:45:09 UTC (rev 306488) +++ php/php-src/trunk/Zend/zend_compile.c 2010-12-20 08:49:59 UTC (rev 306489) @@ -3876,7 +3876,6 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* {{{ */ { - /* HashTable* resulting_table; */ size_t i; zend_property_info *property_info; zend_property_info *coliding_prop; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Mon, 20 Dec 2010 01:42:25 + Revision: http://svn.php.net/viewvc?view=revisionrevision=306479 Log: - Fix build Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-12-20 01:35:53 UTC (rev 306478) +++ php/php-src/trunk/Zend/zend_compile.c 2010-12-20 01:42:25 UTC (rev 306479) @@ -3876,17 +3876,16 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* {{{ */ { - //HashTable* resulting_table; + /* HashTable* resulting_table; */ size_t i; zend_property_info *property_info; zend_property_info *coliding_prop; zval compare_result; char* prop_name; int prop_name_length; - char* class_name_unused; - bool prop_found; - bool not_compatible; + zend_bool prop_found; + zend_bool not_compatible; zval* prop_value; @@ -3911,8 +3910,7 @@ prop_found = zend_hash_quick_find(ce-properties_info, property_info-name, property_info-name_length+1, property_info-h, (void **) coliding_prop) == SUCCESS; - } - else { + } else { /* for private and protected we need to unmangle the names */ zend_unmangle_property_name(property_info-name, property_info-name_length, class_name_unused, prop_name); @@ -3932,16 +3930,14 @@ not_compatible = compare_function(compare_result, ce-default_static_members_table[coliding_prop-offset], ce-traits[i]-default_static_members_table[property_info-offset] TSRMLS_CC) == FAILURE; - } - else { + } else { not_compatible = compare_function(compare_result, ce-default_properties_table[coliding_prop-offset], ce-traits[i]-default_properties_table[property_info-offset] TSRMLS_CC) == FAILURE; } - } - else { + } else { /* the flags are not identical, thus, we assume properties are not compatible */ - not_compatible = true; + not_compatible = 1; } if (not_compatible) { @@ -3951,8 +3947,7 @@ property_info-ce-name, prop_name, ce-name); - } - else { + } else { zend_error(E_STRICT, %s and %s define the same property ($%s) in the composition of %s. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed, find_first_definition(ce, i, prop_name, prop_name_length, coliding_prop-ce)-name, @@ -3965,12 +3960,10 @@ /* property not found, so lets add it */ if (property_info-flags ZEND_ACC_STATIC) { prop_value = ce-traits[i]-default_static_members_table[property_info-offset]; - } - else { + } else { prop_value = ce-traits[i]-default_properties_table[property_info-offset]; } - zend_declare_property_ex(ce, prop_name, prop_name_length, prop_value, property_info-flags,
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
gron Sun, 12 Dec 2010 17:12:29 + Revision: http://svn.php.net/viewvc?view=revisionrevision=306272 Log: Changed E_ERROR to E_COMPILE_ERROR for Trait compilation errors. #Thanks for catching this Kalle. Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-12-12 17:09:20 UTC (rev 306271) +++ php/php-src/trunk/Zend/zend_compile.c 2010-12-12 17:12:29 UTC (rev 306272) @@ -3459,7 +3459,7 @@ if (zend_hash_quick_find(ce-function_table, hash_key-arKey, hash_key-nKeyLength, hash_key-h, (void **)class_fn) == FAILURE || class_fn-common.scope != ce) { - zend_error(E_ERROR, Trait method %s has not been applied, because there are collisions with other trait methods on %s, fn-common.function_name, ce-name); + zend_error(E_COMPILE_ERROR, Trait method %s has not been applied, because there are collisions with other trait methods on %s, fn-common.function_name, ce-name); } zend_function_dtor(fn); @@ -3468,7 +3468,7 @@ } else { /* Add it to result function table */ if (zend_hash_quick_add(resulting_table, hash_key-arKey, hash_key-nKeyLength, hash_key-h, fn, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Trait method %s has not been applied, because failure occured during updating resulting trait method table, fn-common.function_name); + zend_error(E_COMPILE_ERROR, Trait method %s has not been applied, because failure occured during updating resulting trait method table, fn-common.function_name); } } @@ -3632,7 +3632,7 @@ zend_traits_duplicate_function(fn_copy, estrdup(fn-common.function_name) TSRMLS_CC); if (zend_hash_quick_update(ce-function_table, hash_key-arKey, hash_key-nKeyLength, hash_key-h, fn_copy, sizeof(zend_function), (void**)fn_copy_p)==FAILURE) { - zend_error(E_ERROR, Trait method %s has not been applied, because failure occured during updating class method table, hash_key-arKey); + zend_error(E_COMPILE_ERROR, Trait method %s has not been applied, because failure occured during updating class method table, hash_key-arKey); } _ADD_MAGIC_METHOD(ce, hash_key-arKey, hash_key-nKeyLength, fn_copy_p); @@ -3687,7 +3687,7 @@ lcname = zend_str_tolower_dup(aliases[i]-alias, lcname_len); if (zend_hash_add(target, lcname, lcname_len+1, fn_copy, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Failed to add aliased trait method (%s) to the trait table. There is probably already a trait method with the same name, fn_copy.common.function_name); + zend_error(E_COMPILE_ERROR, Failed to add aliased trait method (%s) to the trait table. There is probably already a trait method with the same name, fn_copy.common.function_name); } /* aliases[i]-function = fn_copy; */ efree(lcname); @@ -3725,7 +3725,7 @@ } if (zend_hash_add(target, lcname, fnname_len+1, fn_copy, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Failed to add trait method (%s) to the trait table. There is probably already a trait method with the same name, fn_copy.common.function_name); + zend_error(E_COMPILE_ERROR, Failed to add trait method (%s) to the trait table. There is probably already a trait method with the same name, fn_copy.common.function_name); } } @@ -3799,7 +3799,7 @@ char* lcname = zend_str_tolower_dup(precedences[i]-trait_method-method_name, lcname_len); if (zend_hash_add(exclude_table, lcname, lcname_len, NULL, 0, NULL)==FAILURE) { - zend_error(E_ERROR, Failed to evaluate a trait precedence (%s). Method of trait %s was defined to be excluded multiple times, precedences[i]-trait_method-method_name, trait-name); + zend_error(E_COMPILE_ERROR, Failed to evaluate a trait precedence (%s). Method of trait %s was defined to be excluded multiple times, precedences[i]-trait_method-method_name, trait-name); }
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
pajoye Wed, 01 Dec 2010 16:48:53 + Revision: http://svn.php.net/viewvc?view=revisionrevision=305892 Log: - fix ts build Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-12-01 15:58:17 UTC (rev 305891) +++ php/php-src/trunk/Zend/zend_compile.c 2010-12-01 16:48:53 UTC (rev 305892) @@ -5545,7 +5545,7 @@ fetch_simple_variable(result, variable, 1 TSRMLS_CC); /* there is a chance someone is accessing $this */ if (CG(active_op_array)-scope CG(active_op_array)-this_var == -1) { - CG(active_op_array)-this_var = lookup_cv(CG(active_op_array), estrndup(this, sizeof(this)-1), sizeof(this)-1); + CG(active_op_array)-this_var = lookup_cv(CG(active_op_array), estrndup(this, sizeof(this)-1), sizeof(this)-1 TSRMLS_CC); } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
dmitry Thu, 29 Jul 2010 09:46:59 + Revision: http://svn.php.net/viewvc?view=revisionrevision=301679 Log: ZEND_UNSET_* don't have results Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-07-29 07:27:19 UTC (rev 301678) +++ php/php-src/trunk/Zend/zend_compile.c 2010-07-29 09:46:59 UTC (rev 301679) @@ -5536,12 +5536,15 @@ switch (last_op-opcode) { case ZEND_FETCH_UNSET: last_op-opcode = ZEND_UNSET_VAR; + SET_UNUSED(last_op-result); break; case ZEND_FETCH_DIM_UNSET: last_op-opcode = ZEND_UNSET_DIM; + SET_UNUSED(last_op-result); break; case ZEND_FETCH_OBJ_UNSET: last_op-opcode = ZEND_UNSET_OBJ; + SET_UNUSED(last_op-result); break; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Thu, 08 Jul 2010 15:22:11 + Revision: http://svn.php.net/viewvc?view=revisionrevision=301087 Log: - Fix ZTS build Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-07-08 15:12:52 UTC (rev 301086) +++ php/php-src/trunk/Zend/zend_compile.c 2010-07-08 15:22:11 UTC (rev 301087) @@ -6065,7 +6065,7 @@ { zend_auto_global auto_global; - auto_global.name = zend_new_interned_string(name, name_len + 1, 0); + auto_global.name = zend_new_interned_string(name, name_len + 1, 0 TSRMLS_CC); auto_global.name_len = name_len; auto_global.auto_global_callback = auto_global_callback; auto_global.jit = jit; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Tue, 08 Jun 2010 18:02:10 + Revision: http://svn.php.net/viewvc?view=revisionrevision=300286 Log: - Fix ZTS build Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-06-08 17:43:41 UTC (rev 300285) +++ php/php-src/trunk/Zend/zend_compile.c 2010-06-08 18:02:10 UTC (rev 300286) @@ -3464,7 +3464,7 @@ /* {{{ Originates from php_runkit_function_copy_ctor Duplicate structures in an op_array where necessary to make an outright duplicate */ -static void zend_traits_duplicate_function(zend_function *fe, char *newname) +static void zend_traits_duplicate_function(zend_function *fe, char *newname TSRMLS_DC) { zend_literal *literals_copy; zend_compiled_variable *dupvars; @@ -3473,7 +3473,6 @@ if (fe-op_array.static_variables) { HashTable *tmpHash; - zval tmpZval; ALLOC_HASHTABLE(tmpHash); zend_hash_init(tmpHash, zend_hash_num_elements(fe-op_array.static_variables), NULL, ZVAL_PTR_DTOR, 0); @@ -3596,7 +3595,7 @@ ce-ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS; } fn_copy = *fn; - zend_traits_duplicate_function(fn_copy, estrdup(fn-common.function_name)); + zend_traits_duplicate_function(fn_copy, estrdup(fn-common.function_name) TSRMLS_CC); if (zend_hash_quick_update(ce-function_table, hash_key-arKey, hash_key-nKeyLength, hash_key-h, fn_copy, sizeof(zend_function), (void**)fn_copy_p)==FAILURE) { zend_error(E_ERROR, Trait method %s has not been applied, because failure occured during updating class method table, hash_key-arKey); @@ -3641,7 +3640,7 @@ fn-common.function_name, fnname_len) == 0)) { if (aliases[i]-alias) { fn_copy = *fn; - zend_traits_duplicate_function(fn_copy, estrndup(aliases[i]-alias, aliases[i]-alias_len)); + zend_traits_duplicate_function(fn_copy, estrndup(aliases[i]-alias, aliases[i]-alias_len) TSRMLS_CC); if (aliases[i]-modifiers) { /* if it is 0, no modifieres has been changed */ fn_copy.common.fn_flags = aliases[i]-modifiers; @@ -3669,7 +3668,7 @@ if (zend_hash_find(exclude_table, lcname, fnname_len, dummy) == FAILURE) { /* is not in hashtable, thus, function is not to be excluded */ fn_copy = *fn; - zend_traits_duplicate_function(fn_copy, estrndup(fn-common.function_name, fnname_len)); + zend_traits_duplicate_function(fn_copy, estrndup(fn-common.function_name, fnname_len) TSRMLS_CC); /* apply aliases which are not qualified by a class name, or which have not alias name, just setting visibility */ /* TODO: i am still not sure, that there will be no ambigousities... */ @@ -3686,7 +3685,7 @@ char* lcname2; zend_function fn_copy2 = *fn; - zend_traits_duplicate_function(fn_copy2, estrndup(aliases[i]-alias, aliases[i]-alias_len)); + zend_traits_duplicate_function(fn_copy2, estrndup(aliases[i]-alias, aliases[i]-alias_len) TSRMLS_CC); if (aliases[i]-modifiers) { /* if it is 0, no modifieres has been changed */ fn_copy2.common.fn_flags = aliases[i]-modifiers; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Thu, 06 May 2010 18:20:38 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299088 Log: - Fix error messages WS Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-05-06 17:17:45 UTC (rev 299087) +++ php/php-src/trunk/Zend/zend_compile.c 2010-05-06 18:20:38 UTC (rev 299088) @@ -3530,8 +3530,7 @@ lcname = zend_str_tolower_dup(aliases[i]-alias, lcname_len); if (zend_hash_add(target, lcname, lcname_len+1, fn_copy, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Failed to added aliased trait method (%s) to trait table. Propably there is already a trait method with same name\n, - fn_copy.common.function_name); + zend_error(E_ERROR, Failed to added aliased trait method (%s) to trait table. Propably there is already a trait method with same name, fn_copy.common.function_name); } /* aliases[i]-function = fn_copy; */ efree(lcname); @@ -3576,8 +3575,7 @@ lcname2 = zend_str_tolower_dup(aliases[i]-alias, lcname2_len); if (zend_hash_add(target, lcname2, lcname2_len+1, fn_copy2, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Failed to added aliased trait method (%s) to trait table. Propably there is already a trait method with same name\n, - fn_copy2.common.function_name); + zend_error(E_ERROR, Failed to added aliased trait method (%s) to trait table. Propably there is already a trait method with same name, fn_copy2.common.function_name); } efree(lcname2); } else { @@ -3595,8 +3593,7 @@ if (zend_hash_add(target, lcname, fnname_len+1, fn_copy, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Failed to added trait method (%s) to trait table. Propably there is already a trait method with same name\n, - fn_copy.common.function_name); + zend_error(E_ERROR, Failed to added trait method (%s) to trait table. Propably there is already a trait method with same name, fn_copy.common.function_name); } } @@ -3670,8 +3667,7 @@ char* lcname = zend_str_tolower_dup(precedences[i]-trait_method-method_name, lcname_len); if (zend_hash_add(exclude_table, lcname, lcname_len, NULL, 0, NULL)==FAILURE) { - zend_error(E_ERROR, Failed to evaluate a trait precedence (%s). Method of trait %s was defined to be excluded multiple times.\n, - precedences[i]-trait_method-method_name, trait-name); + zend_error(E_ERROR, Failed to evaluate a trait precedence (%s). Method of trait %s was defined to be excluded multiple times, precedences[i]-trait_method-method_name, trait-name); } efree(lcname); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Thu, 06 May 2010 18:28:45 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299089 Log: - Fix typos Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-05-06 18:20:38 UTC (rev 299088) +++ php/php-src/trunk/Zend/zend_compile.c 2010-05-06 18:28:45 UTC (rev 299089) @@ -3530,7 +3530,7 @@ lcname = zend_str_tolower_dup(aliases[i]-alias, lcname_len); if (zend_hash_add(target, lcname, lcname_len+1, fn_copy, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Failed to added aliased trait method (%s) to trait table. Propably there is already a trait method with same name, fn_copy.common.function_name); + zend_error(E_ERROR, Failed to add aliased trait method (%s) to trait table. Probably there is already a trait method with same name, fn_copy.common.function_name); } /* aliases[i]-function = fn_copy; */ efree(lcname); @@ -3575,7 +3575,7 @@ lcname2 = zend_str_tolower_dup(aliases[i]-alias, lcname2_len); if (zend_hash_add(target, lcname2, lcname2_len+1, fn_copy2, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Failed to added aliased trait method (%s) to trait table. Propably there is already a trait method with same name, fn_copy2.common.function_name); + zend_error(E_ERROR, Failed to add aliased trait method (%s) to trait table. Probably there is already a trait method with same name, fn_copy2.common.function_name); } efree(lcname2); } else { @@ -3591,9 +3591,8 @@ } } - if (zend_hash_add(target, lcname, fnname_len+1, fn_copy, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Failed to added trait method (%s) to trait table. Propably there is already a trait method with same name, fn_copy.common.function_name); + zend_error(E_ERROR, Failed to add trait method (%s) to trait table. Probably there is already a trait method with same name, fn_copy.common.function_name); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Thu, 06 May 2010 19:20:12 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299090 Log: - Added check for 'static' on trait visibility modifier Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-05-06 18:28:45 UTC (rev 299089) +++ php/php-src/trunk/Zend/zend_compile.c 2010-05-06 19:20:12 UTC (rev 299090) @@ -3308,8 +3308,7 @@ if (zend_hash_quick_find(ce-function_table, hash_key-arKey, hash_key-nKeyLength, hash_key-h, (void **)class_fn) == FAILURE || class_fn-common.scope != ce) { - zend_error(E_WARNING, Trait method %s has not been applied, because there are collisions with other trait methods on %s, - fn-common.function_name, ce-name); + zend_error(E_WARNING, Trait method %s has not been applied, because there are collisions with other trait methods on %s, fn-common.function_name, ce-name); } zend_function_dtor(fn); @@ -3318,8 +3317,7 @@ } else { /* Add it to result function table */ if (zend_hash_quick_add(resulting_table, hash_key-arKey, hash_key-nKeyLength, hash_key-h, fn, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Trait method %s has not been applied, because failure occured during updating resulting trait method table., - fn-common.function_name); + zend_error(E_ERROR, Trait method %s has not been applied, because failure occured during updating resulting trait method table, fn-common.function_name); } } @@ -3476,7 +3474,7 @@ } if (zend_hash_quick_update(ce-function_table, hash_key-arKey, hash_key-nKeyLength, hash_key-h, fn, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Trait method %s has not been applied, because failure occured during updating class method table., hash_key-arKey); + zend_error(E_ERROR, Trait method %s has not been applied, because failure occured during updating class method table, hash_key-arKey); } _ADD_MAGIC_METHOD(ce, hash_key-arKey, hash_key-nKeyLength, fn); @@ -3835,6 +3833,11 @@ trait_alias-trait_method = (zend_trait_method_reference*)method_reference-u.op.ptr; trait_alias-modifiers = Z_LVAL(modifiers-u.constant); + + if (Z_LVAL(modifiers-u.constant) == ZEND_ACC_STATIC) { + zend_error(E_COMPILE_ERROR, Cannot use 'static' as method modifier); + return; + } if (alias) { trait_alias-alias = Z_STRVAL(alias-u.constant); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c zend_vm_def.h zend_vm_execute.h
felipe Tue, 04 May 2010 18:21:00 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298986 Log: - Added check for abstract class abstract class foo { } class T { use foo; } // T cannot use foo - it is not a trait - Added check for trait on NEW trait a { } new a; // Cannot instantiate trait a # Tests for errors comming soon :) Changed paths: U php/php-src/trunk/Zend/zend_compile.c U php/php-src/trunk/Zend/zend_vm_def.h U php/php-src/trunk/Zend/zend_vm_execute.h Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-05-04 18:08:14 UTC (rev 298985) +++ php/php-src/trunk/Zend/zend_compile.c 2010-05-04 18:21:00 UTC (rev 298986) @@ -4518,7 +4518,7 @@ opline-opcode = ZEND_ADD_TRAIT; SET_NODE(opline-op1, CG(implementing_class)); zend_resolve_class_name(trait_name, opline-extended_value, 0 TSRMLS_CC); - opline-extended_value = (opline-extended_value ~ZEND_FETCH_CLASS_MASK) | ZEND_FETCH_CLASS_TRAIT; + opline-extended_value = ZEND_FETCH_CLASS_TRAIT; opline-op2_type = IS_CONST; opline-op2.constant = zend_add_class_name_literal(CG(active_op_array), trait_name-u.constant TSRMLS_CC); CG(active_class_entry)-num_traits++; Modified: php/php-src/trunk/Zend/zend_vm_def.h === --- php/php-src/trunk/Zend/zend_vm_def.h2010-05-04 18:08:14 UTC (rev 298985) +++ php/php-src/trunk/Zend/zend_vm_def.h2010-05-04 18:21:00 UTC (rev 298986) @@ -3230,6 +3230,8 @@ if (EX_T(opline-op1.var).class_entry-ce_flags ZEND_ACC_INTERFACE) { class_type = interface; + } else if (EX_T(opline-op1.var).class_entry-ce_flags ZEND_ACC_TRAIT) { + class_type = trait; } else { class_type = abstract class; } @@ -4663,7 +4665,7 @@ opline-extended_value TSRMLS_CC); if (trait) { - if (!(trait-ce_flags ZEND_ACC_TRAIT)) { + if (!((trait-ce_flags ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS) ZEND_ACC_TRAIT)) { zend_error_noreturn(E_ERROR, %s cannot use %s - it is not a trait, ce-name, trait-name); } zend_do_implement_trait(ce, trait TSRMLS_CC); Modified: php/php-src/trunk/Zend/zend_vm_execute.h === --- php/php-src/trunk/Zend/zend_vm_execute.h2010-05-04 18:08:14 UTC (rev 298985) +++ php/php-src/trunk/Zend/zend_vm_execute.h2010-05-04 18:21:00 UTC (rev 298986) @@ -520,6 +520,8 @@ if (EX_T(opline-op1.var).class_entry-ce_flags ZEND_ACC_INTERFACE) { class_type = interface; + } else if (EX_T(opline-op1.var).class_entry-ce_flags ZEND_ACC_TRAIT) { + class_type = trait; } else { class_type = abstract class; } @@ -691,7 +693,7 @@ opline-extended_value TSRMLS_CC); if (trait) { - if (!(trait-ce_flags ZEND_ACC_TRAIT)) { + if (!((trait-ce_flags ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS) ZEND_ACC_TRAIT)) { zend_error_noreturn(E_ERROR, %s cannot use %s - it is not a trait, ce-name, trait-name); } zend_do_implement_trait(ce, trait TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Tue, 04 May 2010 18:45:01 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298988 Log: - Added check for trait when trying to extend it Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-05-04 18:31:40 UTC (rev 298987) +++ php/php-src/trunk/Zend/zend_compile.c 2010-05-04 18:45:01 UTC (rev 298988) @@ -3932,6 +3932,8 @@ if (parent_ce-ce_flags ZEND_ACC_INTERFACE) { zend_error(E_COMPILE_ERROR, Class %s cannot extend from interface %s, ce-name, parent_ce-name); + } else if ((parent_ce-ce_flags ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS) ZEND_ACC_TRAIT) { + zend_error(E_COMPILE_ERROR, Class %s cannot extend from trait %s, ce-name, parent_ce-name); } zend_do_inheritance(ce, parent_ce TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
gron Mon, 03 May 2010 22:08:09 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298935 Log: Changed naming of traits-related helper functions (suggested by Derick), added missing static qualifiers. Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-05-03 22:08:06 UTC (rev 298934) +++ php/php-src/trunk/Zend/zend_compile.c 2010-05-03 22:08:09 UTC (rev 298935) @@ -3231,7 +3231,7 @@ } /* }}} */ -static int _merge_functions(zend_function *fn TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ +static int zend_traits_merge_functions(zend_function *fn TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { size_t current; size_t i; @@ -3320,7 +3320,7 @@ /* {{{ Originates from php_runkit_function_copy_ctor Duplicate structures in an op_array where necessary to make an outright duplicate */ -void _duplicate_function(zend_function *fe, char *newname) +static void zend_traits_duplicate_function(zend_function *fe, char *newname) { zend_literal *literals_copy; zend_compiled_variable *dupvars; @@ -3405,7 +3405,7 @@ } /* */ -static int _merge_functions_to_class(zend_function *fn TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int zend_traits_merge_functions_to_class(zend_function *fn TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { zend_class_entry *ce = va_arg(args, zend_class_entry*); int add = 0; @@ -3465,7 +3465,7 @@ return ZEND_HASH_APPLY_REMOVE; } -static int _copy_functions(zend_function *fn TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int zend_traits_copy_functions(zend_function *fn TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { HashTable* target; zend_trait_alias** aliases; @@ -3492,7 +3492,7 @@ fn-common.function_name, fnname_len) == 0)) { if (aliases[i]-alias) { fn_copy = *fn; - _duplicate_function(fn_copy, estrndup(aliases[i]-alias, aliases[i]-alias_len)); + zend_traits_duplicate_function(fn_copy, estrndup(aliases[i]-alias, aliases[i]-alias_len)); if (aliases[i]-modifiers) { /* if it is 0, no modifieres has been changed */ fn_copy.common.fn_flags = aliases[i]-modifiers; @@ -3521,7 +3521,7 @@ if (zend_hash_find(exclude_table, lcname, fnname_len, dummy) == FAILURE) { /* is not in hashtable, thus, function is not to be excluded */ fn_copy = *fn; - _duplicate_function(fn_copy, estrndup(fn-common.function_name, fnname_len)); + zend_traits_duplicate_function(fn_copy, estrndup(fn-common.function_name, fnname_len)); /* apply aliases which are not qualified by a class name, or which have not alias name, just setting visibility */ /* TODO: i am still not sure, that there will be no ambigousities... */ @@ -3538,7 +3538,7 @@ char* lcname2; zend_function fn_copy2 = *fn; - _duplicate_function(fn_copy2, estrndup(aliases[i]-alias, aliases[i]-alias_len)); + zend_traits_duplicate_function(fn_copy2, estrndup(aliases[i]-alias, aliases[i]-alias_len)); if (aliases[i]-modifiers) { /* if it is 0, no modifieres has been changed */ fn_copy2.common.fn_flags = aliases[i]-modifiers; @@ -3583,12 +3583,12 @@ /** * Copies function table entries to target function table with applied aliasing */ -void copy_trait_function_table(HashTable *target, HashTable *source, zend_trait_alias** aliases, HashTable* exclude_table TSRMLS_DC) { - zend_hash_apply_with_arguments(source TSRMLS_CC, (apply_func_args_t)_copy_functions, 3, /* 3 is number of args for apply_func */ +static void zend_traits_copy_trait_function_table(HashTable *target, HashTable *source, zend_trait_alias** aliases, HashTable* exclude_table TSRMLS_DC) { + zend_hash_apply_with_arguments(source TSRMLS_CC, (apply_func_args_t)zend_traits_copy_functions, 3, /* 3 is number of args for apply_func */ target, aliases, exclude_table); } -void init_trait_structures(zend_class_entry *ce TSRMLS_DC) /* {{{ */ +static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /* {{{ */ { size_t i,
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c zend_opcode.c
gron Sun, 02 May 2010 16:32:25 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298877 Log: Refactored part of the Traits implementation. # - renamed php_runkit_function_copy_ctor to _duplicate_function # REM: runkit does not compile with trunk at the moment, fixing it would introduce even more version #ifs, don't know what the best way is to fix it # - extracted traits related stuff from destroy_zend_class into _destroy_zend_class_traits_info # - need to investigate implementation/handling of internal classes further before enabling internal traits Changed paths: U php/php-src/trunk/Zend/zend_compile.c U php/php-src/trunk/Zend/zend_opcode.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-05-02 15:38:31 UTC (rev 298876) +++ php/php-src/trunk/Zend/zend_compile.c 2010-05-02 16:32:25 UTC (rev 298877) @@ -3321,9 +3321,9 @@ else if (IS_EQUAL(mname, mname_len, unserialize_func))(ce)-unserialize_func = (fe); \ } -/* {{{ php_runkit_function_copy_ctor +/* {{{ Originates from php_runkit_function_copy_ctor Duplicate structures in an op_array where necessary to make an outright duplicate */ -void php_runkit_function_copy_ctor(zend_function *fe, char *newname) +void _duplicate_function(zend_function *fe, char *newname) { zend_literal *literals_copy; zend_compiled_variable *dupvars; @@ -3497,7 +3497,7 @@ fn-common.function_name, fnname_len) == 0)) { if (aliases[i]-alias) { fn_copy = *fn; - php_runkit_function_copy_ctor(fn_copy, estrndup(aliases[i]-alias, aliases[i]-alias_len)); + _duplicate_function(fn_copy, estrndup(aliases[i]-alias, aliases[i]-alias_len)); if (aliases[i]-modifiers) { /* if it is 0, no modifieres has been changed */ fn_copy.common.fn_flags = aliases[i]-modifiers; @@ -3527,7 +3527,7 @@ if (zend_hash_find(exclude_table, lcname, lcname_len, dummy) == FAILURE) { /* is not in hashtable, thus, function is not to be excluded */ fn_copy = *fn; - php_runkit_function_copy_ctor(fn_copy, estrndup(fn-common.function_name, fnname_len)); + _duplicate_function(fn_copy, estrndup(fn-common.function_name, fnname_len)); /* apply aliases which are not qualified by a class name, or which have not alias name, just setting visibility */ /* TODO: i am still not sure, that there will be no ambigousities... */ @@ -3543,7 +3543,7 @@ zend_uint lcname2_len; char* lcname2; zend_function fn_copy2 = *fn; - php_runkit_function_copy_ctor(fn_copy2, estrndup(aliases[i]-alias, aliases[i]-alias_len)); + _duplicate_function(fn_copy2, estrndup(aliases[i]-alias, aliases[i]-alias_len)); if (aliases[i]-modifiers) { /* if it is 0, no modifieres has been changed */ fn_copy2.common.fn_flags = aliases[i]-modifiers; Modified: php/php-src/trunk/Zend/zend_opcode.c === --- php/php-src/trunk/Zend/zend_opcode.c2010-05-02 15:38:31 UTC (rev 298876) +++ php/php-src/trunk/Zend/zend_opcode.c2010-05-02 16:32:25 UTC (rev 298877) @@ -176,6 +176,55 @@ return 0; } +void _destroy_zend_class_traits_info(zend_class_entry *ce) +{ + if (ce-num_traits 0 ce-traits) { + efree(ce-traits); + } + + if (ce-trait_aliases) { + size_t i = 0; + while (ce-trait_aliases[i]) { + if (ce-trait_aliases[i]-trait_method) { + if (ce-trait_aliases[i]-trait_method-method_name) { + efree(ce-trait_aliases[i]-trait_method-method_name); + } + if (ce-trait_aliases[i]-trait_method-class_name) { + efree(ce-trait_aliases[i]-trait_method-class_name); + } + efree(ce-trait_aliases[i]-trait_method); + } + + if (ce-trait_aliases[i]-alias) { + efree(ce-trait_aliases[i]-alias); + } + + efree(ce-trait_aliases[i]); + i++;
Re: [PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c zend_opcode.c
On Sun, 2 May 2010, Stefan Marr wrote: gron Sun, 02 May 2010 16:32:25 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298877 Log: Refactored part of the Traits implementation. # - renamed php_runkit_function_copy_ctor to _duplicate_function Is there a reason why you named this to something with a _ at the start? AFAIK we've never done this, and instead prefer php_ (or in this case, zend_ ) Derick -- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c zend_opcode.c
Hi Derick: On 02 May 2010, at 19:12, Derick Rethans wrote: Is there a reason why you named this to something with a _ at the start? AFAIK we've never done this, and instead prefer php_ (or in this case, zend_ ) I have named all internal helper functions this way in the traits related code. Its a function which is only used in that .c file and not exposed by the header. What is the usual naming convention for that case? Thanks Stefan Derick -- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug -- Stefan Marr Software Languages Lab Vrije Universiteit Brussel Pleinlaan 2 / B-1050 Brussels / Belgium http://soft.vub.ac.be/~smarr Phone: +32 2 629 2974 Fax: +32 2 629 3525 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c zend_opcode.c
On Sun, 2 May 2010, Stefan Marr wrote: On 02 May 2010, at 19:12, Derick Rethans wrote: Is there a reason why you named this to something with a _ at the start? AFAIK we've never done this, and instead prefer php_ (or in this case, zend_ ) I have named all internal helper functions this way in the traits related code. Its a function which is only used in that .c file and not exposed by the header. What is the usual naming convention for that case? I don't know if we have real rules for this, but atleast it should use static then. I would pick something like: static void zend_traits_duplicate_function(zend_function *fe, char *newname) regards, Derick -- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Sun, 02 May 2010 17:39:24 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298878 Log: - Changed zend_hash func calls to use the quick ones Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-05-02 16:32:25 UTC (rev 298877) +++ php/php-src/trunk/Zend/zend_compile.c 2010-05-02 17:39:24 UTC (rev 298878) @@ -3239,7 +3239,6 @@ HashTable* resulting_table; HashTable** function_tables; zend_class_entry *ce; - /* zstr lcname; */ size_t collision = 0; size_t abstract_solved = 0; /* unsigned int name_len; */ @@ -3256,12 +3255,12 @@ continue; /* just skip this, cause its the table this function is applied on */ } - if (zend_hash_find(function_tables[i], hash_key-arKey, hash_key-nKeyLength, (void **)other_trait_fn) == SUCCESS) { + if (zend_hash_quick_find(function_tables[i], hash_key-arKey, hash_key-nKeyLength, hash_key-h, (void **)other_trait_fn) == SUCCESS) { /* if it is an abstract method, there is no collision */ if (other_trait_fn-common.fn_flags ZEND_ACC_ABSTRACT) { /* we can savely free and remove it from other table */ zend_function_dtor(other_trait_fn); - zend_hash_del(function_tables[i], hash_key-arKey, hash_key-nKeyLength); + zend_hash_quick_del(function_tables[i], hash_key-arKey, hash_key-nKeyLength, hash_key-h); } else { /* if it is not an abstract method, there is still no collision */ /* if fn is an abstract method */ @@ -3272,7 +3271,7 @@ /* but else, we have a collision of non-abstract methods */ collision++; zend_function_dtor(other_trait_fn); - zend_hash_del(function_tables[i], hash_key-arKey, hash_key-nKeyLength); + zend_hash_quick_del(function_tables[i], hash_key-arKey, hash_key-nKeyLength, hash_key-h); } } } @@ -3282,7 +3281,7 @@ zend_function* class_fn; /* make sure method is not already overridden in class */ - if (zend_hash_find(ce-function_table, hash_key-arKey, hash_key-nKeyLength, (void **)class_fn) == FAILURE + if (zend_hash_quick_find(ce-function_table, hash_key-arKey, hash_key-nKeyLength, hash_key-h, (void **)class_fn) == FAILURE || class_fn-common.scope != ce) { zend_error(E_WARNING, Trait method %s has not been applied, because there are collisions with other trait methods on %s, fn-common.function_name, ce-name); @@ -3293,14 +3292,12 @@ zend_function_dtor(fn); } else { /* Add it to result function table */ - if (zend_hash_add(resulting_table, hash_key-arKey, hash_key-nKeyLength, - fn, sizeof(zend_function), NULL)==FAILURE) { + if (zend_hash_quick_add(resulting_table, hash_key-arKey, hash_key-nKeyLength, hash_key-h, fn, sizeof(zend_function), NULL)==FAILURE) { zend_error(E_ERROR, Trait method %s has not been applied, because failure occured during updating resulting trait method table., fn-common.function_name); } } - /* efree(lcname.v); */ return ZEND_HASH_APPLY_REMOVE; } /* }}} */ @@ -3453,8 +3450,7 @@ ce-ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS; } - if (zend_hash_update(ce-function_table, hash_key-arKey, hash_key-nKeyLength, - fn, sizeof(zend_function), NULL)==FAILURE) { + if (zend_hash_quick_update(ce-function_table, hash_key-arKey, hash_key-nKeyLength, hash_key-h, fn, sizeof(zend_function), NULL)==FAILURE) { zend_error(E_ERROR, Trait method %s has not been applied, because failure occured during updating class method table., hash_key-arKey); } @@ -3521,10 +3517,9 @@ } } - lcname_len = strlen(fn-common.function_name); lcname = zend_str_tolower_dup(fn-common.function_name, fnname_len); - if (zend_hash_find(exclude_table, lcname, lcname_len, dummy) == FAILURE) { + if (zend_hash_find(exclude_table, lcname, fnname_len, dummy) == FAILURE) { /* is not in hashtable, thus, function
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Sun, 02 May 2010 18:47:27 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298880 Log: - WS Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-05-02 18:06:21 UTC (rev 298879) +++ php/php-src/trunk/Zend/zend_compile.c 2010-05-02 18:47:27 UTC (rev 298880) @@ -3462,7 +3462,6 @@ /* efree(fn); */ } - /* efree(lcname.v); */ return ZEND_HASH_APPLY_REMOVE; } @@ -3538,6 +3537,7 @@ zend_uint lcname2_len; char* lcname2; zend_function fn_copy2 = *fn; + _duplicate_function(fn_copy2, estrndup(aliases[i]-alias, aliases[i]-alias_len)); if (aliases[i]-modifiers) { /* if it is 0, no modifieres has been changed */ @@ -3607,7 +3607,8 @@ j = 0; while (cur_precedence-exclude_from_classes[j]) { char* class_name = (char*)cur_precedence-exclude_from_classes[j]; - zend_uint name_length = strlen(class_name); + zend_uint name_length = strlen(class_name); + cur_ce = zend_fetch_class(class_name, name_length, ZEND_FETCH_CLASS_TRAIT TSRMLS_CC); efree(class_name); cur_precedence-exclude_from_classes[j] = cur_ce; @@ -3803,7 +3804,7 @@ method_ref-mname_len = Z_STRLEN(method_name-u.constant); result-u.op.ptr = method_ref; - result-op_type = IS_TMP_VAR; + result-op_type = IS_TMP_VAR; } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
pajoye Wed, 28 Apr 2010 20:47:13 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298727 Log: - fix build (void is evil) Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-04-28 20:37:55 UTC (rev 298726) +++ php/php-src/trunk/Zend/zend_compile.c 2010-04-28 20:47:13 UTC (rev 298727) @@ -409,7 +409,7 @@ lc_literal = zend_add_literal(CG(active_op_array), c); CALCULATE_LITERAL_HASH(lc_literal); - ns_separator = zend_memrchr(Z_STRVAL_P(zv), '\\', Z_STRLEN_P(zv)) + 1; + ns_separator = (char *) zend_memrchr(Z_STRVAL_P(zv), '\\', Z_STRLEN_P(zv)) + 1; lc_len = Z_STRLEN_P(zv) - (ns_separator - Z_STRVAL_P(zv)); lc_name = zend_str_tolower_dup(ns_separator, lc_len); ZVAL_STRINGL(c, lc_name, lc_len, 0); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c zend_constants.c zend_constants.h zend_vm_def.h zend_vm_execute.h
dmitry Tue, 27 Apr 2010 12:09:13 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298651 Log: - Reimplemented ZEND_INIT_FCALL_BY_NAME and ZEND_INIT_NS_FCALL_BY_NAME to use literals instead of additional operands - Optimized access to global constants Changed paths: U php/php-src/trunk/Zend/zend_compile.c U php/php-src/trunk/Zend/zend_constants.c U php/php-src/trunk/Zend/zend_constants.h U php/php-src/trunk/Zend/zend_vm_def.h U php/php-src/trunk/Zend/zend_vm_execute.h Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-04-27 11:02:51 UTC (rev 298650) +++ php/php-src/trunk/Zend/zend_compile.c 2010-04-27 12:09:13 UTC (rev 298651) @@ -388,7 +388,38 @@ } /* }}} */ +int zend_add_ns_func_name_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC) /* {{{ */ +{ + int ret; + char *lc_name, *ns_separator; + int lc_len; + zval c; + int lc_literal; + if (op_array-last_literal 0 + op_array-literals[op_array-last_literal - 1].constant == zv) { + /* we already have function name as last literal (do nothing) */ + ret = op_array-last_literal - 1; + } else { + ret = zend_add_literal(op_array, zv); + } + + lc_name = zend_str_tolower_dup(Z_STRVAL_P(zv), Z_STRLEN_P(zv)); + ZVAL_STRINGL(c, lc_name, Z_STRLEN_P(zv), 0); + lc_literal = zend_add_literal(CG(active_op_array), c); + CALCULATE_LITERAL_HASH(lc_literal); + + ns_separator = zend_memrchr(Z_STRVAL_P(zv), '\\', Z_STRLEN_P(zv)) + 1; + lc_len = Z_STRLEN_P(zv) - (ns_separator - Z_STRVAL_P(zv)); + lc_name = zend_str_tolower_dup(ns_separator, lc_len); + ZVAL_STRINGL(c, lc_name, lc_len, 0); + lc_literal = zend_add_literal(CG(active_op_array), c); + CALCULATE_LITERAL_HASH(lc_literal); + + return ret; +} +/* }}} */ + int zend_add_class_name_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC) /* {{{ */ { int ret; @@ -1853,13 +1884,13 @@ zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline-opcode = ZEND_INIT_FCALL_BY_NAME; SET_NODE(opline-op2, left_bracket); - if (opline-op2_type == IS_CONST) { - opline-op1_type = IS_CONST; - LITERAL_STRINGL(opline-op1, zend_str_tolower_dup(Z_STRVAL(CONSTANT(opline-op2.constant)), Z_STRLEN(CONSTANT(opline-op2.constant))), Z_STRLEN(CONSTANT(opline-op2.constant)), 0); - CALCULATE_LITERAL_HASH(opline-op1.constant); - } else { - SET_UNUSED(opline-op1); - } + SET_UNUSED(opline-op1); + if (left_bracket-op_type == IS_CONST) { + opline-op2_type = IS_CONST; + opline-op2.constant = zend_add_func_name_literal(CG(active_op_array), left_bracket-u.constant TSRMLS_CC); + } else { + SET_NODE(opline-op2, left_bracket); + } } zend_stack_push(CG(function_call_stack), (void *) ptr, sizeof(zend_function *)); @@ -1883,7 +1914,7 @@ void zend_do_begin_dynamic_function_call(znode *function_name, int ns_call TSRMLS_DC) /* {{{ */ { unsigned char *ptr = NULL; - zend_op *opline, *opline2; + zend_op *opline; opline = get_next_op(CG(active_op_array) TSRMLS_CC); if (ns_call) { @@ -1892,34 +1923,18 @@ /* In run-time PHP will check for function with full name and internal function with short name */ opline-opcode = ZEND_INIT_NS_FCALL_BY_NAME; - SET_NODE(opline-op2, function_name); - opline-op1_type = IS_CONST; - LITERAL_STRINGL(opline-op1, zend_str_tolower_dup(Z_STRVAL(CONSTANT(opline-op2.constant)), Z_STRLEN(CONSTANT(opline-op2.constant))), Z_STRLEN(CONSTANT(opline-op2.constant)), 0); - CALCULATE_LITERAL_HASH(opline-op1.constant); - slash = zend_memrchr(Z_STRVAL(CONSTANT(opline-op1.constant)), '\\', Z_STRLEN(CONSTANT(opline-op1.constant))); - prefix_len = slash-Z_STRVAL(CONSTANT(opline-op1.constant))+1; - name_len = Z_STRLEN(CONSTANT(opline-op1.constant))-prefix_len; - opline2 = get_next_op(CG(active_op_array) TSRMLS_CC); - opline2-opcode = ZEND_OP_DATA; - SET_UNUSED(opline2-op1); - if(!slash) { - zend_error(E_CORE_ERROR, Namespaced name %s should contain slash, Z_STRVAL(CONSTANT(opline-op1.constant))); - } - /* this is the length of namespace prefix */ - opline2-op1.num = prefix_len; - /* this is the hash of the non-prefixed part, lowercased */ - opline2-extended_value = zend_hash_func(slash+1, name_len+1); - SET_UNUSED(opline2-op2); + SET_UNUSED(opline-op1); + opline-op2_type = IS_CONST; + opline-op2.constant = zend_add_ns_func_name_literal(CG(active_op_array), function_name-u.constant TSRMLS_CC); } else { opline-opcode = ZEND_INIT_FCALL_BY_NAME; - SET_NODE(opline-op2, function_name); - if (opline-op2_type == IS_CONST) { - opline-op1_type = IS_CONST; - LITERAL_STRINGL(opline-op1, zend_str_tolower_dup(Z_STRVAL(CONSTANT(opline-op2.constant)), Z_STRLEN(CONSTANT(opline-op2.constant))), Z_STRLEN(CONSTANT(opline-op2.constant)), 0); - CALCULATE_LITERAL_HASH(opline-op1.constant); - } else { - SET_UNUSED(opline-op1); - } + SET_UNUSED(opline-op1); + if
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
dmitry Tue, 27 Apr 2010 12:17:32 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298653 Log: - ws - removed unused variables Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-04-27 12:09:18 UTC (rev 298652) +++ php/php-src/trunk/Zend/zend_compile.c 2010-04-27 12:17:32 UTC (rev 298653) @@ -1883,14 +1883,13 @@ } else { zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline-opcode = ZEND_INIT_FCALL_BY_NAME; - SET_NODE(opline-op2, left_bracket); SET_UNUSED(opline-op1); if (left_bracket-op_type == IS_CONST) { opline-op2_type = IS_CONST; opline-op2.constant = zend_add_func_name_literal(CG(active_op_array), left_bracket-u.constant TSRMLS_CC); - } else { + } else { SET_NODE(opline-op2, left_bracket); - } + } } zend_stack_push(CG(function_call_stack), (void *) ptr, sizeof(zend_function *)); @@ -1918,8 +1917,6 @@ opline = get_next_op(CG(active_op_array) TSRMLS_CC); if (ns_call) { - char *slash; - int prefix_len, name_len; /* In run-time PHP will check for function with full name and internal function with short name */ opline-opcode = ZEND_INIT_NS_FCALL_BY_NAME; @@ -1932,9 +1929,9 @@ if (function_name-op_type == IS_CONST) { opline-op2_type = IS_CONST; opline-op2.constant = zend_add_func_name_literal(CG(active_op_array), function_name-u.constant TSRMLS_CC); - } else { + } else { SET_NODE(opline-op2, function_name); - } + } } zend_stack_push(CG(function_call_stack), (void *) ptr, sizeof(zend_function *)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c zend_execute_API.c zend_vm_def.h zend_vm_execute.h
dmitry Fri, 23 Apr 2010 08:56:03 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298369 Log: Use fast class fetch function Changed paths: U php/php-src/trunk/Zend/zend_compile.c U php/php-src/trunk/Zend/zend_execute_API.c U php/php-src/trunk/Zend/zend_vm_def.h U php/php-src/trunk/Zend/zend_vm_execute.h Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-04-23 08:06:49 UTC (rev 298368) +++ php/php-src/trunk/Zend/zend_compile.c 2010-04-23 08:56:03 UTC (rev 298369) @@ -4506,10 +4506,11 @@ opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline-opcode = ZEND_ADD_TRAIT; - SET_NODE(opline-op1, CG(implementing_class)); + SET_NODE(opline-op1, CG(implementing_class)); zend_resolve_class_name(trait_name, opline-extended_value, 0 TSRMLS_CC); opline-extended_value = (opline-extended_value ~ZEND_FETCH_CLASS_MASK) | ZEND_FETCH_CLASS_TRAIT; - SET_NODE(opline-op2, trait_name); + opline-op2_type = IS_CONST; + opline-op2.constant = zend_add_class_name_literal(CG(active_op_array), trait_name-u.constant TSRMLS_CC); CG(active_class_entry)-num_traits++; } /* }}} */ Modified: php/php-src/trunk/Zend/zend_execute_API.c === --- php/php-src/trunk/Zend/zend_execute_API.c 2010-04-23 08:06:49 UTC (rev 298368) +++ php/php-src/trunk/Zend/zend_execute_API.c 2010-04-23 08:56:03 UTC (rev 298369) @@ -1584,6 +1584,8 @@ if ((fetch_type ZEND_FETCH_CLASS_SILENT) == 0 !EG(exception)) { if ((fetch_type ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) { zend_error(E_ERROR, Interface '%s' not found, class_name); + } else if ((fetch_type ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) { + zend_error(E_ERROR, Trait '%s' not found, class_name); } else { zend_error(E_ERROR, Class '%s' not found, class_name); } Modified: php/php-src/trunk/Zend/zend_vm_def.h === --- php/php-src/trunk/Zend/zend_vm_def.h2010-04-23 08:06:49 UTC (rev 298368) +++ php/php-src/trunk/Zend/zend_vm_def.h2010-04-23 08:56:03 UTC (rev 298369) @@ -4642,8 +4642,9 @@ { zend_op *opline = EX(opline); zend_class_entry *ce = EX_T(opline-op1.var).class_entry; - zend_class_entry *trait = zend_fetch_class(Z_STRVAL_P(opline-op2.zv), + zend_class_entry *trait = zend_fetch_class_by_name(Z_STRVAL_P(opline-op2.zv), Z_STRLEN_P(opline-op2.zv), + opline-op2.literal + 1, opline-extended_value TSRMLS_CC); if (trait) { Modified: php/php-src/trunk/Zend/zend_vm_execute.h === --- php/php-src/trunk/Zend/zend_vm_execute.h2010-04-23 08:06:49 UTC (rev 298368) +++ php/php-src/trunk/Zend/zend_vm_execute.h2010-04-23 08:56:03 UTC (rev 298369) @@ -685,8 +685,9 @@ { zend_op *opline = EX(opline); zend_class_entry *ce = EX_T(opline-op1.var).class_entry; - zend_class_entry *trait = zend_fetch_class(Z_STRVAL_P(opline-op2.zv), + zend_class_entry *trait = zend_fetch_class_by_name(Z_STRVAL_P(opline-op2.zv), Z_STRLEN_P(opline-op2.zv), + opline-op2.literal + 1, opline-extended_value TSRMLS_CC); if (trait) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Thu, 22 Apr 2010 23:16:15 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298351 Log: - Fixed ZTS build comment-style Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-04-22 22:57:35 UTC (rev 298350) +++ php/php-src/trunk/Zend/zend_compile.c 2010-04-22 23:16:15 UTC (rev 298351) @@ -2851,7 +2851,7 @@ } /* }}} */ -static void do_inheritance_check_on_method(zend_function *child, zend_function *parent) +static void do_inheritance_check_on_method(zend_function *child, zend_function *parent TSRMLS_DC) { zend_uint child_flags; zend_uint parent_flags = parent-common.fn_flags; @@ -2932,7 +2932,7 @@ return 1; /* method doesn't exist in child, copy from parent */ } - do_inheritance_check_on_method(child, parent); + do_inheritance_check_on_method(child, parent TSRMLS_CC); return 0; } @@ -3227,13 +3227,13 @@ HashTable* resulting_table; HashTable** function_tables; zend_class_entry *ce; - //zstr lcname; + /* zstr lcname; */ size_t collision = 0; size_t abstract_solved = 0; - //unsigned int name_len; + /* unsigned int name_len; */ zend_function* other_trait_fn; - current = va_arg(args, size_t); // index of current trait + current = va_arg(args, size_t); /* index of current trait */ count = va_arg(args, size_t); resulting_table = va_arg(args, HashTable*); function_tables = va_arg(args, HashTable**); @@ -3241,23 +3241,23 @@ for (i = 0; i count; i++) { if (i == current) { - continue; // just skip this, cause its the table this function is applied on + continue; /* just skip this, cause its the table this function is applied on */ } if (zend_hash_find(function_tables[i], hash_key-arKey, hash_key-nKeyLength, other_trait_fn) == SUCCESS) { - // if it is an abstract method, there is no collision + /* if it is an abstract method, there is no collision */ if (other_trait_fn-common.fn_flags ZEND_ACC_ABSTRACT) { -// we can savely free and remove it from other table +/* we can savely free and remove it from other table */ zend_function_dtor(other_trait_fn); zend_hash_del(function_tables[i], hash_key-arKey, hash_key-nKeyLength); } else { -// if it is not an abstract method, there is still no collision -// iff fn is an abstract method +/* if it is not an abstract method, there is still no collision */ +/* if fn is an abstract method */ if (fn-common.fn_flags ZEND_ACC_ABSTRACT) { - // just mark as solved, will be added if its own trait is processed + /* just mark as solved, will be added if its own trait is processed */ abstract_solved = 1; } else { - // but else, we have a collision of non-abstract methods + /* but else, we have a collision of non-abstract methods */ collision++; zend_function_dtor(other_trait_fn); zend_hash_del(function_tables[i], hash_key-arKey, hash_key-nKeyLength); @@ -3268,7 +3268,7 @@ if (collision) { zend_function* class_fn; - // make sure method is not already overridden in class + /* make sure method is not already overridden in class */ if (zend_hash_find(ce-function_table, hash_key-arKey, hash_key-nKeyLength, class_fn) == FAILURE || class_fn-common.scope != ce) { @@ -3280,7 +3280,7 @@ } else if (abstract_solved) { zend_function_dtor(fn); } else { - // Add it to result function table + /* Add it to result function table */ if (zend_hash_add(resulting_table, hash_key-arKey, hash_key-nKeyLength, fn, sizeof(zend_function), NULL)==FAILURE) { zend_error(E_ERROR, Trait method %s has not been applied, because failure occured during updating resulting trait method table., @@ -3288,7 +3288,7 @@ } } - //efree(lcname.v); + /* efree(lcname.v); */ return ZEND_HASH_APPLY_REMOVE; } /* }}} */ @@ -3365,7 +3365,8 @@ fe-op_array.start_op = fe-op_array.opcodes; fe-op_array.function_name = newname; - //fe-op_array.prototype = fe-op_array.prototype; //was setting it to fe which does not work since fe is stack allocated and not a stable address + /* was setting it to fe which does not work since fe is stack allocated and not a stable address */ + /* fe-op_array.prototype = fe-op_array.prototype; */ if (fe-op_array.arg_info) { zend_arg_info *tmpArginfo; @@ -3388,7 +3389,7 @@ fe-op_array.brk_cont_array = (zend_brk_cont_element*)estrndup((char*)fe-op_array.brk_cont_array, sizeof(zend_brk_cont_element) * fe-op_array.last_brk_cont); - // TODO: check whether there is something similar and whether that is ok + /* TODO: check whether there is something similar and whether that is ok */ zend_literal* literals_copy = (zend_literal*)emalloc(fe-op_array.size_literal * sizeof(zend_literal)); for (i = 0; i fe-op_array.size_literal; i++) { @@ -3403,21 +3404,23
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Thu, 22 Apr 2010 23:25:05 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298353 Log: - Fix zend_hash_apply_with_arguments() calls on ZTS Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-04-22 23:23:10 UTC (rev 298352) +++ php/php-src/trunk/Zend/zend_compile.c 2010-04-22 23:25:05 UTC (rev 298353) @@ -3451,7 +3451,7 @@ _ADD_MAGIC_METHOD(ce, hash_key-arKey, hash_key-nKeyLength, fn); /* it could be necessary to update child classes as well */ - /* zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_methods, 5, dce, dce, dfe, dfunc, dfunc_len); */ + /* zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_methods, 5, dce, dce, dfe, dfunc, dfunc_len); */ } else { zend_function_dtor(fn); /* efree(fn); */ @@ -3576,8 +3576,8 @@ /** * Copies function table entries to target function table with applied aliasing */ -void copy_trait_function_table(HashTable *target, HashTable *source, zend_trait_alias** aliases, HashTable* exclude_table) { - zend_hash_apply_with_arguments(source, (apply_func_args_t)_copy_functions, 3, /* 3 is number of args for apply_func */ +void copy_trait_function_table(HashTable *target, HashTable *source, zend_trait_alias** aliases, HashTable* exclude_table TSRMLS_DC) { + zend_hash_apply_with_arguments(source TSRMLS_CC, (apply_func_args_t)_copy_functions, 3, /* 3 is number of args for apply_func */ target, aliases, exclude_table); } @@ -3683,13 +3683,13 @@ compile_exclude_table(exclude_table, ce-trait_precedences, ce-traits[i]); /* copies functions, applies defined aliasing, and excludes unused trait methods */ - copy_trait_function_table(function_tables[i], ce-traits[i]-function_table, ce-trait_aliases, exclude_table); + copy_trait_function_table(function_tables[i], ce-traits[i]-function_table, ce-trait_aliases, exclude_table TSRMLS_CC); zend_hash_graceful_destroy(exclude_table); } /* now merge trait methods */ for (i = 0; i ce-num_traits; i++) { - zend_hash_apply_with_arguments(function_tables[i], (apply_func_args_t)_merge_functions, 5, /* 5 is number of args for apply_func */ + zend_hash_apply_with_arguments(function_tables[i] TSRMLS_CC, (apply_func_args_t)_merge_functions, 5, /* 5 is number of args for apply_func */ i, ce-num_traits, resulting_table, function_tables, ce); } @@ -3699,7 +3699,7 @@ if there is already a method with the same name it is replaced iff ce != fn.scope -- all inherited methods are overridden, methods defined in the class are leaved untouched */ - zend_hash_apply_with_arguments(resulting_table, (apply_func_args_t)_merge_functions_to_class, 1, ce TSRMLS_CC); + zend_hash_apply_with_arguments(resulting_table TSRMLS_CC, (apply_func_args_t)_merge_functions_to_class, 1, ce); /* free temporary function tables */ for (i = 0; i ce-num_traits; i++) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Fri, 23 Apr 2010 00:54:51 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298357 Log: - Fix ZTS code and CS Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-04-23 00:37:04 UTC (rev 298356) +++ php/php-src/trunk/Zend/zend_compile.c 2010-04-23 00:54:51 UTC (rev 298357) @@ -3244,7 +3244,7 @@ continue; /* just skip this, cause its the table this function is applied on */ } - if (zend_hash_find(function_tables[i], hash_key-arKey, hash_key-nKeyLength, other_trait_fn) == SUCCESS) { + if (zend_hash_find(function_tables[i], hash_key-arKey, hash_key-nKeyLength, (void **)other_trait_fn) == SUCCESS) { /* if it is an abstract method, there is no collision */ if (other_trait_fn-common.fn_flags ZEND_ACC_ABSTRACT) { /* we can savely free and remove it from other table */ @@ -3270,7 +3270,7 @@ zend_function* class_fn; /* make sure method is not already overridden in class */ - if (zend_hash_find(ce-function_table, hash_key-arKey, hash_key-nKeyLength, class_fn) == FAILURE + if (zend_hash_find(ce-function_table, hash_key-arKey, hash_key-nKeyLength, (void **)class_fn) == FAILURE || class_fn-common.scope != ce) { zend_error(E_WARNING, Trait method %s has not been applied, because there are collisions with other trait methods on %s, fn-common.function_name, ce-name); @@ -3344,7 +3344,7 @@ for(i = 0; i fe-op_array.last; i++) { opcode_copy[i] = fe-op_array.opcodes[i]; if (opcode_copy[i].op1_type == IS_CONST) { - zval_copy_ctor(opcode_copy[i].op1.constant); + zval_copy_ctor(CONSTANT_EX(fe-op_array, opcode_copy[i].op1.constant)); } else { if (opcode_copy[i].op1.jmp_addr = fe-op_array.opcodes opcode_copy[i].op1.jmp_addr fe-op_array.opcodes + fe-op_array.last) { @@ -3353,7 +3353,7 @@ } if (opcode_copy[i].op2_type == IS_CONST) { - zval_copy_ctor(opcode_copy[i].op2.constant); + zval_copy_ctor(CONSTANT_EX(fe-op_array, opcode_copy[i].op2.constant)); } else { if (opcode_copy[i].op2.jmp_addr = fe-op_array.opcodes opcode_copy[i].op2.jmp_addr fe-op_array.opcodes + fe-op_array.last) { @@ -3389,13 +3389,13 @@ fe-op_array.brk_cont_array = (zend_brk_cont_element*)estrndup((char*)fe-op_array.brk_cont_array, sizeof(zend_brk_cont_element) * fe-op_array.last_brk_cont); - /* TODO: check whether there is something similar and whether that is ok */ - zend_literal* literals_copy = (zend_literal*)emalloc(fe-op_array.size_literal * sizeof(zend_literal)); + /* TODO: check whether there is something similar and whether that is ok */ + zend_literal* literals_copy = (zend_literal*)emalloc(fe-op_array.size_literal * sizeof(zend_literal)); - for (i = 0; i fe-op_array.size_literal; i++) { -literals_copy[i] = fe-op_array.literals[i]; - } - fe-op_array.literals = literals_copy; + for (i = 0; i fe-op_array.size_literal; i++) { + literals_copy[i] = fe-op_array.literals[i]; + } + fe-op_array.literals = literals_copy; } /* */ @@ -3461,7 +3461,7 @@ return ZEND_HASH_APPLY_REMOVE; } -static int _copy_functions(zend_function *fn, int num_args, va_list args, zend_hash_key *hash_key) +static int _copy_functions(zend_function *fn TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { HashTable* target; zend_trait_alias** aliases; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Fri, 23 Apr 2010 01:43:27 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298359 Log: - Fix function signature Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-04-23 01:10:05 UTC (rev 298358) +++ php/php-src/trunk/Zend/zend_compile.c 2010-04-23 01:43:27 UTC (rev 298359) @@ -3219,7 +3219,7 @@ } /* }}} */ -static int _merge_functions(zend_function *fn, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ +static int _merge_functions(zend_function *fn TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { size_t current; size_t i; @@ -3399,7 +3399,7 @@ } /* */ -static int _merge_functions_to_class(zend_function *fn, int num_args, va_list args, zend_hash_key *hash_key TSRMLS_DC) +static int _merge_functions_to_class(zend_function *fn TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { zend_class_entry *ce = va_arg(args, zend_class_entry*); int add = 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Fri, 23 Apr 2010 01:56:03 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298360 Log: - Fix Windows build (Kalle) Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-04-23 01:43:27 UTC (rev 298359) +++ php/php-src/trunk/Zend/zend_compile.c 2010-04-23 01:56:03 UTC (rev 298360) @@ -3313,6 +3313,7 @@ Duplicate structures in an op_array where necessary to make an outright duplicate */ void php_runkit_function_copy_ctor(zend_function *fe, char *newname) { + zend_literal *literals_copy; zend_compiled_variable *dupvars; zend_op *opcode_copy; int i; @@ -3383,14 +3384,13 @@ fe-op_array.arg_info = tmpArginfo; } - fe-op_array.doc_comment = estrndup(fe-op_array.doc_comment, - fe-op_array.doc_comment_len); + fe-op_array.doc_comment = estrndup(fe-op_array.doc_comment, fe-op_array.doc_comment_len); fe-op_array.try_catch_array = (zend_try_catch_element*)estrndup((char*)fe-op_array.try_catch_array, sizeof(zend_try_catch_element) * fe-op_array.last_try_catch); fe-op_array.brk_cont_array = (zend_brk_cont_element*)estrndup((char*)fe-op_array.brk_cont_array, sizeof(zend_brk_cont_element) * fe-op_array.last_brk_cont); /* TODO: check whether there is something similar and whether that is ok */ - zend_literal* literals_copy = (zend_literal*)emalloc(fe-op_array.size_literal * sizeof(zend_literal)); + literals_copy = (zend_literal*)emalloc(fe-op_array.size_literal * sizeof(zend_literal)); for (i = 0; i fe-op_array.size_literal; i++) { literals_copy[i] = fe-op_array.literals[i]; @@ -3470,6 +3470,7 @@ unsigned int lcname_len; unsigned int fnname_len; zend_function fn_copy; + void* dummy; size_t i = 0; target = va_arg(args, HashTable*); @@ -3513,7 +3514,7 @@ lcname_len = strlen(fn-common.function_name); lcname = zend_str_tolower_dup(fn-common.function_name, fnname_len); - void* dummy; + if (zend_hash_find(exclude_table, lcname, lcname_len, dummy) == FAILURE) { /* is not in hashtable, thus, function is not to be excluded */ fn_copy = *fn; @@ -3530,6 +3531,8 @@ aliases[i]-trait_method-mname_len, fn-common.function_name, fnname_len) == 0)) { if (aliases[i]-alias) { + zend_uint lcname2_len; + char* lcname2; zend_function fn_copy2 = *fn; php_runkit_function_copy_ctor(fn_copy2, estrndup(aliases[i]-alias, aliases[i]-alias_len)); @@ -3540,8 +3543,8 @@ } } - zend_uint lcname2_len = aliases[i]-alias_len; - char* lcname2 = zend_str_tolower_dup(aliases[i]-alias, lcname2_len); + lcname2_len = aliases[i]-alias_len; + lcname2 = zend_str_tolower_dup(aliases[i]-alias, lcname2_len); if (zend_hash_add(target, lcname2, lcname2_len+1, fn_copy2, sizeof(zend_function), NULL)==FAILURE) { zend_error(E_ERROR, Failed to added aliased trait method (%s) to trait table. Propably there is already a trait method with same name\n, @@ -4442,15 +4445,16 @@ * The only difference will be a combined handling of them in the end. * Thus, we need another opcode here. */ if (ce-num_traits 0) { + zend_op *opline; + ce-traits = NULL; ce-num_traits = 0; ce-ce_flags |= ZEND_ACC_IMPLEMENT_TRAITS; /* opcode generation: */ - zend_op *opline; opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline-opcode = ZEND_BIND_TRAITS; -SET_NODE(opline-op1, CG(implementing_class)); + SET_NODE(opline-op1, CG(implementing_class)); } CG(active_class_entry) = NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Fri, 23 Apr 2010 02:57:49 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298363 Log: - Fix memory issue Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-04-23 02:53:01 UTC (rev 298362) +++ php/php-src/trunk/Zend/zend_compile.c 2010-04-23 02:57:49 UTC (rev 298363) @@ -3344,18 +3344,14 @@ opcode_copy = safe_emalloc(sizeof(zend_op), fe-op_array.last, 0); for(i = 0; i fe-op_array.last; i++) { opcode_copy[i] = fe-op_array.opcodes[i]; - if (opcode_copy[i].op1_type == IS_CONST) { - zval_copy_ctor(CONSTANT_EX(fe-op_array, opcode_copy[i].op1.constant)); - } else { + if (opcode_copy[i].op1_type != IS_CONST) { if (opcode_copy[i].op1.jmp_addr = fe-op_array.opcodes opcode_copy[i].op1.jmp_addr fe-op_array.opcodes + fe-op_array.last) { opcode_copy[i].op1.jmp_addr = opcode_copy + (fe-op_array.opcodes[i].op1.jmp_addr - fe-op_array.opcodes); } } - if (opcode_copy[i].op2_type == IS_CONST) { - zval_copy_ctor(CONSTANT_EX(fe-op_array, opcode_copy[i].op2.constant)); - } else { + if (opcode_copy[i].op2_type != IS_CONST) { if (opcode_copy[i].op2.jmp_addr = fe-op_array.opcodes opcode_copy[i].op2.jmp_addr fe-op_array.opcodes + fe-op_array.last) { opcode_copy[i].op2.jmp_addr = opcode_copy + (fe-op_array.opcodes[i].op2.jmp_addr - fe-op_array.opcodes); @@ -3394,6 +3390,7 @@ for (i = 0; i fe-op_array.size_literal; i++) { literals_copy[i] = fe-op_array.literals[i]; + zval_copy_ctor(literals_copy[i].constant); } fe-op_array.literals = literals_copy; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
dmitry Wed, 21 Apr 2010 14:58:33 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298256 Log: Eliminated unnecessary compile-time hash_value recalculation for interned strings Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-04-21 14:19:27 UTC (rev 298255) +++ php/php-src/trunk/Zend/zend_compile.c 2010-04-21 14:58:33 UTC (rev 298256) @@ -62,6 +62,13 @@ target = src; \ } while (0) +#define CALCULATE_LITERAL_HASH(num) do { \ + if (IS_INTERNED(Z_STRVAL(CONSTANT(num { \ + Z_HASH_P(CONSTANT(num)) = INTERNED_HASH(Z_STRVAL(CONSTANT(num))); \ + } else { \ + Z_HASH_P(CONSTANT(num)) = zend_hash_func(Z_STRVAL(CONSTANT(num)), Z_STRLEN(CONSTANT(num))+1); \ + } \ +} while (0) ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename TSRMLS_DC); @@ -357,6 +364,62 @@ } /* }}} */ +int zend_add_func_name_literal(zend_op_array *op_array, const zval *zv) /* {{{ */ +{ + int ret; + char *lc_name; + zval c; + int lc_literal; + + if (op_array-last_literal 0 + op_array-literals[op_array-last_literal - 1].constant == zv) { + /* we already have function name as last literal (do nothing) */ + ret = op_array-last_literal - 1; + } else { + ret = zend_add_literal(op_array, zv); + } + + lc_name = zend_str_tolower_dup(Z_STRVAL_P(zv), Z_STRLEN_P(zv)); + ZVAL_STRINGL(c, lc_name, Z_STRLEN_P(zv), 0); + lc_literal = zend_add_literal(CG(active_op_array), c); + CALCULATE_LITERAL_HASH(lc_literal); + + return ret; +} +/* }}} */ + + +int zend_add_class_name_literal(zend_op_array *op_array, const zval *zv) /* {{{ */ +{ + int ret; + char *lc_name; + int lc_len; + zval c; + int lc_literal; + + if (op_array-last_literal 0 + op_array-literals[op_array-last_literal - 1].constant == zv) { + /* we already have function name as last literal (do nothing) */ + ret = op_array-last_literal - 1; + } else { + ret = zend_add_literal(op_array, zv); + } + + if (Z_STRVAL_P(zv)[0] == '\\') { + lc_len = Z_STRLEN_P(zv) - 1; + lc_name = zend_str_tolower_dup(Z_STRVAL_P(zv) + 1, lc_len); + } else { + lc_len = Z_STRLEN_P(zv); + lc_name = zend_str_tolower_dup(Z_STRVAL_P(zv), lc_len); + } + ZVAL_STRINGL(c, lc_name, lc_len, 0); + lc_literal = zend_add_literal(CG(active_op_array), c); + CALCULATE_LITERAL_HASH(lc_literal); + + return ret; +} +/* }}} */ + #define LITERAL_STRINGL(op, str, len, copy) do { \ zval _c; \ ZVAL_STRINGL(_c, str, len, copy); \ @@ -380,7 +443,7 @@ INIT_ZVAL( _c); \ op.constant = zend_add_literal(CG(active_op_array), _c); \ } while (0) - + void zend_do_binary_op(zend_uchar op, znode *result, const znode *op1, const znode *op2 TSRMLS_DC) /* {{{ */ { zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); @@ -498,7 +561,7 @@ opline_ptr-extended_value = ZEND_FETCH_LOCAL; if (varname-op_type == IS_CONST) { - Z_HASH_P(CONSTANT(opline_ptr-op1.constant)) = zend_hash_func(Z_STRVAL(CONSTANT(opline_ptr-op1.constant)), Z_STRLEN(CONSTANT(opline_ptr-op1.constant))+1); + CALCULATE_LITERAL_HASH(opline_ptr-op1.constant); if (zend_is_auto_global(varname-u.constant.value.str.val, varname-u.constant.value.str.len TSRMLS_CC)) { opline_ptr-extended_value = ZEND_FETCH_GLOBAL; } @@ -536,7 +599,7 @@ opline.result.var = get_temporary_variable(CG(active_op_array)); opline.op1_type = IS_CONST; LITERAL_STRINGL(opline.op1, estrdup(CG(active_op_array)-vars[result-u.op.var].name), CG(active_op_array)-vars[result-u.op.var].name_len, 0); - Z_HASH_P(CONSTANT(opline.op1.constant)) = zend_hash_func(Z_STRVAL(CONSTANT(opline.op1.constant)), Z_STRLEN(CONSTANT(opline.op1.constant))+1); + CALCULATE_LITERAL_HASH(opline.op1.constant); SET_UNUSED(opline.op2); SET_NODE(opline.op2, class_node); GET_NODE(result,opline.result); @@ -555,7 +618,7 @@ opline.result.var = get_temporary_variable(CG(active_op_array)); opline.op1_type = IS_CONST; LITERAL_STRINGL(opline.op1, estrdup(CG(active_op_array)-vars[opline_ptr-op1.var].name), CG(active_op_array)-vars[opline_ptr-op1.var].name_len, 0); - Z_HASH_P(CONSTANT(opline.op1.constant)) = zend_hash_func(Z_STRVAL(CONSTANT(opline.op1.constant)), Z_STRLEN(CONSTANT(opline.op1.constant))+1); + CALCULATE_LITERAL_HASH(opline.op1.constant); SET_UNUSED(opline.op2); SET_NODE(opline.op2, class_node); opline.extended_value |= ZEND_FETCH_STATIC_MEMBER; @@ -598,7 +661,7 @@ zval_dtor(CONSTANT(opline.op2.constant)); ZVAL_LONG(CONSTANT(opline.op2.constant), index); } else { - Z_HASH_P(CONSTANT(opline.op2.constant)) = zend_hash_func(Z_STRVAL(CONSTANT(opline.op2.constant)), Z_STRLEN(CONSTANT(opline.op2.constant))+1); + CALCULATE_LITERAL_HASH(opline.op2.constant); } } @@ -708,7 +771,7
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Wed, 21 Apr 2010 15:08:10 + Revision: http://svn.php.net/viewvc?view=revisionrevision=298257 Log: - Fix ZTS build Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-04-21 14:58:33 UTC (rev 298256) +++ php/php-src/trunk/Zend/zend_compile.c 2010-04-21 15:08:10 UTC (rev 298257) @@ -364,7 +364,7 @@ } /* }}} */ -int zend_add_func_name_literal(zend_op_array *op_array, const zval *zv) /* {{{ */ +int zend_add_func_name_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC) /* {{{ */ { int ret; char *lc_name; @@ -389,7 +389,7 @@ /* }}} */ -int zend_add_class_name_literal(zend_op_array *op_array, const zval *zv) /* {{{ */ +int zend_add_class_name_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC) /* {{{ */ { int ret; char *lc_name; @@ -1774,7 +1774,7 @@ if (last_op-opcode == ZEND_FETCH_OBJ_R) { if (last_op-op2_type == IS_CONST) { last_op-op2.constant = - zend_add_func_name_literal(CG(active_op_array), CONSTANT(last_op-op2.constant)); + zend_add_func_name_literal(CG(active_op_array), CONSTANT(last_op-op2.constant) TSRMLS_CC); } last_op-opcode = ZEND_INIT_METHOD_CALL; SET_UNUSED(last_op-result); @@ -2019,7 +2019,7 @@ zend_resolve_class_name(class_name, opline-extended_value, 0 TSRMLS_CC); opline-op2_type = IS_CONST; opline-op2.constant = - zend_add_class_name_literal(CG(active_op_array), class_name-u.constant); + zend_add_class_name_literal(CG(active_op_array), class_name-u.constant TSRMLS_CC); break; } } else { @@ -2204,14 +2204,14 @@ if (class_node.op_type == IS_CONST) { opline-op1_type = IS_CONST; opline-op1.constant = - zend_add_class_name_literal(CG(active_op_array), class_node.u.constant); + zend_add_class_name_literal(CG(active_op_array), class_node.u.constant TSRMLS_CC); } else { SET_NODE(opline-op1, class_node); } if (method_name-op_type == IS_CONST) { opline-op2_type = IS_CONST; opline-op2.constant = - zend_add_func_name_literal(CG(active_op_array), method_name-u.constant); + zend_add_func_name_literal(CG(active_op_array), method_name-u.constant TSRMLS_CC); } else { SET_NODE(opline-op2, method_name); } @@ -2545,7 +2545,7 @@ opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline-opcode = ZEND_CATCH; opline-op1_type = IS_CONST; - opline-op1.constant = zend_add_class_name_literal(CG(active_op_array), catch_class.u.constant); + opline-op1.constant = zend_add_class_name_literal(CG(active_op_array), catch_class.u.constant TSRMLS_CC); opline-op2_type = IS_CV; opline-op2.var = lookup_cv(CG(active_op_array), catch_var-u.constant.value.str.val, catch_var-u.constant.value.str.len TSRMLS_CC); catch_var-u.constant.value.str.val = CG(active_op_array)-vars[opline-op2.var].name; @@ -3756,7 +3756,7 @@ zend_resolve_class_name(interface_name, opline-extended_value, 0 TSRMLS_CC); opline-extended_value = (opline-extended_value ~ZEND_FETCH_CLASS_MASK) | ZEND_FETCH_CLASS_INTERFACE; opline-op2_type = IS_CONST; - opline-op2.constant = zend_add_class_name_literal(CG(active_op_array), interface_name-u.constant); + opline-op2.constant = zend_add_class_name_literal(CG(active_op_array), interface_name-u.constant TSRMLS_CC); CG(active_class_entry)-num_interfaces++; } /* }}} */ @@ -4103,7 +4103,7 @@ opline-result.var = get_temporary_variable(CG(active_op_array)); if (constant_container-op_type == IS_CONST) { opline-op1_type = IS_CONST; - opline-op1.constant = zend_add_class_name_literal(CG(active_op_array), constant_container-u.constant); + opline-op1.constant = zend_add_class_name_literal(CG(active_op_array), constant_container-u.constant TSRMLS_CC); } else { SET_NODE(opline-op1, constant_container); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php