vkd3d-shader/hlsl: Factor out add_unary_expr().

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-09-23 16:47:03 -05:00 committed by Alexandre Julliard
parent 14e9a1ba1c
commit 9a627494a3

View File

@ -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. */