From 9a627494a3a1612f63e5f876a289904fabe38602 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Thu, 23 Sep 2021 16:47:03 -0500 Subject: [PATCH] vkd3d-shader/hlsl: Factor out add_unary_expr(). Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Giovanni Mascellani Signed-off-by: Matteo Bruni Signed-off-by: Alexandre Julliard --- libs/vkd3d-shader/hlsl.y | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index e9eac555..b8d147a0 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1083,6 +1083,17 @@ static struct list *append_unop(struct list *list, struct hlsl_ir_node *node) return list; } +static struct list *add_unary_expr(struct hlsl_ctx *ctx, struct list *instrs, + enum hlsl_ir_expr_op op, struct vkd3d_shader_location loc) +{ + struct hlsl_ir_node *expr; + + if (!(expr = hlsl_new_unary_expr(ctx, op, node_from_list(instrs), loc))) + return NULL; + list_add_tail(instrs, &expr->entry); + return instrs; +} + static struct list *add_binary_expr(struct hlsl_ctx *ctx, struct list *list1, struct list *list2, enum hlsl_ir_expr_op op, struct vkd3d_shader_location loc) { @@ -3033,7 +3044,7 @@ unary_expr: if ($1 == UNARY_OP_PLUS) $$ = $2; else - $$ = append_unop($2, hlsl_new_unary_expr(ctx, ops[$1], node_from_list($2), @1)); + $$ = add_unary_expr(ctx, $2, ops[$1], @1); } /* var_modifiers is necessary to avoid shift/reduce conflicts. */