From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Tiny improvements.
dlls/d3dcompiler_43/d3dcompiler_private.h | 5 +-- dlls/d3dcompiler_43/hlsl.y | 38 +++++++++++------------ dlls/d3dcompiler_43/utils.c | 5 +-- 3 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index a2d9c04d3bc..d54b9088b68 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -1057,6 +1057,9 @@ static inline void init_node(struct hlsl_ir_node *node, enum hlsl_ir_node_type t node->loc = loc; }
+struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *lhs, + enum parse_assign_op assign_op, struct hlsl_ir_node *rhs) DECLSPEC_HIDDEN; + BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN; struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN; void free_declaration(struct hlsl_ir_var *decl) DECLSPEC_HIDDEN; @@ -1076,8 +1079,6 @@ struct hlsl_ir_expr *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type, struct source_location *loc) DECLSPEC_HIDDEN; struct hlsl_ir_node *implicit_conversion(struct hlsl_ir_node *node, struct hlsl_type *type, struct source_location *loc) DECLSPEC_HIDDEN; -struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assign_op assign_op, - struct hlsl_ir_node *right) DECLSPEC_HIDDEN; void push_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN; BOOL pop_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN; void init_functions_tree(struct wine_rb_tree *funcs) DECLSPEC_HIDDEN; diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index c9dbdeb8c18..511a43d156a 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -775,7 +775,6 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers, struct hlsl_type *type; struct parse_variable_def *v, *v_next; struct hlsl_ir_var *var; - struct hlsl_ir_node *assignment; BOOL ret, local = TRUE; struct list *statements_list = d3dcompiler_alloc(sizeof(*statements_list));
@@ -890,9 +889,8 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
load = new_var_load(var, var->loc); list_add_tail(v->initializer.instrs, &load->node.entry); - assignment = make_assignment(&load->node, ASSIGN_OP_ASSIGN, v->initializer.args[0]); + add_assignment(v->initializer.instrs, &load->node, ASSIGN_OP_ASSIGN, v->initializer.args[0]); d3dcompiler_free(v->initializer.args); - list_add_tail(v->initializer.instrs, &assignment->entry);
if (modifiers & HLSL_STORAGE_STATIC) list_move_tail(&hlsl_ctx.static_initializers, v->initializer.instrs); @@ -2721,24 +2719,24 @@ conditional_expr: logicor_expr FIXME("ternary operator\n"); }
-assignment_expr: conditional_expr - { - $$ = $1; - } - | unary_expr assign_op assignment_expr - { - struct hlsl_ir_node *instr; +assignment_expr:
- if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST) - { - hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, "l-value is const"); - YYABORT; - } - if (!(instr = make_assignment(node_from_list($1), $2, node_from_list($3)))) - YYABORT; - instr->loc = get_location(&@2); - $$ = append_binop($3, $1, instr); - } + conditional_expr + | unary_expr assign_op assignment_expr + { + struct hlsl_ir_node *lhs = node_from_list($1), *rhs = node_from_list($3); + + if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST) + { + hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, "l-value is const"); + YYABORT; + } + list_move_tail($3, $1); + d3dcompiler_free($1); + if (!add_assignment($3, lhs, $2, rhs)) + YYABORT; + $$ = $3; + }
assign_op: '=' { diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c index 4b1e8f7ff06..1c7b5727ebd 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -1443,8 +1443,8 @@ static BOOL invert_swizzle(unsigned int *swizzle, unsigned int *writemask, unsig return TRUE; }
-struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign_op assign_op, - struct hlsl_ir_node *rhs) +struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *lhs, + enum parse_assign_op assign_op, struct hlsl_ir_node *rhs) { struct hlsl_ir_assignment *assign = d3dcompiler_alloc(sizeof(*assign)); struct hlsl_type *lhs_type; @@ -1524,6 +1524,7 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign rhs = expr; } assign->rhs = rhs; + list_add_tail(instrs, &assign->node.entry);
return &assign->node; }