cvs: ZendEngine2 / zend_compile.h zend_vm_def.h zend_vm_execute.h /tests bug38808.phpt

From: Date: Tue, 26 Sep 2006 10:31:04 +0000
Subject: cvs: ZendEngine2 / zend_compile.h zend_vm_def.h zend_vm_execute.h /tests bug38808.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-5272@lists.php.net to get a copy of this message
dmitry Tue Sep 26 10:31:04 2006 UTC Modified files: /ZendEngine2 zend_compile.h zend_vm_def.h zend_vm_execute.h /ZendEngine2/tests bug38808.phpt Log: Fixed bug #38808 ("maybe ref" issue for current() and others) http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.h?r1=1.346&r2=1.347&diff_format=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.346 ZendEngine2/zend_compile.h:1.347 --- ZendEngine2/zend_compile.h:1.346 Tue Sep 19 21:35:59 2006 +++ ZendEngine2/zend_compile.h Tue Sep 26 10:31:04 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.346 2006/09/19 21:35:59 dmitry Exp $ */ +/* $Id: zend_compile.h,v 1.347 2006/09/26 10:31:04 dmitry Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -691,40 +691,23 @@ #define ZEND_SEND_BY_REF 1 #define ZEND_SEND_PREFER_REF 2 -/* Lost In Stupid Parentheses */ -#define ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num) \ - ( \ - zf \ - && ((zend_function *) zf)->common.arg_info \ - && \ - ( \ - ( \ - arg_num<=((zend_function *) zf)->common.num_args \ - && ((zend_function *) zf)->common.arg_info[arg_num-1].pass_by_reference == ZEND_SEND_BY_REF \ - ) \ - || ( \ - arg_num>((zend_function *) zf)->common.num_args \ - && ((zend_function *) zf)->common.pass_rest_by_reference == ZEND_SEND_BY_REF \ - ) \ - ) \ - ) - -#define ARG_MAY_BE_SENT_BY_REF(zf, arg_num) \ - ( \ - zf \ - && ((zend_function *) zf)->common.arg_info \ - && \ - ( \ - ( \ - arg_num<=((zend_function *) zf)->common.num_args \ - && ((zend_function *) zf)->common.arg_info[arg_num-1].pass_by_reference == ZEND_SEND_PREFER_REF \ - ) \ - || ( \ - arg_num>((zend_function *) zf)->common.num_args \ - && ((zend_function *) zf)->common.pass_rest_by_reference == ZEND_SEND_PREFER_REF \ - ) \ - ) \ - ) +#define ARG_SEND_TYPE(zf, arg_num) \ + ((zf) ? \ + ((((zend_function*)(zf))->common.arg_info && \ + arg_num<=((zend_function*)(zf))->common.num_args) ? \ + ((zend_function *)(zf))->common.arg_info[arg_num-1].pass_by_reference : \ + ((zend_function *)(zf))->common.pass_rest_by_reference) : \ + ZEND_SEND_BY_VAL) + +#define ARG_MUST_BE_SENT_BY_REF(zf, arg_num) \ + (ARG_SEND_TYPE(zf, arg_num) == ZEND_SEND_BY_REF) + +#define ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num) \ + (ARG_SEND_TYPE(zf, arg_num) & (ZEND_SEND_BY_REF|ZEND_SEND_PREFER_REF)) + +#define ARG_MAY_BE_SENT_BY_REF(zf, arg_num) \ + (ARG_SEND_TYPE(zf, arg_num) == ZEND_SEND_PREFER_REF) + #define ZEND_RETURN_VAL 0 #define ZEND_RETURN_REF 1 http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h?r1=1.144&r2=1.145&diff_format=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.144 ZendEngine2/zend_vm_def.h:1.145 --- ZendEngine2/zend_vm_def.h:1.144 Tue Sep 19 21:35:59 2006 +++ ZendEngine2/zend_vm_def.h Tue Sep 26 10:31:04 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.144 2006/09/19 21:35:59 dmitry Exp $ */ +/* $Id: zend_vm_def.h,v 1.145 2006/09/26 10:31:04 dmitry Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -2202,7 +2202,7 @@ { zend_op *opline = EX(opline); if (opline->extended_value==ZEND_DO_FCALL_BY_NAME - && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { + && ARG_MUST_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.u.opline_num); } { http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.148&r2=1.149&diff_format=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.148 ZendEngine2/zend_vm_execute.h:1.149 --- ZendEngine2/zend_vm_execute.h:1.148 Tue Sep 19 21:35:59 2006 +++ ZendEngine2/zend_vm_execute.h Tue Sep 26 10:31:04 2006 @@ -1744,7 +1744,7 @@ { zend_op *opline = EX(opline); if (opline->extended_value==ZEND_DO_FCALL_BY_NAME - && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { + && ARG_MUST_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.u.opline_num); } { @@ -4338,7 +4338,7 @@ { zend_op *opline = EX(opline); if (opline->extended_value==ZEND_DO_FCALL_BY_NAME - && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { + && ARG_MUST_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.u.opline_num); } { @@ -7439,7 +7439,7 @@ { zend_op *opline = EX(opline); if (opline->extended_value==ZEND_DO_FCALL_BY_NAME - && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { + && ARG_MUST_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.u.opline_num); } { @@ -19980,7 +19980,7 @@ { zend_op *opline = EX(opline); if (opline->extended_value==ZEND_DO_FCALL_BY_NAME - && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { + && ARG_MUST_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.u.opline_num); } { http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug38808.phpt?r1=1.1&r2=1.2&diff_format=u Index: ZendEngine2/tests/bug38808.phpt diff -u /dev/null ZendEngine2/tests/bug38808.phpt:1.2 --- /dev/null Tue Sep 26 10:31:04 2006 +++ ZendEngine2/tests/bug38808.phpt Tue Sep 26 10:31:04 2006 @@ -0,0 +1,17 @@ +--TEST-- +Bug #38808 ("maybe ref" issue for current() and others) +--FILE-- +<?php +$current = "current"; +$next = "next"; + +$b = array(1=>'one', 2=>'two'); +$a =& $b; + +echo $current($a)."\n"; +$next($a); +echo $current($a)."\n"; +?> +--EXPECT-- +one +two \ No newline at end of file

« previous php.zend-engine.cvs (#5272) next »