From: Nikita Popov Date: Fri, 30 May 2014 14:31:10 +0000 (+0200) Subject: Change precedence of $ operator X-Git-Tag: POST_AST_MERGE^2~236 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=95a3a126577aae761a93b06b051b23322d9a6e41;p=php Change precedence of $ operator $$foo['bar'] is now interpreted as ${$foo}['bar'] rather than ${$foo['bar']}. --- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ea75c1503a..37649e7bb2 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6315,17 +6315,10 @@ void zend_do_include_or_eval(int type, znode *result, znode *op1 TSRMLS_DC) /* { } /* }}} */ -void zend_do_indirect_references(znode *result, const znode *num_references, znode *variable TSRMLS_DC) /* {{{ */ +void zend_do_indirect_reference(znode *result, znode *variable TSRMLS_DC) /* {{{ */ { - int i; + fetch_simple_variable_ex(result, variable, 0, ZEND_FETCH_R TSRMLS_CC); - zend_do_end_variable_parse(variable, BP_VAR_R, 0 TSRMLS_CC); - for (i=1; iu.constant); i++) { - fetch_simple_variable_ex(result, variable, 0, ZEND_FETCH_R TSRMLS_CC); - *variable = *result; - } - zend_do_begin_variable_parse(TSRMLS_C); - 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) { zend_string *key = STR_INIT("this", sizeof("this")-1, 0); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 5b5397844f..9f17b110d1 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -457,7 +457,7 @@ void zend_do_assign(znode *result, znode *variable, znode *value TSRMLS_DC); void zend_do_assign_ref(znode *result, znode *lvar, znode *rvar TSRMLS_DC); void fetch_simple_variable(znode *result, znode *varname, int bp TSRMLS_DC); void fetch_simple_variable_ex(znode *result, znode *varname, int bp, zend_uchar op TSRMLS_DC); -void zend_do_indirect_references(znode *result, const znode *num_references, znode *variable TSRMLS_DC); +void zend_do_indirect_reference(znode *result, znode *variable TSRMLS_DC); void zend_do_fetch_static_variable(znode *varname, znode *static_assignment, int fetch_type TSRMLS_DC); void zend_do_fetch_global_variable(znode *varname, const znode *static_assignment, int fetch_type TSRMLS_DC); diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 43e20cd9ce..886eff03db 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -1130,7 +1130,6 @@ method_or_not: variable_without_objects: reference_variable { $$ = $1; } - | simple_indirect_reference reference_variable { zend_do_indirect_references(&$$, &$1, &$2 TSRMLS_CC); } ; static_member: @@ -1158,20 +1157,19 @@ base_variable_with_function_calls: base_variable: reference_variable { $$ = $1; $$.EA = ZEND_PARSED_VARIABLE; } - | simple_indirect_reference reference_variable { zend_do_indirect_references(&$$, &$1, &$2 TSRMLS_CC); $$.EA = ZEND_PARSED_VARIABLE; } | static_member { $$ = $1; $$.EA = ZEND_PARSED_STATIC_MEMBER; } ; reference_variable: reference_variable '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); } | reference_variable '{' expr '}' { fetch_string_offset(&$$, &$1, &$3 TSRMLS_CC); } - | compound_variable { zend_do_begin_variable_parse(TSRMLS_C); fetch_simple_variable(&$$, &$1, 1 TSRMLS_CC); } + | simple_variable { zend_do_begin_variable_parse(TSRMLS_C); fetch_simple_variable(&$$, &$1, 1 TSRMLS_CC); } ; - -compound_variable: +simple_variable: T_VARIABLE { $$ = $1; } | '$' '{' expr '}' { $$ = $3; } + | '$' simple_variable { zend_do_indirect_reference(&$$, &$2 TSRMLS_CC); } ; dim_offset: @@ -1196,11 +1194,6 @@ variable_name: | '{' expr '}' { $$ = $2; } ; -simple_indirect_reference: - '$' { Z_LVAL($$.u.constant) = 1; } - | simple_indirect_reference '$' { Z_LVAL($$.u.constant)++; } -; - assignment_list: assignment_list ',' assignment_list_element | assignment_list_element