From d9dc1a45549a2db601d2f9afd38c51edeaf8e0c7 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Wed, 30 Mar 2022 23:38:27 +0200 Subject: [PATCH] vkd3d-shader/hlsl: Concatenate nested initializers. Signed-off-by: Francisco Casas Signed-off-by: Zebediah Figura Signed-off-by: Giovanni Mascellani Signed-off-by: Matteo Bruni Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d-shader/hlsl.y | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 0fc8fa29..8f8b3c35 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2408,6 +2408,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl %type func_prototype %type complex_initializer +%type complex_initializer_list %type func_arguments %type initializer_expr_list @@ -3215,15 +3216,36 @@ complex_initializer: $$.args[0] = node_from_list($1); $$.instrs = $1; } - | '{' initializer_expr_list '}' + | '{' complex_initializer_list '}' { $$ = $2; } - | '{' initializer_expr_list ',' '}' + | '{' complex_initializer_list ',' '}' { $$ = $2; } +complex_initializer_list: + complex_initializer + | complex_initializer_list ',' complex_initializer + { + struct hlsl_ir_node **new_args; + unsigned int i; + + $$ = $1; + if (!(new_args = hlsl_realloc(ctx, $$.args, ($$.args_count + $3.args_count) * sizeof(*$$.args)))) + { + free_parse_initializer(&$$); + free_parse_initializer(&$3); + YYABORT; + } + $$.args = new_args; + for (i = 0; i < $3.args_count; ++i) + $$.args[$$.args_count++] = $3.args[i]; + list_move_tail($$.instrs, $3.instrs); + free_parse_initializer(&$3); + } + initializer_expr: assignment_expr