@@ -6174,51 +6174,36 @@ void zend_compile_class_const_decl(zend_ast *ast) /* {{{ */
6174
6174
}
6175
6175
/* }}} */
6176
6176
6177
- static zend_trait_method_reference * zend_compile_method_ref (zend_ast * ast ) /* {{{ */
6177
+ static void zend_compile_method_ref (zend_ast * ast , zend_trait_method_reference * method_ref ) /* {{{ */
6178
6178
{
6179
6179
zend_ast * class_ast = ast -> child [0 ];
6180
6180
zend_ast * method_ast = ast -> child [1 ];
6181
6181
6182
- zend_trait_method_reference * method_ref = emalloc (sizeof (zend_trait_method_reference ));
6183
- method_ref -> ce = NULL ;
6184
6182
method_ref -> method_name = zend_string_copy (zend_ast_get_str (method_ast ));
6185
6183
6186
6184
if (class_ast ) {
6187
6185
method_ref -> class_name = zend_resolve_class_name_ast (class_ast );
6188
6186
} else {
6189
6187
method_ref -> class_name = NULL ;
6190
6188
}
6191
-
6192
- return method_ref ;
6193
- }
6194
- /* }}} */
6195
-
6196
- static zend_string * * zend_compile_name_list (zend_ast * ast ) /* {{{ */
6197
- {
6198
- zend_ast_list * list = zend_ast_get_list (ast );
6199
- zend_string * * names = safe_emalloc (sizeof (zend_string * ), list -> children + 1 , 0 );
6200
- uint32_t i ;
6201
-
6202
- for (i = 0 ; i < list -> children ; ++ i ) {
6203
- zend_ast * name_ast = list -> child [i ];
6204
- names [i ] = zend_resolve_class_name_ast (name_ast );
6205
- }
6206
-
6207
- names [list -> children ] = NULL ;
6208
-
6209
- return names ;
6210
6189
}
6211
6190
/* }}} */
6212
6191
6213
6192
static void zend_compile_trait_precedence (zend_ast * ast ) /* {{{ */
6214
6193
{
6215
6194
zend_ast * method_ref_ast = ast -> child [0 ];
6216
6195
zend_ast * insteadof_ast = ast -> child [1 ];
6196
+ zend_ast_list * insteadof_list = zend_ast_get_list (insteadof_ast );
6197
+ uint32_t i ;
6198
+
6199
+ zend_trait_precedence * precedence = emalloc (sizeof (zend_trait_precedence ) + (insteadof_list -> children - 1 ) * sizeof (zend_string * ));
6200
+ zend_compile_method_ref (method_ref_ast , & precedence -> trait_method );
6201
+ precedence -> num_excludes = insteadof_list -> children ;
6217
6202
6218
- zend_trait_precedence * precedence = emalloc ( sizeof ( zend_trait_precedence ));
6219
- precedence -> trait_method = zend_compile_method_ref ( method_ref_ast ) ;
6220
- precedence -> exclude_from_classes
6221
- = ( void * ) zend_compile_name_list ( insteadof_ast );
6203
+ for ( i = 0 ; i < insteadof_list -> children ; ++ i ) {
6204
+ zend_ast * name_ast = insteadof_list -> child [ i ] ;
6205
+ precedence -> exclude_class_names [ i ] = zend_resolve_class_name_ast ( name_ast );
6206
+ }
6222
6207
6223
6208
zend_add_to_list (& CG (active_class_entry )-> trait_precedences , precedence );
6224
6209
}
@@ -6241,7 +6226,7 @@ static void zend_compile_trait_alias(zend_ast *ast) /* {{{ */
6241
6226
}
6242
6227
6243
6228
alias = emalloc (sizeof (zend_trait_alias ));
6244
- alias -> trait_method = zend_compile_method_ref ( method_ref_ast );
6229
+ zend_compile_method_ref ( method_ref_ast , & alias -> trait_method );
6245
6230
alias -> modifiers = modifiers ;
6246
6231
6247
6232
if (alias_ast ) {
0 commit comments