@@ -7616,6 +7616,23 @@ void zend_compile_class_name(znode *result, zend_ast *ast) /* {{{ */
7616
7616
}
7617
7617
/* }}} */
7618
7618
7619
+ static zend_op * zend_compile_rope_add_ex (zend_op * opline , znode * result , uint32_t num , znode * elem_node ) /* {{{ */
7620
+ {
7621
+ if (num == 0 ) {
7622
+ result -> op_type = IS_TMP_VAR ;
7623
+ result -> u .op .var = -1 ;
7624
+ opline -> opcode = ZEND_ROPE_INIT ;
7625
+ } else {
7626
+ opline -> opcode = ZEND_ROPE_ADD ;
7627
+ SET_NODE (opline -> op1 , result );
7628
+ }
7629
+ SET_NODE (opline -> op2 , elem_node );
7630
+ SET_NODE (opline -> result , result );
7631
+ opline -> extended_value = num ;
7632
+ return opline ;
7633
+ }
7634
+ /* }}} */
7635
+
7619
7636
static zend_op * zend_compile_rope_add (znode * result , uint32_t num , znode * elem_node ) /* {{{ */
7620
7637
{
7621
7638
zend_op * opline = get_next_op ();
@@ -7642,6 +7659,7 @@ static void zend_compile_encaps_list(znode *result, zend_ast *ast) /* {{{ */
7642
7659
zend_op * opline = NULL , * init_opline ;
7643
7660
znode elem_node , last_const_node ;
7644
7661
zend_ast_list * list = zend_ast_get_list (ast );
7662
+ uint32_t reserved_op_number = -1 ;
7645
7663
7646
7664
ZEND_ASSERT (list -> children > 0 );
7647
7665
@@ -7661,14 +7679,23 @@ static void zend_compile_encaps_list(znode *result, zend_ast *ast) /* {{{ */
7661
7679
} else {
7662
7680
last_const_node .op_type = IS_CONST ;
7663
7681
ZVAL_COPY_VALUE (& last_const_node .u .constant , & elem_node .u .constant );
7682
+ /* Reserve place for ZEND_ROPE_ADD instruction */
7683
+ reserved_op_number = get_next_op_number ();
7684
+ opline = get_next_op ();
7685
+ opline -> opcode = ZEND_NOP ;
7664
7686
}
7665
7687
continue ;
7666
7688
} else {
7667
7689
if (j == 0 ) {
7668
- rope_init_lineno = get_next_op_number ();
7690
+ if (last_const_node .op_type == IS_CONST ) {
7691
+ rope_init_lineno = reserved_op_number ;
7692
+ } else {
7693
+ rope_init_lineno = get_next_op_number ();
7694
+ }
7669
7695
}
7670
7696
if (last_const_node .op_type == IS_CONST ) {
7671
- zend_compile_rope_add (result , j ++ , & last_const_node );
7697
+ opline = & CG (active_op_array )-> opcodes [reserved_op_number ];
7698
+ zend_compile_rope_add_ex (opline , result , j ++ , & last_const_node );
7672
7699
last_const_node .op_type = IS_UNUSED ;
7673
7700
}
7674
7701
opline = zend_compile_rope_add (result , j ++ , & elem_node );
@@ -7683,9 +7710,11 @@ static void zend_compile_encaps_list(znode *result, zend_ast *ast) /* {{{ */
7683
7710
ZVAL_EMPTY_STRING (& result -> u .constant );
7684
7711
/* empty string */
7685
7712
}
7713
+ CG (active_op_array )-> last = reserved_op_number - 1 ;
7686
7714
return ;
7687
7715
} else if (last_const_node .op_type == IS_CONST ) {
7688
- opline = zend_compile_rope_add (result , j ++ , & last_const_node );
7716
+ opline = & CG (active_op_array )-> opcodes [reserved_op_number ];
7717
+ opline = zend_compile_rope_add_ex (opline , result , j ++ , & last_const_node );
7689
7718
}
7690
7719
init_opline = CG (active_op_array )-> opcodes + rope_init_lineno ;
7691
7720
if (j == 1 ) {
0 commit comments